/* --- Theme Tokens --- */
:root {
    --fm-surface-card: rgba(31, 41, 55, 0.5);
    --fm-surface-card-strong: linear-gradient(145deg, rgba(21, 30, 46, 0.9), rgba(36, 47, 64, 0.72));
    --fm-surface-border: rgba(148, 163, 184, 0.18);
    --fm-section-surface: rgba(31, 41, 55, 0.44);
    --fm-section-border: rgba(71, 85, 105, 0.3);
    --fm-input-bg: rgba(36, 47, 64, 0.72);
    --fm-input-bg-hover: rgba(45, 58, 78, 0.78);
    --fm-input-border: rgba(148, 163, 184, 0.22);
    --fm-input-border-focus: #94a3b8;
    --fm-text-primary: #f9fafb;
    --fm-text-secondary: #d1d5db;
    --fm-accent: #6366f1;
    --fm-accent-hover: #4f46e5;
    --fm-accent-shadow: rgba(99, 102, 241, 0.45);
    --fm-focus-ring: rgba(148, 163, 184, 0.35);
    --fm-disabled-opacity: 0.6;

    /* Layer tokens */
    --fm-layer-tooltip-host: 1180;
    --fm-layer-tooltip-base: 1200;
    --fm-layer-tooltip-panel: 1210;

    /* Tooltip tokens */
    --fm-tooltip-bg: #111827; /* gray-900 */
    --fm-tooltip-text: #f3f4f6; /* gray-100 */
    --fm-tooltip-border: #334155; /* gray-700 */
    --fm-tooltip-shadow: 0 20px 25px -5px rgb(15 23 42 / 0.45),
        0 10px 10px -5px rgb(15 23 42 / 0.35);

    /* Typography tokens */
    --fm-font-size-page-title: clamp(2.5rem, 2.1rem + 1vw, 3.5rem);
    --fm-font-size-form-control: 0.95rem;
    --fm-font-size-math: clamp(1.05rem, 0.95rem + 0.3vw, 1.25rem);

    /* Layout tokens */
    --fm-layout-result-height-default: clamp(22rem, 68vh, 28rem);
    --fm-layout-result-height-compact: clamp(20rem, 64vh, 24rem);
    --fm-layout-result-height-tall: clamp(24rem, 72vh, 32rem);
    --fm-chart-height-base: 20rem;
    --fm-chart-height-responsive: clamp(20rem, 32vw, 28rem);
    --fm-chart-height-responsive-xl: clamp(22rem, 28vw, 32rem);
    --fm-chart-height-tall: clamp(24rem, 40vw, 34rem);
    --fm-chart-height-tall-xl: clamp(28rem, 32vw, 38rem);
}

/* --- Typography Utilities --- */
.result-heading {
    font-family: 'Noto Sans', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.page-title {
    font-size: var(--fm-font-size-page-title);
    line-height: 1.2;
}

.numeric-output {
    font-family: 'Noto Sans', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 600;
    font-variant-numeric: lining-nums tabular-nums;
    letter-spacing: 0.005em;
}

.math-callout,
.math-notation {
    font-variant-numeric: lining-nums;
}

.math-notation {
    font-size: var(--fm-font-size-math);
    line-height: 1.5;
}

.math-callout mjx-container,
.math-notation mjx-container {
    font-variant-numeric: normal;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.math-callout {
    font-size: var(--fm-font-size-math);
    line-height: 1.6;
    letter-spacing: 0.01em;
}

.math-callout--compact {
    font-size: clamp(0.95rem, 0.85rem + 0.2vw, 1.1rem);
}

.math-callout--compact mjx-container {
    font-size: 0.95em;
}

.math-callout mjx-container {
    text-align: center;
    display: block;
    margin-inline: auto;
    max-width: 100%;
}

code,
kbd,
samp,
pre {
    font-family: 'Noto Sans Math', 'Noto Sans', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-variant-numeric: lining-nums tabular-nums;
}

.panel-card {
    background: var(--fm-surface-card);
    border-radius: 1rem;
    border: 1px solid var(--fm-surface-border);
    box-shadow: 0 18px 32px -24px rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(6px);
}

.panel-card,
.result-container,
.tab-panel,
.mobile-landscape-form,
.mobile-landscape-result {
    min-width: 0;
    max-width: 100%;
}

.panel-card,
.section-card,
.result-container {
    overflow-wrap: break-word;
    word-break: break-word;
}

.result-container[data-result-present="true"] .panel-card--result {
    position: relative;
    z-index: 1;
    background:
        linear-gradient(#1e293b, #1e293b) padding-box,
        linear-gradient(145deg, var(--fm-accent), rgba(148, 163, 184, 0.2) 60%, rgba(148, 163, 184, 0.2)) border-box;
    border: 1.5px solid transparent;
    box-shadow: none;
}

.panel-card--muted {
    background: rgba(30, 41, 59, 0.38);
    border-color: rgba(71, 85, 105, 0.26);
}

.result-container {
    min-height: auto;
}

.result-container--compact {
    min-height: auto;
}

.result-container--tall {
    min-height: auto;
}

[data-calculator-layout] {
    --calculator-note-offset: 0px;
}

[data-calculator-layout] .result-container {
    display: flex;
    flex-direction: column;
    align-self: start;
    position: relative;
    padding-top: var(--calculator-note-offset, 0px);
}

.result-container[data-loading="true"] > :not(.result-loading-overlay) {
    opacity: 0.45;
    filter: blur(1px);
    transition: opacity 0.2s ease, filter 0.2s ease;
}

.result-loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(2px);
    border-radius: inherit;
    z-index: 5;
    pointer-events: none;
}

.result-loading-overlay .loading-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    border-radius: 9999px;
    background: rgba(30, 41, 59, 0.85);
    color: var(--fm-text-primary, #e2e8f0);
    font-weight: 600;
    letter-spacing: 0.01em;
    box-shadow: 0 18px 35px -28px rgba(15, 23, 42, 0.8);
}

.result-loading-overlay .loading-spinner {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    border: 3px solid rgba(148, 163, 184, 0.35);
    border-top-color: var(--fm-accent, #6366f1);
    animation: fm-spin 0.9s linear infinite;
}

.result-loading-overlay .loading-text {
    font-size: 0.95rem;
}

@keyframes fm-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

[data-calculator-layout] .result-container > .panel-card {
    flex: 0 0 auto;
}

[data-calculator-layout] .result-container [data-calculator-note] {
    flex: 0 0 auto;
}

[data-calculator-layout][data-note-active] .result-container [data-calculator-note] {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2;
}

[data-calculator-layout] > [data-calculator-form] {
    transition: margin-top 0.3s ease;
    margin-top: 0;
}

[data-calculator-explanation] {
    --calculator-note-offset: 0px;
    --calculator-explanation-base-offset: 2rem;
    transition: margin-top 0.3s ease;
    margin-top: calc(var(--calculator-explanation-base-offset) + var(--calculator-note-offset));
}

.section-card {
    border-radius: 0.75rem;
    border: 1px solid var(--fm-section-border);
    background: var(--fm-section-surface);
    box-shadow: 0 12px 30px -22px rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(5px);
}

.input-field {
    display: block;
    width: 100%;
    padding: 0.65rem 0.9rem;
    border-radius: 0.65rem;
    background: var(--fm-input-bg);
    border: 1px solid var(--fm-input-border);
    color: var(--fm-text-primary);
    transition: border 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.24);
    font-size: var(--fm-font-size-form-control);
    line-height: 1.5;
}

.input-field:hover {
    background: var(--fm-input-bg-hover);
}

.input-field:focus {
    outline: none;
    border-color: var(--fm-input-border-focus);
    box-shadow: 0 14px 28px -24px rgba(148, 163, 184, 0.7);
    background: rgba(54, 69, 92, 0.78);
}

.form-label {
    font-size: var(--fm-font-size-form-control);
    font-weight: 500;
    line-height: 1.45;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
}

.form-label .label-text {
    flex: 1 1 auto;
    min-width: 0;
}

.form-label .tooltip {
    flex: 0 0 auto;
}

.input-field:disabled,
.input-field[readonly] {
    opacity: var(--fm-disabled-opacity);
    cursor: not-allowed;
}

.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.25rem;
    border-radius: 0.85rem;
    font-weight: 600;
    color: var(--fm-text-primary);
    background: linear-gradient(135deg, var(--fm-accent), #4338ca);
    border: 1px solid transparent;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border 0.2s ease;
    box-shadow: 0 18px 36px -16px var(--fm-accent-shadow);
}

.primary-button:hover {
    transform: translateY(-1px);
    background: linear-gradient(135deg, var(--fm-accent-hover), #4338ca);
    box-shadow: 0 22px 42px -16px rgba(99, 102, 241, 0.55);
}

.primary-button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--fm-focus-ring);
}

.primary-button:disabled {
    opacity: var(--fm-disabled-opacity);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* --- Global Animations & Utilities --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(0.625rem); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in, .fade-in-delay {
    opacity: 0;
    will-change: opacity, transform;
    animation: fadeIn 0.5s ease-out both;
}

.fade-in-delay {
    animation-delay: 0.2s;
}

.no-tap-highlight {
    -webkit-tap-highlight-color: transparent;
}

img {
    max-width: 100%;
    height: auto;
}

/* --- Chart Containers --- */
.chart-box {
    position: relative;
    height: var(--chart-box-height, var(--fm-chart-height-base));
    flex: 0 0 auto;
}

.chart-box canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.chart-box--responsive {
    --chart-box-height: var(--fm-chart-height-responsive);
}

.chart-box--tall {
    --chart-box-height: var(--fm-chart-height-tall);
}

@media (min-width: 1280px) {
    .chart-box--responsive {
        --chart-box-height: var(--fm-chart-height-responsive-xl);
    }

    .chart-box--tall {
        --chart-box-height: var(--fm-chart-height-tall-xl);
    }
}

/* --- Advanced Tooltip Styles (from options.html) --- */
.tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
    z-index: var(--fm-layer-tooltip-base);
    isolation: isolate;
    background: none;
    border: 0;
    padding: 0;
    color: inherit;
    font: inherit;
}

.tooltip.tooltip-active {
    z-index: var(--fm-layer-tooltip-panel);
}

.tooltip-host-active,
.result-container[data-result-present="true"] .tooltip-host-active {
    position: relative;
    z-index: var(--fm-layer-tooltip-host);
    isolation: isolate;
}

.tooltip .tooltiptext {
    --tooltip-inline-shift: 0px;
    visibility: hidden;
    opacity: 0;
    width: min(280px, calc(100vw - 2.5rem)); /* Shrink gracefully when the viewport is narrow */
    background-color: var(--fm-tooltip-bg);
    color: var(--fm-tooltip-text);
    font-size: var(--fm-font-size-form-control);
    line-height: 1.5;
    text-align: left;
    border-radius: 0.5rem; /* rounded-lg */
    padding: 1rem; /* p-4 */
    position: absolute;
    z-index: var(--fm-layer-tooltip-panel);
    bottom: 125%; /* Start by appearing above */
    left: 50%;
    transform: translateX(calc(-50% + var(--tooltip-inline-shift)));
    transition: opacity 0.3s ease;
    box-shadow: var(--fm-tooltip-shadow);
    border: 1px solid var(--fm-tooltip-border);
    backdrop-filter: none;
}

/* Allow tooltips and other overlays to render outside collapsible cards */
details.section-card[data-collapsible-section] {
    overflow: visible;
}

/* Arrow for the tooltip */
.tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    left: calc(50% - var(--tooltip-inline-shift));
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
}

/* Logic for positioning arrow (JS will add/remove these classes) */
.tooltip .tooltiptext.show-top::after {
    top: 100%; /* Arrow at the bottom */
    border-color: var(--fm-tooltip-bg) transparent transparent transparent;
}
.tooltip .tooltiptext.show-bottom::after {
    bottom: 100%; /* Arrow at the top */
    border-color: transparent transparent var(--fm-tooltip-bg) transparent;
}
.tooltip .tooltiptext.show-left {
    left: 0;
    transform: translateX(0);
}
.tooltip .tooltiptext.show-right {
    left: auto;
    right: 0;
    transform: translateX(0);
}
.tooltip .tooltiptext.show-left::after {
    left: 1.5rem;
    margin-left: 0;
}
.tooltip .tooltiptext.show-right::after {
    left: auto;
    right: 1.5rem;
    margin-left: 0;
}

/* A class that our JavaScript will add to show the tooltip */
.tooltip .tooltiptext.tooltip-visible {
    visibility: visible;
    opacity: 1;
}

.tooltip:focus {
    outline: none;
}

.tooltip:focus-visible {
    outline: 2px solid rgba(129, 140, 248, 0.9); /* indigo-400 */
    outline-offset: 2px;
}

/* --- Scrollbar Utilities --- */
.scrollbar-none::-webkit-scrollbar {
    display: none;
}

.scrollbar-none {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* --- Mobile Landscape Layout --- */
@media (orientation: landscape) and (max-width: 1024px) {
    .mobile-landscape-grid {
        display: grid;
        grid-template-columns: 1fr 1.25fr;
        gap: 1.5rem;
    }
    .mobile-landscape-form,
    .mobile-landscape-result {
        min-height: 0;
    }
    .mobile-landscape-sticky {
        position: sticky;
        top: 0.75rem;
        align-self: start;
    }
    .chart-box {
        height: 65vh;
        max-height: 500px;
    }
}

/* --- Currency Switcher Styles --- */
#currency-tooltip {
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#currency-tooltip.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.currency-option[aria-selected="true"] {
    background-color: rgba(79, 70, 229, 0.15);
    color: #e5e7eb;
}

.currency-option[aria-selected="true"]:hover {
    background-color: rgba(79, 70, 229, 0.25);
}

/* --- Footnote Styles --- */
.footnote-ref {
    font-size: 0.7em; /* Slightly smaller than default sup */
    vertical-align: super;
    margin-left: 2px;
    padding: 0.1em 0.3em;
    background-color: rgba(55, 65, 81, 0.5); /* gray-700/50 */
    border-radius: 4px;
    color: #d1d5db; /* gray-300 */
    font-weight: 600;
    line-height: 1; /* Prevent affecting line height */
    text-decoration: none; /* Remove underline from links if any */
}

.footnote-box {
    background-color: rgba(17, 24, 39, 0.5); /* gray-900/50 */
    border: 1px solid rgba(55, 65, 81, 0.3); /* gray-700/30 */
    border-radius: 0.75rem; /* rounded-xl */
    padding: 1.25rem; /* p-5 */
    margin-top: 1.5rem; /* mt-6 */
    font-style: normal; /* Override parent's italic if needed */
}

.footnote-box .footnote-title {
    font-weight: 600;
    color: #9ca3af; /* gray-400 */
    font-size: 1.125rem; /* text-lg */
    margin-bottom: 0.75rem; /* mb-3 */
    border-bottom: 1px solid rgba(55, 65, 81, 0.5);
    padding-bottom: 0.75rem;
}

.footnote-box p, .footnote-box ol, .footnote-box ul {
    color: #9ca3af; /* gray-400 */
}

.footnote-box strong {
    color: #e5e7eb; /* gray-200 */
    font-weight: 600;
}

/* --- Header Layout Helpers --- */
.header-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.25rem;
    row-gap: 1rem;
}

.header-bar__logo {
    flex: 0 0 auto;
    min-width: 0;
}

.header-bar__primary {
    flex: 1 1 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 1.25rem;
    row-gap: 0.75rem;
    min-width: 0;
}

.header-links {
    flex: 1 1 auto;
    min-width: 0;
    column-gap: 1rem;
    row-gap: 0.5rem;
    flex-wrap: wrap;
}

.header-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem 0.75rem;
    flex: 0 1 auto;
    min-width: 0;
}

.header-controls > * {
    flex-shrink: 0;
}

.header-controls__currency {
    flex: 0 0 auto;
}

@media (max-width: 480px) {
    .header-bar {
        gap: 0.75rem;
    }

    .header-bar__logo {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.25rem;
        text-align: center;
    }

    .header-bar__logo img {
        transform: translateY(0.15rem);
    }

    .header-bar__brand {
        font-size: 1.25rem !important;
        line-height: 1.1;
        text-align: center;
        margin-top: -0.05rem;
    }
}

@media (min-width: 640px) {
    .header-controls {
        gap: 0.75rem 1rem;
    }
}

@media (min-width: 1024px) {
    .header-links {
        column-gap: 1.25rem;
    }

    .header-controls {
        gap: 1rem 1.25rem;
        margin-left: 1rem;
    }
}

@media (max-width: 1280px) {
    .header-links {
        column-gap: 0.75rem;
    }
}

/* --- Navigation Tabs --- */
.nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
    text-decoration: none;
    font-weight: 500;
    min-width: 0;
    max-width: 100%;
    line-height: 1.35;
    text-align: center;
    white-space: normal;
}

.nav-link:hover {
    background-color: rgba(55, 65, 81, 0.5); /* gray-700/50 */
    color: #fff;
}

.nav-link.active {
    background-color: #4F46E5; /* indigo-600 */
    color: #fff;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.mobile-nav-link {
    display: block;
    width: 100%;
    margin-bottom: 0.5rem;
}

/* --- Scrolling Tab Controls --- */
.scroll-button {
    display: none;
}

@media (max-width: 767px) {
    .scrolling-tabs-container {
        position: relative;
    }

    .scrolling-tabs-container::before,
    .scrolling-tabs-container::after {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        width: 3rem;
        pointer-events: none;
        transition: opacity 0.3s ease;
        opacity: 0;
        z-index: 5;
    }

    .scrolling-tabs-container::before {
        left: 0;
        background: linear-gradient(to right, rgb(31 41 55), transparent);
    }

    .scrolling-tabs-container::after {
        right: 0;
        background: linear-gradient(to left, rgb(31 41 55), transparent);
    }

    .scrolling-tabs-container.show-scroll-start::before {
        opacity: 1;
    }

    .scrolling-tabs-container.show-scroll-end::after {
        opacity: 1;
    }

    .scroll-button {
        position: absolute;
        top: 0;
        bottom: 0;
        z-index: 10;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 2.5rem;
        background-color: transparent;
        border: none;
        color: #9ca3af;
        cursor: pointer;
        transition: opacity 0.3s ease, color 0.2s ease;
        opacity: 0;
        pointer-events: none;
    }

    .scroll-button:hover {
        color: #fff;
    }

    .scroll-button.left-0 {
        left: 0;
    }

    .scroll-button.right-0 {
        right: 0;
    }

    .scrolling-tabs-container.show-scroll-start [data-scroll-button="left"],
    .scrolling-tabs-container.show-scroll-end [data-scroll-button="right"] {
        opacity: 1;
        pointer-events: auto;
    }
}

/* --- Tab & Panel Animations --- */
.tab-button {
    transition: all 0.2s ease-in-out;
    white-space: normal;
    text-align: left;
    line-height: 1.4;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 0.5rem;
}

.tab-button svg {
    flex-shrink: 0;
    margin-top: 0.05rem;
}

@media (min-width: 768px) {
    .tab-button {
        text-align: center;
        justify-content: center;
        align-items: center;
    }

    .tab-button svg {
        margin-top: 0;
    }
}

.tab-panel {
    animation: fadeIn 0.3s ease-out forwards;
}

/* --- Options Form Enhancements --- */
.radio-card {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.1rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(75, 85, 99, 0.5);
    background: rgba(17, 24, 39, 0.55);
    cursor: pointer;
    transition: border 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.radio-card:hover {
    border-color: rgba(129, 140, 248, 0.7);
    background: rgba(79, 70, 229, 0.15);
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.35);
}

.radio-card--active {
    border-color: rgba(99, 102, 241, 0.9);
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.35), 0 18px 30px rgba(30, 64, 175, 0.35);
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.18), rgba(17, 24, 39, 0.7));
}

.radio-card-title {
    display: block;
    font-weight: 600;
    color: #e5e7eb;
}

.radio-card-description {
    margin-top: 0.35rem;
    font-size: 0.85rem;
    line-height: 1.4;
    color: #94a3b8;
}

.radio-card-input {
    margin-top: 0.25rem;
    flex-shrink: 0;
    accent-color: #6366f1;
}

.breakeven-mode-toggle {
    display: inline-flex;
    padding: 0.25rem;
    background: rgba(31, 41, 55, 0.75);
    border-radius: 9999px;
    gap: 0.25rem;
    border: 1px solid rgba(75, 85, 99, 0.6);
}

.mode-toggle-button {
    border: none;
    background: transparent;
    color: #9ca3af;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.55rem 1.35rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.mode-toggle-button:not(.is-active):hover {
    color: #e5e7eb;
    background: rgba(59, 130, 246, 0.08);
}

.mode-toggle-button.is-active {
    color: #f9fafb;
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.35), rgba(59, 130, 246, 0.35));
    box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.35);
    transform: translateY(-1px);
}

.mode-toggle-button[data-breakeven-mode="pro"].is-active {
    background: linear-gradient(135deg, rgba(20, 184, 166, 0.45), rgba(14, 165, 233, 0.45));
    box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.4);
}

.link-button {
    border: none;
    background: none;
    color: #60a5fa;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
}

.link-button:hover {
    color: #93c5fd;
}

.chip-button {
    border-radius: 9999px;
    border: 1px solid rgba(156, 163, 175, 0.4);
    background: rgba(31, 41, 55, 0.6);
    color: #e5e7eb;
    font-size: 0.75rem;
    padding: 0.3rem 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.chip-button:hover,
.chip-button:focus-visible {
    background: rgba(59, 130, 246, 0.3);
    border-color: rgba(59, 130, 246, 0.5);
    outline: none;
}

.input-field--condensed {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
    min-width: 4.5rem;
}

.range-field {
    width: 100%;
    cursor: pointer;
    accent-color: #a855f7;
}

.stacked-radio-group {
    display: grid;
    gap: 0.5rem;
}

.stacked-radio-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: rgba(31, 41, 55, 0.6);
    border-radius: 0.75rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid rgba(75, 85, 99, 0.5);
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.stacked-radio-option:hover,
.stacked-radio-option:focus-within {
    border-color: rgba(96, 165, 250, 0.6);
    background: rgba(30, 64, 175, 0.35);
}

.stacked-radio-option input[type="radio"] {
    margin-top: 0.35rem;
    accent-color: #60a5fa;
}

.stacked-radio-option .option-title {
    display: block;
    font-weight: 600;
    color: #f9fafb;
    font-size: 0.9rem;
}

.stacked-radio-option .option-hint {
    display: block;
    font-size: 0.75rem;
    color: #9ca3af;
}

.collapsible-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
    list-style: none;
}

.collapsible-summary::-webkit-details-marker {
    display: none;
}

[data-collapsible-section] {
    border-radius: 1rem;
    border: 1px solid rgba(75, 85, 99, 0.4);
    background: rgba(17, 24, 39, 0.75);
}

[data-collapsible-section] + [data-collapsible-section] {
    margin-top: 1.5rem;
}

.section-card details[open] > .collapsible-summary {
    border-bottom: 1px solid rgba(55, 65, 81, 0.6);
}

.range-field:focus-visible,
.chip-button:focus-visible,
.stacked-radio-option:focus-visible,
.mode-toggle-button:focus-visible {
    outline: 2px solid rgba(59, 130, 246, 0.65);
    outline-offset: 2px;
}

.breakeven-pro-sections.hidden {
    display: none;
}

.breakeven-mode-toggle + p strong {
    color: #e0f2fe;
}

.actual-premium-container {
    display: none;
}

.actual-premium-container.is-visible {
    display: block;
}

.regreek-toggle-card {
    border-radius: 0.75rem;
    border: 1px solid rgba(75, 85, 99, 0.55);
    background: rgba(17, 24, 39, 0.55);
    padding: 1.25rem;
    transition: border 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.regreek-toggle-card:hover {
    border-color: rgba(59, 130, 246, 0.55);
}

.regreek-toggle-card[data-regreek-active="true"] {
    border-color: rgba(56, 189, 248, 0.6);
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.3), rgba(13, 148, 136, 0.2));
    box-shadow: 0 12px 24px rgba(13, 148, 136, 0.18);
}

.regreek-toggle-card:focus-within {
    border-color: rgba(129, 140, 248, 0.75);
    box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.25);
}

.toggle-switch {
    position: relative;
    display: inline-flex;
    width: 3.3rem;
    height: 1.7rem;
    border-radius: 9999px;
    border: 1px solid rgba(75, 85, 99, 0.7);
    background: linear-gradient(135deg, rgba(55, 65, 81, 0.85), rgba(17, 24, 39, 0.9));
    cursor: pointer;
    transition: background 0.25s ease, box-shadow 0.25s ease;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    position: absolute;
    inset: 0;
    border-radius: 9999px;
    background: linear-gradient(135deg, rgba(55, 65, 81, 0.85), rgba(17, 24, 39, 0.9));
    transition: background 0.25s ease, box-shadow 0.25s ease;
}

.toggle-thumb {
    position: absolute;
    top: 0.18rem;
    left: 0.2rem;
    width: 1.3rem;
    height: 1.3rem;
    border-radius: 9999px;
    background: #111827;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
    transition: transform 0.25s ease, background 0.25s ease;
}

.toggle-switch input:focus-visible + .toggle-track {
    box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.5);
}

.toggle-switch input:checked + .toggle-track {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.65), rgba(59, 130, 246, 0.65));
    box-shadow: 0 10px 24px rgba(16, 185, 129, 0.25);
}

.toggle-switch input:checked + .toggle-track + .toggle-thumb {
    transform: translateX(1.6rem);
    background: #f9fafb;
}

.language-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    border-radius: 9999px;
    padding: 0.12rem;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.85), rgba(17, 24, 39, 0.92));
    border: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 10px 28px -18px rgba(99, 102, 241, 0.6);
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.language-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 42px -22px rgba(59, 130, 246, 0.45);
}

.language-toggle input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.language-track {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    border-radius: 9999px;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.9));
    border: none;
    min-width: 9.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #9ca3af;
    letter-spacing: 0.02em;
}

.language-option {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 0.55rem 0.95rem;
    transition: color 0.25s ease;
}

.language-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.language-label--short {
    display: none;
    text-transform: uppercase;
}

.language-active {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 50%;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.6), rgba(16, 185, 129, 0.6));
    box-shadow: 0 20px 38px -22px rgba(16, 185, 129, 0.5);
    backdrop-filter: blur(8px);
    border-radius: inherit;
    transform: translateX(0);
    transition: transform 0.3s ease;
}

.language-toggle input:checked + .language-track .language-active {
    transform: translateX(100%);
}

.language-toggle input:not(:checked) + .language-track .language-option--en,
.language-toggle input:checked + .language-track .language-option--es {
    color: #f9fafb;
}

.language-toggle input:focus-visible + .language-track {
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.45);
}

.language-toggle--compact .language-track {
    min-width: 8.8rem;
    font-size: 0.7rem;
}

.language-toggle--compact .language-option {
    padding: 0.45rem 0.75rem;
}

@media (max-width: 380px) {
    .language-toggle--compact .language-track {
        min-width: 8.2rem;
        font-size: 0.66rem;
    }

    .language-toggle--compact .language-option {
        padding: 0.4rem 0.65rem;
    }
}

@media (max-width: 1280px) {
    .language-track {
        min-width: 7rem;
    }

    .language-toggle--compact .language-track {
        min-width: 6.2rem;
    }

    .language-label--full {
        display: none;
    }

    .language-label--short {
        display: inline-flex;
    }
}

.lockable-field[data-locked="false"] .lock-overlay {
    display: none;
}

.lockable-field[data-locked="true"] .lock-overlay {
    opacity: 0;
    transition: opacity 0.25s ease;
}

.lockable-field[data-locked="true"]:hover .lock-overlay {
    opacity: 1;
}

.lockable-field[data-locked="true"] input {
    cursor: not-allowed;
}

/* --- Result Tiles & Badges --- */
.result-tile {
    padding: 1.1rem 1.25rem;
    border-radius: 0.85rem;
    border: 1px solid rgba(71, 85, 105, 0.4);
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.55), rgba(15, 23, 42, 0.85));
    box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.08);
    text-align: center;
}

.result-tile-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
}

.result-tile-value {
    margin-top: 0.3rem;
    font-size: 1.9rem;
    font-weight: 700;
    color: #c7d2fe;
}

.result-tile-description {
    margin-top: 0.45rem;
    font-size: 0.82rem;
    line-height: 1.4;
    color: #94a3b8;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.status-badge svg {
    width: 1rem;
    height: 1rem;
}

/* --- Marketing card backgrounds --- */
.showcase-card__bg {
    --showcase-card-photo: none;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    pointer-events: none;
    position: absolute;
    inset: 0;
    z-index: -1;
}

.showcase-card__bg--growth {
    --showcase-card-photo: url('../images/compound-card-bg.webp');
    background-image:
        radial-gradient(circle at 12% 20%, rgba(99, 102, 241, 0.45), transparent 58%),
        radial-gradient(circle at 82% 86%, rgba(34, 211, 238, 0.3), transparent 60%),
        linear-gradient(135deg, rgba(14, 165, 233, 0.1), rgba(56, 189, 248, 0.05)),
        var(--showcase-card-photo);
}

.showcase-card__bg--diversify {
    --showcase-card-photo: url('../images/dca-card-bg.webp');
    background-image:
        radial-gradient(circle at 18% 78%, rgba(244, 114, 182, 0.4), transparent 60%),
        radial-gradient(circle at 82% 12%, rgba(129, 140, 248, 0.25), transparent 58%),
        linear-gradient(155deg, rgba(217, 70, 239, 0.08), rgba(56, 189, 248, 0.04)),
        var(--showcase-card-photo);
}

.showcase-card__bg--investor {
    --showcase-card-photo: url('../images/capital-gains-card-bg.webp');
    background-image:
        radial-gradient(circle at 18% 18%, rgba(52, 211, 153, 0.4), transparent 58%),
        radial-gradient(circle at 88% 72%, rgba(45, 212, 191, 0.3), transparent 58%),
        linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(30, 64, 175, 0.04)),
        var(--showcase-card-photo);
}

.showcase-card__bg--planning {
    --showcase-card-photo: url('../images/options-card-bg.webp');
    background-image:
        radial-gradient(circle at 14% 70%, rgba(129, 140, 248, 0.38), transparent 60%),
        radial-gradient(circle at 76% 18%, rgba(248, 113, 113, 0.24), transparent 58%),
        linear-gradient(135deg, rgba(14, 165, 233, 0.08), rgba(79, 70, 229, 0.05)),
        var(--showcase-card-photo);
}

@supports (background-image: image-set(url('../images/compound-card-bg.webp') 1x)) {
    .showcase-card__bg--growth {
        --showcase-card-photo: image-set(
            url('../images/compound-card-bg.webp') 1x,
            url('../images/compound-card-bg@2x.webp') 2x
        );
    }

    .showcase-card__bg--diversify {
        --showcase-card-photo: image-set(
            url('../images/dca-card-bg.webp') 1x,
            url('../images/dca-card-bg@2x.webp') 2x
        );
    }

    .showcase-card__bg--investor {
        --showcase-card-photo: image-set(
            url('../images/capital-gains-card-bg.webp') 1x,
            url('../images/capital-gains-card-bg@2x.webp') 2x
        );
    }

    .showcase-card__bg--planning {
        --showcase-card-photo: image-set(
            url('../images/options-card-bg.webp') 1x,
            url('../images/options-card-bg@2x.webp') 2x
        );
    }
}

.showcase-card__bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    opacity: 0.12;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.group:hover .showcase-card__bg::after {
    opacity: 0.3;
}
