/* ================================================================
  什亭之箱 v2 — Design System
  Built with UI-UX-PRO-MAX design intelligence
  Style: Cinema Dark + Subtle Glassmorphism
  ================================================================ */

/* ── Design Tokens ───────────────────────────────────────────── */
:root {
  /* Brand */
  --brand: #3B82F6;
  --brand-hover: #2563EB;
  --brand-ring: rgba(59, 130, 246, 0.30);
  --brand-glow: rgba(59, 130, 246, 0.15);

  /* Surfaces (dark) */
  --bg-root: #09090D;
  --bg-elevated: #0E0E15;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-hover: rgba(255, 255, 255, 0.06);
  --surface-active: rgba(255, 255, 255, 0.10);
  --glass: rgba(14, 14, 21, 0.65);

  /* Text */
  --text-primary: rgba(255, 255, 255, 0.93);
  --text-secondary: rgba(255, 255, 255, 0.62);
  --text-muted: rgba(255, 255, 255, 0.38);

  /* Borders */
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  /* Semantic */
  --success: #22C55E;
  --warning: #F59E0B;
  --danger: #EF4444;
  --danger-surface: rgba(239, 68, 68, 0.12);
  --danger-border: rgba(239, 68, 68, 0.28);

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 30px var(--brand-glow);

  /* Spacing (4px grid) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Typography */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans",
    "PingFang SC", "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 24px;
  --leading-tight: 1.25;
  --leading-normal: 1.55;
  --leading-relaxed: 1.75;

  /* Radii */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  /* Animation */
  --duration-fast: 120ms;
  --duration-normal: 200ms;
  --duration-slow: 350ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --header-h: 60px;
  --aside-w: 280px;
  --content-max: 1180px;
  --gap: 14px;

  color-scheme: dark;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Light Mode ──────────────────────────────────────────────── */
/* Auto: follow system */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg-root: #F8FAFC;
    --bg-elevated: #F1F5F9;
    --surface: rgba(255, 255, 255, 0.88);
    --surface-hover: rgba(255, 255, 255, 0.95);
    --surface-active: rgba(0, 0, 0, 0.04);
    --glass: rgba(248, 250, 252, 0.80);

    --text-primary: rgba(15, 23, 42, 0.93);
    --text-secondary: rgba(15, 23, 42, 0.60);
    --text-muted: rgba(15, 23, 42, 0.40);

    --border: rgba(15, 23, 42, 0.08);
    --border-strong: rgba(15, 23, 42, 0.14);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 30px rgba(59, 130, 246, 0.10);

    color-scheme: light;
  }
}

/* Manual override: light */
[data-theme="light"] {
  --bg-root: #F8FAFC;
  --bg-elevated: #F1F5F9;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-hover: rgba(255, 255, 255, 0.95);
  --surface-active: rgba(0, 0, 0, 0.04);
  --glass: rgba(248, 250, 252, 0.80);

  --text-primary: rgba(15, 23, 42, 0.93);
  --text-secondary: rgba(15, 23, 42, 0.60);
  --text-muted: rgba(15, 23, 42, 0.40);

  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 30px rgba(59, 130, 246, 0.10);

  color-scheme: light;
}

/* Manual override: dark (when system prefers light) */
[data-theme="dark"] {
  --bg-root: #09090D;
  --bg-elevated: #0E0E15;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-hover: rgba(255, 255, 255, 0.06);
  --surface-active: rgba(255, 255, 255, 0.10);
  --glass: rgba(14, 14, 21, 0.65);

  --text-primary: rgba(255, 255, 255, 0.93);
  --text-secondary: rgba(255, 255, 255, 0.62);
  --text-muted: rgba(255, 255, 255, 0.38);

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 30px var(--brand-glow);

  color-scheme: dark;
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-root);
  color: var(--text-primary);
  touch-action: manipulation;
  overscroll-behavior: none;
  position: relative;
}

/* Smooth background transitions */
html, body {
  transition: background-color 600ms var(--ease-out), background-image 600ms var(--ease-out);
}
html.has-custom-bg, body:has(.has-custom-bg) {
  transition: background-color 500ms var(--ease-out), background-image 500ms var(--ease-out);
}

/* ── Animated Background ──────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    /* Top-center warm glow */
    radial-gradient(800px 400px at 50% 0%, rgba(59, 130, 246, 0.10), transparent 60%),
    /* Bottom-left cool accent */
    radial-gradient(600px 500px at 20% 80%, rgba(99, 102, 241, 0.06), transparent 55%),
    /* Top-right warm accent */
    radial-gradient(500px 400px at 80% 20%, rgba(139, 92, 246, 0.04), transparent 50%);
  animation: bgPulse 12s ease-in-out infinite alternate;
}
@keyframes bgPulse {
  0% {
    opacity: 0.7;
    background:
      radial-gradient(800px 400px at 50% 0%, rgba(59, 130, 246, 0.10), transparent 60%),
      radial-gradient(600px 500px at 20% 80%, rgba(99, 102, 241, 0.06), transparent 55%),
      radial-gradient(500px 400px at 80% 20%, rgba(139, 92, 246, 0.04), transparent 50%);
  }
  50% {
    opacity: 1;
    background:
      radial-gradient(850px 420px at 48% 2%, rgba(59, 130, 246, 0.12), transparent 60%),
      radial-gradient(620px 520px at 22% 78%, rgba(99, 102, 241, 0.08), transparent 55%),
      radial-gradient(520px 380px at 78% 22%, rgba(139, 92, 246, 0.05), transparent 50%);
  }
  100% {
    opacity: 0.8;
    background:
      radial-gradient(780px 380px at 52% -1%, rgba(59, 130, 246, 0.09), transparent 60%),
      radial-gradient(580px 480px at 18% 82%, rgba(99, 102, 241, 0.05), transparent 55%),
      radial-gradient(480px 420px at 82% 18%, rgba(139, 92, 246, 0.06), transparent 50%);
  }
}

/* Subtle dot grid overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.03;
  background-image: radial-gradient(circle, rgba(255,255,255,0.8) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* ── Custom User Background ────────────────────────────────── */
.has-custom-bg::before { display: none; }
.has-custom-bg body::after { display: none; }
.has-custom-bg {
  background: var(--custom-bg-color, var(--bg-root)) !important;
}
.has-custom-bg body {
  background: var(--custom-bg-color, var(--bg-root)) !important;
}
/* Custom image background */
body:has(.has-custom-bg) {
  background: var(--custom-bg-image) center / cover fixed !important;
}
body:has(.has-custom-bg)::before { display: none; }
body:has(.has-custom-bg)::after { display: none; }

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.25); }

/* ── Focus Ring ──────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ── Selection ───────────────────────────────────────────────── */
::selection {
  background: rgba(59, 130, 246, 0.3);
  color: #fff;
}

/* ================================================================
   APP SHELL
   ================================================================ */

.app {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--aside-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas:
    "aside header"
    "aside main";
  position: relative;
  z-index: 1;
}

/* ── Header ──────────────────────────────────────────────────── */
.header {
  grid-area: header;
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--glass);
}
@media (min-width: 981px) {
  .header {
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
  }
}
@media (max-width: 980px) {
  .header { background: var(--bg-elevated); }
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 9px;
  flex-shrink: 0;
  object-fit: cover;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.30);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title {
  font-weight: 700;
  font-size: var(--text-base);
  letter-spacing: -0.01em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions { display: flex; align-items: center; gap: var(--space-2); }

/* ── Icon Button ─────────────────────────────────────────────── */
.icon-btn {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition:
    transform var(--duration-fast) var(--ease-out),
    background var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    color var(--duration-fast) ease;
}
.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.icon-btn:active { transform: translateY(0); }
.icon-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-color: var(--brand-ring);
}

/* ── Icons (CSS mask) ────────────────────────────────────────── */
.icon {
  width: 18px; height: 18px;
  display: block;
  flex-shrink: 0;
  background: currentColor;
  mask-size: contain; mask-repeat: no-repeat; mask-position: center;
  -webkit-mask-size: contain; -webkit-mask-repeat: no-repeat; -webkit-mask-position: center;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.aside {
  grid-area: aside;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow: auto;
  border-right: 1px solid var(--border);
  background: var(--glass);
  overscroll-behavior: contain;
}
@media (min-width: 981px) {
  .aside {
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
  }
}
@media (max-width: 980px) {
  .aside {
    background: var(--bg-elevated);
  }
}

.aside-inner {
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* ── Search ──────────────────────────────────────────────────── */
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color var(--duration-fast) ease, background var(--duration-fast) ease;
}
.search:focus-within {
  border-color: var(--brand);
  background: var(--surface-hover);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
.search input {
  border: 0; outline: none; background: transparent;
  width: 100%;
  font-size: var(--text-sm);
  color: var(--text-primary);
}
.search input::placeholder { color: var(--text-muted); }
.search .icon { width: 16px; height: 16px; opacity: 0.5; }

/* ── Nav Group ───────────────────────────────────────────────── */
.nav-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px var(--space-3);
  border-bottom: 1px solid var(--border);
}
.nav-title {
  margin: 0;
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}
.nav-list { display: grid; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--space-3);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  transition: background var(--duration-fast) ease, color var(--duration-fast) ease;
  position: relative;
}
.nav-item:first-child { border-top: 0; }
.nav-item:hover {
  background: rgba(59, 130, 246, 0.08);
  color: var(--text-primary);
}
.nav-item[aria-current="page"] {
  background: rgba(59, 130, 246, 0.14);
  color: var(--brand);
  font-weight: 600;
}
.nav-item[aria-current="page"]::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--brand);
  border-radius: 0 4px 4px 0;
}
.nav-item small {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 1px;
}

/* ── Main Content ────────────────────────────────────────────── */
.main {
  grid-area: main;
  padding: var(--space-5);
  padding-left: calc(var(--space-5) + env(safe-area-inset-left, 0px));
  padding-right: calc(var(--space-5) + env(safe-area-inset-right, 0px));
  padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0px));
}
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  display: grid;
  gap: var(--gap);
}

/* ── Mobile Shell ────────────────────────────────────────────── */
@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-areas: "header" "main";
  }
  .aside {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 30;
    width: min(var(--aside-w), 88vw);
    transform: translateX(-105%);
    transition: transform 280ms var(--ease-out);
    box-shadow: var(--shadow-lg);
  }
  .aside.open { transform: translateX(0); }
}

.aside-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.40);
  z-index: 29;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
}
.aside-scrim.show { opacity: 1; pointer-events: auto; }

/* ================================================================
   COMPONENTS
   ================================================================ */

/* ── Card ────────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg,
    rgba(255, 255, 255, 0.04),
    rgba(255, 255, 255, 0.02));
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition:
    transform 300ms var(--ease-out),
    box-shadow 300ms var(--ease-out),
    border-color 200ms ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), 0 0 40px rgba(59, 130, 246, 0.06);
  border-color: var(--border-strong);
}
@media (max-width: 768px) {
  .card:hover { transform: none; box-shadow: var(--shadow-sm); }
}
.card-head {
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--border);
}
.card-head h1, .card-head h2 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: var(--leading-tight);
}
.card-head p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.card-body { padding: var(--space-4); }

/* ── Button ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 8px var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition:
    transform var(--duration-fast) var(--ease-out),
    background var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease;
  -webkit-user-select: none;
  user-select: none;
}
.btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}

/* Primary */
.btn-primary {
  background: var(--brand);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}
.btn-primary:hover {
  background: var(--brand-hover);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.35);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  background: rgba(59, 130, 246, 0.4);
  box-shadow: none;
}

/* Danger */
.btn-danger {
  background: var(--danger-surface);
  border-color: var(--danger-border);
  color: var(--danger);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.20);
  border-color: rgba(239, 68, 68, 0.45);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

/* Small */
.btn-sm {
  min-height: 32px;
  padding: 4px var(--space-3);
  font-size: var(--text-xs);
  border-radius: 6px;
}

/* Loading */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Form Fields ─────────────────────────────────────────────── */
.field {
  display: grid;
  gap: 6px;
}
.field label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.field input,
.field textarea,
.field select {
  min-height: 42px;
  padding: 10px var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  outline: none;
  font-size: var(--text-sm);
  transition:
    border-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease,
    background var(--duration-fast) ease;
}
.field input::placeholder,
.field textarea::placeholder { color: var(--text-muted); }
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
  background: var(--surface-hover);
}
.field textarea { min-height: 96px; resize: vertical; }

.field-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── List & Items ────────────────────────────────────────────── */
.list { display: grid; gap: var(--space-2); }

.item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  transition:
    border-color var(--duration-fast) ease,
    background var(--duration-fast) ease,
    transform var(--duration-fast) var(--ease-out);
  animation: itemIn 300ms var(--ease-out) both;
}
.item:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}
@keyframes itemIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.item-main { min-width: 0; display: grid; gap: 4px; flex: 1; }
.item-title {
  margin: 0;
  font-weight: 600;
  font-size: var(--text-sm);
  line-height: var(--leading-tight);
  color: var(--text-primary);
}
.item-meta {
  color: var(--text-muted);
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
}
.item-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  flex-shrink: 0;
}

/* ── Key-Value Pairs ─────────────────────────────────────────── */
.kv { display: grid; gap: var(--space-2); }
.kv-row {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}
.kv-row strong {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.kv-row span {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

/* ── Grid ────────────────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: var(--gap);
}
@media (max-width: 980px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.row {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: flex-end;
}
.row > * { flex: 1 1 180px; }

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: var(--space-6);
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 24px));
  z-index: 100;
  display: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: rgba(15, 15, 25, 0.85);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  color: var(--text-primary);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.toast.show {
  display: block;
  animation: toastIn 250ms var(--ease-out) both;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Modal / Notice Overlay ──────────────────────────────────── */
.notice-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(0, 0, 0, 0.60);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-slow) var(--ease-out);
}
.notice-overlay.is-in { opacity: 1; pointer-events: auto; }
.notice-overlay.is-out { opacity: 0; pointer-events: none; }

.notice-card {
  width: min(520px, 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(16px) scale(0.96);
  transition: transform var(--duration-slow) var(--ease-out);
}
.notice-overlay.is-in .notice-card {
  transform: translateY(0) scale(1);
}

/* ── Skeleton Loading ────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface) 25%,
    var(--surface-hover) 50%,
    var(--surface) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-text:last-child { width: 60%; }
.skeleton-title { height: 18px; width: 40%; margin-bottom: 12px; }
.skeleton-card { height: 80px; border-radius: var(--radius); }

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-10) var(--space-4);
  text-align: center;
  gap: var(--space-3);
}
.empty-state-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.empty-state-title {
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--text-secondary);
}
.empty-state-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 280px;
  line-height: var(--leading-normal);
}

/* ── Badge / Tag ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-primary {
  background: rgba(59, 130, 246, 0.15);
  color: var(--brand);
  border: 1px solid rgba(59, 130, 246, 0.25);
}
.badge-success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.25);
}
.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.25);
}
.badge-danger {
  background: var(--danger-surface);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

/* ── Progress Bar ────────────────────────────────────────────── */
.progress {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--surface);
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--brand), #6366F1);
  transition: width 600ms var(--ease-out);
  position: relative;
}
.progress-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  animation: shimmer 2s ease-in-out infinite;
}

/* ── Vote Card (specialized) ─────────────────────────────────── */
.pk-btn {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition:
    border-color var(--duration-fast) ease,
    background var(--duration-fast) ease,
    transform var(--duration-fast) var(--ease-out);
  -webkit-user-select: none;
  user-select: none;
  min-height: 52px;
}
.pk-btn:hover {
  border-color: var(--brand);
  background: rgba(59, 130, 246, 0.06);
}
.pk-btn:active { transform: scale(0.985); }
.pk-btn[aria-disabled="true"] {
  cursor: default;
  pointer-events: none;
}

.pk-fill {
  position: absolute;
  inset: 0;
  transition: width 600ms var(--ease-out);
  z-index: 0;
  border-radius: inherit;
}

.pk-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  gap: var(--space-3);
  flex-wrap: wrap;
}

.pk-name {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
}

.pk-pct {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.pk-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--brand);
  font-weight: 600;
  background: rgba(59, 130, 246, 0.12);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

/* ── Cover Image ─────────────────────────────────────────────── */
.cover-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.cover-wrap img {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

/* ── Footer ──────────────────────────────────────────────────── */
.app-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
  padding: var(--space-6) var(--space-2);
  margin-top: var(--space-2);
}

/* ── Section Spacing ─────────────────────────────────────────── */
.section-gap { height: var(--gap); }

/* ── Dividers ────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-4) 0;
}

/* ── Theme Toggle ────────────────────────────────────────────── */
.theme-toggle {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition:
    transform var(--duration-fast) var(--ease-out),
    background var(--duration-fast) ease,
    color var(--duration-fast) ease;
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
}
.theme-toggle:active { transform: translateY(0) scale(0.95); }
.theme-toggle:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

/* When light mode forced: show sun, hide moon */
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ── Scroll-to-top FAB ──────────────────────────────────────── */
.scroll-top {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-6);
  z-index: 90;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition:
    opacity 250ms var(--ease-out),
    transform 250ms var(--ease-out),
    background var(--duration-fast) ease;
}
.scroll-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.scroll-top:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  transform: translateY(-2px);
}
.scroll-top:active { transform: translateY(0) scale(0.95); }
.scroll-top:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ── Toast Variants ─────────────────────────────────────────── */
.toast-success {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(15, 25, 15, 0.90);
}
.toast-error {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(25, 12, 12, 0.90);
}
.toast-info {
  border-color: rgba(59, 130, 246, 0.30);
  background: rgba(12, 15, 28, 0.90);
}

/* Toast pulse for attention */
.toast-pulse {
  animation: toastPulse 400ms var(--ease-out);
}
@keyframes toastPulse {
  0%   { transform: translateX(-50%) scale(1); }
  50%  { transform: translateX(-50%) scale(1.03); }
  100% { transform: translateX(-50%) scale(1); }
}

/* ── Celebration Overlay ────────────────────────────────────── */
.celebrate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 300ms ease;
}
.celebrate.fire {
  opacity: 1;
  animation: celebratePop 600ms var(--ease-out) both;
}
@keyframes celebratePop {
  0%   { opacity: 0; }
  30%  { opacity: 1; }
  100% { opacity: 0; }
}
.celebrate-icon {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--success), #16A34A);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 60px rgba(34, 197, 94, 0.5);
  animation: celebrateBounce 600ms var(--ease-out) both;
}
@keyframes celebrateBounce {
  0%   { transform: scale(0.3); opacity: 0; }
  50%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* Celebration particles */
.celebrate-particles {
  position: fixed;
  inset: 0;
  z-index: 199;
  pointer-events: none;
}
.particle {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  animation: particleFly 800ms var(--ease-out) both;
}
@keyframes particleFly {
  0%   { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--px), var(--py)) scale(0); }
}

/* ── Page Transition ────────────────────────────────────────── */
.page-enter {
  animation: pageIn 250ms var(--ease-out) both;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Pull-to-refresh indicator ──────────────────────────────── */
.pull-indicator {
  position: fixed;
  top: var(--header-h);
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  padding: 6px 16px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
}
.pull-indicator.show { opacity: 1; }

/* ── Share Button ───────────────────────────────────────────── */
.btn-share {
  gap: 6px;
}
.btn-share.copied {
  border-color: var(--success) !important;
  color: var(--success) !important;
  background: rgba(34, 197, 94, 0.08) !important;
}

/* ── User Dropdown ──────────────────────────────────────────── */
.user-menu {
  position: relative;
  z-index: 25;
}
.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 500;
  transition:
    background var(--duration-fast) ease,
    border-color var(--duration-fast) ease;
}
.user-menu-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}
.user-menu-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition:
    opacity 180ms var(--ease-out),
    transform 180ms var(--ease-out);
}
.user-dropdown.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.user-dropdown-head {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.user-dropdown-head .name {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text-primary);
}
.user-dropdown-head .meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
  transition: background var(--duration-fast) ease;
}
.user-dropdown-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}
.user-dropdown-item.danger {
  color: var(--danger);
}
.user-dropdown-item.danger:hover {
  background: var(--danger-surface);
}

/* ── Login Button ───────────────────────────────────────────── */
.login-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--brand);
  color: var(--brand);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  text-decoration: none;
  transition:
    background var(--duration-fast) ease,
    transform var(--duration-fast) var(--ease-out);
}
.login-btn:hover {
  background: rgba(59, 130, 246, 0.10);
  transform: translateY(-1px);
}

/* ── Check-in Button ────────────────────────────────────────── */
.checkin-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--warning);
  color: var(--warning);
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
  background: rgba(245, 158, 11, 0.08);
  transition:
    background var(--duration-fast) ease,
    transform var(--duration-fast) var(--ease-out);
  white-space: nowrap;
}
.checkin-btn:hover {
  background: rgba(245, 158, 11, 0.16);
  transform: translateY(-1px);
}
.checkin-btn:active { transform: scale(0.95); }
.checkin-btn.done {
  border-color: var(--success);
  color: var(--success);
  background: rgba(34, 197, 94, 0.08);
  cursor: default;
  pointer-events: none;
}

/* ── Comments ───────────────────────────────────────────────── */
.comments-section {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}
.comments-title {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.comment-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.comment-item:last-child { border-bottom: none; }
.comment-body { flex: 1; min-width: 0; }
.comment-author {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.comment-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-normal);
  word-break: break-word;
}
.comment-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}
.comment-delete {
  font-size: 10px;
  color: var(--danger);
  cursor: pointer;
  background: none;
  border: none;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background var(--duration-fast) ease;
  align-self: flex-start;
  margin-top: 2px;
}
.comment-delete:hover { background: var(--danger-surface); }

.comment-form {
  display: flex;
  gap: 8px;
  margin-top: var(--space-2);
}
.comment-form input {
  flex: 1;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-size: var(--text-sm);
  outline: none;
}
.comment-form input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
.comment-form input::placeholder { color: var(--text-muted); }
.comment-login-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-2);
}

/* ── Member List ────────────────────────────────────────────── */
.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-2);
}
.member-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition:
    border-color var(--duration-fast) ease,
    transform var(--duration-fast) var(--ease-out);
}
.member-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.member-info { min-width: 0; }
.member-name {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text-primary);
}
.member-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Notification Dot ───────────────────────────────────────── */
.notify-dot {
  position: relative;
}
.notify-dot::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--bg-elevated);
}

/* ── Tabs ───────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
}
.tab-item {
  padding: 10px var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition:
    color var(--duration-fast) ease,
    border-color var(--duration-fast) ease;
}
.tab-item:hover { color: var(--text-secondary); }
.tab-item.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

/* ── Auth Form ──────────────────────────────────────────────── */
.auth-card {
  max-width: 440px;
  margin: 0 auto;
}
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-bottom: 1px solid var(--border);
}
.auth-tab {
  padding: 12px;
  text-align: center;
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: all var(--duration-fast) ease;
}
.auth-tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}
.auth-tab:hover { color: var(--text-secondary); }

/* ── Streak Badge ───────────────────────────────────────────── */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(239, 68, 68, 0.15));
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--warning);
  font-weight: 800;
  font-size: var(--text-xs);
}
.streak-badge.hot {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(245, 158, 11, 0.2));
  border-color: rgba(239, 68, 68, 0.4);
  color: #FB923C;
  animation: streakPulse 2s ease-in-out infinite;
}
@keyframes streakPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.3); }
  50% { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0); }
}

/* ── Notification Bell ──────────────────────────────────────── */
.notif-bell {
  position: relative;
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition:
    background var(--duration-fast) ease,
    color var(--duration-fast) ease,
    transform var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}
.notif-bell:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
}
.notif-bell:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.notif-bell.has-unread { color: var(--text-primary); }
.notif-bell .badge-dot {
  position: absolute;
  top: 6px; right: 6px;
  min-width: 18px; height: 18px;
  border-radius: var(--radius-full);
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
}

/* Notif dropdown */
.notif-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 340px;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition:
    opacity 180ms var(--ease-out),
    transform 180ms var(--ease-out);
}
.notif-dropdown.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.notif-dropdown-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text-primary);
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  z-index: 1;
}
.notif-dropdown-head button {
  font-size: var(--text-xs);
  color: var(--brand);
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
}
.notif-dropdown-head button:hover { text-decoration: underline; }

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  transition: background var(--duration-fast) ease;
}
.notif-item:hover { background: var(--surface-hover); }
.notif-item.unread {
  background: rgba(59, 130, 246, 0.06);
}
.notif-item.unread::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--brand);
  flex-shrink: 0;
  margin-top: 6px;
}
.notif-item .notif-msg { flex: 1; line-height: var(--leading-normal); }
.notif-item .notif-time { font-size: 10px; color: var(--text-muted); white-space: nowrap; }
.notif-empty {
  text-align: center;
  padding: var(--space-6);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* ── Like Button ────────────────────────────────────────────── */
.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition:
    background var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    color var(--duration-fast) ease,
    transform var(--duration-fast) var(--ease-out);
}
.like-btn:hover {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger);
  transform: scale(1.05);
}
.like-btn.liked {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--danger);
}
.like-btn:active { transform: scale(0.92); }
.like-btn .like-count { font-variant-numeric: tabular-nums; }

/* ── Leaderboard ────────────────────────────────────────────── */
.leaderboard-list { display: grid; gap: 6px; }
.leaderboard-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: transform var(--duration-fast) var(--ease-out);
}
.leaderboard-item:hover { transform: translateX(4px); }
.leaderboard-rank {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: var(--text-sm);
  flex-shrink: 0;
}
.leaderboard-rank.gold { background: linear-gradient(135deg, #F59E0B, #FBBF24); color: #000; }
.leaderboard-rank.silver { background: linear-gradient(135deg, #94A3B8, #CBD5E1); color: #000; }
.leaderboard-rank.bronze { background: linear-gradient(135deg, #D97706, #F59E0B); color: #fff; }
.leaderboard-rank.normal { background: var(--surface); color: var(--text-muted); }
.leaderboard-name { font-weight: 700; font-size: var(--text-sm); color: var(--text-primary); }
.leaderboard-value { margin-left: auto; font-weight: 800; font-size: var(--text-sm); color: var(--brand); }

/* ── Profile Page ───────────────────────────────────────────── */
.profile-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
}
.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.profile-stat {
  text-align: center;
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}
.profile-stat-num {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--brand);
  line-height: 1;
}
.profile-stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Activity Feed ──────────────────────────────────────────── */
.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}
.activity-dot.like { background: var(--danger); }
.activity-dot.comment { background: var(--brand); }
.activity-dot.checkin { background: var(--warning); }
.activity-dot.join { background: var(--success); }

/* ── Tabs Nav ──────────────────────────────────────────────── */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-3);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab-nav-item {
  padding: 10px var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all var(--duration-fast) ease;
}
.tab-nav-item:hover { color: var(--text-secondary); }
.tab-nav-item.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ================================================================
   UTILITY HELPERS
   ================================================================ */

.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-brand { color: var(--brand) !important; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-xs { font-size: var(--text-xs) !important; }
.text-sm { font-size: var(--text-sm) !important; }
.text-lg { font-size: var(--text-lg) !important; }
.font-bold { font-weight: 700 !important; }
.mt-2 { margin-top: var(--space-2) !important; }
.mt-3 { margin-top: var(--space-3) !important; }
.mt-4 { margin-top: var(--space-4) !important; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ================================================================
   REDUCED MOTION
   ================================================================ */

@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;
  }
}

/* ── Bottom Nav — hidden by default, shown on mobile ──────── */
.bottom-nav { display: none; }

/* ================================================================
   MOBILE BOTTOM NAVIGATION (≤768px)
   ================================================================ */

@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0; right: 0;
    z-index: 25;
    height: 64px;
    padding: 0 var(--space-2);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    justify-content: space-around;
    align-items: center;
    gap: 4px;
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    min-width: 56px;
    transition: color var(--duration-fast) ease, background var(--duration-fast) ease;
    -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav-item:active { background: var(--surface-active); }
  .bottom-nav-item.active { color: var(--brand); }
  .bottom-nav-item svg { width: 22px; height: 22px; }

  /* Push main content above bottom nav */
  .app { padding-bottom: 72px; }
  .toast { bottom: calc(72px + var(--space-3) + env(safe-area-inset-bottom, 0px)); }
  .scroll-top { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }

  /* Full-width cards on mobile */
  .card { border-radius: var(--radius); margin-left: calc(-1 * var(--space-3)); margin-right: calc(-1 * var(--space-3)); border-left: none; border-right: none; }
  .card-head { padding: var(--space-3) var(--space-3) var(--space-2); }
  .card-body { padding: var(--space-3); }

  /* Stack grids */
  .grid-2 { grid-template-columns: 1fr; gap: var(--space-3); }
  .row { flex-direction: column; }
  .row > * { flex: 1 1 auto; width: 100%; }

  /* Larger inputs for touch */
  .field input, .field textarea, .field select { min-height: 48px; font-size: 16px; }
  .btn { min-height: 44px; padding: 10px var(--space-4); font-size: var(--text-sm); }

  /* Compact header */
  .header { height: 52px; padding: 0 var(--space-3); }
  :root { --header-h: 52px; }
  .brand-sub { display: none; }
  .brand-title { font-size: 13px; }
  .brand-mark { width: 28px; height: 28px; border-radius: 7px; }
  .shellTime { display: none; }

  /* Member grid single column */
  .member-grid { grid-template-columns: 1fr; }

  /* Tab nav scrollable */
  .tab-nav { overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 0; }
  .tab-nav-item { padding: 10px var(--space-3); font-size: var(--text-xs); }

  /* Leaderboard items more compact */
  .leaderboard-item { padding: var(--space-2) var(--space-3); }

  /* Auth card full width */
  .auth-card { max-width: 100%; }
  .auth-tab { padding: 12px 8px; }

  /* Comment form stack */
  .comment-form { flex-direction: column; }
  .comment-form button { width: 100%; }

  /* Profile header stack */
  .profile-header { flex-direction: column; text-align: center; }
  .profile-stats { grid-template-columns: repeat(3, 1fr); gap: var(--space-1); }
  .profile-stat { padding: var(--space-2); }
  .profile-stat-num { font-size: var(--text-xl); }

  /* User menu compact */
  .user-menu-btn span { display: none; }
  .user-menu-btn { padding: 4px 8px 4px 4px; border-radius: var(--radius-full); }
  .login-btn { padding: 5px 12px; font-size: var(--text-xs); }
  .checkin-btn { padding: 5px 10px; font-size: 10px; }
  .checkin-btn svg { width: 12px; height: 12px; }

  /* Notification dropdown full-width */
  .notif-dropdown { width: calc(100vw - 32px); right: -80px; }
  .user-dropdown { right: -40px; }

  /* Item actions wrap */
  .item { flex-direction: column; }
  .item-actions { width: 100%; justify-content: flex-start; margin-top: var(--space-2); }
}

/* ── Tablet adjustments (768px - 1024px) ───────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
  :root { --aside-w: 240px; }
  .main { padding: var(--space-4); }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ================================================================
   REDUCED MOTION
   ================================================================ */

/* ================================================================
   ENHANCED ANIMATIONS
   ================================================================ */

/* ── Brand Logo Float ─────────────────────────────────────── */
.brand-mark {
  animation: logoFloat 4s ease-in-out infinite;
}
@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(59, 130, 246, 0.40); }
}

/* ── Button Press Ripple ──────────────────────────────────── */
.btn, .btn-primary, .btn-danger {
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.2) 0%, transparent 70%);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 200ms ease, transform 400ms ease;
}
.btn:active::after {
  opacity: 1;
  transform: scale(2);
  transition: opacity 0ms, transform 150ms ease;
}

/* ── List Item Stagger Entrance ───────────────────────────── */
.item {
  animation: itemSlideIn 400ms var(--ease-out) both;
}
@keyframes itemSlideIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Tab Underline Slide ──────────────────────────────────── */
.tab-nav-item {
  position: relative;
  transition: color 200ms ease;
}
.tab-nav-item::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 50%; transform: translateX(-50%);
  width: 0; height: 2px;
  background: var(--brand);
  border-radius: 1px;
  transition: width 250ms var(--ease-out);
}
.tab-nav-item.active::after { width: 60%; }
.auth-tab {
  position: relative;
  transition: color 200ms ease;
}
.auth-tab::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 50%; transform: translateX(-50%);
  width: 0; height: 2px;
  background: var(--brand);
  border-radius: 1px;
  transition: width 250ms var(--ease-out);
}
.auth-tab.active::after { width: 50%; }

/* ── Notification Bell Swing ──────────────────────────────── */
.notif-bell.has-unread svg {
  animation: bellSwing 500ms ease-in-out;
  transform-origin: top center;
}
@keyframes bellSwing {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(15deg); }
  40% { transform: rotate(-12deg); }
  60% { transform: rotate(8deg); }
  80% { transform: rotate(-4deg); }
}

/* ── Like Button Heart Burst ──────────────────────────────── */
.like-btn.liked {
  animation: heartPop 350ms var(--ease-out);
}
@keyframes heartPop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.35); }
  60%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}

/* ── Comment Section Expand ───────────────────────────────── */
.comments-section {
  overflow: hidden;
  animation: commentExpand 300ms var(--ease-out);
}
@keyframes commentExpand {
  from { max-height: 0; opacity: 0; }
  to   { max-height: 2000px; opacity: 1; }
}

/* ── Skeleton Shimmer ─────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    110deg,
    var(--surface) 30%,
    var(--surface-hover) 50%,
    var(--surface) 70%
  );
  background-size: 200% 100%;
  animation: shimmer 2s ease-in-out infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Toast Slide + Pulse ──────────────────────────────────── */
.toast.show {
  animation: toastSlideUp 300ms var(--ease-out) both;
}
@keyframes toastSlideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(16px) scale(0.95); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ── Check-in Button Bounce ───────────────────────────────── */
.checkin-btn:not(.done):hover {
  animation: checkinBounce 600ms ease infinite;
}
@keyframes checkinBounce {
  0%, 100% { transform: translateY(0); }
  25% { transform: translateY(-3px); }
  75% { transform: translateY(-1px); }
}

/* ── Profile Stat Count Up ────────────────────────────────── */
.profile-stat-num {
  animation: statReveal 600ms var(--ease-out) both;
}
@keyframes statReveal {
  from { opacity: 0; transform: scale(0.5); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── Member Card Entrance ─────────────────────────────────── */
.member-card {
  animation: memberSlide 350ms var(--ease-out) both;
}
@keyframes memberSlide {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Leaderboard Item Slide ───────────────────────────────── */
.leaderboard-item {
  animation: lbSlide 300ms var(--ease-out) both;
}
@keyframes lbSlide {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Nav Item Active Indicator Slide ──────────────────────── */
.nav-item[aria-current="page"]::before {
  animation: navIndicator 300ms var(--ease-out);
}
@keyframes navIndicator {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}

/* ── Progress Bar Fill Pulse ──────────────────────────────── */
.progress-fill {
  animation: progressPulse 2s ease-in-out infinite;
}
@keyframes progressPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.2); }
}

/* ── Empty State Fade ─────────────────────────────────────── */
.empty-state {
  animation: emptyFade 500ms var(--ease-out) both;
}
@keyframes emptyFade {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── Badge Pop-in ─────────────────────────────────────────── */
.badge, .streak-badge {
  animation: badgePop 350ms var(--ease-out) both;
}
@keyframes badgePop {
  from { opacity: 0; transform: scale(0.6); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── Dropdown / Menu Slide ────────────────────────────────── */
.user-dropdown.open,
.notif-dropdown.open {
  animation: dropdownSlide 200ms var(--ease-out) both;
}
@keyframes dropdownSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Page-wide Section Reveal ─────────────────────────────── */
@keyframes sectionReveal {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card { animation: sectionReveal 450ms var(--ease-out) both; }
.card:nth-child(1) { animation-delay: 50ms; }
.card:nth-child(2) { animation-delay: 100ms; }
.card:nth-child(3) { animation-delay: 150ms; }
.card:nth-child(4) { animation-delay: 200ms; }
.card:nth-child(5) { animation-delay: 250ms; }
.card:nth-child(6) { animation-delay: 300ms; }

/* ── Glow Pulse on Primary Buttons ────────────────────────── */
.btn-primary {
  animation: glowPulse 3s ease-in-out infinite;
}
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25); }
  50% { box-shadow: 0 4px 20px rgba(59, 130, 246, 0.40), 0 0 40px rgba(59, 130, 246, 0.08); }
}

/* ── Reduced motion: disable all ──────────────────────────── */
@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;
  }
}

/* ================================================================
   LOTTERY / RAFFLE
   ================================================================ */

/* ── Lottery Card ──────────────────────────────────────────── */
.lotto-card { border-color: rgba(245, 158, 11, 0.25); }
.lotto-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--space-3); flex-wrap: wrap;
}
.lotto-prize {
  margin: 0; font-size: var(--text-lg); font-weight: 800;
  background: linear-gradient(135deg, #F59E0B, #F97316, #EF4444);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.lotto-title { margin: 4px 0 0; color: var(--text-secondary); font-size: var(--text-sm); }
.lotto-timer {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: var(--radius-full);
  background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.25);
  white-space: nowrap;
}
.lotto-timer-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #F59E0B;
  animation: timerPulse 1s ease-in-out infinite;
}
@keyframes timerPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(245,158,11,0.4); }
  50% { opacity: 0.6; box-shadow: 0 0 0 6px rgba(245,158,11,0); }
}
.lotto-timer-text { font-weight: 700; font-size: var(--text-sm); color: #F59E0B; font-variant-numeric: tabular-nums; }
.lotto-meta {
  display: flex; gap: var(--space-4); flex-wrap: wrap;
  margin-top: var(--space-3); font-size: var(--text-xs); color: var(--text-muted);
}
.lotto-actions {
  display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center;
  margin-top: var(--space-3);
}
.lotto-join-btn {
  font-size: var(--text-base) !important; padding: 10px 28px !important;
  animation: joinPulse 2s ease-in-out infinite;
}
@keyframes joinPulse {
  0%,100% { box-shadow: 0 2px 8px rgba(59,130,246,0.25); }
  50% { box-shadow: 0 4px 24px rgba(59,130,246,0.50), 0 0 40px rgba(59,130,246,0.12); }
}
.lotto-join-btn.joined {
  background: rgba(34,197,94,0.12) !important; border-color: rgba(34,197,94,0.35) !important;
  color: var(--success) !important; animation: none;
}
.lotto-joined-badge {
  margin-top: var(--space-2); font-size: var(--text-xs); color: var(--success);
  text-align: center; animation: badgePop 400ms var(--ease-out);
}
.btn-lg { min-height: 48px; font-size: var(--text-base); }
.lotto-winners { display: flex; gap: var(--space-2); flex-wrap: wrap; margin: var(--space-3) 0; }
.winner-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 14px; border-radius: var(--radius-full);
  background: linear-gradient(135deg, rgba(245,158,11,0.2), rgba(239,68,68,0.15));
  border: 1px solid rgba(245,158,11,0.35);
  font-weight: 700; font-size: var(--text-sm); color: #FBBF24;
}

/* ── Reveal Overlay (slot machine) ─────────────────────────── */
.reveal-overlay {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(8px);
  animation: overlayIn 300ms ease;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.reveal-card {
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); padding: var(--space-8);
  text-align: center; min-width: 320px; max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 80px rgba(245,158,11,0.15);
  animation: revealCardIn 400ms var(--ease-out);
}
@keyframes revealCardIn { from { transform: scale(0.9) translateY(20px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
.reveal-title { font-size: var(--text-xl); font-weight: 800; margin-bottom: var(--space-4); }
.reveal-slot {
  height: 64px; overflow: hidden; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.reveal-roller { text-align: center; }
.reveal-name { font-size: var(--text-2xl); font-weight: 800; animation: slotBounce 50ms linear infinite; }
@keyframes slotBounce { 0%{transform:translateY(-2px)}100%{transform:translateY(2px)} }

.winner-reveal-item {
  display: flex; align-items: center; gap: var(--space-2); justify-content: center;
  padding: var(--space-2) 0; animation: winnerPop 400ms var(--ease-out) both;
}
@keyframes winnerPop { from { opacity: 0; transform: scale(0.5) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.winner-reveal-medal { font-size: 24px; }
.winner-reveal-name { font-size: var(--text-xl); font-weight: 800; color: #FBBF24; }

/* ── Confetti ──────────────────────────────────────────────── */
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ── Mobile lottery ───────────────────────────────────────── */
@media (max-width: 768px) {
  .lotto-header { flex-direction: column; }
  .reveal-card { padding: var(--space-6) var(--space-4); min-width: auto; }
  .lotto-join-btn { width: 100%; justify-content: center; }
}

/* ── Guestbook (redesigned) ────────────────────────────────── */
.gb-page { display: grid; gap: var(--gap); }
.gb-header-card {
  position: relative; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(59,130,246,0.08), rgba(139,92,246,0.06));
  padding: var(--space-6); text-align: center;
}
.gb-header-glow {
  position: absolute; top: -60px; left: 50%; transform: translateX(-50%);
  width: 200px; height: 120px;
  background: radial-gradient(ellipse, rgba(59,130,246,0.15), transparent 70%);
  pointer-events: none;
}
.gb-title { margin: 0; font-size: var(--text-2xl); font-weight: 800; position: relative; }
.gb-subtitle { margin: 4px 0 0; color: var(--text-muted); font-size: var(--text-sm); position: relative; }
.gb-count { margin-top: var(--space-2); font-size: var(--text-xs); color: var(--text-muted); font-weight: 600; }

.gb-list {
  display: grid; gap: var(--space-3);
  max-height: 55vh; overflow-y: auto; padding-right: 4px;
}
.gb-list::-webkit-scrollbar { width: 4px; }
.gb-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

.gb-empty {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: var(--space-10) var(--space-4); text-align: center;
}
.gb-empty-icon { color: var(--text-muted); opacity: 0.5; margin-bottom: 8px; }
.gb-empty p { margin: 0; font-weight: 600; font-size: var(--text-base); color: var(--text-secondary); }
.gb-empty span { font-size: var(--text-xs); color: var(--text-muted); }

.gb-skeleton {
  height: 56px; border-radius: var(--radius);
  background: linear-gradient(110deg, var(--surface) 30%, var(--surface-hover) 50%, var(--surface) 70%);
  background-size: 200% 100%; animation: shimmer 2s ease-in-out infinite;
}

.gb-bubble {
  display: flex; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--bubble-bg, var(--surface));
  border: 1px solid var(--border);
  animation: bubbleIn 400ms var(--ease-out) both;
  transition: border-color 200ms ease, transform 200ms var(--ease-out);
}
.gb-bubble:hover { border-color: var(--border-strong); transform: translateX(2px); }
.gb-bubble.own { border-color: rgba(59,130,246,0.2); }
@keyframes bubbleIn { from { opacity:0; transform:translateY(16px) scale(0.96); } to { opacity:1; transform:translateY(0) scale(1); } }

.gb-bubble-avatar { flex-shrink: 0; padding-top: 2px; }
.gb-bubble-body { flex: 1; min-width: 0; }
.gb-bubble-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.gb-bubble-head strong { font-size: var(--text-sm); color: var(--text-primary); }
.gb-bubble-head time { font-size: 10px; color: var(--text-muted); }
.gb-admin-badge { font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 10px; background: linear-gradient(135deg,rgba(59,130,246,0.2),rgba(139,92,246,0.15)); color: var(--brand); letter-spacing: 0.04em; }
.gb-bubble-text { font-size: var(--text-sm); line-height: 1.7; color: var(--text-secondary); white-space: pre-wrap; word-break: break-word; }
.gb-bubble-del {
  flex-shrink: 0; align-self: flex-start; margin-top: 4px;
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  padding: 4px; border-radius: 6px; opacity: 0; transition: opacity 150ms ease, color 150ms ease, background 150ms ease;
}
.gb-bubble:hover .gb-bubble-del { opacity: 0.6; }
.gb-bubble-del:hover { opacity: 1 !important; color: var(--danger); background: var(--danger-surface); }

.gb-input-bar {
  position: sticky; bottom: 0; z-index: 5;
  padding: var(--space-3); margin: 0 calc(-1 * var(--space-4));
  background: var(--bg-elevated); border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.gb-input-wrap {
  display: flex; gap: var(--space-2); align-items: flex-end;
  padding: var(--space-2); border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  transition: border-color 200ms ease;
}
.gb-input-wrap:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.gb-input-wrap textarea {
  flex: 1; border: none; outline: none; background: transparent;
  color: var(--text-primary); font-size: var(--text-sm); resize: none;
  min-height: 24px; max-height: 120px; line-height: 1.5; padding: 4px 0;
  font-family: inherit;
}
.gb-input-wrap textarea::placeholder { color: var(--text-muted); }
.gb-login-hint { text-align: center; padding: var(--space-4); font-size: var(--text-sm); color: var(--text-muted); }
.gb-login-hint a { color: var(--brand); font-weight: 600; }

@media (max-width: 768px) {
  .gb-header-card { padding: var(--space-4); }
  .gb-bubble { padding: var(--space-3); }
  .gb-input-bar { margin: 0 calc(-1 * var(--space-3)); padding: var(--space-2); }
}

/* ================================================================
   ADMIN DASHBOARD
   ================================================================ */

/* Stats Row */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--gap);
  margin-bottom: var(--gap);
}
.admin-stat-card {
  position: relative; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--surface), var(--surface-hover));
  padding: var(--space-4); cursor: default;
  transition: transform 250ms var(--ease-out), box-shadow 250ms var(--ease-out), border-color 200ms ease;
}
.admin-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.admin-stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--space-2);
  font-size: 20px;
}
.admin-stat-value {
  font-size: 28px; font-weight: 800; line-height: 1;
  color: var(--text-primary); margin-bottom: 2px;
}
.admin-stat-label { font-size: var(--text-xs); color: var(--text-muted); font-weight: 600; }
.admin-stat-glow {
  position: absolute; top: -20px; right: -20px;
  width: 80px; height: 80px; border-radius: 50%;
  opacity: 0.1; pointer-events: none;
}

/* Admin Section Card */
.admin-section {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); overflow: hidden;
  margin-bottom: var(--gap);
  animation: sectionReveal 400ms var(--ease-out) both;
}
.admin-section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface-hover);
  flex-wrap: wrap; gap: var(--space-2);
}
.admin-section-head h3 { margin: 0; font-size: var(--text-base); font-weight: 700; }
.admin-section-body { padding: var(--space-4); }

/* Admin Field Row */
.admin-field-row {
  display: grid; grid-template-columns: 200px 1fr;
  gap: var(--space-4); align-items: start;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}
.admin-field-row:last-child { border-bottom: none; }
.admin-field-label { font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary); padding-top: 8px; }
.admin-field-label small { display: block; font-weight: 400; color: var(--text-muted); margin-top: 2px; }
.admin-field-input { display: grid; gap: var(--space-2); }

@media (max-width: 768px) {
  .admin-field-row { grid-template-columns: 1fr; gap: var(--space-1); }
  .admin-stats { grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
  .admin-stat-card { padding: var(--space-3); }
  .admin-stat-value { font-size: 22px; }
}

/* Admin Quick Action */
.admin-quick-actions {
  display: flex; gap: var(--space-2); flex-wrap: wrap;
  margin-bottom: var(--gap);
}
.admin-quick-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-full);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-primary); font-size: var(--text-sm); font-weight: 600;
  cursor: pointer;
  transition: all 200ms var(--ease-out);
}
.admin-quick-btn:hover { background: var(--surface-hover); border-color: var(--brand); color: var(--brand); transform: translateY(-1px); }
.admin-quick-btn svg { width: 16px; height: 16px; }

/* Admin Poll Item */
.admin-poll-item {
  display: grid; grid-template-columns: 1fr auto;
  align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
  transition: all 200ms var(--ease-out);
  animation: itemSlideIn 350ms var(--ease-out) both;
}
.admin-poll-item:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.admin-poll-info { min-width: 0; }
.admin-poll-title { font-weight: 700; font-size: var(--text-sm); margin-bottom: 4px; }
.admin-poll-meta { font-size: var(--text-xs); color: var(--text-muted); display: flex; gap: var(--space-3); flex-wrap: wrap; }
.admin-poll-actions { display: flex; gap: var(--space-2); flex-shrink: 0; }

/* Admin Status Pulse */
.admin-status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 4px; vertical-align: middle;
}
.admin-status-dot.active { background: var(--success); animation: timerPulse 1.5s ease-in-out infinite; }
.admin-status-dot.ended { background: var(--text-muted); }
.admin-status-dot.drawn { background: var(--warning); }

/* Admin Modal */
.admin-modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center;
  padding: var(--space-4);
  animation: overlayIn 200ms ease;
}
.admin-modal {
  width: min(560px, 100%); max-height: 80vh; overflow-y: auto;
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  background: var(--bg-elevated); box-shadow: var(--shadow-lg);
  animation: revealCardIn 300ms var(--ease-out);
}
.admin-modal-head {
  padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: var(--text-base);
}
.admin-modal-body { padding: var(--space-4); display: grid; gap: var(--space-3); }
.admin-modal-foot {
  padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border);
  display: flex; gap: var(--space-2); justify-content: flex-end;
}

/* Admin Login Glow */
.admin-login-card {
  position: relative; overflow: hidden;
}
.admin-login-card::before {
  content: ''; position: absolute; top: -60px; left: 50%; transform: translateX(-50%);
  width: 160px; height: 100px;
  background: radial-gradient(ellipse, rgba(59,130,246,0.12), transparent 70%);
  pointer-events: none;
}

/* Admin Tab content transition */
.admin-tab-content {
  animation: tabFadeIn 300ms var(--ease-out);
}
@keyframes tabFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── Test Notification Preview ─────────────────────────────── */
.tn-preview {
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--bg-elevated); overflow: hidden;
  box-shadow: var(--shadow-md); max-width: 340px;
}
.tn-preview-bell {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px var(--space-3); border-bottom: 1px solid var(--border);
  color: var(--text-secondary); font-size: var(--text-sm); font-weight: 700;
}
.tn-preview-dot {
  min-width: 18px; height: 18px; border-radius: var(--radius-full);
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.tn-preview-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px var(--space-3); border-bottom: 1px solid var(--border);
}
.tn-preview-item.unread { background: rgba(59,130,246,0.06); }
.tn-preview-dot-blue {
  width: 6px; height: 6px; border-radius: 50%; background: var(--brand);
  flex-shrink: 0; margin-top: 6px;
}
.tn-preview-title { font-weight: 700; font-size: var(--text-sm); margin-bottom: 2px; }
.tn-preview-text { font-size: var(--text-xs); color: var(--text-secondary); line-height: 1.4; }
.tn-preview-time { font-size: 10px; color: var(--text-muted); margin-top: 4px; }

@media (max-width: 768px) {
  .tn-preview { max-width: 100%; }
}

/* ── Home Check-in Card ────────────────────────────────────── */
.checkin-hero {
  background: linear-gradient(135deg, rgba(245,158,11,0.08), rgba(239,68,68,0.04)) !important;
  border-color: rgba(245,158,11,0.2) !important;
}
.checkin-hero .btn-lg.done {
  cursor: default;
  animation: checkinDone 500ms var(--ease-out);
}
@keyframes checkinDone {
  0% { transform: scale(1); }
  30% { transform: scale(1.08); }
  60% { transform: scale(0.96); }
  100% { transform: scale(1); }
}
@media (max-width: 768px) {
  .checkin-hero .card-body { flex-direction: column; text-align: center; }
}
