/* Get It Done — dark neon theme, matching the weight-tracker-pwa.html mockup.
   Deep near-black "paper", light lavender "ink", Orbitron (display) /
   Rajdhani (body) / Share Tech Mono (data), pink/cyan/gold/moss neon accents. */

:root {
  --paper: #0A0714;        /* page background (near-black) */
  --paper-dim: #6E5FA0;
  --paper-line: rgba(139, 92, 246, 0.22);
  --card: #150C28;
  --ink: #ECE7FB;          /* primary text (light lavender) */
  --ink-soft: #9C90C4;     /* muted text */
  --brick: #FF2D6B;        /* negative / side-A */
  --brick-dim: rgba(255, 45, 107, 0.18);
  --gold: #FFB93D;
  --gold-dim: rgba(255, 185, 61, 0.35);
  --moss: #2EFFB3;         /* on-track / positive */
  --moss-dim: rgba(46, 255, 179, 0.18);
  --pink: #FF2D95;
  --cyan: #33E6FF;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(139, 92, 246, 0.08);
  --radius: 4px;
  --font-display: 'Orbitron', sans-serif;
  --font-body: 'Rajdhani', sans-serif;
  --font-data: 'Share Tech Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* Background lives on the ROOT element so it fills the whole viewport even when
   the content is short (a root-element background always paints the full canvas).
   Body deliberately has NO min-height: any viewport height (100vh = "URL bar
   hidden", taller than the visible screen on mobile) forces a phantom scrollbar
   on browsers without 100dvh, even on tabs whose content already fits. Body
   sizing to its content means short tabs simply don't scroll; the fixed bottom
   nav still anchors to the viewport bottom and the html background fills any gap. */
html {
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--paper-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-line) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -1px -1px;
}

/* ---- splash ---- */
#splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--paper);
  background-image:
    linear-gradient(var(--paper-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-line) 1px, transparent 1px);
  background-size: 24px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  opacity: 1;
  visibility: visible;
  transition: opacity .5s ease, visibility .5s ease;
  cursor: pointer;
}
#splash.hide { opacity: 0; visibility: hidden; }
#splash img {
  width: 72%;
  max-width: 200px;
  filter: drop-shadow(0 0 30px rgba(255, 45, 149, 0.35))
          drop-shadow(0 0 50px rgba(51, 230, 255, 0.2));
  animation: splashPulse 2.2s ease-in-out infinite;
}
#splash .brand { font-size: 1.5rem; }
@keyframes splashPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

/* ---- shared ---- */
.hidden { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin: 18px auto;
  max-width: 560px;
}

section.card:first-of-type { margin-top: 8px; }

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0;
  background: linear-gradient(180deg, #ffffff 0%, #d9d6ec 45%, #9a93bd 55%, #ffffff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 6px rgba(255, 45, 149, 0.35));
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--ink) 0 4px, transparent 4px 8px);
  opacity: 0.3;
}

.subtitle { color: var(--ink-soft); font-size: 0.85rem; font-weight: 400; }

.hint { color: var(--ink-soft); margin: 0 0 14px; }
.error { color: var(--brick); margin: 10px 0 0; }
.status { color: var(--moss); margin: 10px 0 0; }

label { display: block; margin-bottom: 12px; }
label span { display: block; font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-soft); margin-bottom: 4px; }

input[type="number"], input[type="password"], input[type="text"], input[type="date"], select {
  width: 100%;
  padding: 9px 11px;
  font-family: var(--font-data);
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(51, 230, 255, 0.25);
}

.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.row2 { display: flex; align-items: center; gap: 14px; margin-top: 4px; }

/* goal card */
.goal-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label em.opt { font-style: normal; color: var(--ink-soft); font-size: 0.72rem; text-transform: none; letter-spacing: 0; }

.goal-stats {
  display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px;
  font-family: var(--font-data); font-size: 0.82rem; color: var(--ink);
}
.goal-stats .stat b { color: var(--ink); }
.goal-stats .stat { color: var(--ink-soft); }
.goal-stats .num { color: var(--ink); font-weight: 500; }

.goal-svg svg { display: block; width: 100%; height: auto; margin-top: 10px; }
.goal-svg .band { fill: var(--gold-dim); }
.goal-svg .scatter { fill: var(--ink-soft); opacity: 0.55; }
.goal-svg .line-smoothed { fill: none; stroke: var(--moss); stroke-width: 2; }
/* forecast = cyan projection; goal-pace = gold (matches the gold goal card) */
.goal-svg .line-forecast { fill: none; stroke: var(--cyan); stroke-width: 2; stroke-dasharray: 4 3; }
.goal-svg .line-goal { fill: none; stroke: var(--gold); stroke-width: 1.5; stroke-dasharray: 6 4; }
.goal-svg .dot-current { fill: var(--pink); }

/* goal stat tiles */
.goal-tiles { display: flex; gap: 10px; margin: 14px 0 4px; }
.goal-tiles .tile {
  flex: 1; border: 1px solid var(--paper-line); border-radius: var(--radius);
  padding: 12px 14px; background: var(--paper);
  display: flex; flex-direction: column; gap: 4px;
}
.goal-tiles .tile .tile-label { font-family: var(--font-display); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); }
.goal-tiles .tile .num { font-family: var(--font-data); font-size: 1.6rem; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.goal-tiles .tile-goal { border-color: var(--gold); box-shadow: 0 0 12px rgba(255,185,61,0.25), inset 0 0 0 1px rgba(255,185,61,0.25); }
.goal-tiles .tile-goal .tile-label, .goal-tiles .tile-goal .num { color: var(--gold); }

/* legend: forecast vs goal-pace (both dashed, different meanings) */
.legend { display: flex; gap: 14px; margin-top: 6px; font-family: var(--font-data); font-size: 0.72rem; color: var(--ink-soft); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 16px; height: 0; border-top: 2px dashed var(--cyan); display: inline-block; }
.legend .sw-goal { border-color: var(--gold); }

/* goal advisory banner — gold/warning tone, advisory only (never a hard block) */
.goal-banner { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius); font-family: var(--font-data); font-size: 0.84rem; line-height: 1.35; }
.goal-banner.warn { background: rgba(255,185,61,0.12); border: 1px solid rgba(255,185,61,0.4); color: var(--gold); }
.goal-banner.on-track, .goal-banner.goal-met { background: rgba(46,255,179,0.10); border: 1px solid rgba(46,255,179,0.35); color: var(--moss); }

.bf-readout {
  font-family: var(--font-data);
  font-size: 1rem;
  color: var(--moss);
  white-space: nowrap;
}
.bf-readout .dim { color: var(--ink-soft); font-size: 0.8rem; }

/* ---- buttons ---- */
.btn {
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.85rem;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(180deg, #ffffff 0%, #d7d5e8 45%, #9694b0 55%, #ffffff 100%);
  color: #0A0714;
  border: 1px solid var(--pink);
  box-shadow: 0 0 18px rgba(255, 45, 149, 0.35), inset 0 0 0 1px rgba(51, 230, 255, 0.25);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: translateY(1px); }

.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--paper-line); }
.btn-ghost:hover { color: var(--ink); border-color: var(--ink); }

.btn-danger {
  background: transparent; color: var(--brick); border-color: transparent;
  padding: 4px 8px; font-size: 0.8rem;
}
.btn-danger:hover { background: var(--brick-dim); }

/* ---- top bar (brand + user switcher + Lock) ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 22px 12px; max-width: 620px; margin: 0 auto;
  position: relative;
  border-bottom: 1px solid var(--paper-line);
}
.topbar::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, var(--pink), var(--cyan));
  opacity: 0.7;
}

/* ---- user picker (compact segmented control, in the top bar) ---- */
.user-picker { display: flex; gap: 6px; }
.user-btn {
  padding: 7px 12px; font-family: var(--font-display);
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  border: 1px solid var(--paper-line); border-radius: var(--radius);
  background: var(--card); color: var(--ink-soft); cursor: pointer;
}
.user-btn:hover { border-color: var(--ink-soft); color: var(--ink); }
.user-btn.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---- passcode gate ---- */
.gate {
  max-width: 380px; margin: 12vh auto 0; padding: 28px 26px;
  background: var(--card); border: 1px solid var(--paper-line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.gate .brand { font-size: 1.8rem; margin-bottom: 6px; }

/* ---- history ---- */
.history { list-style: none; margin: 0; padding: 0; }
.history li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 4px; border-bottom: 1px dashed var(--paper-line);
  font-family: var(--font-data); font-size: 0.9rem;
}
.history li:last-child { border-bottom: none; }
.history .date { color: var(--ink-soft); font-size: 0.78rem; }
.history .weight { font-size: 1.05rem; font-weight: 500; }
.history .measure { color: var(--ink-soft); font-size: 0.78rem; }
.delete-cell { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }

/* ---- trend charts ---- */
.trend-svg svg { display: block; width: 100%; height: auto; }
.trend-svg .band { fill: var(--moss-dim); }
.trend-svg .scatter { fill: var(--ink-soft); opacity: 0.55; }
.trend-svg .line-forecast { fill: none; stroke: var(--cyan); stroke-width: 2; stroke-dasharray: 4 3; }
.trend-svg .line-goal { fill: none; stroke: var(--gold); stroke-width: 1.5; stroke-dasharray: 6 4; }
.trend-svg .dot-current { fill: var(--pink); }
/* weight (secondary) — pink trend line, moss band */
.trend-weight .line-smoothed { fill: none; stroke: var(--brick); stroke-width: 2; }
/* %BF (headline) — green/teal trend line */
.trend-bf .line-smoothed { fill: none; stroke: var(--moss); stroke-width: 2; }

/* Trend stat line: big number + short status + small rate */
.chart-stat {
  font-family: var(--font-data); margin: 4px 0 6px; font-size: 0.84rem; color: var(--ink);
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.chart-stat .big { font-size: 1.7rem; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.chart-stat .big small { font-size: 0.7rem; color: var(--ink-soft); margin-left: 2px; }
.chart-stat .status-dim { color: var(--ink-soft); font-size: 0.8rem; }
.chart-stat .rate { color: var(--ink-soft); font-size: 0.76rem; }
.chart-stat .pace { font-family: var(--font-display); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
.chart-stat .pace-ok { color: var(--moss); }
.chart-stat .pace-down { color: var(--brick); }
.chart-stat .pace-up { color: var(--gold); }

/* ---- lean-mass trend readout (advisory) ---- */
.lean-trend {
  margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--paper-line);
  font-family: var(--font-data); font-size: 0.82rem; color: var(--ink);
  display: flex; flex-direction: column; gap: 2px;
}
.lean-trend .lean-label {
  font-family: var(--font-display); font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-soft);
}
.lean-trend .lean-readout.up { color: var(--moss); }
.lean-trend .lean-readout .dim { color: var(--ink-soft); font-size: 0.78rem; }
.lean-trend .lean-caveat { color: var(--ink-soft); font-size: 0.74rem; font-style: italic; }

/* ---- tabbed app shell: views + bottom nav ---- */
#app {
  display: flex;
  flex-direction: column;
  /* App-shell: exactly the visible screen height. 100dvh tracks the mobile
     browser URL bar as it shows/hides (100vh is the fallback for browsers
     without dvh). This keeps the bottom nav on-screen in every tab: content
     scrolls inside .views; the page itself never scrolls, so there's never a
     page-level (phantom) scrollbar. */
  height: 100vh;
  height: 100dvh;
}

.views {
  flex: 1 1 auto;
  min-height: 0;             /* allow the flex child to shrink and scroll */
  overflow-y: auto;          /* scroll lives here, not on the page */
  -webkit-overflow-scrolling: touch;
  width: 100%; max-width: 620px; margin: 0 auto;
  padding: 0 0 24px;
}
.view { display: none; }
.view.active { display: block; animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

nav.tabs {
  /* In-flow (no longer fixed): flex pins it to the bottom of the app shell, so
     it stays visible and content scrolls in .views above it instead of under it. */
  flex: 0 0 auto;
  width: 100%; max-width: 620px; margin: 0 auto;
  background: rgba(8, 5, 15, 0.96);
  backdrop-filter: blur(6px);
  border-top: 1px solid rgba(139, 92, 246, 0.3);
  box-shadow: 0 -2px 24px rgba(255, 45, 149, 0.12), 0 -1px 0 rgba(51, 230, 255, 0.2);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 10;
}
nav.tabs button {
  flex: 1;
  background: none; border: none; cursor: pointer;
  color: var(--paper-dim);
  font-family: var(--font-data); font-size: 0.7rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 9px 4px 11px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
nav.tabs button .ic svg {
  width: 18px; height: 18px; display: block;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
nav.tabs button.active { color: var(--gold); text-shadow: 0 0 10px rgba(255, 185, 61, 0.6); }
nav.tabs button.active .ic { color: var(--gold); }

/* ---- log: last-weight scale readout ---- */
.scale-readout { text-align: center; padding: 14px 10px 12px; }
.scale-readout .value {
  font-family: var(--font-data); font-size: 50px; font-weight: 600; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}
.scale-readout .unit { font-family: var(--font-data); font-size: 16px; color: var(--ink-soft); margin-left: 4px; }
.scale-readout .delta { margin-top: 8px; font-family: var(--font-data); font-size: 0.85rem; }
.delta.down { color: var(--moss); }
.delta.up { color: var(--brick); }

/* ---- beam: VS health bars + streaks ---- */
.vs-stage {
  display: flex; flex-direction: column; gap: 22px;
  padding: 14px 0 10px; position: relative;
}
.vs-row { display: flex; align-items: center; gap: 10px; }
.vs-row .vs-name {
  width: 88px; font-family: var(--font-display); font-weight: 600;
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em;
}
.vs-row.side-b { flex-direction: row-reverse; }
.vs-row.side-b .vs-name { text-align: right; }
.vs-track {
  flex: 1; height: 18px; background: var(--paper);
  border: 1px solid var(--paper-line); border-radius: 9px; overflow: hidden; display: flex;
}
.vs-track.side-b { justify-content: flex-end; }
.vs-fill { height: 100%; width: 0%; border-radius: 9px; transition: width 0.7s cubic-bezier(0.2, 0.8, 0.2, 1); }
.vs-fill-a { background: linear-gradient(90deg, rgba(255, 45, 149, 0.35), var(--pink)); box-shadow: 0 0 14px rgba(255, 45, 149, 0.65); }
.vs-fill-b { background: linear-gradient(270deg, rgba(51, 230, 255, 0.35), var(--cyan)); box-shadow: 0 0 14px rgba(51, 230, 255, 0.65); }
.vs-pct {
  width: 44px; text-align: right; font-family: var(--font-data);
  font-weight: 600; font-size: 15px; color: var(--pink);
}
.vs-row.side-b .vs-pct { text-align: left; color: var(--cyan); }
.vs-pct.lead { text-shadow: 0 0 10px currentColor; }
.vs-badge {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--pink);
  box-shadow: 0 0 16px rgba(255, 45, 149, 0.5), 0 0 26px rgba(51, 230, 255, 0.3), inset 0 0 10px rgba(51, 230, 255, 0.15);
  display: flex; align-items: center; justify-content: center; z-index: 2;
}
.vs-badge span {
  font-family: var(--font-display); font-weight: 800; font-size: 15px; letter-spacing: 0.04em;
  background: linear-gradient(180deg, #ffffff 0%, #d9d6ec 45%, #9a93bd 55%, #ffffff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.streaks { display: flex; gap: 12px; margin-top: 6px; }
.streak-box {
  flex: 1; text-align: center; border: 1px solid var(--ink);
  border-radius: var(--radius); padding: 12px 14px; background: var(--paper);
}
.streak-box .flame { font-family: var(--font-data); font-size: 26px; font-weight: 600; color: var(--ink); }
.streak-box .label {
  font-family: var(--font-data); font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-soft); margin-top: 4px;
}
