/*
 * VITAIL UI v2 — self-contained design layer for templates/v2/.
 * Loaded ONLY by v2/base.html; classic vitail.css is untouched and never
 * loaded together with this file. Same token names as classic so the theme
 * toggle and the NW brand keep working, but a fresh scale and component set.
 *
 * No external fonts or icon fonts: system font stack + inline SVG icons.
 */

/* ── Tokens ───────────────────────────────────────────────────────────── */

:root {
  color-scheme: dark;
  --bg: #0c0f15;
  --surface: #151a24;
  --surface2: #1b2130;
  --surface3: #222a3c;
  --border: #2a3344;
  --border-strong: #38445c;
  --text: #eaeef6;
  --muted: #8b95a8;
  --accent: #5b8cff;
  --accent-strong: #7da4ff;
  --accent-dim: #3d5a8f;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --ok: #3ecf8e;
  --ok-soft: rgba(62, 207, 142, 0.14);
  --warn: #e6a23c;
  --warn-soft: rgba(230, 162, 60, 0.14);
  --danger: #e5697a;
  --danger-soft: rgba(229, 105, 122, 0.12);
  --link: #9bb9ff;
  --btn-on-accent: #fff;
  --backdrop: rgba(4, 7, 12, 0.72);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-float: 0 12px 40px rgba(0, 0, 0, 0.45);
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pill: 999px;
  --tap: 2.75rem;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --tabbar-h: calc(3.9rem + env(safe-area-inset-bottom, 0px));
  --topbar-h: 3.4rem;
  /* Gradient identity ("swoosh"): accent → violet ramp, teal for wins */
  --grad-a: #5b8cff;
  --grad-b: #8b5bff;
  --grad-c: #3ecf8e;
  --grad-hero: linear-gradient(135deg, var(--grad-a) 0%, var(--grad-b) 100%);
  --grad-bar: linear-gradient(90deg, var(--grad-a), var(--grad-b));
  --grad-ok: linear-gradient(90deg, var(--grad-c), #6fe0b8);
  --on-hero: #ffffff;
  --on-hero-dim: rgba(255, 255, 255, 0.75);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f4fa;
  --surface: #ffffff;
  --surface2: #f2f4fb;
  --surface3: #e9edf8;
  --border: #dfe4f0;
  --border-strong: #c5cde0;
  --text: #171a2b;
  --muted: #64708a;
  --accent: #4653c8;
  --accent-strong: #3743ad;
  --accent-dim: #3d348f;
  --accent-soft: rgba(70, 83, 200, 0.1);
  --ok: #0a9b6a;
  --ok-soft: rgba(10, 155, 106, 0.12);
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, 0.12);
  --danger: #c2384c;
  --danger-soft: rgba(194, 56, 76, 0.1);
  --link: #4653c8;
  --backdrop: rgba(23, 26, 43, 0.45);
  --shadow-card: 0 1px 3px rgba(15, 20, 40, 0.08);
  --shadow-float: 0 14px 44px rgba(15, 20, 40, 0.22);
  --grad-a: #4653c8;
  --grad-b: #7b3fd6;
}

/* Nordic Wellness white-label: forced light, brand green (mirrors classic nw-theme). */
body[data-brand="nw"] {
  --bg: #efedea;
  --surface: #fbfbfb;
  --surface2: #f5f4f2;
  --surface3: #edecea;
  --border: #d9d9d9;
  --border-strong: #bdbdbd;
  --text: #101010;
  --muted: #696867;
  --accent: #008446;
  --accent-strong: #006b38;
  --accent-dim: #006b38;
  --accent-soft: rgba(0, 132, 70, 0.1);
  --ok: #008446;
  --link: #007f96;
  --grad-a: #008446;
  --grad-b: #00a76a;
  --grad-c: #00a76a;
}

/* ── Reset / base ─────────────────────────────────────────────────────── */

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  background:
    radial-gradient(60rem 26rem at 110% -8%, color-mix(in srgb, var(--grad-b) 16%, transparent) 0%, transparent 60%),
    radial-gradient(50rem 24rem at -18% 4%, color-mix(in srgb, var(--grad-a) 14%, transparent) 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.15em; }

:is(a, button, summary, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

h1, h2, h3, h4, p { margin: 0; }

svg.v2-icon {
  width: 1.35em;
  height: 1.35em;
  vertical-align: -0.28em;
  flex: none;
}

.v2-skip-link {
  position: absolute;
  left: -9999px;
  top: 0.5rem;
  z-index: 200;
  background: var(--accent);
  color: var(--btn-on-accent);
  padding: 0.5rem 1rem;
  border-radius: var(--r-sm);
}
.v2-skip-link:focus { left: 0.5rem; }

/* ── Shell: top bar / content / bottom tab bar ────────────────────────── */

.v2-topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--topbar-h);
  padding: 0 max(1rem, env(safe-area-inset-left)) 0 max(1rem, env(safe-area-inset-right));
  padding-top: env(safe-area-inset-top, 0px);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.v2-topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 0.95rem;
  color: var(--text);
}
.v2-topbar__brand img { height: 1.35rem; width: auto; display: block; }

.v2-topbar__title {
  font-size: 1.02rem;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  text-align: center;
}

.v2-topbar__side {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 4.4rem;
}
.v2-topbar__side--end { justify-content: flex-end; }

.v2-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border: none;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.v2-iconbtn:hover { background: var(--surface2); color: var(--text); }

.v2-main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem max(1rem, env(safe-area-inset-right)) calc(var(--tabbar-h) + 5.5rem)
    max(1rem, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Bottom tab bar (mobile) / left rail (desktop) */
.v2-tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 70;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}

.v2-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  border: none;
  background: none;
  cursor: pointer;
  min-width: 0;
  padding: 0.3rem 0.2rem;
}
.v2-tab svg.v2-icon { width: 1.45rem; height: 1.45rem; }
.v2-tab:hover { color: var(--text); text-decoration: none; }
.v2-tab--active { color: var(--accent-strong); }
.v2-tab--active::after {
  content: "";
  width: 1.4rem;
  height: 3px;
  border-radius: 3px;
  background: var(--grad-bar);
  margin-top: 0.1rem;
}
.v2-tab--locked { opacity: 0.45; }

@media (min-width: 880px) {
  body.v2-app { padding-left: 13rem; }
  .v2-tabbar {
    inset: 0 auto 0 0;
    width: 13rem;
    height: auto;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.15rem;
    padding: calc(var(--topbar-h) + 1rem) 0.6rem 1rem;
    border-top: none;
    border-right: 1px solid var(--border);
  }
  .v2-tab {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.7rem;
    font-size: 0.9rem;
    padding: 0.6rem 0.8rem;
    border-radius: var(--r-sm);
  }
  .v2-tab--active { background: var(--accent-soft); }
  .v2-tab--active::after { display: none; }
  .v2-main { max-width: 44rem; }
}

/* ── Cards / sections ─────────────────────────────────────────────────── */

.v2-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow-card);
}

.v2-card--accent { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }

/* Gradient hero card with a decorative "swoosh" sweep */
.v2-hero {
  position: relative;
  overflow: hidden;
  border: none;
  background: var(--grad-hero);
  color: var(--on-hero);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--grad-a) 35%, transparent);
}
.v2-hero::before,
.v2-hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.09);
  pointer-events: none;
}
.v2-hero::before { width: 26rem; height: 26rem; right: -9rem; top: -17rem; transform: rotate(-12deg); }
.v2-hero::after { width: 16rem; height: 16rem; right: -7rem; bottom: -11rem; background: rgba(255, 255, 255, 0.07); }
.v2-hero > * { position: relative; z-index: 1; }
.v2-hero .v2-eyebrow { color: var(--on-hero-dim); }
.v2-hero .v2-hint { color: var(--on-hero-dim); }
.v2-hero a { color: var(--on-hero); text-decoration: underline; }
.v2-hero .v2-chip {
  background: rgba(255, 255, 255, 0.16);
  border-color: transparent;
  color: var(--on-hero);
  backdrop-filter: blur(4px);
}
.v2-hero .v2-display--sub { color: var(--on-hero); opacity: 0.92; }
.v2-hero .v2-details { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.22); }
.v2-hero .v2-details > summary { color: var(--on-hero); }
.v2-hero .v2-details__body { color: var(--on-hero-dim); }
.v2-hero .v2-details__chev { color: var(--on-hero-dim); }
.v2-card--ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); background: var(--ok-soft); }
.v2-card--error { border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); background: var(--danger-soft); }

.v2-h1 { font-size: 1.45rem; font-weight: 750; letter-spacing: -0.01em; }
.v2-h2 { font-size: 1.05rem; font-weight: 700; }
.v2-eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.v2-hint { font-size: 0.82rem; color: var(--muted); }
.v2-display {
  font-size: clamp(2rem, 9vw, 2.9rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

/* ── Chips / pills / stat tiles ──────────────────────────────────────── */

.v2-chiprow {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
  scrollbar-width: none;
}
.v2-chiprow::-webkit-scrollbar { display: none; }

.v2-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.8rem;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.v2-chip--accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-strong); }
.v2-chip--ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.v2-chip--warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.v2-chip__num { font-variant-numeric: tabular-nums; }

.v2-statgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.75rem;
}
.v2-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0.85rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.v2-stat__label { font-size: 0.72rem; font-weight: 650; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.v2-stat__value { font-size: 1.45rem; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.v2-stat__delta { font-size: 0.78rem; font-weight: 650; }
.v2-stat__delta--up { color: var(--ok); }
.v2-stat__delta--down { color: var(--danger); }
.v2-stat__delta--flat { color: var(--muted); }
.v2-stat svg.v2-spark { width: 100%; height: 30px; margin-top: 0.3rem; }
.v2-spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.v2-bars { display: flex; align-items: flex-end; gap: 3px; height: 42px; margin-top: 0.35rem; }
.v2-bars__bar { flex: 1; min-width: 3px; border-radius: 3px 3px 0 0; background: var(--accent-soft); }
.v2-bars__bar-fill { display: block; width: 100%; border-radius: 3px 3px 0 0; background: linear-gradient(180deg, var(--grad-b), var(--grad-a)); }
.v2-bars__bar--hit .v2-bars__bar-fill { background: linear-gradient(180deg, #6fe0b8, var(--grad-c)); }

/* ── Progress bars ────────────────────────────────────────────────────── */

.v2-progress { display: flex; flex-direction: column; gap: 0.35rem; }
.v2-progress__head { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.v2-progress__bar { height: 8px; border-radius: var(--r-pill); background: var(--surface3); overflow: hidden; }
.v2-progress__fill {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--grad-bar);
  background-size: 200% 100%;
  animation: v2shimmer 3.5s ease-in-out infinite;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes v2shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.v2-progress--done .v2-progress__fill { background: var(--grad-ok); }
.v2-progress--warn .v2-progress__fill { background: linear-gradient(90deg, var(--warn), #f3c26b); }

/* Ring (donut) stat — set fill with style="--p: 62" (0–100) */
.v2-ring {
  --p: 0;
  --ring-size: 6.4rem;
  width: var(--ring-size);
  height: var(--ring-size);
  border-radius: 50%;
  background:
    radial-gradient(closest-side, var(--surface) 76%, transparent 77% 100%),
    conic-gradient(var(--grad-a) 0%, var(--grad-b) calc(var(--p) * 1%), var(--surface3) 0);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: none;
}
.v2-ring--done {
  background:
    radial-gradient(closest-side, var(--surface) 76%, transparent 77% 100%),
    conic-gradient(var(--grad-c) 0%, #6fe0b8 calc(var(--p) * 1%), var(--surface3) 0);
}
.v2-ring__value { font-size: 1.25rem; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.v2-ring__label { font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.v2-ring--on-hero {
  background:
    radial-gradient(closest-side, transparent 74%, transparent 75% 100%),
    conic-gradient(#ffffff 0%, rgba(255, 255, 255, 0.95) calc(var(--p) * 1%), rgba(255, 255, 255, 0.22) 0);
  -webkit-mask: radial-gradient(closest-side, transparent 74%, #000 75%);
  mask: radial-gradient(closest-side, transparent 74%, #000 75%);
  position: relative;
}
/* Masked ring can't hold text — pair it with an overlay label */
.v2-ringwrap { position: relative; width: 6.4rem; height: 6.4rem; flex: none; }
.v2-ringwrap .v2-ring { position: absolute; inset: 0; }
.v2-ringwrap__text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--on-hero);
}
.v2-ringwrap__text .v2-ring__label { color: var(--on-hero-dim); }

.v2-ringrow { display: flex; align-items: center; gap: 1rem; }
.v2-ringrow__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.3rem; }

/* Gradient text for numbers that should pop */
.v2-gradtext {
  background: var(--grad-bar);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ── Buttons ──────────────────────────────────────────────────────────── */

.v2-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--tap);
  padding: 0.65rem 1.3rem;
  border: none;
  border-radius: var(--r-md);
  background: var(--grad-hero);
  color: var(--btn-on-accent);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--grad-a) 35%, transparent);
}
.v2-btn:hover { filter: brightness(1.08); text-decoration: none; }
.v2-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.v2-btn--block { width: 100%; }
.v2-btn--secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.v2-btn--secondary:hover { background: var(--surface3); }
.v2-btn--ghost { background: transparent; color: var(--accent-strong); }
.v2-btn--ghost:hover { background: var(--accent-soft); }
.v2-btn--danger { background: transparent; color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border)); }
.v2-btn--danger:hover { background: var(--danger-soft); }
.v2-btn--sm { min-height: 2.2rem; padding: 0.35rem 0.9rem; font-size: 0.84rem; border-radius: var(--r-sm); }

.v2-btn--loading { position: relative; color: transparent !important; pointer-events: none; }
.v2-btn--loading::after {
  content: "";
  position: absolute;
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: v2spin 0.7s linear infinite;
}
@keyframes v2spin { to { transform: rotate(360deg); } }

/* ── Forms ────────────────────────────────────────────────────────────── */

.v2-field { display: flex; flex-direction: column; gap: 0.35rem; }
.v2-field > label { font-size: 0.83rem; font-weight: 650; color: var(--text); }

.v2-input,
.v2-field input:not([type="checkbox"]):not([type="radio"]),
.v2-field select,
.v2-field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface2);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}
.v2-field input:focus, .v2-field select:focus, .v2-field textarea:focus, .v2-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: transparent;
}

.v2-form { display: flex; flex-direction: column; gap: 1rem; }
.v2-formrow { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 480px) { .v2-formrow { grid-template-columns: 1fr; } }

.v2-check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.92rem;
  cursor: pointer;
}
.v2-check input { width: 1.15rem; height: 1.15rem; margin-top: 0.15rem; accent-color: var(--accent); }

/* Segmented control (Today check-in) */
.v2-seg { display: flex; gap: 0.4rem; }
.v2-seg--wrap { flex-wrap: wrap; }
.v2-seg__opt { flex: 1; position: relative; }
.v2-seg__opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.v2-seg__opt span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0.45rem 0.5rem;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface2);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: all 0.12s ease;
}
.v2-seg__opt input:checked + span {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}
.v2-seg__opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.v2-segrow { display: flex; flex-direction: column; gap: 0.45rem; }
.v2-segrow__label { font-size: 0.85rem; font-weight: 650; }

/* Switch */
.v2-switch { display: flex; align-items: center; gap: 0.7rem; cursor: pointer; }
.v2-switch input { position: absolute; opacity: 0; }
.v2-switch__track {
  flex: none;
  width: 2.9rem;
  height: 1.7rem;
  border-radius: var(--r-pill);
  background: var(--surface3);
  border: 1px solid var(--border);
  position: relative;
  transition: background 0.15s ease;
}
.v2-switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease;
}
.v2-switch input:checked ~ .v2-switch__track { background: var(--accent); border-color: var(--accent); }
.v2-switch input:checked ~ .v2-switch__track::after { transform: translateX(1.2rem); }
.v2-switch input:focus-visible ~ .v2-switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }
.v2-switch__text { font-weight: 650; font-size: 0.95rem; }

/* ── Collapsible sheet sections (details) ─────────────────────────────── */

.v2-details { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.v2-details > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  font-weight: 650;
  font-size: 0.92rem;
  cursor: pointer;
  min-height: var(--tap);
}
.v2-details > summary::-webkit-details-marker { display: none; }
.v2-details > summary .v2-details__chev { transition: transform 0.15s ease; color: var(--muted); }
.v2-details[open] > summary .v2-details__chev { transform: rotate(180deg); }
.v2-details__body { padding: 0 1rem 1rem; display: flex; flex-direction: column; gap: 0.6rem; font-size: 0.92rem; }
.v2-details__body ul { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: 0.35rem; }

/* ── Workout: set checklist + sticky complete bar ─────────────────────── */

.v2-setlist { display: flex; flex-direction: column; gap: 0.5rem; }
.v2-setrow {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: all 0.12s ease;
}
.v2-setrow__check {
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
}
.v2-setrow__label { flex: 1; font-weight: 650; font-variant-numeric: tabular-nums; }
.v2-setrow__meta { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.v2-setrow--done { opacity: 0.62; }
.v2-setrow--done .v2-setrow__check { background: var(--ok); border-color: var(--ok); color: #fff; }
.v2-setrow--done .v2-setrow__label { text-decoration: line-through; }

.v2-restchip {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}
.v2-restchip.is-on { display: flex; }

.v2-completebar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--tabbar-h);
  z-index: 65;
  padding: 0.6rem max(1rem, env(safe-area-inset-right)) 0.6rem max(1rem, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}
.v2-completebar .v2-btn { max-width: 40rem; width: 100%; }
@media (min-width: 880px) {
  .v2-completebar { left: 13rem; bottom: 0; }
}

/* ── Bottom sheet (More menu / completion) ────────────────────────────── */

.v2-sheet { position: fixed; inset: 0; z-index: 90; display: none; }
.v2-sheet.is-open { display: block; }
.v2-sheet__backdrop { position: absolute; inset: 0; background: var(--backdrop); }
.v2-sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 86dvh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow-float);
  padding: 0.6rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  animation: v2sheetup 0.22s ease;
}
@keyframes v2sheetup { from { transform: translateY(30px); opacity: 0.4; } }
@media (min-width: 880px) {
  .v2-sheet__panel {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(30rem, 92vw);
    border-radius: var(--r-lg);
  }
}
.v2-sheet__grab { width: 2.6rem; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 0.25rem auto 0.9rem; }
.v2-sheet__title { font-size: 1rem; font-weight: 750; margin-bottom: 0.6rem; }

.v2-menu { display: flex; flex-direction: column; }
.v2-menu a, .v2-menu button {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: var(--tap);
  padding: 0.65rem 0.5rem;
  border: none;
  background: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  border-radius: var(--r-sm);
  width: 100%;
}
.v2-menu a:hover, .v2-menu button:hover { background: var(--surface2); text-decoration: none; }
.v2-menu svg.v2-icon { color: var(--muted); }
.v2-menu__sep { border: none; border-top: 1px solid var(--border); margin: 0.4rem 0; }
.v2-menu__meta { font-size: 0.78rem; color: var(--muted); padding: 0.4rem 0.5rem; }
.v2-menu__row { display: flex; gap: 0.4rem; padding: 0.3rem 0.5rem; }

/* ── Toasts (flash messages) ──────────────────────────────────────────── */

.v2-toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 4.6rem);
  z-index: 95;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(26rem, calc(100vw - 2rem));
  pointer-events: none;
}
.v2-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-float);
  font-size: 0.9rem;
  font-weight: 600;
  animation: v2toastin 0.25s ease;
}
@keyframes v2toastin { from { transform: translateY(12px); opacity: 0; } }
.v2-toast--ok { border-color: color-mix(in srgb, var(--ok) 50%, var(--border)); }
.v2-toast--ok svg.v2-icon { color: var(--ok); }
.v2-toast--error { border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); }
.v2-toast--error svg.v2-icon { color: var(--danger); }
.v2-toast.is-out { transition: opacity 0.35s ease, transform 0.35s ease; opacity: 0; transform: translateY(8px); }

/* ── Auth pages (no tab bar) ──────────────────────────────────────────── */

body.v2-auth .v2-main { padding-bottom: 2.5rem; }
.v2-auth-hero { text-align: center; padding: 2.2rem 0 0.6rem; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.v2-auth-hero img { height: 3.2rem; width: auto; }
.v2-auth-hero__word { font-size: 1.5rem; font-weight: 800; letter-spacing: 0.14em; }
.v2-auth-hero__tag { color: var(--muted); font-size: 0.9rem; }
.v2-authtabs { display: flex; gap: 0.4rem; background: var(--surface2); border-radius: var(--r-md); padding: 0.3rem; }
.v2-authtabs button {
  flex: 1;
  min-height: 2.5rem;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
}
.v2-authtabs button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }
.v2-authpanel { display: none; }
.v2-authpanel.is-active { display: block; }
.v2-auth-footer { text-align: center; font-size: 0.85rem; margin-top: 0.5rem; }
.v2-auth-switchers { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; margin-top: 1.2rem; }

.v2-valueprops { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.4rem 0 0; padding: 0; list-style: none; font-size: 0.88rem; color: var(--muted); text-align: left; }
.v2-valueprops li { display: flex; gap: 0.55rem; align-items: flex-start; }
.v2-valueprops svg.v2-icon { color: var(--accent); margin-top: 0.1rem; }

/* Password wrap */
.v2-pwwrap { position: relative; }
.v2-pwwrap input { padding-right: 3rem; }
.v2-pwwrap .v2-iconbtn { position: absolute; right: 0.35rem; top: 50%; transform: translateY(-50%); }

/* ── Timeline (logs) ──────────────────────────────────────────────────── */

.v2-weekhead { display: flex; align-items: baseline; justify-content: space-between; padding: 0.2rem 0.2rem 0; }
.v2-weekhead__label { font-size: 0.8rem; font-weight: 700; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; }
.v2-logrow {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.8rem 0.95rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.v2-logrow__badge {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
}
.v2-logrow__main { flex: 1; min-width: 0; }
.v2-logrow__title { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v2-logrow__sub { font-size: 0.8rem; color: var(--muted); }

/* ── Phase stepper (plan) ─────────────────────────────────────────────── */

.v2-phases { display: flex; flex-direction: column; gap: 0; }
.v2-phase { display: flex; gap: 0.9rem; position: relative; padding-bottom: 1.1rem; }
.v2-phase__rail { flex: none; width: 1.5rem; display: flex; flex-direction: column; align-items: center; }
.v2-phase__dot {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  margin-top: 0.3rem;
  flex: none;
}
.v2-phase__line { flex: 1; width: 2px; background: var(--border); margin-top: 0.2rem; }
.v2-phase:last-child .v2-phase__line { display: none; }
.v2-phase--current .v2-phase__dot { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.v2-phase--past .v2-phase__dot { border-color: var(--ok); background: var(--ok); }
.v2-phase__body { flex: 1; padding-bottom: 0.2rem; }
.v2-phase__weeks { font-size: 0.75rem; font-weight: 700; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; }
.v2-phase__title { font-weight: 750; margin: 0.1rem 0 0.25rem; }
.v2-phase__text { font-size: 0.88rem; color: var(--muted); }
.v2-phase__text ul { margin: 0.3rem 0 0; padding-left: 1.1rem; }

/* ── Tables (admin) ───────────────────────────────────────────────────── */

.v2-tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.v2-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.v2-table th, .v2-table td { text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.v2-table th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.v2-table tr:last-child td { border-bottom: none; }

/* ── Misc ─────────────────────────────────────────────────────────────── */

.v2-list-plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.v2-divider { border: none; border-top: 1px solid var(--border); margin: 0.3rem 0; }
.v2-badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.55rem; border-radius: var(--r-pill); font-size: 0.72rem; font-weight: 700; background: var(--surface3); color: var(--muted); }
.v2-badge--accent { background: var(--accent-soft); color: var(--accent-strong); }
.v2-center { text-align: center; }
.v2-stack-sm { display: flex; flex-direction: column; gap: 0.5rem; }
.v2-stack { display: flex; flex-direction: column; gap: 1rem; }
.v2-row-between { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.v2-mt-sm { margin-top: 0.5rem; }
.v2-footer { text-align: center; font-size: 0.78rem; color: var(--muted); padding: 1.2rem 0 0.5rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
