* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ── Design tokens ──
   Single construction-amber accent, WCAG AA:
   --accent        borders, icons, focus rings (non-text, ≥3:1 on white)
   --accent-bright button fills + accents on dark — always pair with near-black text
   --accent-ink    accent-colored TEXT on light backgrounds (7:1 on white)
*/
:root {
    --bg: #f7f8fa;
    --ink: #18181b;
    --border: #e4e4e7;
    --accent: #d97706;
    --accent-bright: #f59e0b;
    --accent-ink: #92400e;
    --accent-tint: rgba(217, 119, 6, 0.07);
    --accent-wash: #fffbeb;
    --accent-soft: #fef3c7;
    --accent-edge: #fde68a;
    --focus-ring: rgba(217, 119, 6, 0.18);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.6;
    min-height: 100vh;
    animation: pageFadeIn 0.15s ease;
}

@keyframes pageFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Skip link ── */

.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    background: #18181b;
    color: #ffffff;
    padding: 0.5rem 1rem;
    border-radius: 0 0 8px 8px;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    z-index: 9999;
    transition: top 0.15s;
}

.skip-link:focus {
    top: 0;
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ── Header ── */

.header {
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 1px 0 #e4e4e7, 0 2px 8px rgba(0, 0, 0, 0.04);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.75rem 0;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 0 2rem;
    gap: 1.5rem;
}

.logo-lockup {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex-shrink: 0;
}

.logo {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
    line-height: 0;
}

.logo img {
    height: 36px;
    width: auto;
    display: block;
}

.header-tagline {
    font-size: 0.8rem;
    color: #a1a1aa;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Group navigation (in header) ── */

#main-nav {
    flex: 1;
    display: flex;
    align-items: center;
}

.nav-group-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.nav-group-btn {
    padding: 0.45rem 1rem;
    background: transparent;
    border: 1.5px solid #e4e4e7;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #71717a;
    cursor: pointer;
    transition: border-color 0.18s, color 0.18s, background 0.18s;
    white-space: nowrap;
}

.nav-group-btn:hover {
    border-color: #a1a1aa;
    color: #27272a;
    background: #f4f4f5;
}

.nav-group-btn.active {
    background: #18181b;
    border-color: #18181b;
    color: #ffffff;
}

.nav-group-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Section labels between button clusters (Calculators / Converters) */
.nav-section-label {
    align-self: center;
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #a1a1aa;
    white-space: nowrap;
    margin: 0 0.2rem 0 0.75rem;
    user-select: none;
}

.nav-section-label:first-child {
    margin-left: 0;
}

/* Calculator group buttons — primary, amber-accented */
.nav-group-btn--calc {
    border-color: var(--accent);
    color: var(--accent-ink);
}

.nav-group-btn--calc:hover {
    border-color: var(--accent);
    color: var(--accent-ink);
    background: var(--accent-tint);
}

.nav-group-btn--calc.active {
    background: var(--accent-bright);
    border-color: var(--accent-bright);
    color: var(--ink);
}

.nav-utility-links {
    margin-left: auto;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.nav-glossary-link {
    font-size: 0.82rem;
    font-weight: 600;
    color: #52525b;
    text-decoration: none;
    white-space: nowrap;
    padding: 0.4rem 0.85rem;
    border-radius: 7px;
    border: 1.5px solid #d4d4d8;
    transition: color 0.18s, background 0.18s, border-color 0.18s;
}

.nav-glossary-link:hover {
    color: #18181b;
    background: #f4f4f5;
    border-color: #a1a1aa;
}

.nav-glossary-link--active {
    color: var(--accent-ink);
    border-color: var(--accent);
    background: var(--accent-tint);
}

.nav-glossary-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.nav-feedback-link {
    color: var(--accent-ink);
    border-color: var(--accent);
    background: var(--accent-tint);
}

.nav-feedback-link:hover {
    color: var(--ink);
    background: var(--accent-bright);
    border-color: var(--accent);
}

/* ── Sub-navigation segmented control (injected into .container by JS) ── */

#sub-nav {
    margin: 0 auto 1.5rem;
}

/* Mobile dropdown — hidden on desktop */
.sub-nav-select {
    display: none;
}

.sub-nav-content {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    gap: 3px;
    padding: 4px;
    background: #f0f0f0;
    border-radius: 12px;
    border: 1px solid #e4e4e7;
}

.sub-nav-content::-webkit-scrollbar {
    display: none;
}

.sub-nav-link {
    padding: 0.5rem 1.1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #71717a;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s, box-shadow 0.15s;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
}

.sub-nav-link:hover {
    color: #27272a;
    background: rgba(255, 255, 255, 0.7);
}

.sub-nav-link.active {
    background: #ffffff;
    color: #18181b;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
}

.sub-nav-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ── Main Container ── */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    min-height: calc(100vh - 100px);
}



/* ── Converter Sections ── */

.converter-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.converter-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.converter-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 2.5rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
    max-width: 600px;
    margin: 0 auto;
    border: 1px solid #e4e4e7;
    border-top: 2.5px solid var(--accent);
}

.converter-title {
    text-align: center;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #18181b;
    letter-spacing: -0.02em;
}

.converter-disclaimer {
    text-align: center;
    font-size: 0.8rem;
    color: #a1a1aa;
    margin-bottom: 1.5rem;
}

.conversion-container {
    display: flex;
    gap: 1rem;
    align-items: end;
    margin-bottom: 1.5rem;
}

.input-group {
    flex: 1;
}

.input-label {
    display: block;
    font-weight: 600;
    color: #52525b;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    letter-spacing: 0.01em;
}

.input-field {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1.5px solid #e4e4e7;
    border-radius: 10px;
    font-size: 1.05rem;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    background: #fafafa;
    color: #18181b;
}

.input-field:focus {
    outline: none;
    border-color: var(--accent);
    background: #ffffff;
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.select-field {
    width: 100%;
    padding: 0.875rem 0.75rem;
    border: 1.5px solid #e4e4e7;
    border-radius: 10px;
    font-size: 0.85rem;
    background: #fafafa;
    color: #18181b;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.select-field:focus {
    outline: none;
    border-color: var(--accent);
    background: #ffffff;
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.swap-button {
    background: var(--accent-bright);
    color: var(--ink);
    border: none;
    border-radius: 50%;
    width: 46px;
    height: 46px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform 0.3s ease, background 0.2s;
    box-shadow: 0 2px 10px rgba(217, 119, 6, 0.35);
    flex-shrink: 0;
    margin-bottom: 1.5rem;
}

.swap-button:hover {
    transform: rotate(180deg) scale(1.08);
    background: var(--accent);
}

.swap-button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.units-container {
    display: flex;
    gap: 1rem;
    align-items: end;
}

.status-display {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #f4f4f5;
    border-radius: 10px;
    text-align: center;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-success { color: #16a34a; }
.status-warning  { color: var(--accent-ink); }
.status-error    { color: #dc2626; }

.refresh-btn {
    background: #3f3f46;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    margin-left: 0.5rem;
    transition: background 0.2s;
}

.refresh-btn:hover {
    background: #18181b;
}

/* ── Formula display ── */

.formula-display {
    margin-top: 1.25rem;
    padding: 0.75rem 1rem;
    background: var(--accent-tint);
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    font-size: 0.925rem;
    color: #3f3f46;
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.formula-display:empty {
    display: none;
}

.formula-label {
    font-weight: 600;
    color: var(--accent-ink);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-right: 0.25rem;
}

/* ── Converter info section ── */

.converter-info {
    max-width: 600px;
    margin: 2rem auto 0;
    padding: 0 0.5rem;
}

.converter-info h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: #27272a;
    margin: 1.5rem 0 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1.5px solid #e4e4e7;
}

.converter-info h3:first-child {
    margin-top: 0;
}

.converter-info p {
    color: #52525b;
    line-height: 1.8;
    margin-bottom: 0.9rem;
    font-size: 0.925rem;
}

.converter-sources {
    margin-top: 1.25rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e4e4e7;
    font-size: 0.8rem;
    color: #a1a1aa;
    line-height: 1.7;
}

.converter-sources a {
    color: #71717a;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.converter-sources a:hover {
    color: var(--accent-ink);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
    margin-top: 1.25rem;
}

.pair-links {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid #e4e4e7;
}

.pair-links h4 {
    font-size: 0.8rem;
    font-weight: 700;
    color: #71717a;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.pair-links-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.pair-links-grid a {
    font-size: 0.85rem;
    color: var(--accent-ink);
    text-decoration: none;
    background: var(--accent-wash);
    border: 1px solid var(--accent-edge);
    border-radius: 6px;
    padding: 0.3rem 0.65rem;
    white-space: nowrap;
}

.pair-links-grid a:hover {
    background: var(--accent-soft);
}

.pair-links-all {
    font-size: 0.85rem;
    color: var(--accent-ink);
    text-decoration: none;
    font-weight: 600;
}

.pair-links-all:hover {
    text-decoration: underline;
}

.info-card {
    background: #ffffff;
    border: 1px solid #e4e4e7;
    border-radius: 12px;
    padding: 1.1rem 1.25rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.info-card h4 {
    font-size: 0.8rem;
    font-weight: 700;
    color: #71717a;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.quick-ref {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.quick-ref td {
    padding: 0.3rem 0.4rem;
    border-bottom: 1px solid #f4f4f5;
    color: #71717a;
    vertical-align: top;
}

.quick-ref td:first-child {
    font-weight: 500;
    color: #27272a;
    white-space: nowrap;
}

.quick-ref td:last-child {
    text-align: right;
    color: #52525b;
}

.quick-ref tr:last-child td {
    border-bottom: none;
}

/* ── Loading ── */

.loading {
    position: relative;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #e4e4e7;
    border-top: 2px solid #52525b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 5px;
}

@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ── Footer ── */

.footer {
    background: #ffffff;
    border-top: 1px solid #e4e4e7;
    padding: 1.5rem 0;
    margin-top: 3rem;
    text-align: center;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.footer-text {
    color: #a1a1aa;
    font-size: 0.875rem;
}

.footer-brand {
    color: #71717a;
    font-weight: 600;
}


/* ── Converter sources link ── */

.converter-sources {
    margin: 1.1rem 0 0;
}

.converter-sources a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.9rem;
    background: #f4f4f5;
    border: 1.5px solid #e4e4e7;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    color: #52525b;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.converter-sources a:hover {
    background: var(--accent-tint);
    border-color: var(--accent);
    color: var(--accent-ink);
}

/* ── Glossary page ── */

.glossary-intro {
    max-width: 640px;
    margin: 0 auto 2.5rem;
    text-align: center;
}

.glossary-intro h1 {
    font-size: 2rem;
    font-weight: 700;
    color: #18181b;
    letter-spacing: -0.02em;
    margin-bottom: 0.6rem;
}

.glossary-intro p {
    color: #71717a;
    font-size: 0.95rem;
    line-height: 1.7;
}

.glossary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.1rem;
    max-width: 1000px;
    margin: 0 auto;
}

.glossary-section {
    background: #ffffff;
    border: 1px solid #e4e4e7;
    border-radius: 14px;
    padding: 1.1rem 1.3rem 1.2rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    scroll-margin-top: 80px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.glossary-section:target {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.glossary-section h2 {
    font-size: 0.9rem;
    font-weight: 700;
    color: #18181b;
    margin-bottom: 0.7rem;
    letter-spacing: -0.01em;
}

.glossary-section h2 a {
    color: inherit;
    text-decoration: none;
}

.glossary-section h2 a:hover {
    color: var(--accent-ink);
}

.glossary-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.glossary-section li {
    font-size: 0.85rem;
    color: #71717a;
    line-height: 1.4;
    padding-left: 0.9rem;
    position: relative;
}

.glossary-section li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--accent-ink);
    font-size: 0.75rem;
    top: 0.1em;
}

.glossary-section li a {
    color: #52525b;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.glossary-section li a:hover {
    color: var(--accent-ink);
}

.source-note {
    display: block;
    color: #a1a1aa;
    font-size: 0.78rem;
    margin-top: 0.1rem;
    line-height: 1.35;
}

/* ── Mobile Responsive ── */

/* ── Hamburger button (hidden on desktop) ── */

.nav-hamburger {
    display: none;
}

@media (max-width: 768px) {

    /* Header row: logo left, hamburger right */
    .header-content {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 0.6rem 1rem;
        gap: 0;
    }

    /* Hamburger button */
    .nav-hamburger {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        width: 40px;
        height: 40px;
        padding: 6px;
        background: transparent;
        border: 1.5px solid #e4e4e7;
        border-radius: 8px;
        cursor: pointer;
        flex-shrink: 0;
        transition: background 0.15s, border-color 0.15s;
    }

    .nav-hamburger:hover {
        background: #f4f4f5;
        border-color: #a1a1aa;
    }

    .nav-hamburger:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }

    .nav-hamburger-bar {
        display: block;
        width: 100%;
        height: 2px;
        background: #52525b;
        border-radius: 2px;
        transform-origin: center;
        transition: transform 0.2s, opacity 0.2s, background 0.15s;
    }

    /* Animate bars into X when open */
    .nav-hamburger--open .nav-hamburger-bar:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }
    .nav-hamburger--open .nav-hamburger-bar:nth-child(2) {
        opacity: 0;
        transform: scaleX(0);
    }
    .nav-hamburger--open .nav-hamburger-bar:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    /* Nav drawer: hidden by default, slides in when .nav-open */
    #main-nav {
        position: fixed;
        top: var(--header-height, 57px);
        left: 0;
        right: 0;
        background: #ffffff;
        border-bottom: 1px solid #e4e4e7;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
        z-index: 99;
        overflow: hidden;
        max-height: 0;
        opacity: 0;
        pointer-events: none;
        transition: max-height 0.25s ease, opacity 0.2s ease;
        flex-direction: column;
        flex: none;
        width: 100%;
    }

    #main-nav.nav-open {
        max-height: 80vh;
        opacity: 1;
        pointer-events: auto;
        overflow-y: auto;
    }

    /* Stack group buttons vertically in the drawer */
    .nav-group-bar {
        display: flex;
        flex-direction: column;
        gap: 0;
        padding: 0.5rem 1rem;
    }

    .nav-group-btn {
        width: 100%;
        text-align: left;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        border: none;
        border-bottom: 1px solid #f4f4f5;
        border-radius: 0;
        background: transparent;
    }

    .nav-group-btn:last-child {
        border-bottom: none;
    }

    .nav-group-btn.active {
        background: #f4f4f5;
        color: #18181b;
        border-color: transparent;
    }

    .nav-group-btn--calc.active {
        background: var(--accent-wash);
        color: var(--accent-ink);
    }

    /* Section labels become drawer section headers */
    .nav-section-label {
        display: block;
        align-self: stretch;
        margin: 0;
        padding: 0.85rem 1rem 0.25rem;
        font-size: 0.68rem;
        border-top: 1px solid #f4f4f5;
    }

    .nav-section-label:first-child {
        border-top: none;
        padding-top: 0.5rem;
    }

    .header-tagline {
        font-size: 0.72rem;
        white-space: normal;
        line-height: 1.25;
    }

    /* Utility links at the bottom of the drawer */
    .nav-utility-links {
        margin-left: 0;
        display: flex;
        gap: 0.75rem;
        padding: 0.75rem 1rem 1rem;
        border-top: 1px solid #e4e4e7;
    }

    .nav-glossary-link {
        flex: 1;
        text-align: center;
    }

    #sub-nav {
        margin-bottom: 1rem;
    }

    /* On mobile: hide tab strip, show dropdown */
    .sub-nav-content {
        display: none;
    }

    .sub-nav-select {
        display: block;
        width: 100%;
        padding: 0.6rem 0.75rem;
        font-size: 0.9375rem;
        font-family: inherit;
        color: #18181b;
        background: #ffffff;
        border: 1.5px solid #d4d4d8;
        border-radius: 0.5rem;
        cursor: pointer;
        appearance: none;
        -webkit-appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%2371717a' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 0.75rem center;
        padding-right: 2.25rem;
    }

    .sub-nav-select:focus {
        outline: none;
        border-color: var(--accent);
        box-shadow: 0 0 0 3px var(--focus-ring);
    }

    .sub-nav-link {
        padding: 0.45rem 0.9rem;
        font-size: 0.825rem;
    }

    .conversion-container {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .units-container {
        align-items: stretch;
        margin-top: 0.25rem;
    }

    .input-group {
        width: 100%;
        min-width: 0;
    }

    .swap-button {
        align-self: center;
        margin: 0.5rem 0;
        transform: rotate(90deg);
    }

    .swap-button:hover {
        transform: rotate(270deg) scale(1.08);
    }

    .converter-card {
        padding: 1.5rem;
    }

    .container {
        padding: 1rem;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .converter-info {
        padding: 0;
    }
}

@media (max-width: 480px) {
    .sub-nav-link {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
}

/* ── Electric type selector tabs ── */

.electric-type-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: #f0f0f0;
    border-radius: 10px;
    padding: 4px;
}

.electric-tab {
    flex: 1;
    padding: 0.45rem 0.75rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #71717a;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.electric-tab.active {
    background: white;
    color: #18181b;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ── Race Time Calculator ── */

.race-calc-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 2.5rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
    max-width: 600px;
    margin: 1.5rem auto 0;
}

.race-distances {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.75rem;
}

.race-dist-btn {
    flex: 1;
    min-width: 0;
    padding: 0.55rem 0.4rem;
    background: #f4f4f5;
    border: 1.5px solid #e4e4e7;
    border-radius: 9px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #52525b;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
}

.race-dist-btn:hover {
    border-color: #a1a1aa;
    color: #18181b;
    background: #efefef;
}

.race-dist-btn.active {
    background: #18181b;
    border-color: #18181b;
    color: #ffffff;
}

.race-dist-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.race-input-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.race-input-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: #52525b;
    width: 120px;
    flex-shrink: 0;
}

.race-time-inputs {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex: 1;
}

.race-time-field {
    width: 3.5rem;
    padding: 0.75rem 0.5rem;
    border: 1.5px solid #e4e4e7;
    border-radius: 10px;
    font-size: 1rem;
    text-align: center;
    background: #fafafa;
    color: #18181b;
    transition: border-color 0.2s, box-shadow 0.2s;
    -moz-appearance: textfield;
}

.race-time-field::-webkit-inner-spin-button,
.race-time-field::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.race-time-field:focus {
    outline: none;
    border-color: var(--accent);
    background: #ffffff;
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.race-time-sep {
    font-size: 0.8rem;
    font-weight: 600;
    color: #a1a1aa;
    user-select: none;
}

.race-divider {
    border: none;
    border-top: 1px solid #f0f0f0;
    margin: 1.25rem 0;
}

.race-results {
    background: #f8f8f8;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.race-result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.race-result-label {
    color: #71717a;
    font-weight: 500;
}

.race-result-value {
    font-weight: 700;
    color: #18181b;
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}

.race-result-value.highlight {
    color: var(--accent-ink);
    font-size: 1.1rem;
}

@media (max-width: 768px) {
    .race-calc-card {
        padding: 1.5rem;
    }

    .race-input-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .race-input-label {
        width: auto;
    }
}

/* ── Related converters strip ── */

.related-converters {
    max-width: 600px;
    margin: 2rem auto 0;
    padding: 0 0.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.related-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #a1a1aa;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    white-space: nowrap;
    margin-right: 0.25rem;
}

.related-link {
    padding: 0.35rem 0.85rem;
    border-radius: 100px;
    font-size: 0.82rem;
    font-weight: 500;
    color: #52525b;
    text-decoration: none;
    background: #f4f4f5;
    border: 1px solid #e4e4e7;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.related-link:hover {
    background: var(--accent-tint);
    border-color: var(--accent);
    color: var(--accent-ink);
}

/* ── 404 error page ── */

.error-page {
    text-align: center;
    padding: 5rem 2rem;
    max-width: 480px;
    margin: 0 auto;
}

.error-code {
    font-size: 7rem;
    font-weight: 800;
    color: #e4e4e7;
    line-height: 1;
    letter-spacing: -4px;
    margin-bottom: 0.75rem;
}

.error-page h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #18181b;
    margin-bottom: 0.6rem;
    letter-spacing: -0.01em;
}

.error-page p {
    color: #71717a;
    font-size: 0.975rem;
    line-height: 1.7;
    margin-bottom: 2rem;
}

.error-links {
    list-style: disc;
    text-align: left;
    display: inline-block;
    margin: 0 auto 2rem;
    padding-left: 1.25rem;
}

.error-links li {
    margin-bottom: 0.4rem;
}

.error-links a {
    color: var(--accent-ink);
    text-decoration: none;
    font-size: 0.95rem;
}

.error-links a:hover {
    text-decoration: underline;
}

.error-home-btn {
    display: block;
    width: fit-content;
    margin: 0 auto;
    align-items: center;
    gap: 0.4rem;
    padding: 0.7rem 1.5rem;
    background: #18181b;
    color: white;
    border-radius: 10px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.2s;
}

.error-home-btn:hover {
    background: var(--accent-bright);
    color: var(--ink);
}

/* ── Developer Snippet Drawer ── */

.snippet-trigger-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0.75rem auto 0;
    padding: 0.4rem 0.9rem;
    background: transparent;
    border: 1.5px solid #e4e4e7;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #71717a;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.snippet-trigger-btn:hover,
.snippet-trigger-btn.active {
    border-color: var(--accent);
    color: var(--accent-ink);
    background: var(--accent-tint);
}

.snippet-trigger-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

#snippet-drawer {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 200;
    pointer-events: none;
    transition: background 0.2s;
}

#snippet-drawer.open {
    background: rgba(0, 0, 0, 0.25);
    pointer-events: all;
}

.snippet-drawer-inner {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #18181b;
    border-radius: 16px 16px 0 0;
    height: 60vh;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.35);
}

#snippet-drawer.open .snippet-drawer-inner {
    transform: translateY(0);
}

.snippet-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem 0.75rem;
    border-bottom: 1px solid #27272a;
    flex-shrink: 0;
}

.snippet-drawer-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #a1a1aa;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.snippet-close-btn {
    background: none;
    border: none;
    color: #71717a;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.15s;
}

.snippet-close-btn:hover {
    color: #e4e4e7;
}

.snippet-toolbar {
    display: flex;
    align-items: center;
    padding: 0.6rem 1.25rem 0;
    flex-shrink: 0;
    gap: 0.5rem;
}

.snippet-lang-tabs {
    display: flex;
    gap: 0.25rem;
}

.snippet-tab {
    padding: 0.35rem 0.85rem;
    border: 1.5px solid #3f3f46;
    border-radius: 6px;
    background: transparent;
    color: #71717a;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.snippet-tab:hover {
    color: #d4d4d8;
    border-color: #52525b;
}

.snippet-tab:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.snippet-tab.active {
    background: var(--accent-bright);
    border-color: var(--accent-bright);
    color: var(--ink);
}

.snippet-body {
    flex: 1;
    overflow: hidden;
    padding: 0.75rem 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
}

.snippet-code-wrap {
    position: relative;
    flex: 1;
    overflow: hidden;
    border-radius: 10px;
    background: #09090b;
    border: 1px solid #27272a;
}

.snippet-code {
    margin: 0;
    padding: 1rem 1rem 1rem 1rem;
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.78rem;
    line-height: 1.65;
    color: #d4d4d8;
    overflow: auto;
    height: 100%;
    white-space: pre;
    tab-size: 4;
    max-height: none;
}

/* Editable JS textarea — same look as the pre */
.snippet-code-editable {
    width: 100%;
    box-sizing: border-box;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    color: #d4d4d8;
    caret-color: var(--accent-bright);
}

/* Actions row (Copy + Run) — sits after tabs with a visible gap */
.snippet-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
    padding-left: 1.5rem;
    border-left: 1px solid #3f3f46;
    margin-left: 0.5rem;
}

.snippet-run-btn {
    padding: 0.3rem 0.7rem;
    background: var(--accent-bright);
    border: 1px solid var(--accent);
    border-radius: 6px;
    color: var(--ink);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.snippet-run-btn:hover {
    background: var(--accent);
}

.snippet-run-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Output panel */
.snippet-output {
    border-top: 1px solid #3f3f46;
    padding: 0.6rem 1rem 0.75rem;
}

.snippet-output-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #71717a;
    margin-bottom: 0.35rem;
}

.snippet-output-pre {
    margin: 0;
    font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.8rem;
    color: #a3e635;
    white-space: pre-wrap;
    word-break: break-all;
}

.snippet-output-pre.snippet-output-error {
    color: #f87171;
}

.snippet-copy-btn {
    padding: 0.3rem 0.7rem;
    background: #27272a;
    border: 1px solid #3f3f46;
    border-radius: 6px;
    color: #a1a1aa;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.snippet-copy-btn:hover {
    background: #3f3f46;
    color: #e4e4e7;
}

.snippet-copy-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.snippet-copy-btn.copied {
    background: var(--accent-bright);
    border-color: var(--accent-bright);
    color: var(--ink);
}

/* ── Footer link ── */

.footer-link {
    color: #a1a1aa;
    text-decoration: none;
}

.footer-link:hover {
    color: var(--accent-ink);
    text-decoration: underline;
}

/* ── Feedback form ── */

.feedback-card {
    max-width: 600px;
    margin: 0 auto;
}

.feedback-intro {
    color: #52525b;
    margin-bottom: 1.5rem;
}

.feedback-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.feedback-row {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.feedback-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #3f3f46;
}

.feedback-optional {
    font-weight: 400;
    color: #a1a1aa;
    font-size: 0.8125rem;
}

.feedback-required {
    color: #dc2626;
}

.feedback-hint {
    font-size: 0.8125rem;
    color: #a1a1aa;
    margin: 0;
}

.feedback-textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid #d4d4d8;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    font-family: inherit;
    color: #18181b;
    background: #fafafa;
    resize: vertical;
    min-height: 120px;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.feedback-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus-ring);
    background: #ffffff;
}

.feedback-submit {
    align-self: flex-start;
    background: var(--accent-bright);
    color: var(--ink);
    border: none;
    border-radius: 0.5rem;
    padding: 0.625rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.feedback-submit:hover {
    background: var(--accent);
}

.feedback-submit:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.feedback-notice[hidden] {
    display: none;
}

.feedback-notice {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
}

.feedback-notice svg {
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.feedback-notice p {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.feedback-notice a {
    color: inherit;
}

.feedback-notice--success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #14532d;
}

.feedback-notice--error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #7f1d1d;
}

/* ── Reduced motion ── */

@media (prefers-reduced-motion: reduce) {
    body,
    .converter-section {
        animation: none;
    }

    .swap-button:hover {
        transform: scale(1.05);   /* keep subtle scale, drop the rotation */
    }

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
    }
}
