/* ===========================================================
   Drop to 185 — styles
   Concept: a training scoreboard. Big, confident metric readouts
   on a dark hero panel; quiet, disciplined surfaces around it.
   =========================================================== */

:root {
  --paper:      #F0F1ED;
  --card:       #FFFFFF;
  --ink:        #14181C;
  --ink-2:      #2A3037;
  --muted:      #6B747E;
  --line:       #E3E5E1;
  --line-soft:  #EFF0EC;

  --accent:     #EA5A2B;   /* energy / deadline */
  --accent-press:#C9491F;
  --accent-soft:#FDEAE1;

  --good:       #1C8C73;   /* on pace / positive */
  --good-soft:  #E1F0EB;
  --warn:       #C98A00;
  --warn-soft:  #FBF0D8;

  --board:      #12161C;   /* scoreboard ink */
  --board-2:    #1B212A;
  --board-line: #2A323D;
  --gold:       #E0A100;

  --shadow:     0 1px 2px rgba(20,24,28,.06), 0 8px 24px rgba(20,24,28,.06);
  --shadow-lg:  0 8px 40px rgba(20,24,28,.16);

  --r:   16px;
  --r-sm:12px;
  --maxw: 460px;
  --nav-h: 64px;

  --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ---------- shell ---------- */
.app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100dvh;
  padding: 0 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px);
  position: relative;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 2px 10px;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand .glyph {
  width: 26px; height: 26px; border-radius: 7px; background: var(--board);
  position: relative; flex: 0 0 auto;
}
.brand .glyph::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 78% 76%, var(--accent) 0 16%, transparent 17%),
    linear-gradient(135deg, transparent 46%, var(--accent) 47% 53%, transparent 54%);
}
.brand b { font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; font-size: 16px; }
.topbar .date { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- view switching ---------- */
.view { display: none; animation: fade .22s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .view, .sheet, * { animation: none !important; } }

.view-title { font-family: var(--font-display); font-weight: 600; font-size: 22px; letter-spacing: -.02em; margin: 8px 2px 14px; }

/* ---------- scoreboard hero ---------- */
.board {
  background: radial-gradient(120% 140% at 0% 0%, var(--board-2), var(--board));
  color: #fff; border-radius: var(--r);
  padding: 20px 20px 18px; box-shadow: var(--shadow-lg);
  position: relative; overflow: hidden;
}
.board::before {
  content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(234,90,43,.22), transparent 70%);
}
.board .eyebrow { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #8A93A0; font-weight: 600; }
.board .big {
  font-family: var(--font-display); font-weight: 700; letter-spacing: -.03em;
  font-size: clamp(54px, 18vw, 76px); line-height: .95; margin: 4px 0 0;
  font-variant-numeric: tabular-nums;
}
.board .big .unit { font-size: .34em; color: #8A93A0; font-weight: 500; margin-left: 6px; letter-spacing: 0; }
.board .sub { display: flex; gap: 18px; margin-top: 12px; }
.board .sub .item { font-size: 13px; color: #AEB6C0; }
.board .sub .item b { display: block; font-family: var(--font-display); font-size: 19px; color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; }
.board .sub .item b.down { color: #6FD3B6; }

.pace {
  position: relative; z-index: 1;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--board-line);
  display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.pace .dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.pace.on .dot { background: #6FD3B6; box-shadow: 0 0 0 4px rgba(111,211,182,.18); }
.pace.behind .dot { background: var(--accent); box-shadow: 0 0 0 4px rgba(234,90,43,.18); }
.pace.ahead .dot { background: var(--gold); box-shadow: 0 0 0 4px rgba(224,161,0,.18); }
.pace span b { color: #fff; font-weight: 600; }
.pace .countdown { margin-left: auto; text-align: right; color: #AEB6C0; }
.pace .countdown b { display: block; font-family: var(--font-display); color: #fff; font-size: 18px; font-variant-numeric: tabular-nums; }

/* ---------- generic card ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; box-shadow: var(--shadow); margin-top: 14px;
}
.card > .hd { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.card > .hd h3 { font-family: var(--font-display); font-size: 15px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.card > .hd .meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- chart ---------- */
.chartwrap { position: relative; }
svg.chart { display: block; width: 100%; height: auto; }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.chart .goalline { stroke: var(--gold); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .projline { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 2 5; opacity:.7; }
.chart .actual { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: url(#g-area); opacity: .5; }
.chart .pt { fill: var(--card); stroke: var(--ink); stroke-width: 2; }
.chart .axislabel { fill: var(--muted); font-size: 10px; font-family: var(--font-body); }
.chart .goaltag { fill: var(--gold); font-size: 10px; font-weight: 600; }
.chart-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 28px 0; }

/* ---------- nutrition rings ---------- */
.rings { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ring { display: flex; align-items: center; gap: 12px; }
.ring svg { width: 64px; height: 64px; flex: 0 0 auto; }
.ring .track { fill: none; stroke: var(--line); stroke-width: 8; }
.ring .fill { fill: none; stroke-width: 8; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset .5s ease; }
.ring .label { font-size: 12px; color: var(--muted); }
.ring .val { font-family: var(--font-display); font-size: 19px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ring .val small { font-size: 12px; color: var(--muted); font-weight: 500; font-family: var(--font-body); }
.ring.cal .fill { stroke: var(--accent); }
.ring.pro .fill { stroke: var(--good); }

.macrobars { display: flex; gap: 8px; margin-top: 14px; }
.macrobars .mb { flex: 1; }
.macrobars .mb .t { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.macrobars .mb .bar { height: 6px; border-radius: 4px; background: var(--line); overflow: hidden; }
.macrobars .mb .bar > i { display: block; height: 100%; border-radius: 4px; }
.macrobars .mb.c .bar > i { background: #5B8DEF; }
.macrobars .mb.f .bar > i { background: var(--warn); }

/* ---------- quick actions ---------- */
.quick { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 14px; }
.quick button {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 14px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ink-2); font-weight: 500; box-shadow: var(--shadow);
  transition: transform .08s ease, border-color .15s;
}
.quick button:active { transform: scale(.96); }
.quick button .ic { font-size: 20px; line-height: 1; }

/* ---------- list rows ---------- */
.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 2px;
  border-bottom: 1px solid var(--line-soft);
}
.row:last-child { border-bottom: 0; }
.row .lead { width: 40px; height: 40px; border-radius: 11px; background: var(--paper); display: grid; place-items: center; font-size: 18px; flex: 0 0 auto; }
.row .body { flex: 1; min-width: 0; }
.row .body .t { font-weight: 600; font-size: 14px; }
.row .body .s { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row .trail { font-family: var(--font-display); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.row .trail .d { font-size: 11px; font-weight: 500; }
.row .trail .d.down { color: var(--good); }
.row .trail .d.up { color: var(--accent); }
.row .del { background: none; border: 0; color: var(--muted); font-size: 18px; padding: 6px; line-height: 1; }
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 22px 0; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 8px 13px; font-size: 13px; font-weight: 500; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 7px;
}
.chip b { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; }
.chip:active { transform: scale(.96); }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; letter-spacing: .01em; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: 15px; background: var(--card); color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field .hint { font-size: 11px; color: var(--muted); margin-top: 5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1; min-width: 64px; padding: 10px; border: 1px solid var(--line); background: var(--card);
  border-radius: var(--r-sm); font-size: 13px; font-weight: 500; color: var(--ink-2);
}
.seg button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.btn {
  width: 100%; padding: 14px; border: 0; border-radius: var(--r-sm);
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 600;
  box-shadow: 0 6px 18px rgba(234,90,43,.28); transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.98); background: var(--accent-press); }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow); }
.btn.dark { background: var(--ink); box-shadow: var(--shadow); }
.btn.sm { width: auto; padding: 9px 14px; font-size: 13px; }
.btnrow { display: flex; gap: 10px; }

/* targets readout in settings */
.targets { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.targets .t {
  background: var(--paper); border-radius: var(--r-sm); padding: 12px;
}
.targets .t .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.targets .t .v { font-family: var(--font-display); font-size: 22px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.targets .t .v small { font-size: 12px; color: var(--muted); font-weight: 500; font-family: var(--font-body); }

.note { font-size: 12px; color: var(--muted); line-height: 1.55; margin-top: 14px; }
.note b { color: var(--ink-2); }

/* ---------- bottom nav ---------- */
.nav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
  width: 100%; max-width: var(--maxw);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255,255,255,.86); backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
  display: flex; align-items: stretch; z-index: 50;
}
.nav button {
  flex: 1; background: none; border: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; color: var(--muted);
  font-size: 10px; font-weight: 600; letter-spacing: .01em; padding: 8px 0 6px;
}
.nav button .ic { font-size: 21px; line-height: 1; transition: transform .15s; }
.nav button.on { color: var(--accent); }
.nav button.on .ic { transform: translateY(-1px); }

/* ---------- bottom sheet ---------- */
.scrim {
  position: fixed; inset: 0; background: rgba(16,20,26,.46); z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.scrim.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(100%);
  bottom: 0; width: 100%; max-width: var(--maxw); z-index: 70;
  background: var(--card); border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(16,20,26,.18);
  transition: transform .26s cubic-bezier(.22,.8,.3,1);
  max-height: 88dvh; overflow-y: auto;
}
.sheet.show { transform: translateX(-50%) translateY(0); }
.sheet .grab { width: 40px; height: 4px; border-radius: 99px; background: var(--line); margin: 6px auto 14px; }
.sheet h3 { font-family: var(--font-display); font-size: 18px; font-weight: 600; margin: 0 0 16px; letter-spacing: -.01em; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px); z-index: 90;
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 500; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* install banner */
.install {
  display: none; align-items: center; gap: 12px; margin-top: 14px;
  background: var(--board); color: #fff; border-radius: var(--r); padding: 14px 16px;
}
.install.show { display: flex; }
.install .txt { flex: 1; font-size: 13px; }
.install .txt b { display: block; font-family: var(--font-display); font-size: 14px; }
.install button { border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 600; font-size: 13px; background: var(--accent); color: #fff; }
.install .x { background: transparent; color: #8A93A0; padding: 6px; font-size: 16px; }

@media (min-width: 480px) {
  .app { box-shadow: 0 0 0 1px var(--line); }
}
