/* REPS · app styles. Colours, type and spacing come from tokens.css only. */
@font-face { font-family: "Inter Tight"; font-weight: 400; font-display: swap; src: url("/fonts/inter-tight-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter Tight"; font-weight: 600; font-display: swap; src: url("/fonts/inter-tight-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter Tight"; font-weight: 700; font-display: swap; src: url("/fonts/inter-tight-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter Tight"; font-weight: 900; font-display: swap; src: url("/fonts/inter-tight-latin-900-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-display: swap; src: url("/fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2"); }

:root { --tabs-height: 60px; --border-strong: #2a2e35; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--ground); color: var(--ink); font-family: var(--font-sans); font-size: var(--text-body);
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; border-radius: var(--radius); }
button { cursor: pointer; background: none; border: 0; }
button:disabled { cursor: default; opacity: 0.45; }
a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- screen ---------- */
.screen {
  max-width: 480px; margin: 0 auto;
  padding: calc(var(--safe-top) + 24px) var(--space-5) calc(var(--safe-bottom) + var(--tabs-height) + 32px);
  display: flex; flex-direction: column; gap: var(--space-6);
}
.screen.no-tabs { padding-bottom: calc(var(--safe-bottom) + 32px); }
header.top { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-3); }
h1 { margin-top: 4px; font-size: var(--text-title); font-weight: 900; letter-spacing: var(--tracking-display); line-height: 1; }
h2 { font-size: var(--text-card); font-weight: 700; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
.small { font-size: var(--text-small); }
.mono { font-family: var(--font-mono); }
.row { display: flex; align-items: center; gap: var(--space-3); }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: var(--space-2); }
.stack-lg { display: flex; flex-direction: column; gap: var(--space-4); }
section { display: flex; flex-direction: column; gap: var(--space-2); }
.rule { border-top: 1px solid var(--hairline); padding-top: var(--space-4); }
.label-ink { color: var(--ink); }
.label-red { color: var(--signal-text); }

/* ---------- header bits ---------- */
.streak { display: flex; align-items: center; gap: 8px; border: 1px solid var(--hairline); padding: 8px 10px; min-height: var(--tap-min); }
.streak .dot { width: 10px; height: 10px; }
.icon-btn { width: var(--tap-min); height: var(--tap-min); display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--hairline); flex: none; }
.icon-btn svg { width: 20px; height: 20px; stroke: var(--ink); fill: none; stroke-width: 1.6; }
.back { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap-min); padding-right: 8px; }

/* ---------- score ---------- */
.score { border: 1px solid var(--hairline); background: var(--surface); padding: var(--space-4);
  display: flex; flex-direction: row; justify-content: space-between; align-items: center; gap: var(--space-3); }
.score-num { font-size: var(--text-hero); font-weight: 900; letter-spacing: var(--tracking-display); line-height: 1; }
.score-num span { color: var(--muted); }
.score-line { margin-top: 6px; font-size: var(--text-small); color: var(--muted); }
.score-dots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 50%; }

/* ---------- habit rows ---------- */
.habits { display: flex; flex-direction: column; gap: var(--space-2); }
.habit { min-height: var(--row-height); width: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: 0 14px; background: var(--ground); border: 1px solid var(--hairline); text-align: left; }
.habit[aria-pressed="true"] { background: var(--surface); border-color: var(--border-strong); }
.habit-name { font-size: var(--text-body); font-weight: 600; }
.habit-state { display: flex; align-items: center; gap: 10px; flex: none; }
.habit .dot { width: 18px; height: 18px; }
.habit:active { background: var(--surface-raised); }

/* ---------- cards ---------- */
.card { border: 1px solid var(--hairline); padding: var(--space-4); display: flex; flex-direction: row; justify-content: space-between; align-items: center; gap: var(--space-3); }
.card.col { flex-direction: column; align-items: stretch; }
.card.surface { background: var(--surface); }
.card-title { margin-top: 4px; font-size: var(--text-card); font-weight: 700; }
.card-sub { font-size: var(--text-small); color: var(--muted); margin-top: 2px; }
.link-card { width: 100%; text-align: left; }
.stat { font-family: var(--font-mono); font-size: 22px; margin-top: 4px; }
.stat span { color: var(--muted); }

/* ---------- buttons and fields ---------- */
.btn-primary, .btn-secondary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: none; }
.btn-primary:active { filter: brightness(0.9); }
.btn-secondary:active { background: var(--surface-raised); }
.btn-ghost { min-height: var(--tap-min); padding: 0 10px; color: var(--muted); font-weight: 600; }
.btn-danger { height: var(--button-height); padding: 0 18px; border: 1px solid var(--hairline); color: var(--signal-text); font-weight: 600; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.btn-row > * { flex: 1 1 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.input { min-height: var(--button-height); width: 100%; padding: 0 12px; background: var(--ground); border: 1px solid var(--hairline); font-size: 16px; }
.input:focus { border-color: var(--muted); outline: none; }
.input:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
textarea.input { padding: 12px; min-height: 88px; resize: vertical; }
select.input { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.input.num { font-family: var(--font-mono); }
.inline-form { display: flex; gap: var(--space-2); }
.inline-form .input { flex: 1; min-width: 0; }

/* chips: day pickers, toggles */
.chips { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.chip { min-height: var(--tap-min); border: 1px solid var(--hairline); font: 500 var(--text-label)/1 var(--font-mono); letter-spacing: 0.08em; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--surface); border-color: var(--ink); color: var(--ink); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: var(--row-height);
  padding: 0 14px; border: 1px solid var(--hairline); width: 100%; text-align: left; }
.switch .state { display: flex; align-items: center; gap: 10px; }
.switch[aria-checked="true"] { background: var(--surface); border-color: var(--border-strong); }

/* ---------- dot pickers (mood, energy, effort) ---------- */
.picker { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-2); }
.pick { height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: var(--ground); border: 1px solid var(--hairline); }
.pick[aria-pressed="true"] { background: var(--surface); border-color: var(--signal); }
.pick-dots { display: flex; gap: 3px; }
.pick-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--hairline); }
.pick-dots i.on { background: var(--muted); }
.pick[aria-pressed="true"] .pick-dots i.on { background: var(--ink); }
.pick-label { font-size: 11px; color: var(--muted); }
.picker.compact .pick { height: var(--button-height); }

/* ---------- calendars ---------- */
.weeks { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 8px; }
.weeks .dot, .month .dot { width: auto; height: auto; aspect-ratio: 1; }
.dot.empty, .dot.missed, .dot.partial, .dot.none { background: var(--dot-empty); }
.dot.partial { box-shadow: inset 0 0 0 1px var(--border-strong); }
.dot.rest { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
.dot.future { background: var(--dot-empty); opacity: 0.5; }
.dot.today.done { background: var(--today); box-shadow: var(--today-glow); }
.month-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; text-align: center; }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.month .cell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.month .cell .dot { width: 100%; max-width: 22px; }
.month .cell .num { font: 500 10px/1 var(--font-mono); color: var(--muted); }
.month .blank { visibility: hidden; }
.year { display: flex; flex-direction: column; gap: 6px; }
.year-row { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 6px; }
.year-dots { display: grid; grid-template-columns: repeat(31, minmax(0, 1fr)); gap: 2px; }
.year-dots .dot { width: auto; height: auto; aspect-ratio: 1; box-shadow: none; }
.year-dots .dot.done { box-shadow: 0 0 4px rgba(242, 242, 240, 0.45); }
.year-dots .dot.today { box-shadow: 0 0 5px rgba(255, 59, 47, 0.8); }
.year-dots .dot.pad { visibility: hidden; }
.legend { display: flex; gap: var(--space-4); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { width: 10px; height: 10px; }

/* ---------- charts ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 40px; }
.bars i { width: 8px; background: var(--hairline); display: block; }
.bars i.latest { background: var(--muted); }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; border-bottom: 1px solid var(--hairline); }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 6px; min-width: 0; }
.chart .bar { width: 100%; max-width: 14px; background: var(--hairline); }
.chart .col.latest .bar { background: var(--ink); }
.chart-x { display: flex; gap: 6px; }
.chart-x span { flex: 1; text-align: center; font: 500 9px/1 var(--font-mono); color: var(--muted); min-width: 0; overflow: hidden; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; border-top: 1px solid var(--hairline); }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: var(--row-height);
  border-bottom: 1px solid var(--hairline); padding: 6px 0; }
.list-item.btn { width: 100%; text-align: left; }
.list-item .meta { font: 500 var(--text-label)/1.3 var(--font-mono); letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }

/* manage habits */
.manage { border: 1px solid var(--hairline); padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); }
.manage-top { display: flex; gap: var(--space-2); align-items: center; }
.manage-top .input { flex: 1; min-width: 0; }
.mini { width: var(--tap-min); height: var(--tap-min); border: 1px solid var(--hairline); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.mini svg { width: 16px; height: 16px; stroke: var(--ink); fill: none; stroke-width: 1.8; }

/* workout logger */
.exercise { border: 1px solid var(--hairline); padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); }
.set-row { display: grid; grid-template-columns: 34px 1fr 1fr 44px; gap: var(--space-2); align-items: center; }
.set-row .label { text-align: center; }

/* ---------- notices ---------- */
.notice { border: 1px solid var(--hairline); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.notice.accent { border-color: var(--border-strong); background: var(--surface); }
.steps { display: flex; flex-direction: column; gap: 6px; counter-reset: s; list-style: none; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 24px 1fr; font-size: var(--text-small); }
.steps li::before { content: counter(s); font: 500 var(--text-label)/1.6 var(--font-mono); color: var(--muted); }

/* ---------- tab bar ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--ground); border-top: 1px solid var(--hairline);
  padding-bottom: var(--safe-bottom); }
.tabs-inner { max-width: 480px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tab { height: var(--tabs-height); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border-top: 2px solid transparent; margin-top: -1px; color: var(--muted); text-decoration: none; }
.tab .t-main { font: 500 14px/1 var(--font-mono); letter-spacing: 0.08em; }
.tab .t-sub { font: 500 9px/1 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; }
.tab[aria-current="page"] { color: var(--ink); border-top-color: var(--signal); }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-bottom) + var(--tabs-height) + 12px); z-index: 20;
  width: calc(100% - 40px); max-width: 440px; background: var(--surface-raised); border: 1px solid var(--border-strong);
  padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); font-size: var(--text-small); }
.toast[hidden] { display: none; }

footer { text-align: center; padding-top: var(--space-2); }
.logo-full { width: 100%; max-width: 320px; height: auto; display: block; margin: 0 auto; }

@media (prefers-reduced-motion: no-preference) {
  .habit, .pick, .chip, .switch { transition: background-color 120ms ease, border-color 120ms ease; }
}

/* icons inside text buttons */
.btn-secondary svg, .btn-primary svg, .back svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; flex: none; }
