/* Kami — dark RPG-HUD theme. Original styling, system fonts only (no external requests). */
:root {
  --bg: #0a0f1a;
  --bg-2: #0d1424;
  --panel: #111a2e;
  --panel-2: #16223b;
  --line: #22314f;
  --text: #e6edf7;
  --muted: #93a3bd;      /* 6.9:1 on --panel */
  --accent: #38d6e8;     /* cyan/teal */
  --accent-dim: #1d7f8c;
  --accent-glow: rgba(56, 214, 232, .22);
  --amber: #f3b64a;
  --danger: #ff6b6b;
  --ok: #4fd98f;
  --radius: 14px;
  --nav-h: 64px;
  --side-w: 232px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(56,214,232,.08), transparent 60%), var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}
h1, h2, h3, p, ul, ol, dl { margin: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: #031418; padding: .6rem 1rem; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: .6rem; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(145deg, #12324a, #0c1c33); border: 1px solid var(--accent-dim);
  color: var(--accent); font: 700 1.05rem var(--mono); box-shadow: 0 0 14px var(--accent-glow);
}
.brand-name { font: 700 1rem var(--mono); letter-spacing: .28em; }
.brand-lg .brand-mark { width: 46px; height: 46px; font-size: 1.4rem; }
.brand-lg .brand-name { font-size: 1.2rem; }

/* ---------- Layout ---------- */
.sidebar { display: none; }
.shell { min-height: 100vh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 12px); }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .9rem;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: rgba(10,15,26,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand-sm .brand-name { display: none; }
.page-title { font-size: 1.15rem; font-weight: 650; }
.content { padding: 16px; max-width: 1080px; margin: 0 auto; display: grid; gap: 16px; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(13,20,36,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bn-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--nav-h); color: var(--muted); text-decoration: none; font-size: .72rem; letter-spacing: .02em;
}
.bn-link.is-active { color: var(--accent); }
.bn-link.is-active .ico { filter: drop-shadow(0 0 6px var(--accent-glow)); }

@media (min-width: 900px) {
  .bottomnav { display: none; }
  .brand-sm { display: none; }
  .shell { margin-left: var(--side-w); padding-bottom: 32px; }
  .topbar { padding: 18px 28px 12px; background: transparent; backdrop-filter: none; border: 0; position: static; }
  .page-title { font-size: 1.5rem; }
  .content { padding: 0 28px 28px; gap: 20px; }
  .sidebar {
    display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: var(--side-w);
    padding: 22px 14px; background: var(--bg-2); border-right: 1px solid var(--line); gap: 22px;
  }
  .sidebar nav { display: grid; gap: 4px; }
  .nav-link {
    display: flex; align-items: center; gap: .75rem; padding: .65rem .8rem; border-radius: 10px;
    color: var(--muted); text-decoration: none; border: 1px solid transparent;
  }
  .nav-link:hover { color: var(--text); background: var(--panel); }
  .nav-link.is-active { color: var(--accent); background: var(--panel); border-color: var(--line); box-shadow: inset 3px 0 0 var(--accent); }
  .sidebar-foot { margin-top: auto; display: grid; gap: .5rem; padding: 0 .4rem; }
  .who { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---------- Panels ---------- */
.panel {
  position: relative; background: linear-gradient(180deg, var(--panel), #0f1830);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
/* HUD corner ticks */
.panel::before, .panel::after {
  content: ""; position: absolute; width: 14px; height: 14px; pointer-events: none; opacity: .75;
  border: 2px solid var(--accent-dim);
}
.panel::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-top-left-radius: var(--radius); }
.panel::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-bottom-right-radius: var(--radius); }
.eyebrow { font: 600 .72rem var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--accent); margin-bottom: .5rem; }
.section-title { font-size: 1rem; font-weight: 650; margin-bottom: .8rem; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: 1fr; }
.stack { display: grid; gap: 14px; align-content: start; }
.grid.rings { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 900px) {
  .grid.two { grid-template-columns: 1.1fr .9fr; }
  .grid.rings { grid-template-columns: repeat(4, 1fr); }
}
.plain-list { margin: .8rem 0; padding-left: 1.2rem; display: grid; gap: .35rem; }

/* ---------- Hero ---------- */
.hero { display: grid; gap: 18px; box-shadow: 0 0 40px rgba(56,214,232,.06); }
.level-row { display: flex; align-items: center; gap: 16px; }
.level-badge {
  display: grid; place-items: center; width: 84px; height: 84px; flex: none; border-radius: 18px;
  background: radial-gradient(circle at 30% 20%, #17405a, #0b1a30); border: 1px solid var(--accent-dim);
  box-shadow: 0 0 22px var(--accent-glow), inset 0 0 14px rgba(56,214,232,.12);
}
.level-cap { font: 600 .7rem var(--mono); letter-spacing: .2em; color: var(--accent); margin-bottom: -6px; }
.level-num { font: 700 2.4rem/1 var(--mono); }
.level-info { flex: 1; min-width: 0; display: grid; gap: 6px; }
.xp-line { font-size: .95rem; }
.hero-side { display: flex; gap: 12px; }
.stat { flex: 1; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; }
.stat-num { font: 700 1.7rem/1.1 var(--mono); color: var(--accent); }
.stat-label { color: var(--muted); font-size: .8rem; }
@media (min-width: 900px) {
  .hero { grid-template-columns: 1fr auto; align-items: center; }
  .hero-side { min-width: 340px; }
}

progress.bar { -webkit-appearance: none; appearance: none; width: 100%; height: 12px; border: 0; border-radius: 99px; overflow: hidden; background: #0a1224; }
progress.bar::-webkit-progress-bar { background: #0a1224; border-radius: 99px; border: 1px solid var(--line); }
progress.bar::-webkit-progress-value { background: linear-gradient(90deg, var(--accent-dim), var(--accent)); border-radius: 99px; box-shadow: 0 0 10px var(--accent-glow); }
progress.bar::-moz-progress-bar { background: linear-gradient(90deg, var(--accent-dim), var(--accent)); border-radius: 99px; }

/* ---------- Rings ---------- */
.ring-card { padding: 14px 10px; }
.ring { position: relative; display: grid; justify-items: center; text-align: center; gap: 2px; }
.ring svg { width: 112px; height: 112px; }
.ring-track { stroke: #1b2a47; }
.ring-value { stroke: var(--accent); filter: drop-shadow(0 0 4px var(--accent-glow)); }
.ring-over .ring-value { stroke: var(--amber); }
.ring-empty .ring-track { stroke-dasharray: 3 7; }
.ring-text { position: absolute; top: 40px; left: 0; right: 0; font: 600 .95rem var(--mono); }
.ring-label { margin-top: 2px; font-weight: 600; font-size: .9rem; }
.ring-sub { color: var(--muted); font-size: .76rem; }
.ring-note { color: var(--amber); font-size: .72rem; }

/* ---------- Radar ---------- */
.radar { margin: 0; display: grid; justify-items: center; gap: 6px; }
.radar svg { width: 100%; max-width: 340px; height: auto; }
.radar-grid { stroke: var(--line); stroke-width: 1; }
.radar-axis { stroke: var(--line); stroke-width: 1; }
.radar-shape { fill: rgba(56,214,232,.22); stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.radar-dot { fill: var(--accent); }
.radar-label { fill: var(--muted); font-size: 12px; }
.legend { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 4px; font-size: .88rem; }
.legend li { display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding-top: 4px; }

/* ---------- Week strip / feed ---------- */
.week { list-style: none; padding: 0; margin: 0 0 .6rem; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.week .wd { display: block; font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.week .dot {
  display: grid; place-items: center; margin: 4px auto 0; width: 34px; height: 34px; border-radius: 50%;
  border: 1px dashed var(--line); color: var(--muted); font: .8rem var(--mono);
}
.week .is-on .dot { background: var(--accent); border: 1px solid var(--accent); color: #031418; font-weight: 700; box-shadow: 0 0 10px var(--accent-glow); }
.week .is-today .dot { outline: 2px solid var(--accent-dim); outline-offset: 2px; }
.feed { list-style: none; padding: 0; display: grid; gap: 2px; }
.feed li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.feed li:first-child { border-top: 0; }
.feed-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font: 600 .68rem var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); border: 1px solid var(--accent-dim); border-radius: 6px; padding: 2px 6px; }
.empty h2 { margin-bottom: .4rem; }

/* ---------- Forms / buttons / alerts ---------- */
.form { display: grid; gap: 14px; }
.form-narrow { max-width: 420px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: .85rem; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; font: inherit; color: var(--text);
  background: #0a1224; border: 1px solid var(--line); border-radius: 10px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 46px; padding: 0 18px;
  font: 600 .95rem inherit; font-family: inherit; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--accent-dim); }
.btn-primary { background: linear-gradient(180deg, #2fc3d5, #1c93a3); color: #031418; border-color: var(--accent); box-shadow: 0 0 16px var(--accent-glow); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 40px; padding: 0 12px; font-size: .85rem; }
.btn-block { width: 100%; }
.alert { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
.alert-error { border-color: var(--danger); color: #ffd5d5; background: rgba(255,107,107,.1); }
.alert-success { border-color: var(--ok); color: #d6ffe9; background: rgba(79,217,143,.1); }

.kv { display: grid; gap: 8px; }
.kv div { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.kv div:first-child { border-top: 0; padding-top: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; text-align: right; }
.menu { list-style: none; padding: 0; margin: 0 0 16px; display: grid; }
.menu a { display: grid; gap: 2px; padding: 14px 4px; min-height: 56px; border-top: 1px solid var(--line); color: var(--text); text-decoration: none; }
.menu li:first-child a { border-top: 0; }

/* ---------- Guest ---------- */
.guest-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-panel { width: 100%; max-width: 400px; display: grid; gap: 14px; padding: 26px 22px; box-shadow: 0 0 60px rgba(56,214,232,.08); }
.auth-title { font-size: 1.5rem; }

@media (prefers-reduced-motion: no-preference) {
  .ring-value { transition: stroke-dasharray .6s ease; }
  progress.bar::-webkit-progress-value { transition: width .6s ease; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ─────────────────────────────────────────────────────────
   Preferences form components  (added Milestone 2-A)
───────────────────────────────────────────────────────── */

/* Fieldset groups inside the preferences panel */
.pref-group {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px 20px;
  margin: 0;
}
.pref-group + .pref-group { margin-top: 14px; }
.pref-legend {
  padding: 0 6px;
  font: 600 .72rem var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
}

/* Responsive column grids for preference fields */
.pref-cols-2,
.pref-cols-3 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 560px) {
  .pref-cols-2 { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 680px) {
  .pref-cols-3 { grid-template-columns: repeat(3, 1fr); }
}

/* Input + unit badge side-by-side */
.input-addon { display: flex; align-items: stretch; }
.input-addon input[type=number] {
  flex: 1;
  min-width: 0;
  width: auto;          /* override the 100% from the general rule */
  border-radius: 10px 0 0 10px;
  border-right: 0;
}
.input-addon input[type=number]:focus-visible {
  border-radius: 10px 0 0 10px;
  border-right: 0;
}
.addon-unit {
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 10px 10px 0;
  color: var(--muted);
  font-size: .82rem;
  white-space: nowrap;
  user-select: none;
}

/* Accessible label span inside a <label> or pointed to by for= */
.field-label { font-size: .85rem; color: var(--muted); }

/* Small helper text below a field */
.field-hint {
  font-size: .76rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Narrow single-column fields (calorie, sleep) capped so they don't stretch full width */
.pref-field-narrow { max-width: 260px; }

/* Macro targets row — extra top gap from the calorie field above it */
.pref-macros-grid { margin-top: 14px; }

/* Spacing utility for nested details/panels inside a module section */
.details-gap { margin-top: 14px; }

/* ── Milestone 2 components ──────────────────────────────────────────────── */

/* Data tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th {
  color: var(--muted); font: 600 .72rem var(--mono); text-transform: uppercase;
  letter-spacing: .06em; padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left;
}
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .mono { font-family: var(--mono); }

/* Section sub-labels */
.section-label {
  font: 600 .72rem var(--mono); letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin: 12px 0 6px;
}

/* Day summary strip */
.day-summary { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.day-stat {
  display: grid; gap: 1px; text-align: center; min-width: 64px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
  text-decoration: none; color: var(--text);
}
.day-stat:hover { border-color: var(--accent-dim); }
.day-stat-num { font: 700 1.05rem var(--mono); color: var(--accent); }
.day-stat-label { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* Habit & care list */
.habit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.habit-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 10px;
  transition: border-color .15s;
}
.habit-row.habit-done { border-color: rgba(79,217,143,.25); background: rgba(79,217,143,.04); }
.habit-name { flex: 1; min-width: 0; font-weight: 600; word-break: break-word; }
.habit-count { font-family: var(--mono); font-size: .78rem; }
.habit-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Care routine time label */
.care-time-label {
  font: 600 .7rem var(--mono); text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 10px 0 4px;
}

/* Module section accordion (details/summary) */
.module-section {
  border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 10px; background: var(--panel);
}
.module-section > summary {
  padding: 14px 18px; cursor: pointer; font-weight: 650; display: flex;
  align-items: center; gap: 8px; list-style: none;
  user-select: none; border-radius: var(--radius);
}
.module-section > summary::-webkit-details-marker { display: none; }
.module-section > summary::after {
  content: '▸'; margin-left: auto; color: var(--muted);
  transition: transform .2s;
}
.module-section[open] > summary::after { transform: rotate(90deg); }
.module-section > .details-body { padding: 0 18px 18px; }
/* Nested module-section inside details-body */
.details-body .module-section { background: var(--bg-2); }

/* Macro progress grid */
.macro-row { display: grid; gap: 10px; }
.macro-item { display: grid; gap: 4px; }
.macro-label { display: flex; justify-content: space-between; font-size: .82rem; }
.bar-sm { height: 5px !important; }

/* Status badges */
.badge {
  display: inline-block; font: 600 .65rem var(--mono); letter-spacing: .06em;
  padding: 2px 8px; border-radius: 6px; border: 1px solid; text-transform: uppercase;
}
.badge-reading  { color: var(--accent); border-color: var(--accent-dim); }
.badge-finished { color: var(--ok);     border-color: #2a6b47; }
.badge-planned  { color: var(--muted);  border-color: var(--line); }
.badge-paused   { color: var(--amber);  border-color: #7a5a1e; }

/* Meal type chips */
.chip { font-size: .7rem; padding: 2px 7px; border-radius: 4px; font-weight: 600; white-space: nowrap; }
.chip-breakfast { background: rgba(243,182,74,.14);  color: var(--amber); }
.chip-lunch     { background: rgba(56,214,232,.14);  color: var(--accent); }
.chip-dinner    { background: rgba(79,217,143,.14);  color: var(--ok); }
.chip-snack     { background: rgba(147,163,189,.14); color: var(--muted); }

/* Tag variants */
.tag-warn { background: rgba(243,182,74,.12); color: var(--amber); border-color: #7a5a1e; }

/* Action row (horizontal button cluster) */
.action-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.action-col  { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; flex-shrink: 0; }

/* Done / OK state button */
.btn-ok { background: rgba(79,217,143,.15); color: var(--ok); border-color: #2a6b47; }
.btn-ok:hover { background: rgba(79,217,143,.25); }

/* Danger ghost button */
.btn-danger { color: var(--danger) !important; border-color: rgba(255,107,107,.3) !important; }
.btn-danger:hover { background: rgba(255,107,107,.1) !important; }

/* Unconfirmed nutrition entry */
.unconfirmed-row { opacity: .6; }

/* Workout header card */
.workout-header { margin-bottom: 10px; }
.workout-header h2 { font-size: 1.3rem; margin: 4px 0 8px; }

/* Workout set groups */
.set-group { margin-bottom: 16px; }
.set-group-name { font-weight: 650; color: var(--accent); font-size: .9rem; margin-bottom: 6px; }

/* Book shelf rows */
.book-row {
  display: flex; gap: 10px; justify-content: space-between; align-items: flex-start;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.book-row:first-of-type { border-top: 0; padding-top: 0; }
.book-title  { font-weight: 600; }
.book-author { color: var(--muted); font-size: .85rem; }

/* Status form inline layout */
.status-form { display: flex; gap: 4px; align-items: center; }
.status-form select { font-size: .8rem; padding: 4px 6px; }

/* Inline form (e.g. delete button next to a list item) */
.inline-form { display: inline; }

/* Feed list: extra items inline */
.feed li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.feed .inline-form { margin-left: auto; }

/* Ring card as link — remove default link decoration */
.ring-link {
  display: block; text-decoration: none; color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.ring-link:hover { border-color: var(--accent-dim); box-shadow: 0 0 0 1px var(--accent-dim); }

/* Stat in hero used as link */
.hero-side .stat { text-decoration: none; color: inherit; }
.hero-side a.stat:hover .stat-num { color: var(--accent); }

/* Compact "stack" inside grid two */
.stack { display: grid; gap: 10px; align-content: start; }

/* ── Responsive overrides ─────────────────────────────────────────────────── */
@media (max-width: 560px) {
  .pref-cols-2, .pref-cols-3 { grid-template-columns: 1fr; }
  .day-summary { gap: 6px; }
  .habit-row { gap: 6px; }
  .book-row { flex-direction: column; }
  .action-col { align-items: flex-start; }
  .data-table { font-size: .82rem; }
  .data-table td, .data-table th { padding: 7px 6px; }
}

/* ── Milestone 3 — Quests & XP ───────────────────────────────────────────── */

/* Level-up banner */
.level-up-banner {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, rgba(56,214,232,.12), rgba(79,217,143,.1));
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius); padding: 14px 20px; margin-bottom: 14px;
  animation: lvlup-in .4s ease;
}
.level-up-icon { font-size: 1.6rem; flex-shrink: 0; }
@keyframes lvlup-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Quest grid layout */
.quest-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* Quest card */
.quest-card { display: flex; flex-direction: column; gap: 8px; }
.quest-card.quest-done { opacity: .6; }
.quest-header { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.quest-cat    { flex: 1; }
.quest-xp     { font: 700 .78rem var(--mono); color: var(--accent); margin-left: auto; white-space: nowrap; }
.quest-title  { font-size: 1rem; font-weight: 650; margin: 2px 0; }
.quest-desc   { font-size: .85rem; margin: 0; }

/* Progress bar — width set by inline data-pct via small JS, or falls back to 0 */
.quest-progress { display: grid; gap: 4px; }
.quest-progress-bar {
  height: 6px; background: var(--bg-2); border-radius: 3px; overflow: hidden;
}
.quest-progress-fill {
  height: 100%; width: 0; background: var(--accent);
  border-radius: 3px; transition: width .4s ease;
}
.quest-progress-label { font-size: .75rem; }
.quest-complete-label { font-size: .78rem; color: var(--ok); font-weight: 600; }

/* Quest actions row */
.quest-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.quest-locked  { opacity: .45; cursor: default; pointer-events: none; }

/* XP rules table */
.rules-grid { display: grid; gap: 6px; }
.rules-row  { display: flex; align-items: center; gap: 8px; }
.rules-label { flex: 1; font-size: .88rem; }
.rules-input { width: 70px; text-align: right; font-family: var(--mono); }

/* Dashboard quest preview list */
.dash-quests { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dash-quest  {
  display: grid; gap: 4px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2);
}
.dash-quest.quest-done { opacity: .55; }
.dash-quest-info { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.dash-quest-title { font-weight: 600; font-size: .9rem; }
.dash-quest-meta  { font-size: .75rem; }

/* Section title link */
.section-link { font: 400 .8rem var(--font); color: var(--accent); margin-left: 8px; }
.section-link:hover { text-decoration: underline; }

/* Progress bar fill animation — driven by data-pct attribute via JS in app.js */
/* Fallback: bars are visible at 0% until JS runs */

/* ── Milestone 4 — Visual Progression System ─────────────────────────────── */

/* Notification stack (level-up + achievement banners) */
.notif-stack { display: grid; gap: 8px; margin-bottom: 14px; }
.notif-item {
  display: flex; align-items: center; gap: 14px;
  border-radius: var(--radius); padding: 14px 18px;
  animation: notif-in .45s cubic-bezier(.22,.8,.42,1) both;
}
@keyframes notif-in {
  from { opacity: 0; transform: translateY(-10px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.level-up-banner {
  background: linear-gradient(120deg, rgba(56,214,232,.14), rgba(79,217,143,.09));
  border: 1px solid var(--accent-dim);
}
.level-up-icon { font-size: 1.7rem; flex-shrink: 0; }
.ach-unlock-banner {
  background: linear-gradient(120deg, rgba(243,182,74,.12), rgba(56,214,232,.07));
  border: 1px solid rgba(243,182,74,.4);
}
.ach-icon-lg { font-size: 1.7rem; flex-shrink: 0; }

/* Status panel */
.status-panel { padding: 20px 24px; }
.status-top { display: flex; align-items: flex-start; gap: 22px; }

/* Level ring */
.status-lv-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; flex-shrink: 0; }
.status-lv-ring {
  position: relative; width: 90px; height: 90px;
  filter: drop-shadow(0 0 12px var(--accent-glow));
}
.lv-ring-svg { width: 100%; height: 100%; }
.lv-ring-arc { stroke: var(--accent); }
.lv-ring-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1;
}
.lv-ring-inner .level-cap { font: 600 .68rem var(--mono); color: var(--muted); letter-spacing: .08em; }
.lv-ring-inner .level-num { font: 800 1.7rem var(--mono); color: var(--accent); }

/* XP block */
.status-xp-block { flex: 1; min-width: 0; }
.status-name { font: 700 .7rem var(--mono); letter-spacing: .14em; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; }
.xp-numbers { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.xp-current { font: 700 1.25rem var(--mono); color: var(--accent); }
.xp-bar-wrap {
  height: 7px; background: var(--bg-2); border-radius: 4px; overflow: hidden; margin-bottom: 12px;
  border: 1px solid var(--line);
}
.xp-bar-fill {
  height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 4px; transition: width .6s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* Status stats row */
.status-stats-row { display: flex; flex-wrap: wrap; gap: 16px 24px; }
.status-stat { display: flex; flex-direction: column; text-decoration: none; }
.status-stat .stat-num { font: 700 1.05rem var(--mono); color: var(--text); }
.status-stat .stat-label { font-size: .72rem; color: var(--muted); }
.status-stat:hover .stat-num { color: var(--accent); }

/* Achievements grid */
.section-label {
  font: 600 .72rem var(--mono); letter-spacing: .1em; color: var(--muted);
  text-transform: uppercase; margin: 14px 0 8px;
}
.ach-category { margin-bottom: 8px; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }

.ach-badge {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); transition: border-color .2s, box-shadow .2s;
}
.ach-badge.ach-unlocked { background: var(--panel-2); }
.ach-badge.ach-locked   { background: var(--bg-2); opacity: .45; }
.ach-icon { font-size: 1.5rem; flex-shrink: 0; line-height: 1; }
.ach-info { min-width: 0; }
.ach-title { font: 600 .88rem/1.2 system-ui; }
.ach-desc  { margin-top: 2px; }
.ach-date  { margin-top: 2px; }

/* Tier colours (border + glow on unlocked) */
.ach-bronze.ach-unlocked  { border-color: #cd7f32; box-shadow: 0 0 10px rgba(205,127,50,.18); }
.ach-silver.ach-unlocked  { border-color: #9da8b8; box-shadow: 0 0 10px rgba(157,168,184,.18); }
.ach-gold.ach-unlocked    { border-color: #f3b64a; box-shadow: 0 0 12px rgba(243,182,74,.22); }
.ach-legendary.ach-unlocked {
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow), 0 0 32px rgba(56,214,232,.1);
  background: linear-gradient(135deg, #12243a, var(--panel-2));
}
/* Newly unlocked: pulse to draw attention */
.ach-new.ach-unlocked { animation: ach-pulse .6s ease 2; }
@keyframes ach-pulse {
  0%,100% { box-shadow: 0 0 0 0 transparent; }
  50%      { box-shadow: 0 0 20px 4px var(--accent-glow); }
}

/* Achievement count pill next to section title */
.ach-count-pill {
  display: inline-block; font: 600 .72rem var(--mono); color: var(--muted);
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 20px; padding: 1px 8px; margin-left: 8px; vertical-align: middle;
}

/* XP bar fill in status panel — set by JS */
/* (re-uses the .quest-progress-fill JS; .xp-bar-fill has its own data-pct attribute) */

/* Reduced-motion: remove all animations, keep opacity/colour changes */
@media (prefers-reduced-motion: reduce) {
  .notif-item, .ach-new.ach-unlocked, .xp-bar-fill, .quest-progress-fill {
    animation: none !important; transition: none !important;
  }
  .xp-bar-fill, .quest-progress-fill { width: attr(data-pct); }
}

/* Mobile adjustments */
@media (max-width: 540px) {
  .status-top { flex-direction: column; align-items: center; }
  .status-xp-block { width: 100%; }
  .ach-grid { grid-template-columns: 1fr; }
  .status-stats-row { gap: 12px 18px; }
}

/* ── Milestone 5 — Analytics ────────────────────────────────────────────── */

/* Range bar */
.an-range-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px;
}
.an-range-btns { display: flex; gap: 4px; }
.an-range-label { margin-left: auto; }

/* Summary stats row */
.an-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.an-stat {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 14px 10px; text-align: center; gap: 4px;
}
.an-stat-num { font: 700 1.4rem/1 var(--mono); color: var(--accent); }
.an-stat-label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* Streak panel */
.an-streak-row { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.an-streak-stat { display: flex; flex-direction: column; align-items: center; }
.an-streak-num  { font: 800 2.4rem/1 var(--mono); color: var(--accent); }
.an-streak-best { color: var(--amber); filter: drop-shadow(0 0 8px rgba(243,182,74,.4)); }
.an-streak-sep  { font: 600 .7rem var(--mono); color: var(--muted); letter-spacing: .1em; }

/* Activity heatmap strip */
.an-heatmap {
  display: flex; flex-wrap: wrap; gap: 3px; margin: 10px 0 4px;
}
.an-heat-cell {
  width: 14px; height: 14px; border-radius: 3px;
  background: var(--bg-2); border: 1px solid var(--line);
  transition: background .15s;
}
.an-heat-on    { background: var(--accent); border-color: var(--accent-dim); box-shadow: 0 0 4px var(--accent-glow); }
.an-heat-today { outline: 2px solid var(--accent-dim); outline-offset: 2px; }
.an-heatmap-legend { display: flex; gap: 12px; margin-top: 2px; }

/* Calendar grid */
.an-cal-head  { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-bottom: 4px; text-align: center; }
.an-cal-dow   { font: 600 .65rem var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.an-cal-grid  { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.an-cal-cell  {
  aspect-ratio: 1; border-radius: 6px; border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-2);
}
.an-cal-num   { font: .7rem var(--mono); color: var(--muted); }
.an-cal-on    { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 6px var(--accent-glow); }
.an-cal-on .an-cal-num { color: #031418; font-weight: 700; }
.an-cal-today { outline: 2px solid var(--accent-dim); outline-offset: 1px; }
.an-cal-empty { background: transparent; border-color: transparent; }

/* Hunter attribute bars */
.an-attrs { display: grid; gap: 10px; }
.an-attr-header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.an-attr-icon   { font-size: 1rem; flex-shrink: 0; }
.an-attr-label  { font: 600 .88rem system-ui; flex: 1; }
.an-attr-raw    { font-size: .72rem; }
.an-attr-score  { font: 700 .9rem var(--mono); color: var(--accent); min-width: 28px; text-align: right; }
.an-attr-bar-wrap {
  height: 6px; background: var(--bg-2); border-radius: 3px; overflow: hidden;
  border: 1px solid var(--line);
}
.an-attr-bar {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 3px; transition: width .5s cubic-bezier(.4,0,.2,1);
}
.an-attr-nodata { background: var(--line); }

/* Charts grid */
.an-charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.an-chart-card { display: flex; flex-direction: column; gap: 8px; }
.an-chart-foot { margin-top: 4px; }

/* SVG sparkline */
.an-spark-wrap { position: relative; }
.an-spark-rel  { position: relative; }
.spark-svg     { width: 100%; height: 50px; display: block; overflow: visible; }
.spark-line    { stroke: var(--accent); stroke-width: 2; fill: none; }
.spark-weight  { stroke: var(--amber); }
.spark-sleep   { stroke: var(--ok); }
.spark-nut     { stroke: #e07cf7; }
.an-spark-legend { margin-top: 4px; }

/* Sparkline target reference overlay */
.spark-target-svg   { position: absolute; inset: 0; width: 100%; height: 50px; pointer-events: none; }
.spark-target-label { display: block; font-size: .68rem; color: var(--amber); margin-top: 2px; }

/* Bar chart SVG */
.an-bar-chart-wrap { overflow: hidden; }
.bar-svg  { width: 100%; height: 50px; display: block; }
.bar-rect { fill: var(--accent); opacity: .75; transition: opacity .15s; }
.bar-rect:hover { opacity: 1; }

/* Workout type badges */
.an-type-badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.badge-type { color: var(--accent); border-color: var(--accent-dim); font: 600 .65rem var(--mono); }

/* Empty state */
.an-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 40px 24px; text-align: center; }
.an-empty-icon { font-size: 2.5rem; }

/* Reduced-motion: disable bar fill transition */
@media (prefers-reduced-motion: reduce) {
  .an-attr-bar, .bar-rect, .spark-line { transition: none !important; animation: none !important; }
}

/* Mobile */
@media (max-width: 560px) {
  .an-stats-row { grid-template-columns: repeat(3, 1fr); }
  .an-charts-grid { grid-template-columns: 1fr; }
  .an-heat-cell { width: 10px; height: 10px; }
}
