/* ============================================================
   FORGE — heated-iron health cockpit
   Temperature is state: cool steel = ahead of you, ember = effort/done.
   ============================================================ */

:root {
  /* Iron & graphite */
  --bg: #14110e;
  --bg-2: #1b1712;
  --surface: #221d17;
  --surface-hi: #2c261e;
  --line: #38312a;
  --line-soft: #2a241e;

  /* Type */
  --ink: #f3ecdf;
  --ink-dim: #ab9f8d;
  --ink-faint: #6f6759;

  /* Cool — steel, for what's ahead / at rest */
  --steel: #7ea8bd;
  --steel-deep: #3f5a68;
  --steel-glow: rgba(126, 168, 189, 0.22);

  /* Hot — ember, for effort & completion */
  --ember: #ff7a18;
  --ember-hi: #ffb020;
  --ember-deep: #e0381f;
  --ember-glow: rgba(255, 122, 24, 0.28);

  --danger: #ff5c47;

  --radius: 18px;
  --radius-lg: 26px;
  --tap: 56px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

/* Warm forge glow bleeding up from the floor of the app */
body::before {
  content: "";
  position: fixed;
  inset: auto 0 0 0;
  height: 45vh;
  background: radial-gradient(120% 100% at 50% 140%, var(--ember-glow), transparent 70%);
  pointer-events: none;
  z-index: 0;
  opacity: 0.7;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(var(--safe-t) + 14px) 18px calc(96px + var(--safe-b)) 18px;
}

button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font: inherit; color: inherit; }

/* ---- Type primitives ---- */
.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.num {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 0.9;
}
h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }

/* =============================== HEADER =============================== */
.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
}
.top .greeting { display: flex; flex-direction: column; gap: 3px; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ember-hi);
}
.brand .spark { width: 8px; height: 8px; border-radius: 50%; background: var(--ember-hi);
  box-shadow: 0 0 10px var(--ember); }
.date-chip {
  font-size: 12px; font-weight: 600; color: var(--ink-dim);
  text-align: right; line-height: 1.3;
}

/* =============================== CARDS =============================== */
.card {
  background: linear-gradient(180deg, var(--surface-hi), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card + .card { margin-top: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* =============================== EFFORT GAUGE =============================== */
.gauge-card {
  display: flex; align-items: center; gap: 18px;
  background: radial-gradient(120% 120% at 80% 0%, rgba(255,122,24,0.08), transparent 60%),
    linear-gradient(180deg, var(--surface-hi), var(--surface));
  border-radius: var(--radius-lg);
}
.gauge { position: relative; width: 128px; height: 128px; flex: 0 0 auto; }
.gauge svg { transform: rotate(-90deg); display: block; }
.gauge .track { stroke: var(--line); }
.gauge .fill {
  stroke: url(#emberGrad);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  filter: drop-shadow(0 0 6px var(--ember-glow));
}
.gauge .center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.gauge .center .pct { font-size: 34px; }
.gauge .center .pct.num { color: var(--ink); }
.gauge .center small { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); }
.big-flame { color: var(--ember-hi); display: inline-flex; }
.big-flame svg { width: 54px; height: 54px; filter: drop-shadow(0 0 14px var(--ember-glow)); }
.gauge-meta { flex: 1; min-width: 0; }
.gauge-meta h1 { margin-bottom: 6px; }
.gauge-meta p { color: var(--ink-dim); font-size: 13.5px; }

/* =============================== BUTTONS =============================== */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; min-height: var(--tap);
  border-radius: 15px; font-weight: 700; font-size: 16px;
  letter-spacing: 0.01em; transition: transform 0.08s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.985); }
.btn svg { width: 20px; height: 20px; flex: 0 0 auto; }
.done-stamp svg { width: 20px; height: 20px; }
.btn-hot {
  color: #1a0f04;
  background: linear-gradient(135deg, var(--ember-hi), var(--ember) 55%, var(--ember-deep));
  box-shadow: 0 10px 26px var(--ember-glow), inset 0 1px 0 rgba(255,255,255,0.25);
}
.btn-steel {
  color: var(--ink);
  background: linear-gradient(135deg, #40606f, var(--steel-deep));
  box-shadow: 0 8px 20px var(--steel-glow);
}
.btn-ghost { border: 1px solid var(--line); color: var(--ink-dim); background: var(--surface); }
.btn-ghost:active { background: var(--surface-hi); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.btn-sm { min-height: 44px; font-size: 14px; border-radius: 12px; padding: 0 14px; width: auto; }
.done-stamp {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--tap); border-radius: 15px; font-weight: 800; letter-spacing: 0.02em;
  color: var(--ember-hi); border: 1.5px solid rgba(255,176,32,0.4);
  background: rgba(255,122,24,0.08);
}

/* =============================== TODAY: LISTS =============================== */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 2px 2px 10px;
}
.section-head .eyebrow { color: var(--ink-dim); }
.section-head a { color: var(--steel); font-size: 12px; font-weight: 700; text-decoration: none; }

.row {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line-soft);
}
.row:last-child { border-bottom: none; }
.row .body { flex: 1; min-width: 0; }
.row .body .name { font-weight: 600; font-size: 15px; }
.row .body .sub { font-size: 12.5px; color: var(--ink-dim); margin-top: 1px; }
.row .body .sub .dose { color: var(--steel); font-weight: 600; }

/* Check toggle */
.check {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--line); background: transparent;
  display: grid; place-items: center; transition: all 0.18s ease;
}
.check svg { width: 15px; height: 15px; opacity: 0; transform: scale(0.5); transition: all 0.18s ease; }
.check.on {
  border-color: transparent;
  background: linear-gradient(135deg, var(--ember-hi), var(--ember));
  box-shadow: 0 0 14px var(--ember-glow);
}
.check.on svg { opacity: 1; transform: scale(1); stroke: #1a0f04; }
.row.taken .name { color: var(--ink-faint); text-decoration: line-through; text-decoration-color: var(--line); }

.tag {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.tag-steel { color: var(--steel); background: var(--steel-glow); }
.tag-ember { color: var(--ember-hi); background: rgba(255,122,24,0.12); }
.tag-lead {
  color: var(--steel); border: 1px solid var(--steel-deep);
  background: transparent; display: inline-flex; align-items: center; gap: 4px;
}

/* =============================== STREAK / STATS =============================== */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 12px; text-align: center;
}
.stat .v { font-size: 28px; }
.stat .v.num { color: var(--ink); }
.stat .k { font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); margin-top: 4px; }
.stat.hot .v { color: var(--ember-hi); }

/* =============================== BOTTOM NAV =============================== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center;
  padding: 8px 12px calc(8px + var(--safe-b));
  background: linear-gradient(180deg, rgba(20,17,14,0), var(--bg) 42%);
  pointer-events: none;
}
.tabbar-inner {
  pointer-events: auto;
  display: flex; width: 100%; max-width: 456px;
  background: rgba(34, 29, 23, 0.86);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px; color: var(--ink-faint); font-size: 10px; font-weight: 700;
  letter-spacing: 0.04em; transition: color 0.15s ease;
}
.tab svg { width: 23px; height: 23px; }
.tab.active { color: var(--ember-hi); }
.tab.active svg { filter: drop-shadow(0 0 8px var(--ember-glow)); }

/* =============================== GUIDED SESSION =============================== */
.session {
  position: fixed; inset: 0; z-index: 40;
  background:
    radial-gradient(120% 80% at 50% 120%, rgba(255,122,24,0.14), transparent 60%),
    var(--bg);
  display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 12px) 18px calc(var(--safe-b) + 18px);
}
.session.cool {
  background: radial-gradient(120% 80% at 50% 120%, var(--steel-glow), transparent 62%), var(--bg);
}
.session-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.session-top .quit { color: var(--ink-faint); font-size: 13px; font-weight: 600; padding: 8px; }
.session-top .phase-pill {
  font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ember-hi);
}
.session.cool .session-top .phase-pill { color: var(--steel); }

/* thin segmented progress */
.segbar { display: flex; gap: 3px; margin: 6px 0 auto; }
.segbar span { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.segbar span.done { background: linear-gradient(90deg, var(--ember), var(--ember-hi)); }
.segbar span.cur { background: var(--ink-dim); }

.stage {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  text-align: center; gap: 4px; padding: 12px 0;
}
.stage .round-tag { font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); }
.stage .ex-name { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; margin: 8px 0 4px; }
.stage .side { color: var(--steel); font-weight: 800; }

.prescription { font-size: 88px; margin: 6px 0; color: var(--ember-hi); text-shadow: 0 0 40px var(--ember-glow); }
.prescription .unit { font-size: 24px; color: var(--ink-dim); font-weight: 700; letter-spacing: 0; text-shadow: none; margin-left: 6px; }
.session.cool .prescription { color: var(--steel); text-shadow: 0 0 40px var(--steel-glow); }

.cue { color: var(--ink-dim); font-size: 15px; max-width: 300px; margin: 0 auto; }
.watch {
  margin: 14px auto 0; max-width: 320px;
  display: flex; align-items: flex-start; gap: 9px; text-align: left;
  background: rgba(255,92,71,0.09); border: 1px solid rgba(255,92,71,0.25);
  color: #ffb4a6; font-size: 13px; padding: 11px 13px; border-radius: 13px;
}
.watch svg { flex: 0 0 auto; margin-top: 1px; }
.lead-note {
  margin: 12px auto 0; display: inline-flex; align-items: center; gap: 7px;
  color: var(--steel); font-size: 13px; font-weight: 700;
  padding: 7px 13px; border: 1px solid var(--steel-deep); border-radius: 999px;
}

/* Timer ring inside stage */
.timer { position: relative; width: 250px; height: 250px; margin: 4px auto; }
.timer svg { transform: rotate(-90deg); }
.timer .t-track { stroke: var(--line); }
.timer .t-fill { stroke: url(#emberGrad); stroke-linecap: round; filter: drop-shadow(0 0 8px var(--ember-glow)); }
.session.cool .timer .t-fill { stroke: url(#steelGrad); filter: drop-shadow(0 0 8px var(--steel-glow)); }
.timer .t-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.timer .t-center .clock { font-size: 62px; color: var(--ink); }
.timer .t-center .lbl { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-faint); margin-top: 4px; }

.session-actions { display: flex; flex-direction: column; gap: 10px; }
.mini-actions { display: flex; gap: 10px; }
.mini-actions .btn { flex: 1; }

/* Mode / start card */
.start-card { text-align: center; }
.mode-toggle { display: flex; gap: 8px; margin: 16px 0; }
.mode-toggle button {
  flex: 1; padding: 14px 10px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--surface); text-align: left; transition: all 0.15s ease;
}
.mode-toggle button.sel { border-color: var(--ember); background: rgba(255,122,24,0.08); }
.mode-toggle .m-title { font-weight: 800; font-size: 15px; }
.mode-toggle .m-sub { font-size: 12px; color: var(--ink-dim); margin-top: 2px; }
.mode-toggle button.sel .m-title { color: var(--ember-hi); }

/* =============================== FORMS (Fuel) =============================== */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-faint); margin-bottom: 6px; }
.input {
  width: 100%; min-height: 50px; padding: 12px 14px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 13px; color: var(--ink);
}
.input:focus { outline: 2px solid var(--steel); outline-offset: 1px; border-color: transparent; }
select.input { -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23ab9f8d' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.icon-btn { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  color: var(--ink-faint); border: 1px solid var(--line); background: var(--surface); }
.icon-btn:active { background: var(--surface-hi); }
.icon-btn.danger:active { color: var(--danger); }

.empty { text-align: center; color: var(--ink-dim); padding: 30px 10px; }
.empty .big { font-size: 40px; margin-bottom: 8px; opacity: 0.5; }

/* =============================== LOG =============================== */
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.heat .cell { aspect-ratio: 1; border-radius: 6px; background: var(--surface); border: 1px solid var(--line-soft); }
.heat .cell.today { outline: 1.5px solid var(--steel); }
.heat-legend { display: flex; align-items: center; gap: 6px; justify-content: flex-end;
  font-size: 10px; color: var(--ink-faint); margin-top: 10px; letter-spacing: 0.08em; }
.heat-legend .sw { width: 12px; height: 12px; border-radius: 3px; }

.totals { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.totals div { display: flex; justify-content: space-between; font-size: 13.5px;
  padding: 5px 0; border-bottom: 1px solid var(--line-soft); }
.totals div span:first-child { color: var(--ink-dim); }
.totals div span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }

.log-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.log-item:last-child { border-bottom: none; }
.log-item .dot { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(135deg, var(--ember-hi), var(--ember)); box-shadow: 0 0 8px var(--ember-glow); flex: 0 0 auto; }
.log-item .li-body { flex: 1; }
.log-item .li-body .li-t { font-weight: 600; font-size: 14px; }
.log-item .li-body .li-s { font-size: 12px; color: var(--ink-dim); }
.log-item .li-dur { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--steel); }

/* Settings rows */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line-soft); }
.set-row:last-child { border-bottom: none; }
.set-row .sr-t { font-weight: 600; font-size: 15px; }
.set-row .sr-s { font-size: 12px; color: var(--ink-dim); margin-top: 1px; }

.switch { position: relative; width: 50px; height: 30px; flex: 0 0 auto; border-radius: 999px; background: var(--line); transition: background 0.2s ease; }
.switch.on { background: linear-gradient(135deg, var(--ember-hi), var(--ember)); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.2s ease; }
.switch.on::after { transform: translateX(20px); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: var(--surface-hi); border: 1px solid var(--line); color: var(--ink);
  padding: 11px 18px; border-radius: 13px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); opacity: 0; transition: all 0.25s ease; z-index: 60; pointer-events: none;
  max-width: 88%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Enter animation for views */
.view-enter { animation: rise 0.32s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.stage-enter { animation: pop 0.28s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes pop { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

.hint { font-size: 12px; color: var(--ink-faint); line-height: 1.5; }
.hint a, a.link { color: var(--steel); }
.divider { height: 1px; background: var(--line-soft); margin: 4px 0; border: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
