/* XPward v2 — Workshop Blueprint + collapsible sidebar + themes + density */

/* ── Theme tokens (dark = default) ─────────────────────────────────────── */
:root {
  --bg:        #0a0a0b;
  --surface:   #0f0f11;
  --surface-2: #141417;
  --surface-3: #1a1a1e;
  --line:      #26262b;
  --line-soft: #1b1b1f;
  --text:      #ececee;
  --text-dim:  #8a8a92;
  --text-faint:#5a5a62;

  /* accent — amber default, overridden per user setting */
  --accent:     #e8853a;
  --accent-dim: #b9682c;
  --accent-fg:  #17110a;

  --career:  #e8853a;
  --money:   #6ee7a0;
  --health:  #ff6b6b;
  --skills:  #5ab0ff;
  --social:  #c58bff;

  --radius: 4px;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body:    "Inter", system-ui, sans-serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, monospace;

  /* density — comfortable default */
  --sp-xs: 6px;
  --sp-s:  10px;
  --sp-m:  16px;
  --sp-l:  22px;
  --sp-xl: 28px;
  --panel-pad: 20px;
  --font-size-base: 15px;
  --font-size-sm:   13px;
  --font-size-xs:   11px;
  --font-size-xxs:  10px;

  /* sidebar */
  --sb-w:          240px;
  --sb-w-collapsed: 62px;
}

/* ── Theme overrides ─────────────────────────────────────────────────────── */
[data-theme="deep-dark"] {
  --bg:        #000000;
  --surface:   #080808;
  --surface-2: #0d0d0d;
  --surface-3: #111111;
  --line:      #1e1e1e;
  --line-soft: #161616;
}
[data-theme="light"] {
  --bg:        #f0f0f2;
  --surface:   #ffffff;
  --surface-2: #f5f5f7;
  --surface-3: #ebebed;
  --line:      #d8d8de;
  --line-soft: #e4e4e8;
  --text:      #111113;
  --text-dim:  #52525a;
  --text-faint:#8a8a96;
  --accent-fg: #ffffff;
}
[data-theme="light"] body::before { opacity: 0.18; }

/* ── Accent overrides ────────────────────────────────────────────────────── */
[data-accent="amber"] { --accent:#e8853a; --accent-dim:#b9682c; --accent-fg:#17110a; }
[data-accent="blue"]  { --accent:#5ab0ff; --accent-dim:#2e7ec7; --accent-fg:#050c18; }
[data-accent="green"] { --accent:#6ee7a0; --accent-dim:#3dbb72; --accent-fg:#041209; }
[data-accent="purple"]{ --accent:#c58bff; --accent-dim:#9955e8; --accent-fg:#0e0519; }
[data-accent="red"]   { --accent:#ff6b6b; --accent-dim:#d43a3a; --accent-fg:#1a0303; }

/* ── Density: compact ────────────────────────────────────────────────────── */
[data-density="compact"] {
  --sp-xs: 4px;
  --sp-s:  7px;
  --sp-m:  11px;
  --sp-l:  16px;
  --sp-xl: 20px;
  --panel-pad: 14px;
  --font-size-base: 13px;
  --font-size-sm:   12px;
  --font-size-xs:   10px;
  --font-size-xxs:  9px;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
}

body::before {
  content: "";
  position: fixed; inset: 0;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 44px 44px;
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sb-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  z-index: 20;
  transition: transform 220ms cubic-bezier(.22,1,.36,1);
  overflow: hidden;
}
.sidebar.collapsed { transform: translateX(-100%); }

/* Claude-style toggle tab */
.sb-toggle {
  /* When sidebar is expanded: sits inside sidebar, top-right of profile row */
  position: fixed;
  left: calc(var(--sb-w) - 44px);
  top: 12px;
  width: 32px; height: 32px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
  transition: left 220ms cubic-bezier(.22,1,.36,1), color 150ms, background 150ms;
  z-index: 25; flex-shrink: 0;
}
.sb-toggle:hover { color: var(--text); background: var(--surface-2); }
.sb-toggle::after { display: none; }
/* When collapsed: moves to just outside the hidden sidebar (top-left of content) */
body.sb-collapsed .sb-toggle { left: 12px; }

/* profile block */
.sb-profile {
  padding: var(--sp-m) 48px var(--sp-s) var(--sp-m);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: var(--sp-s);
  flex-shrink: 0; overflow: hidden;
}
.sb-avatar-wrap { position: relative; flex-shrink: 0; cursor: pointer; }
.sb-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface-3); border: 2px solid var(--line);
  object-fit: cover; display: block;
  transition: border-color 150ms;
}
.sb-avatar-wrap:hover .sb-avatar { border-color: var(--accent); }
.sb-avatar-overlay {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: #fff; opacity: 0;
  transition: opacity 150ms; pointer-events: none;
  font-family: var(--font-mono); letter-spacing: 0.05em;
}
.sb-avatar-wrap:hover .sb-avatar-overlay { opacity: 1; }
.sb-avatar-input { display: none; }
/* Avatar placeholder when no image */
.sb-avatar[src=""], .sb-avatar:not([src]),
.mh-avatar[src=""], .mh-avatar:not([src]) {
  background: var(--accent); 
  color: var(--bg); font-weight: 700;
}


.sb-profile-info { flex: 1; min-width: 0; overflow: hidden; }
.sb-name {
  font-family: var(--font-display); font-weight: 600;
  font-size: var(--font-size-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-email { display: none; }
.sb-lv {
  font-family: var(--font-mono); font-size: var(--font-size-xxs); color: var(--accent); margin-top: 3px;
  letter-spacing: 0.1em;
}

/* nav */
.sb-nav { flex: 1; overflow-y: auto; padding: var(--sp-s) 0; }
.sb-nav::-webkit-scrollbar { display: none; }
.sb-item {
  display: flex; align-items: center; gap: var(--sp-m);
  padding: var(--sp-s) var(--sp-m);
  cursor: pointer; border-radius: 0;
  color: var(--text-dim);
  font-size: var(--font-size-sm); font-family: var(--font-display); font-weight: 500;
  white-space: nowrap; overflow: hidden;
  transition: background 120ms, color 120ms;
  border-left: 2px solid transparent;
  text-decoration: none;
}
.sb-item:hover { background: var(--surface-2); color: var(--text); }
.sb-item.active { color: var(--accent); border-left-color: var(--accent); background: var(--surface-2); }
.sb-item .si-icon { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }
.sb-item .si-label { transition: opacity 150ms; }
.sidebar.collapsed .si-label { opacity: 0; pointer-events: none; }

.sb-section-label {
  font-family: var(--font-mono); font-size: var(--font-size-xxs); letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-faint);
  padding: var(--sp-m) var(--sp-m) var(--sp-xs);
  white-space: nowrap; overflow: hidden;
  transition: opacity 150ms;
}
.sidebar.collapsed .sb-section-label { opacity: 0; }

/* bottom */
.sb-foot {
  padding: var(--sp-s) 0;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

/* ── Main layout ─────────────────────────────────────────────────────────── */
.main-area {
  flex: 1;
  margin-left: var(--sb-w);
  transition: margin-left 220ms cubic-bezier(.22,1,.36,1);
  position: relative; z-index: 1;
  min-height: 100vh;
}
/* toggle button space when sidebar visible */
.wrap { padding-top: 56px; }
body.sb-collapsed .main-area { margin-left: 0; }

.wrap { max-width: 1080px; margin: 0 auto; padding: var(--sp-xl) var(--sp-l) 96px; }

/* ── Brand assets ────────────────────────────────────────────────────────── */
.brand-logo {
  display: block; flex: 0 0 auto; aspect-ratio: 1; object-fit: contain;
  background: #ffffff; border-radius: 7px;
  box-shadow: 0 0 0 1px rgba(5,16,147,0.14);
}
.auth-brand-logo { width: 38px; height: 38px; }
.masthead-brand-logo { width: 40px; height: 40px; border-radius: 9px; }
.sb-brand-logo, .mh-brand-logo { width: 30px; height: 30px; }

/* ── Auth gate ───────────────────────────────────────────────────────────── */
#authGate {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
#authGate::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 44px 44px; opacity: 0.35;
}
.auth-card {
  position: relative; z-index: 1;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 36px 32px;
  width: min(94vw, 400px);
  animation: popIn 320ms cubic-bezier(.22,1.2,.36,1);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.auth-brand h1 { font-family: var(--font-display); font-size: 22px; font-weight: 600; }
.auth-tabs { display: flex; gap: 0; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.auth-tab {
  flex: 1; padding: var(--sp-s); text-align: center;
  font-family: var(--font-display); font-size: var(--font-size-sm); font-weight: 500;
  color: var(--text-dim); cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color 150ms, border-color 150ms;
}
.auth-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.auth-err {
  background: rgba(255,107,107,0.08); border: 1px solid rgba(255,107,107,0.3);
  color: var(--health); border-radius: var(--radius);
  padding: 10px 12px; font-size: var(--font-size-sm); margin-bottom: 14px; display: none;
}
.auth-err.show { display: block; }
.auth-note { font-size: var(--font-size-xs); color: var(--text-faint); margin-top: 14px; text-align: center; }

.auth-link-btn {
  appearance: none; background: none; border: 0; padding: 0;
  color: var(--text-faint); font: inherit; font-size: 12px; line-height: 1.5;
  cursor: pointer; text-decoration: none; transition: color 150ms;
}
.auth-link-btn:hover, .auth-link-btn:focus-visible { color: var(--text); }
.auth-link-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 2px; }

/* ── Header ─────────────────────────────────────────────────────────────── */
.masthead {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-m); flex-wrap: wrap;
  padding-bottom: var(--sp-m); margin-bottom: var(--sp-l);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-family: var(--font-display); font-weight: 600; font-size: 26px; letter-spacing: -0.02em; }
.brand .tag { font-family: var(--font-mono); font-size: var(--font-size-xxs); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-faint); }
.mode-pill {
  font-family: var(--font-mono); font-size: var(--font-size-xxs); letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-dim);
  border: 1px solid var(--line); border-radius: 100px;
  padding: 5px 11px; display: inline-flex; align-items: center; gap: 7px;
}
.mode-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); }
.mode-pill.ai .dot   { background: var(--money); box-shadow: 0 0 8px var(--money); }
.mode-pill.local .dot{ background: var(--accent); box-shadow: 0 0 8px var(--accent); }

/* ── Stat sheet ─────────────────────────────────────────────────────────── */
.statsheet {
  display: grid; grid-template-columns: auto 1fr; gap: var(--sp-xl);
  align-items: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--sp-l) calc(var(--sp-l) + 4px); margin-bottom: var(--sp-l);
}
.ring-wrap { position: relative; width: 128px; height: 128px; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--line); stroke-width: 8; }
.ring-fill {
  fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round;
  transition: stroke-dashoffset 900ms cubic-bezier(.22,1,.36,1);
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 60%, transparent));
}
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring-center .lvl-label { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-faint); }
.ring-center .lvl-num { font-family: var(--font-display); font-weight: 700; font-size: 42px; line-height: 1; }
.ring-wrap.pulse .ring-fill { animation: ringPulse 700ms ease; }
@keyframes ringPulse {
  50% { filter: drop-shadow(0 0 22px var(--accent)); stroke: color-mix(in srgb, var(--accent) 60%, white); }
}
.stat-side { display: flex; flex-direction: column; gap: var(--sp-s); }
.xp-line { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-m); }
.xp-total { font-family: var(--font-display); font-weight: 600; font-size: 22px; }
.xp-total span { color: var(--text-dim); font-weight: 400; font-size: var(--font-size-xs); font-family: var(--font-mono); }
.xp-next { font-family: var(--font-mono); font-size: var(--font-size-xs); color: var(--text-dim); }
.xp-bar { height: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 100px; overflow: hidden; }
.xp-bar-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 100px; transition: width 900ms cubic-bezier(.22,1,.36,1); }
.stat-chips { display: flex; gap: var(--sp-l); flex-wrap: wrap; }
.chip .k { font-family: var(--font-mono); font-size: var(--font-size-xxs); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); }
.chip .v { font-family: var(--font-display); font-weight: 600; font-size: 18px; }
.chip .v .flame { color: var(--accent); }

/* ── Sync pill ───────────────────────────────────────────────────────────── */
.sync-pill {
  font-family: var(--font-mono); font-size: var(--font-size-xxs); letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-faint);
  display: inline-flex; align-items: center; gap: 6px;
}
.sync-pill.saving { color: var(--accent); }
.sync-pill.error  { color: var(--health); }

/* ── Layout columns ─────────────────────────────────────────────────────── */
.cols { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: var(--sp-l); align-items: start; }
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--panel-pad);
}
.panel + .panel { margin-top: var(--sp-l); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-m); }
.panel-head h2 { font-family: var(--font-mono); font-size: var(--font-size-xxs); letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-dim); font-weight: 500; }
.panel-head .sub { font-family: var(--font-mono); font-size: var(--font-size-xxs); color: var(--text-faint); }

/* ── Composer ────────────────────────────────────────────────────────────── */
.composer textarea {
  width: 100%; min-height: 130px; resize: vertical;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--sp-s); font-family: var(--font-body); font-size: var(--font-size-base); line-height: 1.6;
}
.composer textarea:focus { outline: none; border-color: var(--accent-dim); }
.composer textarea::placeholder { color: var(--text-faint); }
.composer-foot { display: flex; align-items: center; justify-content: space-between; margin-top: var(--sp-s); gap: var(--sp-s); }
.composer-foot .count { font-family: var(--font-mono); font-size: var(--font-size-xs); color: var(--text-faint); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  font-family: var(--font-display); font-weight: 600; font-size: var(--font-size-sm);
  background: var(--accent); color: var(--accent-fg); border: none;
  border-radius: var(--radius); padding: 11px 20px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  transition: background 150ms ease, transform 80ms ease;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--line); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.danger { background: transparent; color: var(--health); border: 1px solid var(--line); }
.btn.danger:hover { background: rgba(255,107,107,0.08); border-color: var(--health); }
.btn.small { font-size: var(--font-size-xs); padding: 7px 12px; }
.btn.full { width: 100%; justify-content: center; }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(0,0,0,0.25); border-top-color: currentColor; border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Categories ─────────────────────────────────────────────────────────── */
.cat-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--sp-s); }
.cat-row:last-child { margin-bottom: 0; }
.cat-top { display: flex; align-items: center; justify-content: space-between; }
.cat-name { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-size: var(--font-size-sm); font-weight: 500; }
.cat-name .glyph { font-size: 13px; }
.cat-xp { font-family: var(--font-mono); font-size: var(--font-size-xs); color: var(--text-dim); }
.cat-bar { height: 6px; background: var(--surface-2); border-radius: 100px; overflow: hidden; }
.cat-bar-fill { height: 100%; width: 0%; border-radius: 100px; transition: width 800ms cubic-bezier(.22,1,.36,1); }

/* ── Quests ─────────────────────────────────────────────────────────────── */
.quest { display: flex; align-items: center; gap: var(--sp-s); padding: var(--sp-s) 0; border-bottom: 1px solid var(--line-soft); }
.quest:last-child { border-bottom: none; }
.quest .box { width: 20px; height: 20px; border: 1px solid var(--line); border-radius: 4px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; color: transparent; transition: all 200ms ease; }
.quest.done .box { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.quest .qtext { flex: 1; font-size: var(--font-size-sm); }
.quest.done .qtext { color: var(--text-dim); text-decoration: line-through; }
.quest .qxp { font-family: var(--font-mono); font-size: var(--font-size-xs); color: var(--accent); }
.quest .qprog { font-family: var(--font-mono); font-size: var(--font-size-xs); color: var(--text-faint); }

/* ── History ─────────────────────────────────────────────────────────────── */
.hist-item { display: grid; grid-template-columns: 3px 1fr auto; gap: var(--sp-s); padding: var(--sp-s) 0; border-bottom: 1px solid var(--line-soft); align-items: start; }
.hist-item:last-child { border-bottom: none; }
.hist-bar { width: 3px; border-radius: 2px; min-height: 34px; }
.hist-main .htitle { font-size: var(--font-size-sm); font-weight: 500; margin-bottom: 3px; }
.hist-main .hmeta { font-family: var(--font-mono); font-size: var(--font-size-xxs); color: var(--text-faint); letter-spacing: 0.04em; display: flex; gap: 10px; flex-wrap: wrap; }
.hist-main .hmeta .cat { color: var(--text-dim); }
.hist-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.hist-side .hxp { font-family: var(--font-mono); font-size: var(--font-size-xs); font-weight: 500; color: var(--accent); }
.hist-actions { display: flex; gap: 6px; }
.icon-btn { background: transparent; border: 1px solid var(--line); border-radius: 4px; color: var(--text-faint); cursor: pointer; font-size: var(--font-size-xxs); padding: 3px 7px; font-family: var(--font-mono); transition: all 120ms ease; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn.del:hover { color: var(--health); border-color: var(--health); }
.empty { text-align: center; padding: 30px 10px; color: var(--text-faint); font-size: var(--font-size-sm); }

/* ── Summaries ───────────────────────────────────────────────────────────── */
.sum-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: var(--sp-s); margin-bottom: var(--sp-m); }
.sum-cell { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: var(--sp-s) var(--sp-m); }
.sum-cell .k { font-family: var(--font-mono); font-size: var(--font-size-xxs); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-faint); }
.sum-cell .v { font-family: var(--font-display); font-weight: 600; font-size: 22px; margin-top: 3px; }
.week-chart { display: flex; align-items: flex-end; gap: 8px; height: 90px; margin-top: var(--sp-xs); }
.week-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.week-col .bar { width: 100%; max-width: 30px; background: var(--accent-dim); border-radius: 3px 3px 0 0; min-height: 2px; transition: height 700ms cubic-bezier(.22,1,.36,1); }
.week-col .bar.today { background: var(--accent); }
.week-col .lbl { font-family: var(--font-mono); font-size: 9px; color: var(--text-faint); }

/* ── Settings panel ─────────────────────────────────────────────────────── */
.settings-section { margin-bottom: var(--sp-l); }
.settings-section:last-child { margin-bottom: 0; }
.settings-section h3 { font-family: var(--font-mono); font-size: var(--font-size-xxs); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-faint); margin-bottom: var(--sp-s); }
.option-row { display: flex; gap: var(--sp-s); flex-wrap: wrap; }
.opt-btn {
  padding: var(--sp-xs) var(--sp-m); border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text-dim); cursor: pointer; font-family: var(--font-display);
  font-size: var(--font-size-sm); transition: all 140ms ease;
}
.opt-btn:hover { color: var(--text); border-color: var(--text-faint); }
.opt-btn.active { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface-2)); }
.accent-dot {
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: border-color 140ms, transform 140ms;
  flex-shrink: 0;
}
.accent-dot:hover { transform: scale(1.15); }
.accent-dot.active { border-color: var(--text); }

/* ── Toasts + level-up ───────────────────────────────────────────────────── */
.toast-stack { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 10px; align-items: center; width: min(92vw, 460px); }
.toast { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; width: 100%; font-size: var(--font-size-sm); display: flex; align-items: center; gap: 10px; animation: toastIn 300ms cubic-bezier(.22,1,.36,1); box-shadow: 0 8px 30px rgba(0,0,0,0.5); }
.toast .tglyph { color: var(--accent); font-family: var(--font-mono); }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.levelup-overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(6,6,7,0.72); backdrop-filter: blur(3px); animation: fadeIn 250ms ease; }
.levelup-card { text-align: center; padding: 40px 48px; border: 1px solid var(--accent-dim); border-radius: 8px; background: var(--surface); animation: popIn 500ms cubic-bezier(.22,1.4,.36,1); position: relative; overflow: hidden; }
.levelup-card .lu-label { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--accent); }
.levelup-card .lu-num { font-family: var(--font-display); font-weight: 700; font-size: 84px; line-height: 1; margin: 8px 0; }
.levelup-card .lu-sub { font-size: var(--font-size-sm); color: var(--text-dim); }
.spark { position: absolute; width: 5px; height: 5px; background: var(--accent); border-radius: 50%; pointer-events: none; }
.xp-fly { position: fixed; font-family: var(--font-mono); font-weight: 600; font-size: 15px; color: var(--accent); pointer-events: none; z-index: 55; animation: fly 1100ms cubic-bezier(.22,1,.36,1) forwards; }
@keyframes fly { 0% { opacity: 0; transform: translateY(0) scale(0.8); } 15% { opacity: 1; } 100% { opacity: 0; transform: translateY(-70px) scale(1.1); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn  { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-back { position: fixed; inset: 0; z-index: 70; background: rgba(6,6,7,0.7); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadeIn 180ms ease; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 24px; width: min(94vw, 440px); animation: popIn 260ms cubic-bezier(.22,1.2,.36,1); }
.modal h3 { font-family: var(--font-display); font-size: 18px; margin-bottom: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-family: var(--font-mono); font-size: var(--font-size-xxs); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 6px; }
.field input, .field select { width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); padding: 9px 11px; font-family: var(--font-body); font-size: var(--font-size-sm); }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent-dim); }
.field-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.footer { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer .note { font-family: var(--font-mono); font-size: var(--font-size-xxs); color: var(--text-faint); letter-spacing: 0.05em; }

/* ── Page sections (for sidebar nav) ────────────────────────────────────── */
.page-section { display: none; }
.page-section.active { display: block; }

/* ── Form helpers ────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--line); margin: var(--sp-m) 0; }
.label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-s); }


/* ── Eye toggle button ───────────────────────────────────────────────────── */
.eye-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--text-faint); display: flex; align-items: center;
  padding: 0; transition: color 150ms; z-index: 2;
}
.eye-btn:hover { color: var(--text); }
.field input[type="password"],
.field input[type="text"] { padding-right: 40px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .cols { grid-template-columns: 1fr; }
  .statsheet { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .stat-side { width: 100%; }
  .stat-chips { justify-content: center; }
}


/* ── Language selector grid ────────────────────────────────────────────── */
.lang-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
}
.lang-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--line);
  cursor: pointer; color: var(--text-dim);
  font-size: 13px; font-family: var(--font);
  transition: border-color 150ms, color 150ms;
}
.lang-btn:hover { border-color: var(--text-faint); color: var(--text); }
.lang-btn.active { border-color: var(--accent); color: var(--accent); background: var(--surface-3); }
.lang-btn .lang-flag { font-size: 16px; }

/* ── Mobile sidebar brand header ───────────────────────────────────────── */
.sb-brand-mobile {
  display: none; /* only on mobile via media query */
  align-items: center; gap: 8px;
  padding: 14px 16px 4px;
}
.sb-brand-title {
  font-family: var(--font-display); font-weight: 700;
  font-size: 18px; color: var(--text);
}
.sb-user-mobile {
  display: none; /* only on mobile */
  padding: 2px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.sb-user-name {
  font-family: var(--font-display); font-weight: 600;
  font-size: 14px; color: var(--text);
}
.sb-user-lv {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--accent); margin-top: 2px;
}

/* ── Mobile header bar ──────────────────────────────────────────────────── */
.mobile-header {
  display: none; /* shown only on mobile */
  position: fixed; top: 0; left: 0; right: 0;
  height: 52px; z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 14px;
  align-items: center; justify-content: space-between;
}
.mh-brand { display: flex; align-items: center; gap: 8px; }
.mh-title {
  font-family: var(--font-display); font-weight: 700;
  font-size: 18px; color: var(--text);
}
.mh-right { display: flex; align-items: center; gap: 10px; }
.mobile-sync { font-size: 11px; }
.mh-avatar-btn {
  width: 30px; height: 30px; border-radius: 50%;
  background: none; border: 2px solid var(--line); cursor: pointer;
  padding: 0; overflow: hidden;
  transition: border-color 150ms;
}
.mh-avatar-btn:hover { border-color: var(--accent); }
.mh-avatar {
  width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%;
}

/* ── Mobile bottom nav tabs ────────────────────────────────────────────── */
.mobile-nav {
  display: none; /* shown only on mobile */
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 56px; z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--line);
  align-items: center; justify-content: space-around;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.mn-tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-decoration: none; color: var(--text-faint);
  font-size: 10px; font-family: var(--font-mono);
  letter-spacing: 0.03em; padding: 6px 8px;
  transition: color 150ms;
  -webkit-tap-highlight-color: transparent;
}
.mn-tab svg { stroke: var(--text-faint); transition: stroke 150ms; }
.mn-tab.active { color: var(--accent); }
.mn-tab.active svg { stroke: var(--accent); }

.sb-backdrop { display: none; position: fixed; inset: 0; z-index: 19; background: rgba(0,0,0,0.5); }
.sb-backdrop.show { display: block; }

@media (max-width: 720px) {
  input, textarea, select { font-size: 16px !important; }
  .sidebar { transform: translateX(-100%); transition: transform 220ms cubic-bezier(.22,1,.36,1); top: 52px; bottom: 56px; border-radius: 0; }
  .sb-profile { display: none; }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-area { margin-left: 0 !important; }
  .sb-toggle { display: none; }
  
  /* Show mobile header + bottom nav + sidebar brand */
  .sb-brand-mobile { display: flex; }
  .sb-user-mobile { display: block; }
  .mobile-header { display: flex; }
  .mobile-nav { display: flex; }
  
  /* Push content below header and above bottom nav */
  .main-area { padding-top: 56px !important; padding-bottom: 68px !important; }
  .wrap { padding-top: 0; }
  
  /* Hide desktop masthead brand on mobile (shown in mobile header) */
  .masthead .brand { display: none; }
  
  /* Masthead becomes a slim bar with just sync + mode pills */
  .masthead {
    justify-content: flex-end; padding: var(--sp-s) 0;
    border-bottom: none; margin-bottom: var(--sp-s);
  }
}
@media (min-width: 721px) {
  .mobile-header { display: none !important; }
  .mobile-nav { display: none !important; }
}
@media (max-width: 480px) {
  .field-row { grid-template-columns: 1fr; }
  .brand h1 { font-size: 22px; }
  .auth-card { padding: 24px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* Language cards: system default + manual overrides */
.lang-btn-system { grid-column: 1 / -1; }
.lang-btn .lang-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  line-height: 1.2;
}
.lang-btn .lang-copy strong {
  color: inherit;
  font: inherit;
  font-weight: 600;
}
.lang-btn .lang-copy small {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .03em;
}
.lang-btn.active .lang-copy small { color: var(--accent); opacity: .8; }
