/* VeloTracker v2.6 — full rewrite.
   Dark theme is primary. All user-facing strings in /locales/*.json.
   Pure CSS — no framework. */

/* -------- Font: Inter (variable) with Cyrillic -------- */
@import url("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;0,14..32,800;0,14..32,900&display=swap");

/* -------- Design tokens — DARK (primary) -------- */
:root,
:root[data-theme="dark"] {
  --bg:              #050B1A;
  --bg-2:            #07112A;
  --surface:         #0F1A2E;
  --surface-2:       #182843;
  --surface-3:       #1E3050;
  --card:            #0F1A2E;
  --border:          rgba(255,255,255,0.08);
  --border-strong:   rgba(255,255,255,0.18);
  --text:            #FFFFFF;
  --text-dim:        #8B96AB;
  --text-mute:       #5C6680;
  --accent-pink:     #FF6482;
  --accent-gold:     #C9A24B;
  --accent-green:    #34C759;
  --accent-red:      #FF3B30;
  --accent-cyan:     #5BD1E6;
  --shield-fill-a:   #FFB3A6;
  --shield-fill-b:   #FF6E62;
  --on-accent:       #FFFFFF;

  --shadow-card:     0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.4);
  --shadow-pop:      0 12px 32px rgba(0,0,0,0.55);

  --radius-sm:   10px;
  --radius:      14px;
  --radius-lg:   22px;
  --radius-card: 16px;
  --radius-pill: 999px;

  --nav-h:          68px;
  --top-h:          56px;
  --sheet-collapsed: 280px;
  --sidebar-w:       80px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  color-scheme: dark;
}

/* -------- Light theme — separate token set (NOT dark inversion) -------- */
:root[data-theme="light"] {
  --bg:              #F0F2F7;
  --bg-2:            #E4E8F0;
  --surface:         #FFFFFF;
  --surface-2:       #F4F6FA;
  --surface-3:       #EBEEf4;
  --card:            #FFFFFF;
  --border:          rgba(15,18,28,0.09);
  --border-strong:   rgba(15,18,28,0.20);
  --text:            #0E1118;
  --text-dim:        #5C6478;
  --text-mute:       #8089A0;
  --shadow-card:     0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(20,24,38,0.07);
  --shadow-pop:      0 8px 28px rgba(20,24,38,0.18);
  color-scheme: light;
}

/* -------- Reset -------- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  overscroll-behavior: none;
  touch-action: pan-x pan-y;
}
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.005em;
}
button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; padding: 0; }
a { color: inherit; text-decoration: none; }
input, textarea, select {
  font-family: inherit; font-size: 15px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; outline: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input:focus, textarea:focus { border-color: var(--border-strong); box-shadow: 0 0 0 3px rgba(255,100,130,0.12); }
img, svg { display: block; }

/* -------- Helpers -------- */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1 1 auto; min-width: 0; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.center { display: flex; align-items: center; justify-content: center; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.txt-sm { font-size: 13px; }
.txt-xl { font-size: 22px; letter-spacing: -0.01em; }
.txt-dim { color: var(--text-dim); }
.txt-mute { color: var(--text-mute); }
.bold { font-weight: 700; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }
.hidden { display: none !important; }
.spin {
  display: inline-block; width: 22px; height: 22px;
  border: 3px solid rgba(255,255,255,0.22);
  border-top-color: #fff;
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* -------- Card brick -------- */
.card {
  background: var(--card);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  padding: 16px;
  box-shadow: var(--shadow-card);
}
.card-gap { display: flex; flex-direction: column; gap: 12px; }

/* -------- Starfield background (dark only) -------- */
:root[data-theme="dark"] body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,0.6) 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 42%, rgba(255,255,255,0.35) 50%, transparent 51%),
    radial-gradient(1px 1px at 44% 12%, rgba(255,255,255,0.5)  50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 62% 60%, rgba(255,255,255,0.4) 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 22%, rgba(255,255,255,0.55) 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 88% 76%, rgba(255,255,255,0.35) 50%, transparent 51%),
    radial-gradient(1px 1px at 18% 82%, rgba(255,255,255,0.45) 50%, transparent 51%),
    radial-gradient(1px 1px at 52% 88%, rgba(255,255,255,0.4) 50%, transparent 51%),
    radial-gradient(1200px 600px at 50% -10%, #0A1530 0%, #050B1A 60%);
  pointer-events: none;
  z-index: 0;
}
#app { position: relative; z-index: 1; height: 100%; }

/* =====================================================
   WELCOME / AUTH SCREEN
   Animated organic gradient — iOS-style pink/peach/coral.
   ===================================================== */

.welcome-screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  padding: 56px 28px 36px;
  color: #FFFFFF;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: #F39B89;
  isolation: isolate;
}
.welcome-inner {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding-bottom: 24px;
}
.welcome-screen::before,
.welcome-screen::after,
.welcome-blob {
  content: "";
  position: absolute; inset: -40%;
  z-index: -1;
  pointer-events: none;
  will-change: transform, filter;
}
.welcome-screen::before {
  background:
    radial-gradient(circle at 25% 30%, #FF6E8E 0%, transparent 42%),
    radial-gradient(circle at 75% 20%, #FFB199 0%, transparent 48%),
    radial-gradient(circle at 80% 80%, #E84F6E 0%, transparent 50%),
    radial-gradient(circle at 12% 88%, #FFD7B5 0%, transparent 42%);
  filter: blur(36px);
  animation: blobDrift 14s ease-in-out infinite alternate;
}
.welcome-screen::after {
  inset: -45%;
  background:
    radial-gradient(circle at 60% 40%, #FF8FB1 0%, transparent 52%),
    radial-gradient(circle at 18% 62%, #F25D7C 0%, transparent 50%),
    radial-gradient(circle at 88% 88%, #FFC2A0 0%, transparent 48%),
    radial-gradient(circle at 50% 10%, #FF9D8F 0%, transparent 45%);
  filter: blur(40px);
  animation: blobDrift2 18s ease-in-out infinite alternate;
  mix-blend-mode: screen;
  opacity: 0.95;
}
.welcome-blob {
  inset: -50%;
  background:
    radial-gradient(circle at 35% 75%, #FFAE8E 0%, transparent 55%),
    radial-gradient(circle at 80% 30%, #FF5E8A 0%, transparent 50%),
    radial-gradient(circle at 10% 35%, #FFCBB0 0%, transparent 48%);
  filter: blur(48px);
  animation: blobDrift3 22s ease-in-out infinite alternate;
  mix-blend-mode: overlay;
  opacity: 0.85;
}
@keyframes blobDrift {
  0%   { transform: translate3d(-8%, -6%, 0) scale(1.0) rotate(0deg); }
  25%  { transform: translate3d(6%, -10%, 0) scale(1.15) rotate(8deg); }
  50%  { transform: translate3d(10%, 8%, 0)  scale(1.25) rotate(-5deg); }
  75%  { transform: translate3d(-6%, 12%, 0) scale(1.1)  rotate(12deg); }
  100% { transform: translate3d(-10%, -4%, 0) scale(1.3) rotate(-10deg); }
}
@keyframes blobDrift2 {
  0%   { transform: translate3d(8%, 6%, 0)   scale(1.1) rotate(0deg); }
  25%  { transform: translate3d(-10%, 4%, 0) scale(1.25) rotate(-12deg); }
  50%  { transform: translate3d(-4%, -10%, 0) scale(1.15) rotate(10deg); }
  75%  { transform: translate3d(12%, -6%, 0) scale(1.3)  rotate(-8deg); }
  100% { transform: translate3d(4%, 12%, 0)  scale(1.0) rotate(15deg); }
}
@keyframes blobDrift3 {
  0%   { transform: translate3d(0%, 0%, 0)    scale(1.0) rotate(0deg); }
  33%  { transform: translate3d(-12%, 8%, 0)  scale(1.2) rotate(-15deg); }
  66%  { transform: translate3d(10%, -10%, 0) scale(1.3) rotate(20deg); }
  100% { transform: translate3d(6%, 14%, 0)   scale(1.1) rotate(-8deg); }
}

.welcome-title {
  font-size: clamp(44px, 9vw, 64px);
  font-weight: 900;
  letter-spacing: 4px;
  color: #FFFFFF;
  text-shadow: 0 4px 24px rgba(0,0,0,0.18);
  text-align: center;
  margin: 10vh 0 28px;
  line-height: 1;
}
@media (max-height: 720px) {
  .welcome-title { margin: 5vh 0 18px; font-size: 48px; }
}

/* Auth method buttons */
.auth-btn {
  width: 100%;
  background: #0E1118;
  color: #FFFFFF;
  font-weight: 700; font-size: 16px;
  padding: 18px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.22);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.auth-btn:active { transform: scale(0.985); }
.auth-btn:disabled { opacity: 0.7; }
.auth-btn.secondary {
  background: rgba(255,255,255,0.18);
  border: 1.5px solid rgba(255,255,255,0.55);
  color: #FFFFFF;
}
.auth-terms {
  text-align: center;
  color: rgba(255,255,255,0.8);
  font-size: 12px; font-weight: 500;
  margin-top: 10px;
}
.auth-terms a { color: #FFFFFF; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* Email/phone flow inputs */
.welcome-form { display: flex; flex-direction: column; gap: 14px; }
.welcome-form input {
  width: 100%;
  background: #FFFFFF;
  color: #0E1118;
  border: 0;
  border-radius: 12px;
  padding: 18px;
  font-size: 16px; font-weight: 500;
}
.welcome-form input::placeholder { color: #8A8A93; font-weight: 500; }
.welcome-signin {
  width: 100%; background: #0E1118; color: #FFFFFF;
  font-weight: 700; font-size: 16px;
  padding: 18px; border-radius: 12px;
  margin-top: 8px;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
  box-shadow: 0 8px 24px rgba(0,0,0,0.22);
}
.welcome-signin:active { transform: scale(0.985); }
.welcome-signin:disabled { opacity: 0.7; }
.welcome-back {
  text-align: center; margin-top: 16px;
  color: rgba(255,255,255,0.9); font-weight: 600; font-size: 14px;
}
.welcome-back a { color: #FFFFFF; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.welcome-err {
  color: #6B0F18; background: rgba(255,255,255,0.7);
  border-radius: 10px; padding: 8px 12px; font-size: 13px;
  font-weight: 600; min-height: 0;
}
.welcome-footer {
  margin-top: auto; text-align: center; padding-top: 18px;
  color: rgba(255,255,255,0.9); font-weight: 600; font-size: 13px;
}
.welcome-footer a {
  color: #FFFFFF; font-weight: 800;
  text-decoration: underline; text-underline-offset: 3px;
}

/* Phone flow */
.phone-prefix-row {
  display: flex; gap: 8px;
}
.phone-prefix-select {
  width: 120px; flex-shrink: 0;
  background: #FFFFFF; color: #0E1118;
  border: 0; border-radius: 12px;
  padding: 18px 12px;
  font-size: 16px; font-weight: 600;
  appearance: none;
}
.phone-number-input {
  flex: 1;
}

/* SMS code boxes */
.sms-code-row {
  display: flex; gap: 8px; justify-content: center;
  margin: 6px 0;
}
.sms-box {
  width: 48px; height: 56px;
  background: #FFFFFF;
  border: 2.5px solid transparent;
  border-radius: 12px;
  font-size: 24px; font-weight: 800;
  color: #0E1118;
  text-align: center;
  outline: none;
  transition: border-color .15s var(--ease);
  caret-color: #FF6482;
}
.sms-box:focus { border-color: #FF6482; }

/* Math captcha card */
.captcha-card {
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  border: 1.5px solid rgba(255,255,255,0.3);
  padding: 20px;
  text-align: center;
  color: #FFFFFF;
}
.captcha-question {
  font-size: 28px; font-weight: 800; margin-bottom: 14px;
  letter-spacing: 1px;
}
.captcha-input {
  width: 100%; background: rgba(255,255,255,0.95);
  color: #0E1118; border: 0; border-radius: 10px;
  padding: 14px; font-size: 18px; font-weight: 700;
  text-align: center; margin-bottom: 12px;
}
.captcha-btn {
  width: 100%; background: #0E1118; color: #FFFFFF;
  font-weight: 700; font-size: 15px;
  padding: 14px; border-radius: 10px;
  transition: transform .15s var(--ease);
}
.captcha-btn:active { transform: scale(0.985); }

/* =====================================================
   /app — Play screen
   ===================================================== */

.app-screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.map-host {
  position: absolute; inset: 0;
  background: var(--bg);
}
.map-host #map { width: 100%; height: 100%; }
.map-host .maplibregl-ctrl-attrib { font-size: 10px; }

/* Map fallback — animated dotted globe */
.map-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 45%, #0F1A2E 0%, #050B1A 70%);
}
.map-fallback svg { width: min(78vw, 480px); height: auto; opacity: 0.95; }
.map-fallback .globe-spin { animation: spinSlow 80s linear infinite; transform-origin: center; }
@keyframes spinSlow { to { transform: rotate(360deg); } }

/* Top seg-pill */
.app-top {
  position: absolute; top: 0; left: 0; right: 0;
  padding: 14px 14px 8px;
  z-index: 5;
  pointer-events: none;
}
.app-top > * { pointer-events: auto; }

.seg-pill {
  display: flex;
  width: 100%;
  background: rgba(8, 14, 30, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: var(--radius-pill);
  padding: 4px;
  border: 1px solid rgba(255,255,255,0.06);
}
.seg-pill button {
  flex: 1;
  padding: 10px 8px;
  border-radius: var(--radius-pill);
  color: rgba(255,255,255,0.55);
  font-weight: 600;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  gap: 4px;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.seg-pill button.active {
  background: #E9EDF5;
  color: #0E1118;
}
.seg-pill button .caret {
  width: 12px; height: 12px;
  opacity: 0.7;
}

/* Bell + shield row */
.app-top-row {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-top: 14px;
  padding: 0 4px;
}
.bell-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(8, 14, 30, 0.72);
  backdrop-filter: blur(14px);
  display: flex; align-items: center; justify-content: center;
  color: #FFFFFF;
  border: 1px solid rgba(255,255,255,0.06);
}
.my-runs-pill {
  display: inline-flex; align-items: center;
  margin-top: 14px;
  padding: 9px 16px;
  background: rgba(8, 14, 30, 0.78);
  border-radius: var(--radius-pill);
  color: #FFFFFF; font-weight: 700; font-size: 13px;
  border: 1px solid rgba(255,255,255,0.06);
}
.bell-col { display: flex; flex-direction: column; align-items: flex-start; }

/* Shield avatar */
.shield-avatar {
  position: relative;
  width: 56px; height: 64px;
  filter: drop-shadow(0 6px 16px rgba(0,0,0,0.45));
}
.shield-avatar.big { width: 120px; height: 136px; }
.shield-avatar svg { width: 100%; height: 100%; display: block; }
.shield-avatar .lvl-badge {
  position: absolute; left: 50%;
  bottom: -2px;
  transform: translateX(-50%);
  background: #FFFFFF;
  color: #0E1118;
  font-weight: 800; font-size: 10px;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1.5px solid #0E1118;
}
.shield-avatar.big .lvl-badge { font-size: 13px; padding: 5px 14px; }

/* Util column (right edge of /app) */
.util-col {
  position: absolute;
  right: 14px;
  top: 220px;
  display: flex; flex-direction: column; gap: 14px;
  z-index: 4;
}
.util-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  background: rgba(8, 14, 30, 0.85);
  border: 1px solid rgba(255,255,255,0.10);
  color: #FFFFFF;
  transition: transform .15s var(--ease);
}
.util-btn:active { transform: scale(0.94); }
.util-btn.eye {
  background: #25E07A;
  color: #0E1118;
  box-shadow: 0 0 0 3px rgba(37,224,122,0.18), 0 0 24px rgba(37,224,122,0.45);
}
.util-btn.eye::before {
  content: "";
  position: absolute; left: 50%; top: -22px;
  transform: translateX(-50%);
  width: 6px; height: 22px;
  background: linear-gradient(180deg, #FFFFFF 0%, #25E07A 100%);
  border-radius: 999px;
}
.util-btn.target {
  background: rgba(8, 14, 30, 0.85);
  color: #FF4044;
  border-color: #FF4044;
  box-shadow: 0 0 18px rgba(255,64,68,0.45);
}
.util-btn.checkpoint {
  background: transparent;
  color: var(--accent-cyan);
  border-color: transparent;
  box-shadow: 0 0 28px rgba(91,209,230,0.55);
}
.util-btn.checkpoint svg { filter: drop-shadow(0 0 10px rgba(91,209,230,0.8)); }
.util-btn.more {
  background: rgba(8, 14, 30, 0.9);
  color: #FFFFFF;
}

/* =====================================================
   Bottom sheet
   ===================================================== */
.sheet {
  position: fixed; left: 0; right: 0;
  bottom: var(--nav-h);
  height: calc(100vh - var(--nav-h) - 12px);
  background: var(--surface-2);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.45);
  z-index: 9;
  display: flex; flex-direction: column;
  transform: translateY(calc(100% - var(--sheet-collapsed)));
  transition: transform 0.32s var(--ease);
  will-change: transform;
  touch-action: none;
}
.sheet.expanded {
  transform: translateY(0);
}
.sheet.dragging { transition: none; }

/* Grip handle — large 48x6px, hover state */
.sheet-handle {
  height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: grab;
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
}
.sheet-handle::before {
  content: "";
  width: 48px; height: 6px;
  background: rgba(255,255,255,0.22);
  border-radius: 999px;
  transition: background .15s var(--ease), transform .15s var(--ease);
}
.sheet-handle:hover::before {
  background: rgba(255,255,255,0.45);
  transform: scaleX(1.08);
}
.sheet-handle:active,
.sheet.dragging .sheet-handle { cursor: grabbing; }
.sheet.dragging .sheet-handle::before { background: rgba(255,255,255,0.55); }

/* Light theme handle */
:root[data-theme="light"] .sheet-handle::before {
  background: rgba(0,0,0,0.14);
}
:root[data-theme="light"] .sheet-handle:hover::before {
  background: rgba(0,0,0,0.28);
}

.sheet-tabs {
  display: flex;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sheet-tabs button {
  flex: 1;
  padding: 12px 4px 14px;
  color: var(--text-dim);
  font-weight: 600; font-size: 15px;
  position: relative;
  border-bottom: 2px solid transparent;
  transition: color .15s var(--ease);
}
.sheet-tabs button.active {
  color: var(--text);
  border-bottom-color: var(--text);
}
:root[data-theme="light"] .sheet-tabs button { color: var(--text-dim); }
:root[data-theme="light"] .sheet-tabs button.active { color: var(--text); }

.sheet-body {
  flex: 1; overflow-y: auto;
  padding: 16px 18px 24px;
  -webkit-overflow-scrolling: touch;
}

/* Desktop sheet — right sidebar pinned */
@media (min-width: 1024px) {
  .sheet {
    left: auto;
    right: 0;
    bottom: 0;
    width: 480px;
    height: 100%;
    max-height: 85vh;
    min-height: 200px;
    border-radius: 24px 0 0 24px;
    transform: translateY(0);
    top: auto;
    bottom: 0;
    /* snap to right, no full-screen */
  }
  .sheet.expanded { transform: translateY(0); }
}

/* LB chips */
.chip-row {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 12px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 14px;
  background: var(--surface-3);
  color: var(--text-dim);
  border-radius: 12px;
  font-weight: 700; font-size: 11px; letter-spacing: 0.5px;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid var(--border);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.chip.active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.chip svg { color: currentColor; }

.toggle-row {
  display: flex; gap: 8px;
  background: var(--surface-3);
  border-radius: var(--radius-pill);
  padding: 4px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}
.toggle-row button {
  flex: 1; padding: 10px;
  color: var(--text-dim); font-weight: 600; font-size: 14px;
  border-radius: var(--radius-pill);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.toggle-row button.active { background: var(--surface-2); color: var(--text); }

.lb-list { display: flex; flex-direction: column; gap: 8px; }
.lb-row {
  display: grid;
  grid-template-columns: 32px 28px 36px 1fr auto;
  align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--player-color, var(--surface-3));
  color: #FFFFFF;
}
.lb-row .pos { font-weight: 800; }
.lb-row .ava {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #FFFFFF;
  background-size: cover; background-position: center;
  font-size: 13px;
}
.lb-row .km { font-weight: 700; font-size: 14px; }
.lb-row .km .unit { font-size: 10px; opacity: 0.75; margin-left: 2px; }

.section-title {
  font-size: 12px; font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.8px;
  margin: 16px 0 8px;
}
.empty-state {
  color: var(--text-dim);
  text-align: center;
  padding: 32px 12px;
  font-size: 14px;
}

/* =====================================================
   Bottom nav (4 tabs — mobile) + Left sidebar (desktop)
   ===================================================== */
.nav-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: var(--nav-h);
  z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(5, 11, 26, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
:root[data-theme="light"] .nav-bar {
  background: rgba(244, 246, 250, 0.94);
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  color: var(--text-dim);
  font-size: 11px; font-weight: 600;
  position: relative;
  text-align: center;
  padding-top: 8px;
  min-height: 44px;
  transition: color .15s var(--ease);
}
.nav-btn.active { color: var(--text); }
.nav-btn svg { color: currentColor; }
.nav-btn .nav-icon-wrap {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
}
.nav-btn.active .nav-icon-wrap.boxed {
  background: var(--surface-2);
}

/* Desktop: left sidebar 80px icon-only */
@media (min-width: 1024px) {
  .nav-bar {
    top: 0; right: auto; bottom: 0; left: 0;
    width: var(--sidebar-w);
    height: 100%;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, auto);
    border-top: 0;
    border-right: 1px solid var(--border);
    padding-bottom: 0;
    padding-top: 80px;
    align-content: start;
    gap: 4px;
    justify-items: stretch;
  }
  .nav-btn {
    flex-direction: column;
    padding: 14px 0;
    font-size: 10px;
    position: relative;
  }
  .nav-btn .nav-label { display: none; }
  .nav-btn:hover .nav-label {
    display: block;
    position: absolute;
    left: calc(100% + 8px);
    top: 50%; transform: translateY(-50%);
    background: var(--surface-2);
    color: var(--text);
    font-size: 12px; font-weight: 600;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    white-space: nowrap;
    pointer-events: none;
    z-index: 100;
    box-shadow: var(--shadow-pop);
  }
  /* App content offset */
  .app-screen { padding-left: var(--sidebar-w); }
  .scroll-page { left: var(--sidebar-w); }
}

/* =====================================================
   /me — Profile screen
   ===================================================== */
.scroll-page {
  position: fixed; inset: 0 0 var(--nav-h) 0;
  overflow-y: auto;
  background: var(--bg);
}
@media (min-width: 1024px) {
  .scroll-page { bottom: 0; left: var(--sidebar-w); }
}
.me-page { padding: 28px 18px 32px; display: flex; flex-direction: column; align-items: center; position: relative; }
.me-page .kebab {
  position: absolute; top: 14px; right: 14px;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
}
.me-name {
  font-size: clamp(20px, 5vw, 26px); font-weight: 800;
  margin: 26px 0 8px;
  text-align: center;
  letter-spacing: -0.01em;
}
.follow-row {
  display: flex; align-items: center; gap: 28px;
  margin-bottom: 24px;
}
.follow-stat { text-align: center; }
.follow-stat .num { font-size: 18px; font-weight: 800; }
.follow-stat .lbl { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

.stats-grid-2 {
  width: 100%;
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 0 12px;
}
.stat-big {
  text-align: center;
  padding: 20px 16px;
}
.stat-big .num { font-size: 34px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.stat-big .lbl { font-size: 13px; color: var(--text-dim); margin-top: 8px; font-weight: 500; }

.pb-row {
  width: 100%;
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 0 12px;
}
.pb-row .pb { text-align: center; }
.pb-row .pb .v {
  font-size: 22px; font-weight: 800; color: var(--text-dim);
  letter-spacing: 1px;
}
.pb-row .pb .l { font-size: 14px; color: var(--text); font-weight: 600; margin-top: 6px; }

/* Bar chart */
.bar-chart-wrap {
  width: 100%; margin-top: 0;
  border-radius: var(--radius-card);
  padding: 16px 0 18px;
}
.bar-chart-title {
  font-size: 16px; font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}
.bar-chart {
  position: relative;
  height: 200px;
  display: flex; align-items: flex-end;
  gap: 4px;
  padding: 0 4px;
  border-bottom: 1.2px solid var(--accent-pink);
}
.bar-chart .bar {
  flex: 1;
  background: var(--accent-pink);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  opacity: 0.9;
  transition: height .4s var(--ease);
}
.bar-chart .grid-line {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: var(--border);
}
.bar-chart-axis {
  display: flex; justify-content: space-between;
  margin-top: 6px;
  color: var(--text-dim); font-size: 13px;
  padding: 0 4px;
}

/* Settings sheet (kebab menu) */
.settings-sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--surface-2);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 16px 18px calc(env(safe-area-inset-bottom, 0) + 24px);
  z-index: 50;
  transform: translateY(100%);
  transition: transform 0.32s var(--ease);
  box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}
@media (min-width: 600px) {
  .settings-sheet { left: 50%; transform: translateX(-50%) translateY(100%); right: auto; width: 480px; }
  .settings-sheet.open { transform: translateX(-50%) translateY(0); }
}
.settings-sheet.open { transform: translateY(0); }

.settings-sheet .sheet-handle { margin: -6px auto 10px; }
.settings-sheet-title {
  font-size: 17px; font-weight: 800; text-align: center;
  margin-bottom: 16px; letter-spacing: -0.01em;
}

/* Theme toggles row */
.theme-toggle-row {
  display: flex; gap: 10px; justify-content: center;
  margin-bottom: 16px;
}
.theme-toggle-btn {
  width: 64px; height: 64px;
  border-radius: 16px;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  transition: border-color .15s var(--ease), background .15s var(--ease);
  cursor: pointer;
}
.theme-toggle-btn.active {
  border-color: var(--accent-pink);
  background: var(--surface-3);
}

/* Language select */
.lang-select {
  width: 100%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 15px; font-weight: 600;
  margin-bottom: 14px;
  appearance: none;
  cursor: pointer;
}

/* Territory color picker */
.color-picker-label {
  font-size: 13px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.6px;
  margin-bottom: 10px;
}
.color-chips {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.color-chip {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .15s var(--ease), border-color .15s var(--ease);
}
.color-chip:hover { transform: scale(1.12); }
.color-chip.active { border-color: #FFFFFF; box-shadow: 0 0 0 2px var(--surface-2); }
:root[data-theme="light"] .color-chip.active { border-color: #0E1118; }

/* Danger / logout */
.settings-sheet .item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 6px;
  border-bottom: 1px solid var(--border);
  font-size: 16px; font-weight: 600;
  min-height: 44px;
  width: 100%;
  text-align: left;
}
.settings-sheet .item:last-child { border-bottom: 0; }
.settings-sheet .item .right { margin-left: auto; color: var(--text-dim); font-weight: 600; }
.settings-sheet .danger { color: var(--accent-red); }

.scrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 49;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s var(--ease);
}
.scrim.open { opacity: 1; pointer-events: auto; }

/* =====================================================
   /feed
   ===================================================== */
.feed-page { padding: 14px 16px 28px; }
.feed-top {
  display: grid; grid-template-columns: 44px 1fr 56px;
  align-items: center;
  margin-bottom: 14px;
}
.feed-top .title {
  text-align: center;
  font-weight: 900; letter-spacing: 4px; font-size: 18px;
}
.feed-tabs {
  display: flex; gap: 0;
  margin-bottom: 18px;
  padding: 0 4px;
}

/* Feed tab pills — proper contrast (AA compliant) */
.tab-pill {
  flex: 1;
  padding: 11px 0;
  color: var(--text-dim);
  font-weight: 700; font-size: 15px;
  border-radius: 8px;
  position: relative;
  transition: color .15s var(--ease), background .15s var(--ease);
  border-bottom: 2px solid transparent;
  text-align: center;
}
/* Inactive tabs: AA contrast against both themes */
.tab-pill:not(.active) {
  color: var(--text-dim);
}
:root[data-theme="light"] .tab-pill:not(.active) {
  color: #5C6478; /* >= 4.5:1 on #F0F2F7 */
}
.tab-pill.active {
  color: var(--text);
  border-bottom-color: var(--text);
  background: rgba(255,255,255,0.06);
}
:root[data-theme="light"] .tab-pill.active {
  background: rgba(14,17,24,0.06);
}

.vis-card {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 20px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
}
.vis-card h3 {
  text-align: center; margin: 0 0 16px;
  font-size: 17px; font-weight: 800; letter-spacing: -0.01em;
}
.vis-card .opt {
  display: grid; grid-template-columns: 1fr auto;
  align-items: flex-start; gap: 14px;
  padding: 12px 0;
  cursor: pointer;
}
.vis-card .opt + .opt { border-top: 1px solid var(--border); margin-top: 4px; }
.vis-card .opt h4 { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.vis-card .opt p { margin: 0; color: var(--text-dim); font-size: 13px; line-height: 1.45; }
.vis-card .radio {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.vis-card .radio.checked { border-color: var(--text); }
.vis-card .radio.checked::after {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  background: var(--text);
}

.feed-add-friends {
  width: 100%;
  padding: 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  background: transparent;
  color: var(--text);
  font-weight: 800; font-size: 16px;
  margin-bottom: 12px;
  transition: background .15s var(--ease);
}
.feed-add-friends:hover { background: var(--surface-2); }
.feed-composer {
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 12px 16px 12px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}
.feed-composer .placeholder {
  flex: 1;
  color: var(--text-dim);
  font-size: 14px;
}
.feed-composer .shield-avatar { width: 40px; height: 46px; }
.feed-composer .shield-avatar .lvl-badge { font-size: 8px; padding: 2px 6px; }

.feed-empty {
  text-align: center; padding: 40px 12px;
  color: var(--text-dim); font-weight: 600; font-size: 15px;
}

/* =====================================================
   /run — Start Run screen
   ===================================================== */
.run-screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
}
.run-map {
  position: absolute; inset: 0 0 var(--run-sheet-h, 360px) 0;
  background: linear-gradient(160deg, #DAE2EB 0%, #F4F0E6 100%);
}
.run-map #runMap { width: 100%; height: 100%; }
.run-top {
  position: absolute; top: 14px; left: 14px; right: 14px;
  display: flex; justify-content: space-between;
  z-index: 4;
}
.run-top .icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: #FFFFFF;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
  color: #0E1118;
}
.run-top .icon-btn.target { color: #0A77FF; }
.run-top-right { display: flex; gap: 10px; }

.run-sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: #FAF7F2;
  color: #0E1118;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 14px 18px calc(env(safe-area-inset-bottom, 0) + 22px);
  box-shadow: 0 -12px 32px rgba(0,0,0,0.18);
  z-index: 6;
}
.run-sheet .sheet-handle::before { background: rgba(0,0,0,0.18); }

/* Desktop run layout */
@media (min-width: 1024px) {
  .run-map {
    inset: 0 420px 0 var(--sidebar-w);
  }
  .run-sheet {
    left: auto; right: 0;
    top: 0; bottom: 0;
    width: 420px;
    border-radius: 0;
    border-left: 1px solid rgba(0,0,0,0.12);
    overflow-y: auto;
    padding-top: 28px;
  }
}

.run-progress {
  display: grid; grid-template-columns: 1fr auto;
  align-items: center;
  padding: 10px 6px 4px;
}
.run-progress .left { text-align: center; flex: 1; }
.run-progress .area { font-size: 32px; font-weight: 900; letter-spacing: -0.02em; }
.run-progress .area .unit { font-size: 16px; font-weight: 800; margin-left: 4px; }
.run-progress .area-label { font-size: 13px; color: #6B7280; font-weight: 600; margin-top: 2px; }
.run-progress .gps {
  display: inline-flex; align-items: center; gap: 6px;
  color: #FF7273; font-weight: 700; font-size: 14px;
}

/* Metrics grid — 2 col mobile, 4 col wide sheet */
.run-metrics {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 16px 0 20px;
}
@media (min-width: 1024px) {
  .run-metrics { grid-template-columns: repeat(4, 1fr); }
}
.run-metric {
  text-align: center;
  background: rgba(0,0,0,0.04);
  border-radius: 12px;
  padding: 12px 8px;
}
.run-metric .num {
  font-size: 26px; font-weight: 900;
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.01em;
}
.run-metric .num .unit { font-size: 14px; font-weight: 800; margin-left: 2px; }
.run-metric .lbl { font-size: 12px; color: #6B7280; font-weight: 600; margin-top: 2px; }

.run-start-btn {
  width: 100%;
  height: 56px;
  border: 2px solid #0E1118;
  border-radius: 14px;
  background: #0E1118;
  color: #FFFFFF;
  font-weight: 800; font-size: 17px;
  letter-spacing: 0.2px;
  transition: transform .15s var(--ease), background .15s var(--ease);
}
.run-start-btn:active { transform: scale(0.987); }
.run-other {
  display: block;
  text-align: center;
  margin-top: 14px;
  color: #0E1118;
  text-decoration: underline;
  text-underline-offset: 4px;
  font-weight: 600;
  font-size: 14px;
}

/* =====================================================
   AI Assistant FAB + Chat Drawer
   ===================================================== */

/* FAB button */
.ai-fab {
  position: fixed;
  right: 18px;
  bottom: calc(var(--nav-h) + 14px);
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF6482 0%, #FFAE8E 100%);
  color: #FFFFFF;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(255,100,130,0.45), 0 2px 8px rgba(0,0,0,0.25);
  z-index: 30;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
  border: 0;
}
.ai-fab:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 28px rgba(255,100,130,0.55), 0 3px 12px rgba(0,0,0,0.3);
}
.ai-fab:active { transform: scale(0.96); }
.ai-fab svg { width: 26px; height: 26px; }
.ai-fab .badge {
  position: absolute; top: 6px; right: 6px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #34C759;
  border: 2px solid var(--bg);
  display: none;
}
.ai-fab.has-unread .badge { display: block; }

@media (min-width: 1024px) {
  .ai-fab { bottom: 24px; }
}

/* Chat drawer */
.ai-drawer {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  z-index: 40;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s var(--ease);
  will-change: transform;
}
.ai-drawer.open { transform: translateX(0); }

/* Mobile: full screen */
@media (max-width: 599px) {
  .ai-drawer { max-width: 100%; }
}

.ai-drawer-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ai-drawer-head .ava {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #FF6482 0%, #FFAE8E 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.ai-drawer-head .meta { flex: 1; min-width: 0; }
.ai-drawer-head .nm { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.ai-drawer-head .st { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.ai-drawer-head .st .dot {
  width: 7px; height: 7px; border-radius: 50%; background: #34C759;
  flex-shrink: 0;
}
.ai-drawer-head .close-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
  flex-shrink: 0;
}
.ai-drawer-head .close-btn:hover { color: var(--text); }

.ai-feed {
  flex: 1; overflow-y: auto;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 12px;
  -webkit-overflow-scrolling: touch;
}

/* Message bubbles */
.ai-msg {
  max-width: 84%; padding: 12px 14px;
  font-size: 14px; font-weight: 500; line-height: 1.55;
  border-radius: 16px;
}
.ai-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #FF6482 0%, #FFAE8E 100%);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
}
.ai-msg.assistant {
  align-self: flex-start;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
/* Markdown bold/code in messages */
.ai-msg strong { font-weight: 700; }
.ai-msg code {
  background: rgba(255,255,255,0.15);
  padding: 1px 5px; border-radius: 4px;
  font-size: 13px; font-family: 'SF Mono', 'Fira Code', monospace;
}
.ai-msg.assistant code { background: var(--surface-3); }

/* Typing indicator */
.ai-typing {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px; border-bottom-left-radius: 4px;
  padding: 14px 18px;
  display: flex; gap: 5px; align-items: center;
}
.ai-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-dim);
  animation: typingDot 1.4s ease-in-out infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Suggestion chips */
.ai-suggestions {
  display: flex; gap: 7px;
  overflow-x: auto;
  padding: 8px 18px 4px;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}
.ai-sugg-chip {
  flex-shrink: 0;
  padding: 8px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px; font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
  transition: background .15s var(--ease), color .15s var(--ease);
  cursor: pointer;
}
.ai-sugg-chip:hover { background: var(--surface-3); color: var(--text); }

/* Input area */
.ai-input-area {
  padding: 12px 18px calc(env(safe-area-inset-bottom, 0) + 14px);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.ai-input-row {
  display: flex; gap: 10px; align-items: flex-end;
}
.ai-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 12px 16px;
  font-size: 14px; font-weight: 500;
  color: var(--text);
  resize: none;
  outline: none;
  min-height: 44px;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.4;
  transition: border-color .15s var(--ease);
}
.ai-input:focus { border-color: var(--border-strong); }
.ai-send-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, #FF6482 0%, #FFAE8E 100%);
  color: #FFFFFF;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform .15s var(--ease), opacity .15s var(--ease);
}
.ai-send-btn:hover { transform: scale(1.06); }
.ai-send-btn:active { transform: scale(0.94); }
.ai-send-btn:disabled { opacity: 0.5; transform: none; }

.ai-fallback-msg {
  text-align: center; color: var(--text-mute); font-size: 13px;
  padding: 8px; font-style: italic;
}

/* Scrim for drawer */
.ai-scrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 39;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s var(--ease);
}
.ai-scrim.open { opacity: 1; pointer-events: auto; }

/* =====================================================
   Admin panel
   ===================================================== */

/* Admin outer container */
.admin-wrap {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
  overflow: hidden;
  font-size: 14px;
}

/* Admin top header */
.admin-header {
  height: 56px;
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}
.admin-header .logo {
  font-size: 16px; font-weight: 800; letter-spacing: -0.01em;
  color: var(--text);
}
.admin-header .logo span { color: var(--accent-pink); }
.admin-header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* Admin body: sidebar + content */
.admin-body {
  display: flex; flex: 1; overflow: hidden;
}

/* Sidebar */
.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 14px 10px;
  overflow-y: auto;
}
@media (max-width: 767px) {
  .admin-sidebar { width: 56px; }
  .admin-sidebar .nav-label { display: none; }
}

.admin-nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-dim);
  font-weight: 600; font-size: 14px;
  cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
  text-decoration: none;
  min-height: 44px;
  border: 0; background: none; width: 100%; text-align: left;
}
.admin-nav-link svg { flex-shrink: 0; color: currentColor; }
.admin-nav-link:hover { background: var(--surface-2); color: var(--text); }
.admin-nav-link.active {
  background: rgba(255,100,130,0.12);
  color: var(--accent-pink);
  font-weight: 700;
}

/* Admin main content */
.admin-main {
  flex: 1; overflow-y: auto;
  padding: 24px;
}
.admin-page-title {
  font-size: 20px; font-weight: 800; letter-spacing: -0.02em;
  margin: 0 0 20px;
}

/* KPI cards grid */
.admin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
@media (max-width: 1023px) {
  .admin-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 599px) {
  .admin-kpi-grid { grid-template-columns: 1fr; }
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}
.kpi-card .label {
  font-size: 12px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.7px;
  margin-bottom: 8px;
}
.kpi-card .value {
  font-size: 28px; font-weight: 900; letter-spacing: -0.02em;
  font-feature-settings: "tnum" 1;
}

/* Data tables */
.data-table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead {
  position: sticky; top: 0;
  background: var(--surface-2);
  z-index: 2;
}
.data-table th {
  padding: 12px 14px;
  text-align: left;
  font-size: 11px; font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.7px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 14px;
  font-size: 14px; font-weight: 500;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.data-table tr:last-child td { border-bottom: 0; }
/* Zebra striping */
.data-table tbody tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
:root[data-theme="light"] .data-table tbody tr:nth-child(even) td { background: rgba(0,0,0,0.02); }
/* Hover row */
.data-table tbody tr:hover td { background: var(--surface-2); }

/* Admin action buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: opacity .15s var(--ease), transform .15s var(--ease);
  border: 0;
}
.btn:active { transform: scale(0.97); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-primary {
  background: var(--accent-pink);
  color: #FFFFFF;
}
.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-danger {
  background: var(--accent-red);
  color: #FFFFFF;
}
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* Admin search row */
.admin-search-row {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 16px;
}
.admin-search-row input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px; color: var(--text);
}

/* Admin login card */
.admin-login-wrap {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.admin-login-card {
  width: 100%; max-width: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: var(--shadow-pop);
}
.admin-login-logo {
  text-align: center; margin-bottom: 24px;
  font-size: 20px; font-weight: 900; letter-spacing: -0.01em;
}
.admin-login-logo span { color: var(--accent-pink); }
.admin-login-title {
  font-size: 22px; font-weight: 800; text-align: center;
  margin-bottom: 6px; letter-spacing: -0.01em;
}
.admin-login-sub {
  text-align: center; color: var(--text-dim); font-size: 14px;
  margin-bottom: 24px;
}
.admin-login-form { display: flex; flex-direction: column; gap: 12px; }
.admin-login-form label { font-size: 12px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; }
.admin-login-form input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px; color: var(--text);
  margin-top: 4px;
}
.admin-login-foot {
  text-align: center; margin-top: 18px;
  font-size: 13px; color: var(--text-dim);
}
.admin-login-foot a { color: var(--accent-pink); font-weight: 600; }
.admin-err {
  color: var(--accent-red); font-size: 13px; font-weight: 600;
  min-height: 18px; text-align: center;
}

/* hCaptcha placeholder */
.hcaptcha-placeholder {
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  color: var(--text-dim); font-size: 13px;
}

/* =====================================================
   Error boundary
   ===================================================== */
.error-boundary {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  padding: 36px 20px;
  background: var(--bg);
  color: var(--text);
  overflow: auto;
}
.error-boundary h2 { margin: 0 0 12px; font-weight: 800; color: var(--accent-red); }
.error-boundary pre {
  white-space: pre-wrap; word-break: break-word;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: 12px;
  color: var(--text-dim);
}

/* =====================================================
   Responsive helpers
   ===================================================== */
@media (min-width: 1024px) {
  .hide-desktop { display: none !important; }
}
@media (max-width: 1023px) {
  .hide-mobile { display: none !important; }
}
