/* eBay Calculator — themed edition
 * Source of truth: eoa-portal/resources/css/app.css (HSL channel variables)
 * Six themes: kopi-o (default), midnight, nyonya, terminal, sunset, aurora
 * Slogan gets its own display font per theme with signature animation.
 */

/* ============================================================
   THEME TOKENS — each theme overrides the HSL channel variables
   ============================================================ */

:root,
[data-theme="kopi-o"] {
    /* Warm Malaysian coffee-shop — cream paper, dark roast, amber sugar */
    --background: 36 33% 94%;          /* #F5EFE6 */
    --foreground: 22 22% 12%;          /* #1F1611 */
    --card: 36 40% 98%;                /* #FCFAF6 */
    --card-foreground: 22 22% 12%;
    --popover: 36 40% 98%;
    --popover-foreground: 22 22% 12%;
    --primary: 22 22% 12%;
    --primary-foreground: 36 33% 94%;
    --secondary: 33 28% 86%;
    --secondary-foreground: 22 22% 12%;
    --muted: 33 28% 86%;
    --muted-foreground: 22 12% 38%;
    --accent: 28 75% 52%;              /* amber sugar */
    --accent-foreground: 22 22% 12%;
    --destructive: 4 72% 48%;
    --destructive-foreground: 36 33% 94%;
    --border: 30 18% 82%;
    --input: 30 18% 82%;
    --ring: 28 75% 52%;

    --result-positive: 142 50% 34%;
    --result-negative: 4 72% 48%;
    --result-neutral: 22 12% 38%;

    --theme-accent: 28 75% 52%;
    --theme-glow: 28 90% 65%;
    --theme-bg-image: radial-gradient(at 18% 12%, hsl(28 80% 88% / 0.55) 0px, transparent 50%),
                      radial-gradient(at 82% 8%, hsl(22 50% 82% / 0.45) 0px, transparent 50%);
    --slogan-font: "Bungee", "Impact", system-ui, sans-serif;
    --slogan-weight: 400;
    --slogan-spacing: 0.02em;
    --slogan-transform: uppercase;
}

[data-theme="midnight"] {
    /* After-hours trader — charcoal, neon ringgit-green */
    --background: 220 14% 7%;          /* #0B0D10 */
    --foreground: 210 20% 92%;
    --card: 220 14% 10%;
    --card-foreground: 210 20% 92%;
    --popover: 220 14% 10%;
    --popover-foreground: 210 20% 92%;
    --primary: 145 75% 52%;            /* ringgit-green */
    --primary-foreground: 220 14% 7%;
    --secondary: 220 14% 16%;
    --secondary-foreground: 210 20% 92%;
    --muted: 220 14% 14%;
    --muted-foreground: 210 12% 62%;
    --accent: 145 75% 52%;
    --accent-foreground: 220 14% 7%;
    --destructive: 0 80% 58%;
    --destructive-foreground: 210 20% 92%;
    --border: 220 14% 20%;
    --input: 220 14% 20%;
    --ring: 145 75% 52%;

    --result-positive: 145 75% 52%;
    --result-negative: 0 80% 58%;
    --result-neutral: 210 12% 62%;

    --theme-accent: 145 75% 52%;
    --theme-glow: 145 95% 60%;
    --theme-bg-image: radial-gradient(at 80% 0%, hsl(145 80% 22% / 0.35) 0px, transparent 55%),
                      radial-gradient(at 0% 100%, hsl(200 80% 22% / 0.25) 0px, transparent 55%);
    --slogan-font: "Bungee", "Impact", system-ui, sans-serif;
    --slogan-weight: 400;
    --slogan-spacing: 0.04em;
    --slogan-transform: uppercase;
}

[data-theme="nyonya"] {
    /* Peranakan tilework — pastel teal, rose, ceramic */
    --background: 174 45% 94%;          /* pale teal paper */
    --foreground: 340 30% 18%;
    --card: 0 0% 100%;
    --card-foreground: 340 30% 18%;
    --popover: 0 0% 100%;
    --popover-foreground: 340 30% 18%;
    --primary: 340 55% 42%;             /* rose-red */
    --primary-foreground: 0 0% 100%;
    --secondary: 174 35% 86%;
    --secondary-foreground: 340 30% 18%;
    --muted: 174 30% 88%;
    --muted-foreground: 340 18% 38%;
    --accent: 174 60% 36%;              /* teal */
    --accent-foreground: 0 0% 100%;
    --destructive: 0 70% 50%;
    --destructive-foreground: 0 0% 100%;
    --border: 174 25% 78%;
    --input: 174 25% 78%;
    --ring: 340 55% 42%;

    --result-positive: 145 45% 35%;
    --result-negative: 0 70% 50%;
    --result-neutral: 340 18% 38%;

    --theme-accent: 340 55% 42%;
    --theme-glow: 174 60% 50%;
    --theme-bg-image: repeating-linear-gradient(
        45deg,
        hsl(174 45% 94%) 0px,
        hsl(174 45% 94%) 24px,
        hsl(174 35% 88% / 0.5) 24px,
        hsl(174 35% 88% / 0.5) 48px
    );
    --slogan-font: "Pacifico", "Brush Script MT", cursive;
    --slogan-weight: 400;
    --slogan-spacing: 0;
    --slogan-transform: none;
}

[data-theme="terminal"] {
    /* CRT terminal — black surfaces, amber body text, green reserved for accents.
     * Body text is amber-cream for legibility (think modern IDE dark + IBM 3270);
     * phosphor green is intentionally LIMITED to the slogan, the typed-cursor,
     * and the profit-positive state — exactly where the eye should snap. */
    --background: 0 0% 5%;              /* near-black, slight warmth */
    --foreground: 38 60% 78%;           /* amber-cream body text */
    --card: 0 0% 8%;
    --card-foreground: 38 60% 78%;
    --popover: 0 0% 8%;
    --popover-foreground: 38 60% 78%;
    --primary: 38 90% 60%;             /* amber for primary actions */
    --primary-foreground: 0 0% 5%;
    --secondary: 0 0% 14%;
    --secondary-foreground: 38 60% 78%;
    --muted: 0 0% 13%;
    --muted-foreground: 38 15% 58%;    /* dimmer amber for labels */
    --accent: 140 100% 55%;            /* phosphor green — accent only */
    --accent-foreground: 0 0% 5%;
    --destructive: 0 90% 60%;
    --destructive-foreground: 38 60% 78%;
    --border: 38 25% 20%;              /* amber-tinted borders */
    --input: 38 25% 20%;
    --ring: 38 90% 60%;

    --result-positive: 140 100% 60%;   /* green for positive */
    --result-negative: 0 90% 60%;
    --result-neutral: 38 15% 58%;

    --theme-accent: 140 100% 65%;
    --theme-glow: 140 100% 75%;
    --theme-bg-image: none;
    --slogan-font: "VT323", "Courier New", monospace;
    --slogan-weight: 400;
    --slogan-spacing: 0.08em;
    --slogan-transform: uppercase;
}

[data-theme="sunset"] {
    /* Pasar malam sunset — orange→magenta gradient */
    --background: 18 60% 12%;          /* deep burnt orange ground */
    --foreground: 32 90% 96%;
    --card: 18 45% 17%;
    --card-foreground: 32 90% 96%;
    --popover: 18 45% 17%;
    --popover-foreground: 32 90% 96%;
    --primary: 42 95% 60%;             /* gold */
    --primary-foreground: 18 60% 12%;
    --secondary: 18 45% 24%;
    --secondary-foreground: 32 90% 96%;
    --muted: 18 45% 22%;
    --muted-foreground: 32 50% 75%;
    --accent: 320 80% 60%;             /* magenta */
    --accent-foreground: 32 90% 96%;
    --destructive: 4 80% 58%;
    --destructive-foreground: 32 90% 96%;
    --border: 18 40% 28%;
    --input: 18 40% 28%;
    --ring: 42 95% 60%;

    --result-positive: 142 60% 55%;
    --result-negative: 4 80% 58%;
    --result-neutral: 32 50% 75%;

    --theme-accent: 42 95% 60%;
    --theme-glow: 320 80% 70%;
    --theme-bg-image: linear-gradient(180deg,
        hsl(18 60% 12%) 0%,
        hsl(320 50% 20%) 60%,
        hsl(280 50% 14%) 100%);
    --slogan-font: "Bungee", "Impact", system-ui, sans-serif;
    --slogan-weight: 400;
    --slogan-spacing: 0.02em;
    --slogan-transform: uppercase;
}

[data-theme="aurora"] {
    /* Northern lights — deep indigo with shimmering conic gradient */
    --background: 230 45% 8%;
    --foreground: 200 80% 92%;
    --card: 230 40% 12%;
    --card-foreground: 200 80% 92%;
    --popover: 230 40% 12%;
    --popover-foreground: 200 80% 92%;
    --primary: 175 80% 60%;            /* cyan */
    --primary-foreground: 230 45% 8%;
    --secondary: 230 40% 18%;
    --secondary-foreground: 200 80% 92%;
    --muted: 230 40% 16%;
    --muted-foreground: 200 30% 70%;
    --accent: 280 80% 65%;             /* violet */
    --accent-foreground: 200 80% 92%;
    --destructive: 4 80% 58%;
    --destructive-foreground: 200 80% 92%;
    --border: 230 35% 22%;
    --input: 230 35% 22%;
    --ring: 175 80% 60%;

    --result-positive: 150 75% 60%;
    --result-negative: 4 80% 58%;
    --result-neutral: 200 30% 70%;

    --theme-accent: 175 80% 60%;
    --theme-glow: 280 80% 70%;
    --theme-bg-image: conic-gradient(from 0deg at 50% -10%,
        hsl(175 80% 30% / 0.35) 0deg,
        hsl(280 80% 30% / 0.35) 120deg,
        hsl(220 80% 30% / 0.35) 240deg,
        hsl(175 80% 30% / 0.35) 360deg);
    --slogan-font: "Bungee", "Impact", system-ui, sans-serif;
    --slogan-weight: 400;
    --slogan-spacing: 0.03em;
    --slogan-transform: uppercase;
}

/* System fallback if no data-theme set yet — kopi-o warmth */
:root {
    --radius: 0.625rem;
    --container-max: 1280px;
}

/* ============================================================
   BASE
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    background-color: hsl(var(--background));
    background-image: var(--theme-bg-image);
    background-attachment: fixed;
    color: hsl(var(--foreground));
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    margin: 0;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.5s ease, color 0.5s ease;
}

h1, h2, h3, h4, h5, h6, p { margin: 0; }
[x-cloak] { display: none !important; }

/* ============================================================
   SKIP LINK (a11y)
   ============================================================ */

.skip-to-content {
    position: absolute;
    top: -100px;
    left: 1rem;
    z-index: 100;
    padding: 0.5rem 1rem;
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    border-radius: calc(var(--radius) - 2px);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: top 0.15s;
}
.skip-to-content:focus,
.skip-to-content:focus-visible {
    top: 1rem;
    outline: none;
    box-shadow: 0 0 0 3px hsl(var(--ring) / 0.5);
}

/* ============================================================
   THEME PICKER
   ============================================================ */

.theme-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.625rem 1rem;
    margin: 0 auto 1rem;
    max-width: var(--container-max);
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--card) / 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.04);
}

.theme-bar-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: hsl(var(--muted-foreground));
}

.theme-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.theme-swatch {
    --swatch-bg: hsl(var(--theme-accent));
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid hsl(var(--border));
    border-radius: 9999px;
    background: hsl(var(--background) / 0.6);
    color: hsl(var(--foreground));
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.theme-swatch:hover {
    transform: translateY(-1px);
    border-color: hsl(var(--ring));
    box-shadow: 0 4px 10px hsl(var(--theme-accent) / 0.2);
}

.theme-swatch:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px hsl(var(--ring) / 0.45);
}

.theme-swatch[aria-pressed="true"] {
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    border-color: hsl(var(--foreground));
}

.theme-swatch .dot {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    background: var(--swatch-bg);
    box-shadow: 0 0 0 2px hsl(var(--background)) inset, 0 0 8px var(--swatch-bg);
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .theme-bar { flex-direction: column; align-items: stretch; }
    .theme-options { justify-content: flex-start; }
}

/* ============================================================
   LAYOUT
   ============================================================ */

.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 1.5rem;
}

.stack-results-first { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
.stack-results-first > .stack-item-inputs   { order: 2; }
.stack-results-first > .stack-item-results  { order: 1; }

@media (min-width: 1024px) {
    .stack-results-first {
        grid-template-columns: 1fr 1.05fr;
    }
    .stack-results-first > .stack-item-inputs  { order: 1; }
    .stack-results-first > .stack-item-results { order: 2; }
}

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px)  { .grid-2 { grid-template-columns: repeat(2, 1fr); } }

.grid-3 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px)  { .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

.grid-4 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px)  { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } }

/* ============================================================
   CARD
   ============================================================ */

.card {
    background: hsl(var(--card));
    color: hsl(var(--card-foreground));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.04);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: background-color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}

.card::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    background: linear-gradient(135deg, hsl(var(--theme-accent) / 0.04) 0%, transparent 60%);
    opacity: 0.7;
}

/* ============================================================
   HEADER + BRAND
   ============================================================ */

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    min-width: 0;
}

.header-content > div:first-child {
    flex: 1 1 260px;
    min-width: 0;
}

.calculator-intro { min-width: 0; max-width: 100%; }

.brand-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.625rem;
    max-width: 100%;
    margin-bottom: 1rem;
    position: relative;
}

.brand-logo {
    display: block;
    width: min(220px, 100%);
    height: auto;
    transition: filter 0.5s ease, mix-blend-mode 0.5s ease;
}

/* On dark-background themes, lift the logo's dark text off the surface.
 * The logo PNG mixes a near-black wordmark with a magenta rocket-A. We
 * use `mix-blend-mode: screen` so dark pixels (the text) become bright
 * while the magenta accent passes through unchanged. Bright-background
 * themes get no blend so the original colors stay true. */
[data-theme="midnight"] .brand-logo,
[data-theme="terminal"] .brand-logo,
[data-theme="aurora"] .brand-logo,
[data-theme="sunset"] .brand-logo {
    mix-blend-mode: screen;
    filter: brightness(1.15) contrast(1.05);
}

/* Nyonya is the only dark-on-light logo theme that should stay pure. */

/* ============================================================
   SLOGAN — THE STAR OF THE SHOW
   Each theme animates the slogan differently.
   ============================================================ */

.brand-slogan {
    --slogan-base: hsl(var(--foreground));
    position: relative;
    max-width: 100%;
    color: var(--slogan-base);
    font-family: var(--slogan-font);
    font-weight: var(--slogan-weight);
    letter-spacing: var(--slogan-spacing);
    text-transform: var(--slogan-transform);
    font-size: clamp(1rem, 2.4vw, 1.5rem);
    line-height: 1.15;
    overflow-wrap: anywhere;
    padding: 0.15rem 0;
    display: inline-block;
}

/* ---- KOPI-O: gentle coffee steam on hover ---- */
[data-theme="kopi-o"] .brand-slogan {
    text-shadow: 0 1px 0 hsl(var(--theme-accent) / 0.35);
    transition: transform 0.4s ease;
}
[data-theme="kopi-o"] .brand-slogan:hover {
    transform: translateY(-2px) rotate(-0.6deg);
}
[data-theme="kopi-o"] .brand-slogan::before {
    content: "";
    position: absolute;
    left: 8%;
    top: -120%;
    width: 80%;
    height: 120%;
    pointer-events: none;
    background:
        radial-gradient(circle at 30% 80%, hsl(var(--theme-accent) / 0.18) 0 6px, transparent 7px),
        radial-gradient(circle at 65% 60%, hsl(var(--theme-accent) / 0.12) 0 5px, transparent 6px);
    opacity: 0;
    transition: opacity 0.4s ease;
}
[data-theme="kopi-o"] .brand-slogan:hover::before {
    opacity: 1;
    animation: steam-rise 1.8s ease-out infinite;
}
@keyframes steam-rise {
    0%   { transform: translateY(20px) scale(0.6); opacity: 0; }
    40%  { opacity: 0.9; }
    100% { transform: translateY(-30px) scale(1.1); opacity: 0; }
}

/* ---- MIDNIGHT: glitch flicker ---- */
[data-theme="midnight"] .brand-slogan {
    color: hsl(var(--theme-accent));
    text-shadow:
        0 0 6px hsl(var(--theme-glow) / 0.6),
        0 0 18px hsl(var(--theme-glow) / 0.35);
    animation: glitch-flicker 4.5s infinite;
}
@keyframes glitch-flicker {
    0%, 92%, 100% { transform: translate(0, 0); filter: none; }
    93%   { transform: translate(-2px, 1px); filter: hue-rotate(20deg); }
    94%   { transform: translate(2px, -1px); }
    95%   { transform: translate(-1px, 0); filter: hue-rotate(-20deg); }
    96%   { transform: translate(0, 0); filter: none; }
}

/* ---- NYONNYA: stamped ink underline ---- */
[data-theme="nyonya"] .brand-slogan {
    color: hsl(var(--foreground));
    font-style: italic;
    display: inline-block;
    position: relative;
    padding-bottom: 0.35rem;
}
[data-theme="nyonya"] .brand-slogan::after {
    content: "";
    position: absolute;
    left: 4%;
    bottom: -2px;
    height: 6px;
    width: 0;
    background: linear-gradient(90deg,
        hsl(var(--accent)),
        hsl(var(--accent) / 0.4));
    border-radius: 999px;
    transition: width 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}
[data-theme="nyonya"] .brand-slogan.is-loaded::after { width: 92%; }

/* ---- TERMINAL: typed letter-by-letter ---- */
[data-theme="terminal"] .brand-slogan {
    color: hsl(var(--theme-accent));
    text-shadow: 0 0 6px hsl(var(--theme-glow) / 0.7);
    border-right: 2px solid hsl(var(--theme-accent));
    white-space: nowrap;
    overflow: hidden;
    width: 0;
    animation: type-slogan 3.2s steps(38, end) 0.3s forwards,
               cursor-blink 0.9s step-end infinite;
}
@keyframes type-slogan {
    from { width: 0; }
    to   { width: 100%; }
}
@keyframes cursor-blink {
    50% { border-color: transparent; }
}

/* ---- SUNSET: shimmering gold foil sweep ---- */
[data-theme="sunset"] .brand-slogan {
    background: linear-gradient(110deg,
        hsl(42 95% 70%) 0%,
        hsl(42 95% 90%) 30%,
        hsl(28 90% 55%) 50%,
        hsl(42 95% 90%) 70%,
        hsl(42 95% 70%) 100%);
    background-size: 250% 100%;
    -webkit-background-clip: text;
            background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    animation: foil-sweep 4s ease-in-out infinite;
    filter: drop-shadow(0 0 12px hsl(var(--theme-glow) / 0.35));
}
@keyframes foil-sweep {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

/* ---- AURORA: northern-lights shimmer wave ---- */
[data-theme="aurora"] .brand-slogan {
    background: linear-gradient(90deg,
        hsl(175 90% 70%),
        hsl(220 90% 75%),
        hsl(280 90% 75%),
        hsl(175 90% 70%));
    background-size: 300% 100%;
    -webkit-background-clip: text;
            background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    animation: aurora-flow 6s ease-in-out infinite;
    filter: drop-shadow(0 0 10px hsl(175 80% 60% / 0.45));
}
@keyframes aurora-flow {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

/* ============================================================
   TICKER (a recurring accent under the slogan)
   ============================================================ */

.slogan-ticker {
    overflow: hidden;
    border-top: 1px dashed hsl(var(--border));
    border-bottom: 1px dashed hsl(var(--border));
    margin: -0.5rem 0 1rem;
    padding: 0.4rem 0;
    background: hsl(var(--muted) / 0.3);
    border-radius: calc(var(--radius) - 2px);
}

.slogan-ticker-track {
    display: inline-flex;
    gap: 2.5rem;
    white-space: nowrap;
    animation: ticker-scroll 28s linear infinite;
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
    font-family: ui-sans-serif, system-ui, sans-serif;
}

.slogan-ticker-track span {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.slogan-ticker-track span::before {
    content: "✦";
    color: hsl(var(--theme-accent));
    font-size: 0.7em;
}

@keyframes ticker-scroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

/* ============================================================
   FEE NOTE + ACTIONS
   ============================================================ */

.fee-schedule-note {
    max-width: 100%;
    margin-top: 0.75rem;
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
    line-height: 1.25rem;
    overflow-wrap: anywhere;
}
.fee-schedule-note strong {
    color: hsl(var(--foreground));
    font-weight: 600;
}

.rate-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    min-width: 0;
    max-width: 100%;
}

.rate-box {
    flex: 1 1 200px;
    min-width: 0;
    max-width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 2px);
    background: hsl(var(--background));
    transition: background-color 0.5s ease, border-color 0.5s ease;
}

.currency-toggle {
    display: flex;
    gap: 0.25rem;
    padding: 0.25rem;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 2px);
    background: hsl(var(--background));
    max-width: 100%;
}

/* ============================================================
   FORM CONTROLS
   ============================================================ */

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--foreground));
    margin-bottom: 0.25rem;
}

.grid-2 > div > label,
.grid-3 > div > label,
.grid-4 > div > label {
    min-height: 2.75rem;
}

input[type="text"],
input[type="number"],
select,
textarea {
    display: flex;
    width: 100%;
    min-width: 0;
    height: 2.5rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid hsl(var(--input));
    border-radius: calc(var(--radius) - 2px);
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    font-size: 0.875rem;
    line-height: 1.25rem;
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.5s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15);
}

input[type="checkbox"] {
    accent-color: hsl(var(--foreground));
    width: 1rem;
    height: 1rem;
}

.checkbox {
    width: auto !important;
    height: auto !important;
    display: inline-block;
    margin-right: 0.5rem;
    vertical-align: middle;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 2px);
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s, transform 0.15s ease;
}

.btn:hover {
    background: hsl(var(--muted));
    transform: translateY(-1px);
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px hsl(var(--ring) / 0.35);
}

.btn-active {
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    border-color: hsl(var(--foreground));
}
.btn-active:hover {
    background: hsl(var(--foreground) / 0.9);
}

.btn-primary {
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    border-color: hsl(var(--foreground));
    position: relative;
    overflow: hidden;
}
.btn-primary:hover {
    background: hsl(var(--foreground) / 0.9);
}
.btn-primary::after {
    content: "";
    position: absolute;
    top: 50%;
    left: -100%;
    width: 60%;
    height: 200%;
    background: linear-gradient(120deg,
        transparent 30%,
        hsl(var(--theme-accent) / 0.35) 50%,
        transparent 70%);
    transform: translateY(-50%);
    transition: left 0.6s ease;
}
.btn-primary:hover::after { left: 120%; }

.flex-1 { flex: 1 1 0%; }

/* ============================================================
   TYPOGRAPHY UTILITIES
   ============================================================ */

.text-xs   { font-size: 0.75rem; line-height: 1rem; }
.text-sm   { font-size: 0.875rem; line-height: 1.25rem; }
.text-lg   { font-size: 1.125rem; line-height: 1.75rem; }
.text-2xl  { font-size: 1.5rem; line-height: 2rem; }
.text-3xl  { font-size: 1.875rem; line-height: 2.25rem; }

.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

.text-foreground         { color: hsl(var(--foreground)); }
.text-muted-foreground   { color: hsl(var(--muted-foreground)); }
.text-positive           { color: hsl(var(--result-positive)); }
.text-negative           { color: hsl(var(--result-negative)); }
.text-neutral-result     { color: hsl(var(--result-neutral)); }

.text-center  { text-align: center; }
.text-right   { text-align: right; }

.uppercase    { text-transform: uppercase; }
.tracking-wider { letter-spacing: 0.05em; }
.tracking-tight { letter-spacing: 0; }

/* ============================================================
   SPACING
   ============================================================ */

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mr-2 { margin-right: 0.5rem; }
.ml-2 { margin-left: 0.5rem; }
.p-3  { padding: 0.75rem; }
.p-4  { padding: 1rem; }
.p-6  { padding: 1.5rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.border-b { border-bottom: 1px solid hsl(var(--border)); }
.rounded      { border-radius: calc(var(--radius) - 2px); }
.rounded-md   { border-radius: calc(var(--radius) - 2px); }
.rounded-lg   { border-radius: var(--radius); }

/* ============================================================
   LAYOUT HELPERS
   ============================================================ */

.flex         { display: flex; }
.items-center { align-items: center; }
.items-end    { align-items: flex-end; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.gap-2        { gap: 0.5rem; }
.gap-3        { gap: 0.75rem; }
.gap-4        { gap: 1rem; }
.flex-wrap    { flex-wrap: wrap; }
.hidden       { display: none; }
.block        { display: block; }
.w-full       { width: 100%; }

/* ============================================================
   RESULT BLOCKS
   ============================================================ */

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0;
    border-bottom: 1px solid hsl(var(--border));
}
.result-row:last-child { border-bottom: 0; }

.result-hero {
    background: hsl(var(--muted) / 0.5);
    border-radius: calc(var(--radius) - 2px);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
    transition: background-color 0.5s ease;
}

.result-hero-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.result-hero-number {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.1;
    color: hsl(var(--foreground));
    transition: color 0.4s ease;
}
.result-hero-number.text-positive { color: hsl(var(--result-positive)); }
.result-hero-number.text-negative { color: hsl(var(--result-negative)); }

/* Profit pulse — only when positive change */
[data-theme="midnight"] .result-hero-number.text-positive,
[data-theme="sunset"] .result-hero-number.text-positive,
[data-theme="aurora"] .result-hero-number.text-positive {
    animation: profit-pulse 2.6s ease-in-out infinite;
}
@keyframes profit-pulse {
    0%, 100% { filter: drop-shadow(0 0 0 transparent); }
    50%      { filter: drop-shadow(0 0 14px hsl(var(--result-positive) / 0.55)); }
}

/* ============================================================
   SPINNER
   ============================================================ */

.spin {
    display: inline-block;
    width: 1rem;
    height: 1rm;
    width: 1rem;
    height: 1rem;
    border: 2px solid hsl(var(--border));
    border-top-color: hsl(var(--foreground));
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   CRT scanlines (terminal theme only)
   ============================================================ */

[data-theme="terminal"] body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 3px,
        hsl(38 60% 70% / 0.025) 4px,
        transparent 5px
    );
    mix-blend-mode: overlay;
}

/* ============================================================
   AURORA conic rotation
   ============================================================ */

[data-theme="aurora"] body {
    background-image: conic-gradient(from var(--aurora-angle, 0deg) at 50% -10%,
        hsl(175 80% 30% / 0.4) 0deg,
        hsl(280 80% 30% / 0.4) 120deg,
        hsl(220 80% 30% / 0.4) 240deg,
        hsl(175 80% 30% / 0.4) 360deg);
    animation: aurora-rotate 22s linear infinite;
}
@keyframes aurora-rotate {
    from { --aurora-angle: 0deg; }
    to   { --aurora-angle: 360deg; }
}

/* ============================================================
   BADGES + FOOTER
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    border: 1px solid hsl(var(--border));
}

footer {
    text-align: center;
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    margin-top: 1.5rem;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

footer p { margin: 0; }

.footer-credit {
    color: hsl(var(--foreground));
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.footer-credit strong {
    color: hsl(var(--theme-accent));
    font-weight: 600;
}

/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 639px) {
    .container { padding: 1rem; }
    .card { padding: 1rem; }

    .header-content,
    .rate-actions { align-items: stretch; width: 100%; }

    .brand-logo { width: min(190px, 100%); }

    .rate-box { flex-basis: 100%; }

    .currency-toggle {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .currency-toggle .btn {
        width: 100%;
        min-width: 0;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .result-row { align-items: flex-start; gap: 0.75rem; }
    .result-row > span:first-child {
        min-width: 0;
        overflow-wrap: anywhere;
    }
    .result-row > span:last-child {
        flex: 0 0 auto;
        text-align: right;
        white-space: nowrap;
    }

    .result-hero-number { font-size: 1.875rem; }
}

/* ============================================================
   REDUCED MOTION — respect user preference
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .slogan-ticker-track { animation: none; }
    [data-theme="terminal"] .brand-slogan {
        width: auto;
        border-right: 0;
    }
}

/* ============================================================
   THEME TRANSITION HELPERS
   ============================================================ */

.theme-fade {
    animation: theme-fade-in 0.45s ease-out;
}
@keyframes theme-fade-in {
    from { opacity: 0.4; transform: translateY(4px); }
    to   { opacity: 1;   transform: translateY(0); }
}