/* ============================================================
   health.hacker.nl — "heat-treated titanium"
   Matte black + satin graphite + brushed chrome.
   Anodized-titanium iridescence is RESERVED for earned progress.
   ============================================================ */
:root {
  --ink: #0A0A0B;
  --surface: #16171A;
  --surface-2: #1E2024;
  --surface-3: #26282D;
  --hairline: rgba(201, 205, 210, 0.10);
  --hairline-2: rgba(201, 205, 210, 0.18);

  --chrome-1: #E8EAED;
  --chrome-2: #9AA0A8;
  --chrome-3: #54585F;
  --chrome: linear-gradient(180deg, var(--chrome-1), var(--chrome-2) 52%, var(--chrome-3));

  --text: #C9CDD2;
  --text-bright: #E8EAED;
  --muted: #6E747C;

  --blue: #2E7BFF;
  --violet: #7A4DFF;
  --magenta: #FF3DAE;
  --accent: linear-gradient(100deg, var(--blue), var(--violet) 55%, var(--magenta));
  --danger: #E0566B;

  --radius: 16px;
  --radius-lg: 22px;
  --frame: 460px;

  --font-display: 'Saira Condensed', 'Arial Narrow', system-ui, sans-serif;
  --font-body: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', 'Roboto Mono', monospace;
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 50% -10%, #121317 0%, transparent 60%),
    #050506;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}
.hidden { display: none !important; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow {
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--muted);
}
.chrome-label {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--chrome-2);
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input { font: inherit; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; border-radius: 6px; }

/* ---------- shared centered "device" column ---------- */
.splash, .auth, .app {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: var(--frame);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  overflow: hidden;
}
@media (min-width: 520px) {
  .splash, .auth, .app {
    /* Only adjust the vertical insets here. Do NOT use the `inset` shorthand —
       it resets `left` to auto, and with translateX(-50%) still applied the
       card would slide off-screen to the left. Keep left:50% from the base rule. */
    top: 18px;
    bottom: 18px;
    height: calc(100% - 36px);
    border-radius: 30px;
    border: 1px solid var(--hairline);
    box-shadow: 0 40px 120px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  }
}

/* ---------- splash ---------- */
.splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  z-index: 50;
  transition: opacity 0.5s ease, transform 0.5s var(--ease-spring);
}
.splash.done { opacity: 0; transform: translateX(-50%) translateY(-12px); pointer-events: none; }
.splash-brand { text-align: center; display: grid; gap: 6px; }
.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(54px, 17vw, 104px);
  line-height: 0.86;
  letter-spacing: 0.005em;
  background: linear-gradient(100deg,
    var(--chrome-2) 0%, var(--chrome-1) 28%, #ffffff 40%,
    var(--blue) 48%, var(--violet) 55%, var(--magenta) 62%,
    var(--chrome-1) 76%, var(--chrome-2) 100%);
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  animation: sweep 2.6s var(--ease-spring) both;
}
.wordmark.sm { font-size: 34px; animation: none; }
.splash-tag {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(18px, 5vw, 26px);
  letter-spacing: 0.04em;
  color: var(--chrome-2);
}
.splash-bar {
  width: 120px; height: 2px; border-radius: 2px;
  background: var(--hairline);
  position: relative; overflow: hidden;
}
.splash-bar::after {
  content: ''; position: absolute; inset: 0;
  background: var(--accent);
  transform: translateX(-100%);
  animation: load 1.6s var(--ease-spring) infinite;
}
@keyframes sweep { from { background-position: 130% 0; } to { background-position: -30% 0; } }
@keyframes load { 0% { transform: translateX(-100%); } 60%, 100% { transform: translateX(100%); } }

/* ---------- cards / generic ---------- */
.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
}

/* ---------- auth ---------- */
.auth { display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; padding: 28px 22px; }
.auth-brand { display: flex; align-items: baseline; gap: 10px; margin-bottom: 22px; }
.auth-brand .wordmark.sm {
  background: var(--chrome); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.auth-form h2 { font-family: var(--font-display); font-weight: 700; font-size: 30px; color: var(--text-bright); margin-bottom: 14px; }
.auth-note { color: var(--muted); font-size: 13.5px; line-height: 1.5; margin-bottom: 16px; }
.auth-note b { color: var(--text); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12px; letter-spacing: 0.06em; color: var(--muted); }
.input, .field input {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--hairline-2);
  border-radius: 12px;
  padding: 13px 14px;
  color: var(--text-bright);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus, .field input:focus {
  outline: none;
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(122, 77, 255, 0.18);
}
.hint { font-size: 12px; color: var(--muted); margin: -6px 0 14px; }
.btn-primary {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #06070A;
  background: var(--accent);
  box-shadow: 0 8px 28px rgba(122, 77, 255, 0.28);
  transition: transform 0.12s var(--ease-spring), filter 0.15s ease;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { filter: grayscale(0.5) brightness(0.7); cursor: default; }
.btn-danger {
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  font-weight: 600;
  color: var(--danger);
  border: 1px solid rgba(224, 86, 107, 0.4);
  margin-top: 10px;
  background: rgba(224, 86, 107, 0.06);
}
.btn-danger:active { transform: scale(0.98); }
.auth-links { display: flex; justify-content: space-between; margin-top: 16px; }
.link { color: var(--chrome-2); font-size: 13.5px; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--text-bright); }

/* ---------- app shell ---------- */
.app { display: flex; flex-direction: column; }
.rail {
  display: flex; align-items: center; gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 18px 12px;
  border-bottom: 1px solid var(--hairline);
}
.tabs { position: relative; display: flex; flex: 1; gap: 4px; }
.tab {
  flex: 1;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.02em;
  color: var(--muted);
  padding: 4px 0 12px;
  text-align: center;
  transition: color 0.2s ease;
}
.tab.is-active { color: var(--text-bright); }
.tab-indicator {
  position: absolute;
  bottom: 0; left: 0;
  width: 50%; height: 2px;
  background: var(--chrome);
  border-radius: 2px;
  transition: transform 0.42s var(--ease-spring);
}
.rail-account {
  width: 38px; height: 38px; flex: none;
  border-radius: 50%;
  border: 1px solid var(--hairline-2);
  background: var(--surface-2);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--chrome-1);
}
.rail-account:active { transform: scale(0.95); }

.panels { display: flex; width: 200%; flex: 1; min-height: 0; transition: transform 0.42s var(--ease-spring); touch-action: pan-y; }
.panel { width: 50%; min-height: 0; position: relative; }
.panel-scroll { height: 100%; overflow-y: auto; padding: 16px 16px 110px; }

/* ---------- food: datebar ---------- */
.datebar { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 14px; }
.date-nav { width: 36px; height: 36px; border-radius: 50%; color: var(--chrome-2); font-size: 22px; border: 1px solid var(--hairline); }
.date-nav:active { background: var(--surface-2); }
.date-label {
  font-family: var(--font-display); font-weight: 700; font-size: 22px;
  color: var(--text-bright); min-width: 140px; text-align: center; letter-spacing: 0.02em;
}

/* ---------- food: gauges ---------- */
.gauges { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; padding: 16px 14px; }
.gauge { display: grid; gap: 10px; padding: 4px 8px; text-align: left; border-radius: 12px; }
.gauge + .gauge { border-left: 1px solid var(--hairline); }
.gauge-top { display: grid; gap: 4px; }
.gauge-val { color: var(--text-bright); font-size: 13px; }
.gauge-val b { font-family: var(--font-display); font-weight: 700; font-size: 28px; letter-spacing: 0.01em; }
.gauge-val i { font-style: normal; color: var(--muted); font-size: 11px; }
.gauge-track { height: 5px; border-radius: 4px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.gauge-fill { display: block; height: 100%; width: 0; border-radius: 4px; transition: width 0.7s var(--ease-spring); }
.gauge-fill.protein { background: linear-gradient(90deg, #2E7BFF, #5b93ff); }
.gauge-fill.carbs { background: linear-gradient(90deg, #7A4DFF, #9a78ff); }
.gauge-fill.fat { background: linear-gradient(90deg, #FF3DAE, #ff77c8); }
.gauge-fill.over { box-shadow: 0 0 10px currentColor; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { filter: brightness(1.25); } }

.section-head { margin: 22px 4px 10px; }

/* ---------- food: entries ---------- */
.entries { list-style: none; display: grid; gap: 8px; }
.entry {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 14px; padding: 12px 14px;
}
.entry-main { flex: 1; display: flex; flex-direction: column; gap: 3px; text-align: left; min-width: 0; }
.entry-name { color: var(--text-bright); font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-amount { color: var(--muted); font-size: 12px; }
.entry-macros { display: flex; gap: 8px; font-size: 12px; color: var(--chrome-2); flex: none; }
.entry-macros b { font-weight: 500; }
.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 30px 20px; line-height: 1.6; }
.empty b { color: var(--chrome-1); }

/* ---------- fab ---------- */
.fab {
  position: absolute; right: 18px; bottom: max(20px, env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 18px;
  font-size: 30px; font-weight: 300; line-height: 1;
  color: var(--chrome-1);
  background: linear-gradient(180deg, var(--surface-3), var(--surface));
  border: 1px solid var(--hairline-2);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.14s var(--ease-spring), border-color 0.2s ease;
}
.fab:hover { border-color: var(--violet); }
.fab:active { transform: scale(0.92); }

/* ---------- train: day picker ---------- */
.daypick {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 14px; padding: 4px; margin-bottom: 12px;
}
.day {
  padding: 11px 0; border-radius: 10px; text-align: center;
  font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: 0.03em;
  color: var(--muted); transition: color 0.2s ease, background 0.2s ease;
}
.day.is-active { color: var(--text-bright); background: var(--surface-3); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06); }
.cycle-hint { color: var(--muted); font-size: 12.5px; letter-spacing: 0.04em; margin: 0 4px 14px; }

/* ---------- train: exercise card + ledger ---------- */
.exercises { display: grid; gap: 12px; }
.ex { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 14px 14px 10px; }
.ex-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.ex-name { font-family: var(--font-display); font-weight: 700; font-size: 19px; color: var(--text-bright); letter-spacing: 0.01em; }
.ex-target { display: block; margin-top: 2px; }
.ex-menu { color: var(--muted); font-size: 20px; padding: 0 6px; line-height: 1; }
.ex-menu:hover { color: var(--text-bright); }

.ex-cols, .setrow { display: grid; grid-template-columns: 30px 1fr 1fr 1.2fr; gap: 8px; align-items: center; }
.ex-cols { padding: 0 4px 6px; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.ex-cols span:nth-child(n+2) { text-align: center; }
.ex-cols span:last-child { text-align: right; }

.setrow { padding: 5px 4px; position: relative; border-radius: 8px; }
.set-i { color: var(--chrome-2); font-size: 13px; text-align: center; }
.set-kg, .set-reps {
  width: 100%; text-align: center;
  background: var(--ink); border: 1px solid var(--hairline-2); border-radius: 9px;
  padding: 9px 4px; color: var(--text-bright); font-size: 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.set-kg:focus, .set-reps:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(122, 77, 255, 0.16); }
.set-last { text-align: right; font-size: 13px; color: var(--chrome-2); display: flex; align-items: center; justify-content: flex-end; gap: 5px; white-space: nowrap; }
.set-last .last-val.muted { color: var(--muted); }
.last-arrow { font-size: 10px; width: 12px; text-align: center; }

/* the signature: beating last session heats the row into titanium */
.setrow.beaten { background: linear-gradient(90deg, rgba(46, 123, 255, 0.05), rgba(255, 61, 174, 0.07)); }
.setrow.beaten .last-val,
.setrow.beaten .last-arrow {
  background: var(--accent); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  font-weight: 600;
}
.setrow.beaten::before {
  content: ''; position: absolute; left: 0; top: 6px; bottom: 6px; width: 2px;
  border-radius: 2px; background: var(--accent);
  animation: heat 1.4s var(--ease-spring);
}
.setrow.down .last-arrow, .setrow.down .last-val { color: var(--muted); }
.setrow.even .last-arrow { color: var(--chrome-3); }
@keyframes heat { from { opacity: 0; transform: scaleY(0.2); } to { opacity: 1; transform: scaleY(1); } }

/* ---------- bottom sheets ---------- */
#sheetRoot { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.sheet-backdrop {
  position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(2, 3, 5, 0); transition: background 0.24s ease; pointer-events: auto;
}
.sheet-backdrop.open { background: rgba(2, 3, 5, 0.62); }
.sheet-backdrop.closing { background: rgba(2, 3, 5, 0); }
.sheet {
  width: 100%; max-width: var(--frame);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--hairline); border-bottom: none;
  border-radius: 26px 26px 0 0;
  padding: 10px 18px max(24px, env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform 0.32s var(--ease-spring);
  max-height: 88%; overflow-y: auto;
}
.sheet-backdrop.open .sheet { transform: translateY(0); }
.sheet-backdrop.closing .sheet { transform: translateY(100%); }
.sheet-grip { width: 38px; height: 4px; border-radius: 4px; background: var(--hairline-2); margin: 4px auto 14px; }
.sheet-title { font-family: var(--font-display); font-weight: 700; font-size: 24px; color: var(--text-bright); margin-bottom: 14px; }
.sheet-lead { font-family: var(--font-display); font-weight: 700; font-size: 20px; color: var(--text-bright); margin-bottom: 6px; }
.sheet-body { display: block; }
.sheet-body .btn-primary { margin-top: 16px; }

/* sheet controls */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--ink); border: 1px solid var(--hairline); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.seg-btn { padding: 9px 0; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg-btn.is-active { color: var(--text-bright); background: var(--surface-3); }
.view { display: block; }
.food-results { display: grid; gap: 6px; margin-top: 12px; max-height: 320px; overflow-y: auto; }
.food-result { display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--hairline); background: var(--surface); }
.food-result:active { background: var(--surface-2); }
.fr-name { color: var(--text-bright); font-weight: 600; font-size: 15px; }
.fr-macros { color: var(--muted); font-size: 12px; }
.preview { margin: 12px 0 4px; color: var(--chrome-1); font-size: 14px; letter-spacing: 0.02em; }
.macro-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.macro-grid.two { grid-template-columns: 1fr 1fr; }
.micro-label { font-size: 12px; color: var(--muted); margin: 4px 0 6px; }
.inline-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.inline-label { font-size: 12px; color: var(--muted); letter-spacing: 0.06em; }
.unit-toggle { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 3px; background: var(--ink); border: 1px solid var(--hairline-2); border-radius: 10px; padding: 3px; }
.unit-btn { padding: 7px 16px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--muted); }
.unit-btn.is-active { color: var(--text-bright); background: var(--surface-3); }
.check { display: flex; align-items: center; gap: 10px; margin-top: 14px; color: var(--text); font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--violet); }

/* ---------- toasts ---------- */
.toast-root { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; width: calc(100% - 40px); max-width: 420px; pointer-events: none; }
.toast {
  justify-self: center;
  background: var(--surface-3); border: 1px solid var(--hairline-2);
  color: var(--text-bright); padding: 12px 18px; border-radius: 12px; font-size: 14px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  opacity: 0; transform: translateY(12px); transition: opacity 0.3s ease, transform 0.3s var(--ease-spring);
  max-width: 100%;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-color: rgba(122, 77, 255, 0.5); }
.toast-error { border-color: rgba(224, 86, 107, 0.55); color: #ffd9df; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .wordmark { background-position: 0 0; }
}
