@import "./fonts.css";
@tailwind base;
@tailwind components;
@tailwind utilities;

/* Colour palettes (same set as Dot). Shades are 'R G B' triples. */
:root, :root[data-palette="citrus"] { --brand-50:255 247 237; --brand-100:255 237 213; --brand-200:253 186 116; --brand-300:253 186 116; --brand-400:251 146 60; --brand-500:249 115 22; --brand-600:234 88 12; --brand-700:194 65 12; --brand-800:154 52 18; --brand-900:124 45 18; --brand-rgb:249,115,22; --accent2-rgb:234,179,8; }
:root[data-palette="coral"] { --brand-50:255 247 237; --brand-100:255 237 213; --brand-200:253 186 116; --brand-300:253 186 116; --brand-400:251 146 60; --brand-500:249 115 22; --brand-600:234 88 12; --brand-700:194 65 12; --brand-800:154 52 18; --brand-900:124 45 18; --brand-rgb:249,115,22; --accent2-rgb:253,186,116; }
:root[data-palette="emerald"] { --brand-50:236 253 245; --brand-100:209 250 229; --brand-200:110 231 183; --brand-300:110 231 183; --brand-400:52 211 153; --brand-500:16 185 129; --brand-600:5 150 105; --brand-700:4 120 87; --brand-800:6 95 70; --brand-900:6 78 59; --brand-rgb:16,185,129; --accent2-rgb:110,231,183; }
:root[data-palette="ocean"] { --brand-50:239 246 255; --brand-100:219 234 254; --brand-200:147 197 253; --brand-300:147 197 253; --brand-400:96 165 250; --brand-500:59 130 246; --brand-600:37 99 235; --brand-700:29 78 216; --brand-800:30 64 175; --brand-900:30 58 138; --brand-rgb:59,130,246; --accent2-rgb:147,197,253; }
:root[data-palette="violet"] { --brand-50:245 243 255; --brand-100:237 233 254; --brand-200:196 181 253; --brand-300:196 181 253; --brand-400:167 139 250; --brand-500:139 92 246; --brand-600:124 58 237; --brand-700:109 40 217; --brand-800:91 33 182; --brand-900:76 29 149; --brand-rgb:139,92,246; --accent2-rgb:196,181,253; }
:root[data-palette="rose"] { --brand-50:255 241 242; --brand-100:255 228 230; --brand-200:253 164 175; --brand-300:253 164 175; --brand-400:251 113 133; --brand-500:244 63 94; --brand-600:225 29 72; --brand-700:190 18 60; --brand-800:159 18 57; --brand-900:136 19 55; --brand-rgb:244,63,94; --accent2-rgb:253,164,175; }
:root[data-palette="amber"] { --brand-50:255 251 235; --brand-100:254 243 199; --brand-200:252 211 77; --brand-300:252 211 77; --brand-400:251 191 36; --brand-500:245 158 11; --brand-600:217 119 6; --brand-700:180 83 9; --brand-800:146 64 14; --brand-900:120 53 15; --brand-rgb:245,158,11; --accent2-rgb:252,211,77; }
:root[data-palette="teal"] { --brand-50:240 253 250; --brand-100:204 251 241; --brand-200:94 234 212; --brand-300:94 234 212; --brand-400:45 212 191; --brand-500:20 184 166; --brand-600:13 148 136; --brand-700:15 118 110; --brand-800:17 94 89; --brand-900:19 78 74; --brand-rgb:20,184,166; --accent2-rgb:94,234,212; }
:root[data-palette="slate"] { --brand-50:248 250 252; --brand-100:241 245 249; --brand-200:203 213 225; --brand-300:203 213 225; --brand-400:148 163 184; --brand-500:100 116 139; --brand-600:71 85 105; --brand-700:51 65 85; --brand-800:30 41 59; --brand-900:15 23 42; --brand-rgb:100,116,139; --accent2-rgb:203,213,225; }
:root[data-palette="sky"] { --brand-50:240 249 255; --brand-100:224 242 254; --brand-200:125 211 252; --brand-300:125 211 252; --brand-400:56 189 248; --brand-500:14 165 233; --brand-600:2 132 199; --brand-700:3 105 161; --brand-800:7 89 133; --brand-900:12 74 110; --brand-rgb:14,165,233; --accent2-rgb:125,211,252; }
:root[data-palette="indigo"] { --brand-50:238 242 255; --brand-100:224 231 255; --brand-200:165 180 252; --brand-300:165 180 252; --brand-400:129 140 248; --brand-500:99 102 241; --brand-600:79 70 229; --brand-700:67 56 202; --brand-800:55 48 163; --brand-900:49 46 129; --brand-rgb:99,102,241; --accent2-rgb:165,180,252; }
:root[data-palette="fuchsia"] { --brand-50:253 244 255; --brand-100:250 232 255; --brand-200:240 171 252; --brand-300:240 171 252; --brand-400:232 121 249; --brand-500:217 70 239; --brand-600:192 38 211; --brand-700:162 28 175; --brand-800:134 25 143; --brand-900:112 26 117; --brand-rgb:217,70,239; --accent2-rgb:240,171,252; }
:root[data-palette="crimson"] { --brand-50:254 242 242; --brand-100:254 226 226; --brand-200:252 165 165; --brand-300:252 165 165; --brand-400:248 113 113; --brand-500:239 68 68; --brand-600:220 38 38; --brand-700:185 28 28; --brand-800:153 27 27; --brand-900:127 29 29; --brand-rgb:239,68,68; --accent2-rgb:252,165,165; }
:root[data-palette="sunset"] { --brand-50:255 247 237; --brand-100:255 237 213; --brand-200:253 186 116; --brand-300:253 186 116; --brand-400:251 146 60; --brand-500:249 115 22; --brand-600:234 88 12; --brand-700:194 65 12; --brand-800:154 52 18; --brand-900:124 45 18; --brand-rgb:249,115,22; --accent2-rgb:236,72,153; }
:root[data-palette="aurora"] { --brand-50:236 253 245; --brand-100:209 250 229; --brand-200:110 231 183; --brand-300:110 231 183; --brand-400:52 211 153; --brand-500:16 185 129; --brand-600:5 150 105; --brand-700:4 120 87; --brand-800:6 95 70; --brand-900:6 78 59; --brand-rgb:16,185,129; --accent2-rgb:6,182,212; }
:root[data-palette="cosmos"] { --brand-50:238 242 255; --brand-100:224 231 255; --brand-200:165 180 252; --brand-300:165 180 252; --brand-400:129 140 248; --brand-500:99 102 241; --brand-600:79 70 229; --brand-700:67 56 202; --brand-800:55 48 163; --brand-900:49 46 129; --brand-rgb:99,102,241; --accent2-rgb:217,70,239; }
:root[data-palette="berry"] { --brand-50:254 242 242; --brand-100:254 226 226; --brand-200:252 165 165; --brand-300:252 165 165; --brand-400:248 113 113; --brand-500:239 68 68; --brand-600:220 38 38; --brand-700:185 28 28; --brand-800:153 27 27; --brand-900:127 29 29; --brand-rgb:239,68,68; --accent2-rgb:124,58,237; }
:root[data-palette="lagoon"] { --brand-50:240 249 255; --brand-100:224 242 254; --brand-200:125 211 252; --brand-300:125 211 252; --brand-400:56 189 248; --brand-500:14 165 233; --brand-600:2 132 199; --brand-700:3 105 161; --brand-800:7 89 133; --brand-900:12 74 110; --brand-rgb:14,165,233; --accent2-rgb:20,184,166; }

/* Design tokens - shared "Dot family" language; accent follows the chosen palette */
:root {
    --bg-primary: rgb(var(--brand-50));                       /* pale tinted page */
    --bg-secondary: #ffffff;                                   /* card / surface */
    --bg-inset: color-mix(in srgb, rgb(var(--brand-50)) 45%, #ffffff);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --action-primary: rgb(var(--brand-600));
    --action-hover: rgb(var(--brand-700));
    --action-soft: rgb(var(--brand-500) / 0.1);
    --success: #059669;
    --success-soft: rgba(16, 185, 129, 0.1);
    --error: #e11d48;
    --border-default: color-mix(in srgb, rgb(var(--brand-200)) 30%, #e7e5e4);
    --shadow-glass: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.theme-dark {
    --bg-primary: #070605;          /* near-black page */
    --bg-secondary: #0a0a0a;        /* surface */
    --bg-inset: #111010;
    --text-primary: #f1f5f9;
    --text-secondary: #a1a1aa;
    --text-muted: #8a8a93;
    --action-primary: rgb(var(--brand-400));
    --action-hover: rgb(var(--brand-500));
    --action-soft: rgb(var(--brand-400) / 0.1);
    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.1);
    --error: #fb7185;
    --border-default: rgba(255, 255, 255, 0.1);
    --shadow-glass: none;
}

/* Base Styles */
html { color-scheme: light; }
html:has(body.theme-dark) { color-scheme: dark; }
body, button, input, textarea, select {
    font-family: 'Exo 2', system-ui, sans-serif;
}
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Utility Classes */
.font-poppins { font-family: 'Exo 2', system-ui, sans-serif; }
.tabular-nums { font-variant-numeric: tabular-nums; }

/* Surface (kept the old class name so every screen picks it up) */
.glass {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-glass);
}

/* Card hover glow, Dot style */
.glass-glow {
    position: relative;
    transition: border-color .25s ease, box-shadow .25s ease;
}
@media (hover: hover) {
    .glass-glow:hover {
        border-color: rgba(var(--brand-rgb), .35);
        box-shadow: 0 14px 36px rgba(var(--brand-rgb), .08);
    }
}

/* Primary Button */
.btn-primary {
    /* brand-700 keeps white text above the 4.5:1 contrast ratio in every palette */
    background: var(--action-primary-solid, rgb(var(--brand-700)));
    color: #fff;
    box-shadow: 0 10px 15px -3px rgba(var(--brand-rgb), .2), 0 4px 6px -4px rgba(var(--brand-rgb), .2);
    transition: background-color .2s ease, transform .2s ease;
}
.btn-primary:hover { background: rgb(var(--brand-800)); }
.btn-primary:active { transform: scale(.98); }

/* Eyebrow label above page headlines */
.eyebrow {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .16em;
    color: var(--action-primary);
}

/* Ambient background: soft blobs + non-interactive growth rings/bars */
.ambient-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.ambient-blob { position: absolute; border-radius: 9999px; filter: blur(90px); opacity: .5; animation: ambient-drift 18s ease-in-out infinite; }
.ambient-blob--1 { width: 420px; height: 420px; top: -120px; right: 10%; background: rgba(var(--brand-rgb), .18); }
.ambient-blob--2 { width: 360px; height: 360px; bottom: -140px; left: 20%; background: rgba(var(--accent2-rgb), .12); animation-delay: -6s; }
.theme-dark .ambient-blob--1 { background: rgba(var(--brand-rgb), .14); }
.theme-dark .ambient-blob--2 { background: rgba(var(--accent2-rgb), .1); }
@keyframes ambient-drift { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(30px, -30px) scale(1.08); } }
@media (max-width: 767px) { .ambient-blob { filter: blur(60px); } }

/* Money art: 3 outline coins + 1 outline note, Dot-style slow motion */
/* Lives in the top hero strip (header + page heading) and scrolls with nothing */
.hero-money {
    position: absolute; left: 0; right: 0; top: 0; height: 290px; z-index: 0;
    pointer-events: none; overflow: hidden;
    color: rgb(var(--brand-rgb)); opacity: .34;
    -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 45%), linear-gradient(to bottom, #000 80%, transparent);
    -webkit-mask-composite: source-in;
    mask-image: linear-gradient(to right, transparent 0%, #000 45%), linear-gradient(to bottom, #000 80%, transparent);
    mask-composite: intersect;
}
.theme-dark .hero-money { opacity: .32; }
.money-coin, .money-note { position: absolute; will-change: transform; }
.money-coin--1 { width: 190px; height: 190px; top: 8px; right: 4%; animation: money-float 14s ease-in-out infinite; }
.money-coin--2 { width: 104px; height: 104px; top: 18px; right: 33%; animation: money-float 17s ease-in-out -6s infinite; }
.money-coin--3 { width: 70px; height: 70px; top: 168px; right: 44%; animation: money-float 12s ease-in-out -3s infinite; }
.money-note { width: 220px; height: 116px; top: 128px; right: 19%; animation: note-float 16s ease-in-out infinite; }
/* coins revolve slowly like Dot's ring; the dashed inner ring turns the other way */
.money-spin { width: 100%; height: 100%; animation: orbit-turn 40s linear infinite; }
.money-coin--2 .money-spin { animation-duration: 55s; animation-direction: reverse; }
.money-coin--3 .money-spin { animation-duration: 32s; }
.coin-ring { transform-box: fill-box; transform-origin: center; animation: orbit-turn 24s linear infinite reverse; }
@keyframes orbit-turn { to { transform: rotate(360deg); } }
@keyframes money-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-18px); } }
@keyframes note-float {
    0%, 100% { transform: translateY(0) rotate(-8deg); }
    50%      { transform: translateY(-20px) rotate(-3deg); }
}
@media (max-width: 767px) {
    .hero-money { height: 260px; opacity: .24; }
    .money-coin--1 { width: 130px; height: 130px; top: 40px; right: -24px; }
    .money-coin--2 { width: 70px; height: 70px; top: 150px; right: 38%; }
    .money-coin--3 { display: none; }
    .money-note { width: 150px; height: 79px; top: 175px; right: 6%; }
}

/* Entrance animation for cards */
.dot-reveal { animation: dot-reveal .7s cubic-bezier(.22, 1, .36, 1) backwards; }
.dot-reveal-1 { animation-delay: .06s; } .dot-reveal-2 { animation-delay: .12s; } .dot-reveal-3 { animation-delay: .18s; }
@keyframes dot-reveal { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }

/* Keyboard focus, palette-aware */
:focus-visible { outline: 2px solid rgb(var(--brand-rgb)); outline-offset: 3px; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; }
#root { height: 100vh; height: 100dvh; }

/* Mobile bottom navigation */
.mobile-nav { padding-bottom: max(8px, env(safe-area-inset-bottom)); }

/* Scrollbar Styles */
.custom-scrollbar::-webkit-scrollbar { width: 4px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(var(--brand-rgb), .5);
    border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: rgb(var(--brand-rgb)); }
* { scrollbar-color: rgba(var(--brand-rgb), .5) transparent; }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Animations - Use GPU-accelerated properties */
.fade-in { 
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1); 
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(12px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.animate-scale-in { 
    animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1); 
}

@keyframes scaleIn {
    from { 
        opacity: 0; 
        transform: scale(0.9); 
    }
    to { 
        opacity: 1; 
        transform: scale(1); 
    }
}

/* Reduce animations on mobile and for users who prefer reduced motion */
@media (max-width: 768px), (prefers-reduced-motion: reduce) {
    .fade-in {
        animation: fadeInSimple 0.3s ease-out;
    }
    
    @keyframes fadeInSimple {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    
    .animate-scale-in {
        animation: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dot-reveal, .ambient-blob { animation: none; }
}

/* ---------- Scrolling ---------- */
/* Main page area: Lenis eases mouse-wheel scrolling (see hooks/useSmoothScroll). */
.app-scroll {
    overscroll-behavior: contain;          /* no scroll chaining / rubber-banding the whole app */
    scrollbar-gutter: stable;              /* pages of different length don't jump sideways */
    scroll-padding-top: 16px;
}
@media (prefers-reduced-motion: no-preference) {
    html, .app-scroll, .overflow-y-auto, .overflow-x-auto { scroll-behavior: smooth; }  /* keyboard / anchor jumps */
}
.lenis.lenis-smooth { scroll-behavior: auto !important; }      /* Lenis does the easing itself */
.lenis:not(.lenis-autoToggle).lenis-stopped { overflow: clip; }
.lenis.lenis-smooth iframe { pointer-events: none; }
/* Inner scroll areas (lists, menus, pop-ups) keep their scroll to themselves */
.overflow-y-auto, .overflow-x-auto, .overflow-auto, .select-menu { overscroll-behavior: contain; }
body { overscroll-behavior: none; }

/* Header gets a hairline once content scrolls beneath it */
.app-header { transition: box-shadow .25s ease, background-color .25s ease; }
@media (min-width: 1024px) {
    .app-header[data-scrolled] { box-shadow: 0 1px 0 var(--border-default); }
}

/* Back to top */
.back-to-top {
    bottom: calc(88px + env(safe-area-inset-bottom));
    opacity: 0; transform: translateY(12px) scale(.9); pointer-events: none;
    transition: opacity .25s ease, transform .3s var(--ease-out, ease), background-color .2s ease;
}
.back-to-top.is-visible { opacity: 1; transform: none; pointer-events: auto; }
@media (min-width: 1024px) { .back-to-top { bottom: 32px; } }

/* ---------- UI standards ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
/* Faster taps on touch screens (no double-tap-zoom delay) */
a, button, [role="button"], [role="option"], [role="tab"], label, input, select, textarea, summary { touch-action: manipulation; }
/* Buttons and nav shouldn't select as text on double-click / long-press */
button, [role="button"], [role="tab"], [role="option"], nav { -webkit-user-select: none; user-select: none; }
/* Headings break evenly, paragraphs avoid lone last words */
h1, h2, h3, h4 { text-wrap: balance; }
p { text-wrap: pretty; }
/* Numbers line up in columns */
.tabular-nums, table td { font-variant-numeric: tabular-nums; }
/* Text selection in the palette colour */
::selection { background: rgba(var(--brand-rgb), .25); }
/* Stop iOS zooming into a field: inputs must be at least 16px on phones */
@media (max-width: 767px) {
    :is(input, select, textarea):is([class*="text-xs"], [class*="text-sm"], [class*="text-[1"]),
    :is(input, select, textarea):not([class*="text-"]) { font-size: 16px; }
}
/* Mouse users don't get a focus ring on click; keyboard users always do */
:focus:not(:focus-visible) { outline: none; }
/* Windows high-contrast mode keeps visible focus */
@media (forced-colors: active) { :focus-visible { outline: 2px solid CanvasText; } }

/* Respect "reduce motion" everywhere: no looping or sliding animation */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Custom Date Input Styling */
input[type="date"] {
    position: relative;
    color-scheme: light; /* Default */
}

.theme-dark input[type="date"] {
    color-scheme: dark;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    background: transparent;
    bottom: 0;
    color: transparent;
    cursor: pointer;
    height: auto;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    width: auto;
    z-index: 10;
}

/* Ensure placeholder-like behavior for date input when empty or unselected */
input[type="date"]::-webkit-datetime-edit {
    display: flex;
}

input[type="date"]::-webkit-datetime-edit-fields-wrapper {
    padding-left: 0.5rem;
}

/* Citrus logo pieces that follow the theme */
.dark-stroke-white { stroke: #1e293b; }
.theme-dark .dark-stroke-white { stroke: #ffffff; }
.citrus-logo-cut { stroke: var(--bg-secondary); }
.citrus-logo-core { fill: var(--bg-secondary); }


/* ---------- Motion & transitions ---------- */
:root { --ease-out: cubic-bezier(.22, 1, .36, 1); }

/* Progress bars grow from the left on first paint and glide when values change */
.progress-fill {
    position: relative; overflow: hidden;
    transform-origin: left center;
    animation: bar-grow 1.1s var(--ease-out) both;
    transition: width .8s var(--ease-out), background-color .3s ease;
}
.progress-fill::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent);
    transform: translateX(-100%);
    animation: bar-shine 2.4s 1.1s ease-in-out;
}
@keyframes bar-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes bar-shine { to { transform: translateX(100%); } }

/* Page change: content slides up softly */
.page-enter { animation: page-enter .45s var(--ease-out) backwards; }
@keyframes page-enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Pop-ups and overlays (the components already use these class names) */
.animate-in { animation: pop-enter .32s var(--ease-out) backwards; }
.animate-in.fade-in:not([class*="zoom-in"]):not([class*="slide-in"]) { animation-name: overlay-enter; }
@keyframes overlay-enter { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-enter { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.animate-in[class*="slide-in-from-top"] { animation-name: drop-enter; }
@keyframes drop-enter { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* Staggered list rows */
.list-enter { animation: list-enter .4s var(--ease-out) backwards; }
@keyframes list-enter { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }

/* Smooth hover/focus colour changes on every button */
button { transition-property: color, background-color, border-color, box-shadow, opacity; transition-duration: .2s; }

/* Theme switch cross-fade: only while switching (see utils/themeFade.ts), never on page load */
html.theme-switching :is(body, .glass, aside, header, .mobile-nav) { transition: background-color .4s ease, border-color .4s ease, color .3s ease; }

/* Until the app has loaded (html.motion-ready, set in index.tsx) the decorative loops stay still
   and the first page appears without a fade, so first paint and the headline are not delayed. */
html:not(.motion-ready) :is(.money-coin, .money-note, .money-spin, .coin-ring, .ambient-blob, .vault-pattern-spin, .vault-pattern-drift) { animation-play-state: paused; }
html:not(.motion-ready) .page-enter { animation: none; }
/* The dashed ring turns an SVG child, which repaints on the main thread every frame: skip it on phones. */
@media (max-width: 767px) { .coin-ring { animation: none; } }

@media (prefers-reduced-motion: reduce) {
    .money-coin, .money-note, .money-spin, .coin-ring, .ambient-blob,
    .progress-fill, .progress-fill::after, .page-enter, .animate-in, .list-enter { animation: none !important; }
}

/* Custom dropdown menu */
.select-menu { animation: drop-enter .16s var(--ease-out) both; transform-origin: top; }
.select-menu--up { transform-origin: bottom; }
@media (prefers-reduced-motion: reduce) { .select-menu { animation: none; } }

/* ---------- Toasts (Dot-style) ---------- */
.toast-viewport {
    position: fixed; z-index: 500; left: 50%; transform: translateX(-50%);
    bottom: calc(84px + env(safe-area-inset-bottom));
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    width: max-content; max-width: calc(100vw - 32px); pointer-events: none;
}
@media (min-width: 1024px) { .toast-viewport { bottom: 28px; } }
.toast {
    pointer-events: auto; display: flex; align-items: center; gap: 10px;
    min-width: min(320px, calc(100vw - 32px)); max-width: 460px;
    padding: 12px 12px 12px 16px; border-radius: 14px;
    border: 1px solid var(--border-default); background: var(--bg-secondary); color: var(--text-primary);
    box-shadow: 0 12px 36px rgba(0,0,0,.18); font-size: .875rem; line-height: 1.4;
    animation: toast-in .32s var(--ease-out, ease) backwards;
}
.theme-dark .toast { background: #141312; box-shadow: 0 12px 36px rgba(0,0,0,.5); }
.toast--leaving { animation: toast-out .2s ease forwards; }
.toast-icon { color: var(--action-primary); }
.toast--success .toast-icon { color: var(--success); }
.toast--error .toast-icon { color: var(--error); }
.toast-action {
    flex-shrink: 0; padding: 6px 10px; border-radius: 8px; font-weight: 600;
    color: var(--action-primary); background: var(--action-soft);
}
.toast-action:hover { background: rgba(var(--brand-rgb), .18); }
.toast-close { flex-shrink: 0; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: var(--text-muted); }
.toast-close:hover { color: var(--text-primary); background: var(--action-soft); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.97); } }

/* ---------- Skeleton placeholders ---------- */
.skeleton {
    position: relative; overflow: hidden;
    background: color-mix(in srgb, var(--text-muted) 12%, transparent);
}
.skeleton::after {
    content: ''; position: absolute; inset: 0; transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--bg-secondary) 55%, transparent), transparent);
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
@keyframes skeleton-shimmer { to { transform: translateX(100%); } }

/* ---------- Vault cards: neutral surface + outline pattern in the theme colour ---------- */
.vault-card {
    transition: transform .3s var(--ease-out, ease), box-shadow .3s ease, border-color .3s ease;
    box-shadow: var(--shadow-glass);
}
.vault-card::before {           /* thin theme-coloured strip along the top */
    content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px;
    background: linear-gradient(90deg, rgb(var(--brand-rgb)), rgba(var(--accent2-rgb), .7));
    opacity: .7;
}
@media (hover: hover) {
    .vault-card[role="button"]:hover { transform: translateY(-3px); border-color: rgba(var(--brand-rgb), .35); box-shadow: 0 14px 30px -14px rgba(0,0,0,.35); }
}
.vault-card--selected {
    border-color: rgba(var(--brand-rgb), .7);
    box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .15), 0 14px 30px -16px rgba(var(--brand-rgb), .45);
}
.vault-card--selected::before { opacity: 1; }
.vault-pattern {
    position: absolute; right: -36px; top: -36px; width: 210px; height: 210px; pointer-events: none;
    color: rgb(var(--brand-rgb)); opacity: .32;
    -webkit-mask-image: radial-gradient(circle at 70% 30%, #000 30%, transparent 72%);
    mask-image: radial-gradient(circle at 70% 30%, #000 30%, transparent 72%);
    transition: opacity .3s ease;
}
.theme-dark .vault-pattern { opacity: .38; }
.vault-card:hover .vault-pattern, .vault-card--selected .vault-pattern { opacity: .55; }
.vault-pattern svg { width: 100%; height: 100%; }
.vault-pattern-spin { animation: orbit-turn 60s linear infinite; transform-origin: center; }
.vault-pattern-drift { animation: vault-drift 14s ease-in-out infinite; }
@keyframes vault-drift { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-8px, 6px); } }

/* ---------- Form fields: one consistent focus ring that never gets clipped ---------- */
/* Fields show focus with their own border + soft glow, so the extra outline is not needed. */
:is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), textarea, select):focus {
    outline: none;
    border-color: rgba(var(--brand-rgb), .6);
    box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .15);
}
/* Checkboxes keep a tight ring (an offset outline gets cut off inside table cells) */
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline-offset: 1px; }
/* Scrolling bodies of pop-ups: room above the first field so its glow isn't sliced off */
.modal-body { padding-top: 6px; }
/* Scrolling lists: keep focus outlines of items inside the box */
.overflow-y-auto > :is(button, a, [tabindex]):focus-visible,
.overflow-x-auto > :is(button, a, [tabindex]):focus-visible { outline-offset: -2px; }
