@layer base, layout, components, utilities;

@property --bg-1 { syntax: '<color>'; initial-value: #081120; inherits: false; }
@property --bg-2 { syntax: '<color>'; initial-value: #10223d; inherits: false; }
@property --bg-3 { syntax: '<color>'; initial-value: #17355f; inherits: false; }

:root {
  color-scheme: dark;
  --bg-1: #081120;
  --bg-2: #10223d;
  --bg-3: #17355f;
  --surface-1: rgba(9, 18, 35, 0.78);
  --surface-2: rgba(18, 30, 54, 0.88);
  --surface-stroke: rgba(181, 213, 255, 0.16);
  --text-1: #eef7ff;
  --text-2: rgba(238, 247, 255, 0.82);
  --text-3: rgba(238, 247, 255, 0.62);
  --accent-1: #7dd3fc;
  --accent-2: #facc15;
  --accent-3: #fb923c;
  --accent-glow: rgba(125, 211, 252, 0.32);
  --danger: #f87171;
  --success: #10b981;
  --shadow-1: 0 18px 60px rgba(0, 0, 0, 0.32);
  --shadow-2: 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  --radius-panel: 1.5rem;
  --radius-soft: 999px;
  --space-1: clamp(0.75rem, 0.7rem + 0.2vw, 0.95rem);
  --space-2: clamp(1rem, 0.92rem + 0.35vw, 1.25rem);
  --space-3: clamp(1.25rem, 1.1rem + 0.7vw, 1.75rem);
  --space-4: clamp(1.5rem, 1.25rem + 1vw, 2.25rem);
  --space-5: clamp(2rem, 1.7rem + 1.4vw, 3rem);
}

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

  html {
    overflow-x: hidden;
  }

  body {
    margin: 0;
    min-height: 100dvh;
    padding:
      max(0.6rem, env(safe-area-inset-top))
      max(0.6rem, env(safe-area-inset-right))
      max(0.6rem, env(safe-area-inset-bottom))
      max(0.6rem, env(safe-area-inset-left));
    font-family: "Segoe UI Variable", "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    color: var(--text-1);
    line-height: 1.55;
    letter-spacing: 0.01em;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scrollbar-gutter: stable;
    display: grid;
    place-items: center;
    overscroll-behavior: none;
    position: relative;
    overflow-x: hidden;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }

  body::before {
    content: "";
    position: fixed;
    inset: -30%;
    z-index: -2;
    background:
      radial-gradient(circle at top, rgba(125, 211, 252, 0.15), transparent 35%),
      linear-gradient(145deg, var(--bg-1), var(--bg-2) 48%, var(--bg-3));
    background-size: 100% 100%, 200% 200%;
    will-change: transform;
    animation: bgShift 22s ease-in-out infinite;
    pointer-events: none;
  }

  body.theme-sunset {
    --bg-1: #180927;
    --bg-2: #341639;
    --bg-3: #522131;
    --accent-1: #fda4af;
    --accent-2: #fef08a;
    --accent-3: #fdba74;
    --accent-glow: rgba(253, 164, 175, 0.34);
    --surface-1: rgba(26, 12, 40, 0.78);
    --surface-2: rgba(40, 18, 54, 0.88);
    --surface-stroke: rgba(253, 164, 175, 0.15);
  }

  body.theme-midnight {
    --bg-1: #020206;
    --bg-2: #07071c;
    --bg-3: #120626;
    --accent-1: #f472b6;
    --accent-2: #38bdf8;
    --accent-3: #c084fc;
    --accent-glow: rgba(244, 114, 182, 0.32);
    --surface-1: rgba(6, 6, 20, 0.84);
    --surface-2: rgba(14, 10, 32, 0.9);
    --surface-stroke: rgba(244, 114, 182, 0.18);
  }

  body.theme-rain {
    --bg-1: #0a0f1d;
    --bg-2: #141c2f;
    --bg-3: #222d42;
    --accent-1: #cbd5e1;
    --accent-2: #38bdf8;
    --accent-3: #2dd4bf;
    --accent-glow: rgba(148, 163, 184, 0.3);
    --surface-1: rgba(10, 15, 29, 0.82);
    --surface-2: rgba(20, 28, 47, 0.9);
    --surface-stroke: rgba(148, 163, 184, 0.16);
  }

  body.theme-aurora {
    --bg-1: #030f0c;
    --bg-2: #052115;
    --bg-3: #11182c;
    --accent-1: #4ade80;
    --accent-2: #a78bfa;
    --accent-3: #2dd4bf;
    --accent-glow: rgba(74, 222, 128, 0.3);
    --surface-1: rgba(3, 15, 12, 0.82);
    --surface-2: rgba(8, 28, 20, 0.9);
    --surface-stroke: rgba(74, 222, 128, 0.16);
  }

  body.theme-meadow {
    --bg-1: #0d1710;
    --bg-2: #1b3520;
    --bg-3: #35512f;
    --accent-1: #86efac;
    --accent-2: #fde68a;
    --accent-3: #facc15;
    --accent-glow: rgba(134, 239, 172, 0.32);
    --surface-1: rgba(15, 25, 16, 0.8);
    --surface-2: rgba(25, 41, 24, 0.9);
    --surface-stroke: rgba(190, 242, 100, 0.18);
  }

  @keyframes bgShift {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1.0); }
    50% { transform: translate3d(2%, 2%, 0) scale(1.03); }
  }

  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  .skip-link {
    position: absolute;
    top: -3rem;
    left: 1rem;
    z-index: 200;
    padding: 0.6rem 1rem;
    background: var(--accent-1);
    color: #000;
    text-decoration: none;
    font-weight: 700;
    border-radius: 0.6rem;
    transition: top 0.2s ease;
  }
  .skip-link:focus { top: 1rem; }
}

@layer layout {
  .shell {
    width: min(100%, 72rem);
    display: grid;
    gap: var(--space-3);
    container-type: inline-size;
    container-name: shell;
  }

  .panel {
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 35%),
      linear-gradient(180deg, var(--surface-1), var(--surface-2));
    border: 1px solid var(--surface-stroke);
    border-radius: var(--radius-panel);
    box-shadow: var(--shadow-1), var(--shadow-2);
    -webkit-backdrop-filter: blur(18px) saturate(1.05);
    backdrop-filter: blur(18px) saturate(1.05);
  }

  @supports not (backdrop-filter: blur(1px)) {
    .panel {
      background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 35%),
        linear-gradient(180deg, rgba(9, 18, 35, 0.95), rgba(18, 30, 54, 0.98));
    }
  }

  @media (prefers-reduced-transparency: reduce) {
    .panel,
    .customizer-drawer {
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
      background:
        linear-gradient(180deg, rgba(9, 18, 35, 0.98), rgba(18, 30, 54, 0.99));
    }
  }

  .hero,
  .stage,
  .card {
    padding: var(--space-4);
  }

  .canvas-wrap {
    position: relative;
    width: min(100%, 420px);
    margin-inline: auto;
  }
}

@layer components {
  .eyebrow {
    margin: 0 0 var(--space-2);
    color: var(--accent-1);
    font-size: clamp(0.74rem, 0.7rem + 0.25vw, 0.9rem);
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
  }

  .hero-layout,
  .stage-topbar,
  .meta-grid {
    display: grid;
    gap: var(--space-3);
  }

  .hero-layout {
    grid-template-columns: minmax(0, 1.35fr) minmax(16rem, 0.9fr);
    align-items: start;
  }

  .stage-topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    margin-bottom: var(--space-3);
  }

  .meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  h1,
  h2 {
    margin: 0;
    line-height: 1.05;
    letter-spacing: -0.03em;
    text-wrap: balance;
  }

  h1 { font-size: clamp(2.05rem, 1.6rem + 2vw, 3.4rem); }
  h2 { font-size: clamp(1.18rem, 1.05rem + 0.75vw, 1.55rem); }

  p {
    margin: 0;
    color: var(--text-2);
    text-wrap: pretty;
  }

  .lede,
  .stage-copy p,
  .card p {
    max-width: 62ch;
    font-size: clamp(1rem, 0.96rem + 0.25vw, 1.08rem);
  }

  .hero-copy {
    display: grid;
    gap: var(--space-2);
  }

  .status-cluster,
  .toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
  }

  .status-cluster {
    justify-content: flex-end;
    align-self: start;
  }

  .status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 2.4rem;
    padding: 0.55rem 0.9rem;
    border-radius: var(--radius-soft);
    border: 1px solid rgba(125, 211, 252, 0.22);
    background: rgba(125, 211, 252, 0.08);
    color: var(--text-1);
    font-size: 0.88rem;
    font-weight: 650;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  }

  .ui-button {
    appearance: none;
    border: 1px solid rgba(238, 247, 255, 0.15);
    border-radius: var(--radius-soft);
    min-height: 2.85rem;
    padding: 0.78rem 1rem;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
      rgba(9, 18, 35, 0.9);
    color: var(--text-1);
    font: inherit;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: transform 160ms ease, box-shadow 220ms ease, border-color 220ms ease, background 220ms ease;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  }

  .ui-button:hover {
    transform: translateY(-1px);
    border-color: rgba(125, 211, 252, 0.32);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.24);
  }
  .ui-button:active { transform: translateY(0); }
  .ui-button:focus-visible {
    outline: 3px solid rgba(125, 211, 252, 0.55);
    outline-offset: 3px;
  }
  .ui-button[aria-pressed="true"] {
    border-color: rgba(250, 204, 21, 0.4);
    background:
      linear-gradient(180deg, rgba(250, 204, 21, 0.18), rgba(251, 146, 60, 0.12)),
      rgba(20, 26, 18, 0.9);
  }
  .ui-button:disabled {
    opacity: 0.58;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
  }
  .ui-button.danger {
    border-color: rgba(248, 113, 113, 0.5);
    color: var(--danger);
  }
  .ui-button.danger:hover {
    background: rgba(248, 113, 113, 0.12);
  }
  #postcardCopyBtn { display: none; }

  canvas {
    width: 100%;
    height: auto;
    aspect-ratio: 420 / 640;
    display: block;
    background: linear-gradient(180deg, #7bd8ff 0%, #93e0ff 60%, #c4f2ff 100%);
    border-radius: calc(var(--radius-panel) - 0.1rem);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow:
      0 24px 60px rgba(0, 0, 0, 0.26),
      0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    touch-action: manipulation;
    cursor: pointer;
    user-select: none;
    -webkit-touch-callout: none;
    contain: strict;
    will-change: contents;
    transition: box-shadow 180ms ease;
  }
  canvas:active {
    box-shadow:
      0 16px 42px rgba(0, 0, 0, 0.28),
      0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  }
  canvas:focus-visible {
    outline: 3px solid rgba(125, 211, 252, 0.55);
    outline-offset: 4px;
  }

  /* Mobile control bar */
  .mobile-controls {
    display: none;
    margin-top: 0.6rem;
    gap: 0.6rem;
    grid-template-columns: 1fr 1.3fr 1fr;
  }
  .m-btn {
    appearance: none;
    border: 1px solid rgba(238, 247, 255, 0.18);
    border-radius: 1rem;
    min-height: 64px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
      rgba(9, 18, 35, 0.92);
    color: var(--text-1);
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: 0.02em;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
    touch-action: manipulation;
    transition: transform 80ms ease, background 120ms ease, box-shadow 120ms ease;
  }
  .m-btn:active {
    transform: translateY(1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
    background:
      linear-gradient(180deg, rgba(125, 211, 252, 0.18), rgba(125, 211, 252, 0.06)),
      rgba(9, 18, 35, 0.95);
  }
  .m-flap { border-color: rgba(250, 204, 21, 0.4); }
  .m-brake { border-color: rgba(125, 211, 252, 0.36); }
  .m-dive { border-color: rgba(251, 146, 60, 0.4); }

  @media (pointer: coarse), (max-width: 540px) {
    body {
      padding-bottom: calc(5.8rem + env(safe-area-inset-bottom));
    }

    .mobile-controls {
      display: grid;
      position: fixed;
      left: max(1rem, env(safe-area-inset-left));
      right: max(1rem, env(safe-area-inset-right));
      bottom: max(0.75rem, env(safe-area-inset-bottom));
      z-index: 80;
      width: min(420px, calc(100vw - 2rem));
      margin: 0 auto;
      padding: 0.55rem;
      border: 1px solid rgba(238, 247, 255, 0.16);
      border-radius: 1.25rem;
      background: rgba(9, 18, 35, 0.9);
      -webkit-backdrop-filter: blur(18px) saturate(1.1);
      backdrop-filter: blur(18px) saturate(1.1);
      box-shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
    }
  }

  /* Tutorial overlay */
  .tutorial-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 5;
    background: rgba(0, 0, 0, 0.55);
    border-radius: calc(var(--radius-panel) - 0.1rem);
    backdrop-filter: blur(4px);
  }
  .tutorial-overlay.show { display: flex; }
  .tutorial-card {
    max-width: 320px;
    width: 100%;
    background: linear-gradient(180deg, var(--surface-1), var(--surface-2));
    border: 1px solid var(--surface-stroke);
    border-radius: 1.2rem;
    padding: 1.2rem;
    color: var(--text-1);
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  }
  .tutorial-card h3 {
    margin: 0 0 0.6rem;
    font-size: 1.15rem;
  }
  .tutorial-card ul {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
    display: grid;
    gap: 0.4rem;
    text-align: left;
    font-size: 0.92rem;
  }
  .t-key {
    display: inline-block;
    padding: 0.18rem 0.5rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    font-weight: 700;
    font-size: 0.85rem;
    margin-right: 0.4rem;
  }

  .control-list {
    list-style: none;
    padding: 0;
    margin: var(--space-2) 0 0;
    display: grid;
    gap: 0.85rem;
  }
  .control-list li {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.8rem;
    align-items: center;
    color: var(--text-2);
  }
  kbd {
    min-width: 3.5ch;
    padding: 0.42rem 0.72rem;
    border-radius: 0.85rem;
    border: 1px solid rgba(238, 247, 255, 0.16);
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04)),
      rgba(7, 13, 27, 0.92);
    color: var(--text-1);
    font: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    text-align: center;
    font-variant-numeric: tabular-nums;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.08),
      0 4px 12px rgba(0, 0, 0, 0.14);
  }
  .microcopy {
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-3);
  }
}

@layer utilities {
  @container (max-width: 54rem) {
    .hero-layout,
    .stage-topbar,
    .meta-grid {
      grid-template-columns: 1fr;
    }
    .status-cluster { justify-content: flex-start; }
    .toolbar { width: 100%; }
    .ui-button { flex: 1 1 9rem; }
  }

  @media (max-width: 640px) {
    .stage { order: -1; }
    .hero { padding: var(--space-2) var(--space-3); }
    .hero h1 { font-size: 1.5rem; }
    .lede { font-size: 0.95rem; }
    .status-cluster { display: none; }
    .meta-grid { display: none; }
    .stage { padding: var(--space-2); }
  }

  @media (pointer: coarse) {
    .ui-button { min-height: 3.15rem; }
    .close-btn { padding: 0.6rem 0.9rem; font-size: 1.7rem; }
    .theme-btn { min-height: 3.15rem; }
  }

  @media (prefers-contrast: more) {
    .panel,
    canvas,
    .ui-button,
    kbd,
    .status-pill,
    .m-btn {
      border-color: rgba(255, 255, 255, 0.40);
    }
    .eyebrow { color: #a5f3fc; }
  }

  @media (forced-colors: active) {
    .panel,
    canvas,
    .ui-button,
    .m-btn,
    .customizer-drawer,
    .theme-btn {
      border: 1px solid CanvasText;
    }
    .ui-button:focus-visible,
    .m-btn:focus-visible,
    .theme-btn:focus-visible {
      outline: 3px solid Highlight;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
    body::before { animation: none !important; }
    .customizer-drawer { transition: none !important; }
  }

  /* Customizer Drawer */
  .customizer-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: min(100%, 400px);
    height: 100dvh;
    z-index: 100;
    background: linear-gradient(180deg, var(--surface-1), var(--surface-2));
    border-left: 1px solid var(--surface-stroke);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.4);
    -webkit-backdrop-filter: blur(25px) saturate(1.1);
    backdrop-filter: blur(25px) saturate(1.1);
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    padding: var(--space-4);
    overflow-y: auto;
    visibility: hidden;
    will-change: transform;
  }
  .customizer-drawer.open {
    transform: translateX(0);
    visibility: visible;
  }
  .customizer-drawer:not(.open) {
    width: 0;
    padding-inline: 0;
    border-left: 0;
    overflow: hidden;
  }
  .customizer-drawer[inert] { pointer-events: none; }

  .drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
    border-bottom: 1px solid var(--surface-stroke);
    padding-bottom: var(--space-2);
  }
  .drawer-header h2 {
    font-size: 1.4rem;
    margin: 0;
    color: var(--text-1);
    letter-spacing: -0.02em;
  }
  .close-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-2);
    transition: color 0.2s;
    padding: 0.5rem 0.8rem;
    min-height: 44px;
    min-width: 44px;
    border-radius: 0.5rem;
  }
  .close-btn:hover { color: var(--accent-1); background: rgba(255,255,255,0.06); }

  .drawer-section { margin-bottom: var(--space-4); }
  .drawer-section h3 {
    font-size: 0.85rem;
    margin: 0 0 var(--space-2);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-1);
    font-weight: 700;
  }
  .drawer-microcopy {
    font-size: 0.78rem;
    color: var(--text-3);
    margin-top: 0.6rem;
  }
  .drawer-inline-btn {
    margin-top: 0.8rem;
    width: 100%;
    min-height: 2.6rem;
    padding: 0.5rem 0.9rem;
    font-size: 0.9rem;
  }

  .control-grid-vertical {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
  .control-item {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
  }
  .control-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-2);
    display: flex;
    justify-content: space-between;
  }
  .control-value {
    color: var(--accent-2);
    font-weight: 700;
  }

  .theme-cluster {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(6.8rem, 1fr));
    gap: 0.7rem;
  }
  .theme-btn {
    appearance: none;
    border: 1px solid rgba(238, 247, 255, 0.12);
    border-radius: 1rem;
    padding: 0.78rem 0.65rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
    color: var(--text-2);
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    font-size: 0.88rem;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.25;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.16);
    transform: translateY(0);
  }
  .theme-btn:hover {
    border-color: var(--accent-1);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.04));
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
  }
  .theme-btn.active {
    color: var(--text-1);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.06));
    border-color: var(--accent-1);
    box-shadow:
      0 14px 28px rgba(0, 0, 0, 0.24),
      0 0 18px var(--accent-glow);
    transform: translateY(-2px);
  }

  .slider-custom {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.12);
    outline: none;
    transition: background 0.2s;
    touch-action: pan-y;
  }
  .slider-custom::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent-1);
    cursor: pointer;
    transition: transform 0.1s, background 0.1s;
    box-shadow: 0 0 8px var(--accent-1);
  }
  .slider-custom::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    background: var(--accent-2);
  }
  .slider-custom::-moz-range-thumb {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent-1);
    cursor: pointer;
    border: none;
    transition: transform 0.1s, background 0.1s;
    box-shadow: 0 0 8px var(--accent-1);
  }
  .slider-custom::-moz-range-thumb:hover {
    transform: scale(1.15);
    background: var(--accent-2);
  }

  /* shadcn field-switch pattern (vanilla): label + description left, switch right */
  .field-switch {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
  }
  .field-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }
  .field-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-1);
    cursor: pointer;
  }
  .field-description {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--text-3);
  }
  .field-status {
    margin: 0.15rem 0 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-2);
  }

  .switch {
    -webkit-appearance: none;
    appearance: none;
    flex-shrink: 0;
    width: 2.75rem;
    height: 1.5rem;
    margin-top: 0.15rem;
    border-radius: 999px;
    border: 1px solid rgba(238, 247, 255, 0.18);
    background: rgba(255, 255, 255, 0.12);
    cursor: pointer;
    position: relative;
    transition: background 0.2s ease, border-color 0.2s ease;
  }
  .switch::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 50%;
    background: var(--text-1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .switch:checked {
    background: var(--accent-1);
    border-color: var(--accent-1);
  }
  .switch:checked::before {
    transform: translateX(1.25rem);
    background: var(--surface-1);
  }
  .switch:focus-visible {
    outline: 2px solid var(--accent-1);
    outline-offset: 2px;
  }
  .switch:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  .stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
    margin-top: var(--space-2);
  }
  .stat-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 1rem;
    padding: 0.8rem;
    text-align: center;
  }
  .stat-num {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent-2);
    margin: 0;
  }
  .stat-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-3);
    margin: 0.2rem 0 0;
  }

  .achievements-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: var(--space-2);
  }
  .achievement-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 1rem;
    padding: 0.6rem 0.8rem;
    transition: transform 0.2s, border-color 0.2s;
  }
  .achievement-item:hover {
    border-color: var(--surface-stroke);
  }
  .achievement-badge {
    font-size: 1.4rem;
    filter: grayscale(1);
    transition: filter 0.3s;
  }
  .achievement-item.unlocked .achievement-badge { filter: grayscale(0); }
  .achievement-details { min-width: 0; }
  .achievement-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-2);
    margin: 0;
  }
  .achievement-desc {
    font-size: 0.74rem;
    color: var(--text-3);
    margin: 0.1rem 0 0;
  }
  .achievement-progress {
    font-size: 0.7rem;
    color: var(--accent-2);
    margin: 0.15rem 0 0;
    font-weight: 600;
  }
  .achievement-item.unlocked .achievement-progress { color: var(--success); }
  .achievement-check {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: transparent;
    transition: all 0.3s;
  }
  .achievement-item.unlocked .achievement-check {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
    font-weight: 700;
  }

  .theme-btn:focus-visible {
    outline: 3px solid var(--accent-1);
    outline-offset: 2px;
  }
  .slider-custom:focus-visible {
    outline: 3px solid var(--accent-1);
    outline-offset: 4px;
  }
  .close-btn:focus-visible {
    outline: 3px solid var(--accent-1);
    outline-offset: 1px;
    border-radius: 4px;
  }
}
