/* =====================================================================
   LockedIn - dark UI.

   Built on a 4px spacing scale, a 6-step type scale and a near-monochrome
   palette with one accent. Surfaces are separated by hairline borders
   rather than shadows or gradients, so the interface stays flat and the
   only saturated colour on screen is data: category, rank, state.
   ===================================================================== */

:root {
  /* neutrals */
  --bg:        #0c0e11;
  --surface:   #131619;
  --surface-2: #191d22;
  --surface-3: #1f242a;
  --line:      #23282f;
  --line-soft: #1b1f24;

  --text:      #e6e9ed;
  --text-dim:  #8d96a3;
  --text-faint:#5c6672;

  /* one accent, used sparingly */
  --accent:    #5b8cff;
  --accent-dim:#3f68cc;
  --accent-bg: rgba(91, 140, 255, .12);

  --good:      #3fb950;
  --warn:      #d29922;
  --alert:     #e0603f;

  /* category hues - desaturated so six of them can coexist */
  --c-school: #5b8cff;
  --c-study: #6b8afd;
  --c-code:  #4bb3a6;
  --c-read:  #c58bd6;
  --c-gym:   #dd7350;
  --c-sleep: #8b7ad6;
  --c-meal:  #c9973f;
  --c-work:  #4d9e83;
  --c-other: #7d8794;

  /* spacing scale */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s7: 32px; --s8: 44px;

  /* radii - restrained; nothing is a pill except true chips */
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabbar: 58px;

  --ease: cubic-bezier(.2, .7, .3, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}
body { min-height: 100dvh; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  font-size: 16px;          /* keep at 16: smaller triggers iOS zoom on focus */
  letter-spacing: inherit;
}
button { cursor: pointer; border: none; background: none; padding: 0; }

.hidden { display: none !important; }
.ic { display: block; flex: none; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ============================ typography ============================ */

.h1 { font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.h2 { font-size: 17px; font-weight: 600; letter-spacing: -.015em; }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  margin: var(--s7) 2px var(--s3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.section-title .meta { text-transform: none; letter-spacing: 0; font-weight: 450; color: var(--text-dim); font-size: 12.5px; }

.hint { font-size: 12.5px; color: var(--text-faint); line-height: 1.45; }

/* ============================== login =============================== */

#login {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(var(--safe-t) + var(--s6)) var(--s6) calc(var(--safe-b) + var(--s6));
  background: var(--bg);
  z-index: 60;
}
.login-inner { width: 100%; max-width: 360px; margin: 0 auto; }

.brand { margin-bottom: var(--s7); }
.brand-mark {
  width: 44px; height: 44px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid; place-items: center;
  color: var(--accent);
  margin-bottom: var(--s5);
}
.brand h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -.025em; }
.brand p { margin: var(--s1) 0 0; color: var(--text-dim); font-size: 14px; }

.field { margin-bottom: var(--s3); }
.field label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 500;
}
.field textarea {
  width: 100%;
  padding: 12px 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  outline: none;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.5;
}
.field textarea:focus { border-color: var(--accent); }

.field input, .field select, .task-add input {
  width: 100%;
  padding: 12px 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  outline: none;
  transition: border-color .12s var(--ease);
}
.field input:focus, .field select:focus, .task-add input:focus { border-color: var(--accent); }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  width: 100%;
  min-height: 46px;
  padding: 12px 16px;
  border-radius: var(--r);
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 550;
  transition: filter .12s var(--ease), transform .06s var(--ease);
}
.btn:active { transform: scale(.99); filter: brightness(1.08); }
.btn.ghost { background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.btn.ghost:active { background: var(--surface-2); }
.btn.danger { background: transparent; border: 1px solid var(--line); color: var(--alert); }
.btn.sm { min-height: 34px; padding: 7px 12px; font-size: 13.5px; width: auto; font-weight: 500; }

.remember {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin: var(--s3) 0 var(--s5);
  color: var(--text-dim);
  font-size: 13.5px;
}
.remember input { width: 17px; height: 17px; accent-color: var(--accent); }

.login-error { color: var(--alert); font-size: 13px; min-height: 18px; margin-top: var(--s3); }

/* ============================== shell =============================== */

#app { padding-bottom: calc(var(--tabbar) + var(--safe-b) + var(--s5)); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(var(--safe-t) + var(--s4)) var(--s5) var(--s3);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  transition: border-color .2s;
}
.topbar.stuck { border-bottom-color: var(--line-soft); }
.topbar h2 { margin: 0; font-size: 21px; font-weight: 600; letter-spacing: -.022em; }
.topbar .sub { color: var(--text-dim); font-size: 12.5px; margin-top: 1px; }

.rank-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 550;
  white-space: nowrap;
}
.rank-dot { width: 7px; height: 7px; border-radius: 2px; transform: rotate(45deg); }

.view { padding: var(--s1) var(--s5) var(--s2); }

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: var(--s5);
}
.card + .card { margin-top: var(--s3); }
.card.tight { padding: 0 var(--s5); }

/* ============================= now panel ============================ */

.now {
  border-color: var(--line);
  padding: var(--s5);
}
.now-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.now-head .live {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--good);
  animation: blink 2.4s var(--ease) infinite;
}
@keyframes blink { 0%, 60%, 100% { opacity: 1 } 80% { opacity: .25 } }

.now-title { display: flex; align-items: center; gap: var(--s3); margin: var(--s3) 0 var(--s1); }
.now-title .ic { width: 20px; height: 20px; }
.now h3 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.now .when { color: var(--text-dim); font-size: 13px; }

.note-line {
  margin-top: var(--s3);
  padding-left: var(--s3);
  border-left: 2px solid var(--line);
  font-size: 13px;
  color: var(--text-dim);
}

.progress { height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; margin-top: var(--s4); }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .5s var(--ease); }

.now-actions { display: flex; gap: var(--s2); margin-top: var(--s4); }
.now-actions .btn { flex: 1; }
.now-actions .btn.icon-only { flex: 0 0 46px; }

/* ============================= timeline ============================= */
/* A time gutter, a hairline rail and a node per block: the schedule reads
   as one continuous day rather than a stack of unrelated cards. */

.timeline { margin-top: var(--s1); }

.tl-row {
  display: grid;
  grid-template-columns: 44px 18px 1fr auto;
  align-items: start;
  gap: 0 var(--s3);
  min-height: 62px;
}
/* "12:45 PM" needs more gutter than "12:45" - the column width is the only
   thing that changes; everything else belongs to every row. */
body.ampm .tl-row { grid-template-columns: 62px 18px 1fr auto; }
.tl-time {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-dim);
  text-align: right;
  padding-top: 16px;
  font-variant-numeric: tabular-nums;
}
.tl-rail { position: relative; justify-self: center; width: 18px; align-self: stretch; }
.tl-rail::before {
  content: "";
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 1px;
  background: var(--line);
  transform: translateX(-.5px);
}
.tl-row:first-child .tl-rail::before { top: 18px; }
.tl-row:last-child  .tl-rail::before { bottom: calc(100% - 18px); }
.tl-node {
  position: absolute;
  top: 16px; left: 50%;
  width: 9px; height: 9px;
  margin-left: -4.5px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--line);
  z-index: 1;
}
.tl-row.is-done .tl-node { background: var(--text-faint); border-color: var(--text-faint); }
.tl-row.is-now  .tl-node {
  width: 11px; height: 11px; margin-left: -5.5px;
  background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.tl-body { padding: 13px 0; min-width: 0; }
.tl-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -.01em;
}
.tl-label .ic { width: 15px; height: 15px; }
.tl-meta {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tl-meta .ic { width: 12px; height: 12px; }
.tl-meta .dot { width: 2px; height: 2px; border-radius: 50%; background: currentColor; opacity: .6; }

.tl-row.is-done .tl-label { color: var(--text-dim); }
.tl-row.is-done .tl-label .name { text-decoration: line-through; text-decoration-color: var(--text-faint); }
.tl-row.is-past:not(.is-done) .tl-body { opacity: .55; }
.tl-row.is-now .tl-label { color: var(--text); }

.tl-open { color: var(--text-faint); padding-top: 13px; align-self: start; }

.tl-check {
  width: 28px; height: 28px;
  margin: 13px 0 0;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  color: transparent;
  display: grid;
  place-items: center;
  transition: background .14s var(--ease), border-color .14s var(--ease), color .14s var(--ease);
}
.tl-check .ic { width: 14px; height: 14px; }
.tl-check:active { transform: scale(.92); }
.tl-row.is-done .tl-check { background: var(--good); border-color: var(--good); color: #0c0e11; }

.now-badge {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 1px 4px;
  line-height: 1.35;
}

/* The finished part of the day, folded away. */
.earlier > summary {
  display: flex; align-items: center; gap: 6px;
  padding: var(--s3) 0 var(--s3) 62px;
  font-size: 12.5px; color: var(--text-faint);
  cursor: pointer; list-style: none;
}
.earlier > summary::-webkit-details-marker { display: none; }
.earlier[open] > summary .gp-chev { transform: rotate(90deg); }

/* ============================== stat row ============================ */

.daystat { display: flex; }
.daystat > div { flex: 1; padding: var(--s4) 0; text-align: center; position: relative; }
.daystat > div + div::before {
  content: ""; position: absolute; left: 0; top: 22%; bottom: 22%; width: 1px; background: var(--line-soft);
}
.daystat span { display: block; font-size: 11px; color: var(--text-faint); font-weight: 500; }
.daystat b { display: block; font-size: 19px; font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* Four stacked full-width rows read as a wall; as tiles they are one glance. */
.quicklog { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s2); margin-top: var(--s3); }
.ql {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: var(--s4);
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r);
  color: var(--text-faint); text-align: left;
}
.ql:active { background: var(--surface-2); }
.ql > .ic { margin-bottom: var(--s2); }
.ql b {
  display: flex; align-items: center;
  font-size: 22px; font-weight: 550; letter-spacing: -.02em; color: var(--text);
  line-height: 1.1;
}
.ql span {
  font-size: 11.5px; color: var(--text-faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.ql .ql-ok { color: var(--good); }
.ql .ql-late { color: var(--alert); }

/* Rank, surfaced on Today - it was previously only reachable by knowing the
   chip in the top bar was a button. */
.rankstrip {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; text-align: left; margin-top: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r);
}
.rankstrip:active { background: var(--surface-2); }
.rankstrip svg { flex: none; }
.rs-main { flex: 1; min-width: 0; }
.rs-name { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.rs-bar { height: 3px; border-radius: 2px; background: var(--surface-3); margin: 6px 0 5px; overflow: hidden; }
.rs-bar > i { display: block; height: 100%; border-radius: 2px; }
.rs-sub { font-size: 11.5px; color: var(--text-faint); }
.rs-xp { font-size: 17px; font-weight: 550; letter-spacing: -.01em; text-align: right; }
.rs-xp span { display: block; font-size: 9.5px; font-weight: 600; letter-spacing: .08em; color: var(--text-faint); }

/* ============================ countdowns ============================ */

.countdowns { display: flex; gap: var(--s2); overflow-x: auto; padding: 2px 0 var(--s3); scrollbar-width: none; }
.countdowns::-webkit-scrollbar { display: none; }
.countdown {
  flex: none;
  min-width: 104px;
  max-width: 170px;
  padding: 11px 13px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--line-soft);
}
.countdown b { display: block; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.countdown span { display: block; font-size: 12px; color: var(--text-dim); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.countdown.soon { border-color: color-mix(in srgb, var(--alert) 40%, transparent); }
.countdown.soon b { color: var(--alert); }

/* ============================== tasks =============================== */

.task-add { display: flex; gap: var(--s2); margin-bottom: var(--s2); }
.task-add input { flex: 1; }
.task-add-btn {
  width: 44px;
  flex: none;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-dim);
  display: grid;
  place-items: center;
}
.task-add-btn:active { background: var(--surface-2); color: var(--text); }
.task-add-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

.t-rep {
  color: var(--accent);
  font-weight: 500;
}

.task {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}
.task:last-of-type { border-bottom: none; }
.task .tl-check { margin: 0; }
.task.done .tl-check { background: var(--good); border-color: var(--good); color: #0c0e11; }
.task-main { flex: 1; min-width: 0; }
.task-main .t-text { font-size: 14.5px; }
.task-main .t-xp { font-size: 12px; color: var(--text-faint); }
.task.done .t-text { text-decoration: line-through; color: var(--text-dim); }
.task-del { color: var(--text-faint); padding: 8px; display: grid; place-items: center; }

.empty {
  color: var(--text-faint);
  padding: var(--s6) var(--s4);
  font-size: 13.5px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--r);
}

/* =============================== week =============================== */

.daytabs { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; padding: 2px 0 var(--s4); }
.daytab {
  padding: 9px 0 8px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  font-size: 12px;
  font-weight: 550;
  color: var(--text-dim);
  transition: background .12s var(--ease), color .12s var(--ease);
}
.daytab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.daytab.today:not(.on) { color: var(--text); border-color: var(--line); }
.daytab.today::after {
  content: ""; display: block; width: 3px; height: 3px; border-radius: 50%;
  background: currentColor; margin: 3px auto 0; opacity: .8;
}
.daytab:not(.today)::after { content: ""; display: block; height: 3px; margin-top: 3px; }

.weekbars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.weekbar { text-align: center; }
.wb-track {
  height: 64px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  display: flex; align-items: flex-end; overflow: hidden;
}
.wb-track > i { display: block; width: 100%; background: var(--accent-dim); }
.wb-track.is-today > i { background: var(--accent); }
.weekbar span { display: block; font-size: 11px; color: var(--text-faint); margin-top: 5px; font-weight: 500; }
.weekbar span.is-today { color: var(--text); }

/* ============================= progress ============================= */

.rank-hero { text-align: center; padding: var(--s6) var(--s5) var(--s5); }
.rank-hero svg { margin: 0 auto var(--s4); display: block; }
.rank-tier { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); }
.rank-name { font-size: 23px; font-weight: 600; letter-spacing: -.02em; margin-top: 3px; }
.rank-xp { color: var(--text-dim); font-size: 13px; margin-top: var(--s1); font-variant-numeric: tabular-nums; }
.rank-next { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-faint); margin-top: 9px; font-variant-numeric: tabular-nums; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); margin-top: var(--s3); }
.stat {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: var(--s3) var(--s2);
  text-align: center;
}
.stat b {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.015em;
}
.stat b .ic { width: 14px; height: 14px; color: var(--warn); }
.stat span { display: block; font-size: 11px; color: var(--text-faint); margin-top: 2px; }

.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; align-items: end; height: 84px; }
.bar { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.bar > i { display: block; border-radius: 3px; background: var(--accent-dim); min-height: 2px; }
.bar.is-today > i { background: var(--accent); }
.bar span { text-align: center; font-size: 11px; color: var(--text-faint); margin-top: 6px; }
.bars-note { text-align: center; font-size: 12.5px; color: var(--text-dim); margin-top: var(--s4); font-variant-numeric: tabular-nums; }

/* 7 rows = Sun..Sat, filling down each column, so columns read as weeks */
.heat { display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; }
.heat > i { aspect-ratio: 1; border-radius: 2px; background: var(--surface-2); }
.heat .h1 { background: rgba(91, 140, 255, .25); }
.heat .h2 { background: rgba(91, 140, 255, .5); }
.heat .h3 { background: rgba(91, 140, 255, .75); }
.heat .h4 { background: var(--accent); }
.heat-key { display: flex; align-items: center; justify-content: space-between; margin-top: var(--s3); font-size: 11px; color: var(--text-faint); }
.heat-key div { display: flex; gap: 2px; }
.heat-key i { width: 10px; height: 10px; border-radius: 2px; display: block; }

.ach-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s2); }
.ach {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 13px 12px;
}
.ach .ic { width: 17px; height: 17px; color: var(--text-faint); margin-top: 1px; }
.ach.got .ic { color: var(--accent); }
.ach-nm { font-size: 13px; font-weight: 550; color: var(--text-dim); }
.ach.got .ach-nm { color: var(--text); }
.ach-ds { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; line-height: 1.35; }

.ladder-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 11px 13px;
  border-radius: var(--r);
  border: 1px solid var(--line-soft);
  background: var(--surface);
}
.ladder-row + .ladder-row { margin-top: 5px; }
.ladder-row.current { border-color: var(--line); background: var(--surface-2); }
.ladder-tier {
  width: 24px; height: 24px; flex: none;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ladder-row .nm { flex: 1; font-size: 14px; font-weight: 500; color: var(--text-dim); }
.ladder-row.current .nm, .ladder-row.reached .nm { color: var(--text); }
.ladder-row .xp { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* ============================= settings ============================= */

/* A collapsible group. The summary is styled like a section heading so an
   open group is indistinguishable from a plain one. */
.group { margin-top: var(--s7); }
.group > summary {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); padding: 0 2px var(--s4);
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-faint);
  cursor: pointer; list-style: none;
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary:active { color: var(--text-dim); }
.gp-chev { transition: transform .18s var(--ease); }
.group[open] > summary .gp-chev { transform: rotate(90deg); }

/* A tappable destination, as opposed to a setting you change in place. */
.navgroup { display: grid; gap: 6px; margin-top: var(--s2); }
.navrow {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; padding: var(--s3) var(--s4);
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r); text-align: left; color: var(--text-faint);
}
.navrow:active { background: var(--surface-2); }
.nav-main { flex: 1; min-width: 0; }
.nav-label { font-size: 14.5px; color: var(--text); font-weight: 450; }
.nav-value { font-size: 12px; color: var(--text-dim); margin-top: 1px; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--line-soft);
  min-height: 54px;
}
.row:last-child { border-bottom: none; }
.row .lbl { font-size: 14.5px; font-weight: 450; }
.row .hint { margin-top: 2px; }

.switch { width: 44px; height: 26px; border-radius: 13px; background: var(--surface-3); position: relative; flex: none; transition: background .16s var(--ease); }
.switch::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #cfd5dd;
  transition: transform .16s var(--ease), background .16s;
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(18px); background: #fff; }

.pill-status { font-size: 12px; font-weight: 500; padding: 3px 9px; border-radius: 5px; background: var(--surface-3); color: var(--text-dim); }
.pill-status.ok  { background: rgba(63, 185, 80, .13); color: var(--good); }
.pill-status.bad { background: rgba(224, 96, 63, .13); color: var(--alert); }

.mini-select {
  width: 112px; padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  flex: none;
  font-size: 14px;
}

/* ============================== tab bar ============================= */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  padding-bottom: var(--safe-b);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px) saturate(140%);
  border-top: 1px solid var(--line-soft);
}
.tab {
  height: var(--tabbar);
  padding: 0 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .01em;
  transition: color .12s var(--ease);
}
.tab .ic { width: 20px; height: 20px; }
.tab.on { color: var(--text); }
.tab.on .ic { color: var(--accent); }

/* =============================== sheet ============================== */

.sheet-wrap {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(6, 7, 9, .66);
  display: flex; align-items: flex-end;
  animation: fade .16s var(--ease);
}
.sheet {
  width: 100%;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  border-top: 1px solid var(--line);
  padding: var(--s2) var(--s5) calc(var(--safe-b) + var(--s6));
  animation: rise .22s var(--ease);
}
.grabber { width: 34px; height: 4px; border-radius: 2px; background: var(--line); margin: var(--s2) auto var(--s5); }
.sheet h3 { margin: 0 0 var(--s5); font-size: 17px; font-weight: 600; letter-spacing: -.015em; }
.sheet .btn + .btn, .sheet .two { margin-top: var(--s2); }

@keyframes fade { from { opacity: 0 } }
@keyframes rise { from { transform: translateY(22px) } }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13.5px;
  font-weight: 450;
  color: var(--text-dim);
  transition: border-color .12s, color .12s, background .12s;
}
.chip .ic { width: 14px; height: 14px; }
.chip.on { color: var(--text); border-color: var(--accent); background: var(--accent-bg); }
.chip.sm { padding: 6px 10px; font-size: 12.5px; }
.chip[disabled] { opacity: .3; }
.daypick { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.daypick .chip { padding: 10px 0; justify-content: center; border-radius: var(--r-sm); font-size: 12.5px; }
.quickdays { display: flex; gap: 6px; margin-top: var(--s2); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }

/* ============================= school ============================== */

.tag {
  font-size: 9.5px; font-weight: 700; letter-spacing: .06em;
  color: var(--accent); border: 1px solid var(--accent);
  border-radius: 3px; padding: 1px 4px; line-height: 1.4;
}
.task.overdue { border-left: 2px solid var(--alert); padding-left: 10px; margin-left: -12px; }

/* meridiem: present but never louder than the digits */
.ap, .wh-ap, .ar-ap, .cm-ap, .mini-ap {
  font-size: .42em;
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--text-dim);
  margin-left: .28em;
}
.tl-time .ap { font-size: .82em; margin-left: .18em; }
.cm-ap { color: var(--text-faint); }

/* ============================= wake up ============================= */

.armcard { border-color: var(--line); }
.armcard.is-armed { border-color: var(--good); background: linear-gradient(160deg, rgba(63,185,80,.06), transparent 60%); }
.arm-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 5px; max-width: 25em; line-height: 1.45; }
.armcard.is-armed .hd-label { color: var(--good); }

.wake-hero { padding: var(--s5); }
.wake-hero.is-off { opacity: .62; }
.wh-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.wh-time { font-size: 52px; font-weight: 200; letter-spacing: -.04em; line-height: 1.05; margin-top: 2px; }
.wh-days { margin-top: var(--s3); }
.wh-days > span { width: 20px; font-size: 11px; }
.wh-sub { font-size: 12.5px; color: var(--text-dim); margin-top: var(--s2); }
.wh-skip {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; margin-top: var(--s2); padding: 10px;
  font-size: 12.5px; color: var(--text-faint);
  border: 1px solid var(--line-soft); border-radius: var(--r);
}
.wh-skip:active { background: var(--surface-2); }
.wh-skip.is-skipped { color: var(--warn); border-color: rgba(210,153,34,.35); }

.wakedots { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; }
.wd { display: block; aspect-ratio: 1; border-radius: 3px; background: var(--surface-3); }
.wd.ontime  { background: var(--good); }
.wd.snoozed { background: var(--warn); }
.wd.missed  { background: rgba(224, 96, 63, .55); }
.wd.pending { background: var(--surface-3); border: 1px solid var(--accent); }
.wd.off     { background: var(--surface-2); }
.heat-key span { display: inline-flex; align-items: center; gap: 5px; }
.heat-key .wd { width: 9px; height: 9px; aspect-ratio: auto; }

.bar.is-good > i { background: var(--good); }

/* ============================== food =============================== */

.kcalcard { display: flex; align-items: center; gap: var(--s5); padding: var(--s5); }
.kc-ring { position: relative; width: 130px; flex: none; }
.kcalring { width: 100%; height: auto; display: block; transform: rotate(-90deg); }
.kcalring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.kr-track  { stroke: var(--surface-3); }
.kr-fill   { stroke: var(--accent); transition: stroke-dashoffset .5s var(--ease); }
.kr-fill.over { stroke: var(--warn); }
.kr-excess { stroke: var(--alert); transition: stroke-dashoffset .5s var(--ease); }
.kc-centre {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.kc-centre b { font-size: 30px; font-weight: 300; letter-spacing: -.03em; line-height: 1; }
.kc-centre span { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); margin-top: 4px; }

.kc-side { flex: 1; min-width: 0; }
.kc-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); padding: 3px 0; }
.kc-row span { font-size: 12px; color: var(--text-faint); }
.kc-row b { font-size: 15px; font-weight: 550; }
.kc-row.muted b { color: var(--text-dim); font-weight: 450; }
.kc-goal {
  margin-top: var(--s3); font-size: 12px; color: var(--accent);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 10px; width: 100%;
}

.macro + .macro { margin-top: var(--s4); }
.mc-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); }
.mc-name { font-size: 12.5px; color: var(--text-dim); }
.mc-num { font-size: 15px; font-weight: 550; }
.mc-num em { font-style: normal; font-size: 11.5px; font-weight: 450; color: var(--text-faint); margin-left: 2px; }
.mc-bar { height: 6px; border-radius: 3px; background: var(--surface-3); margin-top: 7px; overflow: hidden; }
.mc-bar > i { display: block; height: 100%; border-radius: 3px; transition: width .4s var(--ease); }

.minors {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2);
  margin-top: var(--s5); padding-top: var(--s4); border-top: 1px solid var(--line-soft);
}
.minors > div { text-align: center; }
.minors span { display: block; font-size: 10.5px; color: var(--text-faint); }
.minors b { display: block; font-size: 15px; font-weight: 550; margin-top: 3px; }
.minors b em { font-style: normal; font-size: 10.5px; font-weight: 450; color: var(--text-faint); }
.minors b.bad { color: var(--warn); }
.minors b.good { color: var(--good); }

.faves { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.fave {
  text-align: left; padding: var(--s3); border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line-soft);
}
.fave:active { background: var(--surface-2); }
.fv-name {
  font-size: 13px; font-weight: 500; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.fv-sub { font-size: 11px; color: var(--text-faint); margin-top: 3px; }

.pt-preview, .po-preview { font-size: 15px; font-weight: 500; margin-top: 6px; line-height: 1.45; }

/* the barcode window is wide and short, unlike the square QR frame */
.scan-frame { position: relative; width: min(78vw, 300px); height: 150px; margin: 0 auto; }
.scan-frame i { position: absolute; width: 28px; height: 28px; border: 2px solid #fff; }
.scan-frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 6px 0 0 0; }
.scan-frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 6px 0 0; }
.scan-frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 6px; }
.scan-frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 6px 0; }

/* stepping back through the log */
.daynav { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s3); }
.dn-arrow {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center; color: var(--text-dim);
  border: 1px solid var(--line); border-radius: var(--r);
}
.dn-arrow:active { background: var(--surface-2); }
.dn-arrow.is-off { opacity: .3; }
.dn-arrow .flip { transform: rotate(180deg); }
.dn-label { flex: 1; text-align: center; }
.dn-label b { display: block; font-size: 15px; font-weight: 600; }
.dn-label span { display: block; font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }

/* a meal's photograph, beside its row */
.mealshot {
  width: 40px; height: 40px; flex: none;
  border-radius: var(--r-sm); object-fit: cover;
  background: var(--surface-3);
}

/* what the targets were derived from */
.bodybasis { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3) var(--s2); margin-top: var(--s3); }
.bodybasis > div { text-align: center; }
.bodybasis span { display: block; font-size: 10.5px; color: var(--text-faint); }
.bodybasis b { display: block; font-size: 16px; font-weight: 550; margin-top: 2px; }
.bodybasis b em { font-style: normal; font-size: 10.5px; font-weight: 450; color: var(--text-faint); margin-left: 1px; }

/* a recognised item that has been unticked */
.hw.is-off { opacity: .45; }
.hw .tl-check.on { background: var(--good); border-color: var(--good); color: #0c0e11; }

/* ============================ homework ============================= */

.hw {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r); color: var(--text-faint);
}
.hw + .hw { margin-top: 6px; }
.hw.is-late { border-left: 2px solid var(--alert); }
.hw.is-high:not(.is-late) { border-left: 2px solid var(--warn); }
.hw-main { flex: 1; min-width: 0; }
.hw-title { font-size: 14.5px; font-weight: 500; color: var(--text); line-height: 1.3; }
.hw-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  font-size: 11.5px; color: var(--text-faint); margin-top: 4px;
}
.hw-sub { display: inline-flex; align-items: center; gap: 5px; }
.hw-sub i { width: 7px; height: 7px; border-radius: 50%; display: block; }

.subjects { display: flex; flex-wrap: wrap; gap: 6px; }
.subject {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 13px; color: var(--text-dim);
}
.subject i { width: 8px; height: 8px; border-radius: 50%; display: block; }
.subject b { color: var(--text); font-weight: 600; font-size: 12px; }
.subject:active { background: var(--surface-2); }

.chip .dotc { width: 8px; height: 8px; border-radius: 50%; display: block; }
.chip.swatch { padding: 8px 10px; }
.chip.swatch i { width: 16px; height: 16px; border-radius: 50%; display: block; }

/* ============================ LED strip ============================ */

.ledcard { border-color: var(--line); }

.slider {
  flex: 1; max-width: 150px; height: 26px;
  background: transparent; -webkit-appearance: none; appearance: none;
}
.slider::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--surface-3); }
.slider::-moz-range-track { height: 4px; border-radius: 2px; background: var(--surface-3); }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); border: none; margin-top: -8px;
}
.slider::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); border: none;
}

.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: var(--s3) 0 var(--s2); }
.swatch-btn { text-align: center; }
.swatch-btn i {
  display: block; width: 100%; aspect-ratio: 1; border-radius: 50%;
  border: 2px solid transparent;
}
.swatch-btn.on i { border-color: var(--text); }
.swatch-btn span {
  display: block; font-size: 9.5px; color: var(--text-faint); margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.swatch-btn.on span { color: var(--text); }

.switch.is-locked { opacity: .4; }

/* ============================= alarms ============================== */

.alarm-row {
  display: flex; align-items: center; gap: var(--s3);
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r); padding: var(--s3) var(--s4);
}
.alarm-row + .alarm-row { margin-top: 6px; }
.alarm-row.off { opacity: .5; }
.ar-main { flex: 1; min-width: 0; }
.ar-time { font-size: 25px; font-weight: 300; letter-spacing: -.03em; line-height: 1.1; }
.ar-label { font-size: 13.5px; margin-top: 1px; }
.ar-days { display: flex; align-items: center; gap: 3px; margin-top: 5px; flex-wrap: wrap; }
.ar-days > span {
  font-size: 10px; font-weight: 600; color: var(--text-faint);
  width: 15px; text-align: center;
}
.ar-days > span.on { color: var(--accent); }
.ar-hard, .ar-src {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 9.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  border-radius: 3px; padding: 1px 5px; margin-left: 5px; width: auto !important;
}
.ar-hard { color: var(--alert); border: 1px solid rgba(224,96,63,.4); }
.ar-src  { color: var(--text-faint); border: 1px solid var(--line); }

.nextlist { margin-top: var(--s4); border-top: 1px solid var(--line-soft); padding-top: var(--s3); }
.nextlist > div {
  display: flex; align-items: baseline; gap: var(--s2);
  font-size: 13px; color: var(--text-dim); padding: 3px 0;
}
.nextlist > div > span:first-child { color: var(--text); min-width: 46px; }
.nextlist b { margin-left: auto; font-weight: 450; color: var(--text-faint); font-size: 12px; }

/* ========================== health & gym =========================== */

.hd { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.hd-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); }
.hd-value { font-size: 34px; font-weight: 300; letter-spacing: -.03em; line-height: 1.1; margin-top: 4px; }
.hd-value .unit { font-size: 15px; font-weight: 450; color: var(--text-dim); margin-left: 5px; letter-spacing: 0; }
.hd-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }

.spark { width: 100%; height: 72px; display: block; margin: var(--s4) 0 var(--s2); }

.hd-row { display: flex; border-top: 1px solid var(--line-soft); margin-top: var(--s3); }
.hd-row > div { flex: 1; padding-top: var(--s3); text-align: center; position: relative; }
.hd-row > div + div::before {
  content: ""; position: absolute; left: 0; top: 40%; bottom: 10%; width: 1px; background: var(--line-soft);
}
.hd-row span { display: block; font-size: 11px; color: var(--text-faint); margin-bottom: 3px; }

.delta { font-size: 14px; font-weight: 500; }
.delta.up   { color: var(--warn); }
.delta.down { color: var(--good); }
.delta.flat { color: var(--text-dim); }

.card.mini { padding: var(--s4); }
.mini-value { font-size: 24px; font-weight: 400; letter-spacing: -.02em; margin-top: 5px; }
.mini-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.mini-edit { font-size: 12.5px; color: var(--accent); margin-top: 6px; }

.stepper { display: flex; align-items: center; gap: var(--s3); flex: none; }
.stepper button {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface-2);
  display: grid; place-items: center; color: var(--text-dim);
}
.stepper button:active { background: var(--surface-3); }
.stepper b { min-width: 22px; text-align: center; font-size: 17px; font-weight: 550; }

.volbars { display: flex; gap: 6px; align-items: end; height: 76px; margin-top: var(--s4); }
.volbar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.volbar > i { display: block; border-radius: 3px; background: var(--c-gym); opacity: .85; min-height: 3px; }
.volbar span { text-align: center; font-size: 10.5px; color: var(--text-faint); margin-top: 5px; }

.splitbar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface-3); }
.splitbar > i { display: block; height: 100%; }
.splitkey { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); margin-top: var(--s4); }
.splitkey span { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); }
.splitkey i { width: 8px; height: 8px; border-radius: 2px; display: block; }
.splitkey b { color: var(--text); font-weight: 550; }

.routine {
  display: flex; align-items: center; gap: var(--s3);
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r); padding: var(--s3) var(--s4);
}
.routine + .routine { margin-top: 6px; }
.rt-main { flex: 1; min-width: 0; }
.rt-name { font-size: 15px; font-weight: 550; }
.rt-sub { font-size: 12px; color: var(--text-faint); margin-top: 1px; }
.rt-edit { color: var(--text-faint); padding: 8px; display: grid; place-items: center; }

.linkbtn {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--accent); font-size: 13px; font-weight: 500;
  padding: 8px 0; text-transform: none; letter-spacing: 0;
}

/* set logger */
.ex { border: 1px solid var(--line-soft); border-radius: var(--r); padding: var(--s3) var(--s4) var(--s2); margin-bottom: var(--s2); background: var(--surface); }
.ex-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s2); }
.ex-name { font-size: 14.5px; font-weight: 550; }
.ex-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }
.ex-del { color: var(--text-faint); padding: 4px 2px 4px 10px; }
.setgrid { display: grid; grid-template-columns: 24px 1fr 1fr 38px; gap: 6px; align-items: center; margin-top: var(--s3); }
.sg-tick {
  width: 34px; height: 34px; border-radius: 9px;
  border: 1.5px solid var(--line); background: var(--surface-2);
  color: transparent; display: grid; place-items: center; justify-self: end;
  transition: background .14s var(--ease), color .14s var(--ease), border-color .14s var(--ease);
}
.sg-tick.on { background: var(--good); border-color: var(--good); color: #0c0e11; }
.sg-tick:active { transform: scale(.92); }
.ex-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.linkbtn.muted { color: var(--text-faint); }

/* rest timer: pinned above the sheet, because scrolling the exercise list
   must not scroll away the only thing you are watching */
#rest {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--safe-b) + 0px);
  z-index: 55;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  padding: 0 var(--s5) calc(var(--s3) + var(--safe-b));
}
.rest-bar { height: 3px; background: var(--surface-3); margin: 0 calc(var(--s5) * -1); }
.rest-bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s linear; }
.rest-row { display: flex; align-items: center; gap: var(--s3); padding-top: var(--s3); }
.rest-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); }
.rest-time { flex: 1; font-size: 22px; font-weight: 400; letter-spacing: -.02em; }
.rest-btn {
  font-size: 13px; color: var(--text-dim); padding: 8px 11px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
}
.rest-btn:active { background: var(--surface-3); }
#rest.done { background: rgba(63, 185, 80, .14); }
#rest.done .rest-time { color: var(--good); }
#rest.done .rest-bar > i { background: var(--good); }
.sg-h { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; text-align: center; }
.sg-n { font-size: 12.5px; color: var(--text-faint); text-align: center; }
.sg-in {
  width: 100%; padding: 9px 8px; text-align: center;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); outline: none; font-size: 15px;
}
.sg-in:focus { border-color: var(--accent); }
.sg-del { color: var(--text-faint); display: grid; place-items: center; height: 34px; }
.setspec {
  width: 46px; padding: 7px 4px; text-align: center; flex: none;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); outline: none; font-size: 14px;
}

.qr-card { background: #fff; border-radius: var(--r); padding: var(--s4); display: grid; place-items: center; }
.qr-card img { display: block; width: 100%; max-width: 260px; height: auto; image-rendering: pixelated; }

/* ---------------------- body composition + photos ------------------- */

.comp { display: flex; }
.comp > div { flex: 1; text-align: center; position: relative; }
.comp > div + div::before {
  content: ""; position: absolute; left: 0; top: 15%; bottom: 15%; width: 1px; background: var(--line-soft);
}
.comp span { display: block; font-size: 11px; color: var(--text-faint); }
.comp b { display: block; font-size: 22px; font-weight: 500; letter-spacing: -.02em; margin-top: 3px; }
.comp b em { font-style: normal; font-size: 12px; font-weight: 450; color: var(--text-dim); margin-left: 2px; }

.compbar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin-top: var(--s4); }
.compbar > i { display: block; height: 100%; }

.photostrip { display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.photostrip::-webkit-scrollbar { display: none; }
.photo {
  flex: none; width: 96px; text-align: left;
  border: 1px solid var(--line-soft); border-radius: var(--r);
  overflow: hidden; background: var(--surface-2);
}
.photo img { display: block; width: 100%; height: 128px; object-fit: cover; background: var(--surface-3); }
.photo span {
  display: block; padding: 6px 8px; font-size: 10.5px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.photo-full { border-radius: var(--r); overflow: hidden; background: var(--surface-2); }
.photo-full img { display: block; width: 100%; max-height: 58dvh; object-fit: contain; }

label.btn { cursor: pointer; }

/* ------------------------- the body model --------------------------- */

.bodycard { padding: var(--s5) var(--s4); }

/* figure left, headline numbers right - the figure alone is decoration,
   the numbers alone are a spreadsheet */
.bodygrid { display: grid; grid-template-columns: 1fr 1.15fr; gap: var(--s4); align-items: center; }
.bg-figure { min-width: 0; }
.bg-stat { min-width: 0; }
.bodymodel { display: block; width: 100%; max-width: 150px; margin: 0 auto; height: auto; }

.bm-empty-fill { fill: var(--surface-3); }
.bm-fill { fill: var(--accent); }
.bm-level { stroke: var(--text); stroke-width: 1.4; stroke-dasharray: 4 3; opacity: .55; }

.bm-part { cursor: pointer; }
.bm-hit { fill: transparent; }
.bm-ring { fill: none; stroke: transparent; stroke-width: 2; }
.bm-dot { fill: var(--text-faint); stroke: var(--bg); stroke-width: 1.5; }
.bm-part.set   .bm-dot { fill: #fff; }
.bm-part.stale .bm-dot { fill: var(--warn); }
.bm-part.empty .bm-dot { fill: var(--bg); stroke: var(--text-faint); stroke-width: 1.5; }
.bm-part.active .bm-ring { stroke: #fff; }
.bm-part:active .bm-dot { r: 6; }

.bh-pct {
  font-size: 52px; font-weight: 250; letter-spacing: -.04em; line-height: 1;
  color: var(--accent);
}
.bh-pct em { font-style: normal; font-size: 21px; font-weight: 400; margin-left: 1px; }
.bh-cap {
  font-size: 10.5px; line-height: 1.35; color: var(--text-faint);
  letter-spacing: .07em; text-transform: uppercase; margin-top: 6px;
}
.bg-nums { margin-top: var(--s4); border-top: 1px solid var(--line-soft); padding-top: var(--s3); }
.bg-nums > div { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); padding: 3px 0; }
.bg-nums span { font-size: 11.5px; color: var(--text-faint); }
.bg-nums b { font-size: 13.5px; font-weight: 550; }

.bm-legend {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: var(--s2) var(--s4); margin-top: var(--s4);
  padding-top: var(--s3); border-top: 1px solid var(--line-soft);
  font-size: 11px; color: var(--text-faint);
}
.bm-legend span { display: inline-flex; align-items: center; gap: 5px; }
.bm-legend i { width: 8px; height: 8px; border-radius: 50%; display: block; }
.bm-legend i.set { background: #fff; }
.bm-legend i.stale { background: var(--warn); }
.bm-legend i.empty { border: 1px solid var(--text-faint); }

/* A card that is really a button: the app should never say "needs your age"
   without giving you somewhere to put it. */
.setupcard {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; text-align: left; margin-bottom: var(--s3);
  border-color: var(--accent); background: var(--accent-bg);
  color: var(--accent);
}
.setupcard:active { filter: brightness(1.15); }
.su-main { flex: 1; min-width: 0; }
.su-title { display: flex; align-items: center; gap: 7px; font-size: 14.5px; font-weight: 600; color: var(--text); }
.su-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 4px; line-height: 1.45; }

.empty.as-button { width: 100%; display: block; }
.em-cta { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); margin-top: 8px; }

/* ------------------------- area breakdown --------------------------- */

.areagrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s2); }
.area {
  text-align: left; padding: var(--s3) var(--s4) 13px;
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r);
}
.area:active { background: var(--surface-2); }
.ar-name {
  font-size: 11px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-faint);
  display: flex; align-items: baseline; gap: 5px;
}
.ar-name i { font-style: normal; font-size: 8.5px; opacity: .7; letter-spacing: .04em; }
.ar-now { font-size: 22px; font-weight: 500; letter-spacing: -.02em; margin-top: 3px; }
.ar-now em { font-style: normal; font-size: 11px; font-weight: 450; color: var(--text-dim); margin-left: 2px; }
.ar-bar { height: 3px; border-radius: 2px; background: var(--surface-3); margin-top: 9px; overflow: hidden; }
.ar-bar > i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.ar-goal { font-size: 11px; color: var(--text-faint); margin-top: 5px; }
.area.is-stale .ar-now { color: var(--warn); }
.area.is-empty { border-style: dashed; }
.area.is-empty .ar-now { font-size: 13px; color: var(--text-faint); font-weight: 450; margin-top: 6px; }
.ar-add { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--accent); margin-top: 7px; }

/* ---------------------- potential meter ----------------------------- */

.potbar {
  position: relative;
  height: 8px; border-radius: 4px;
  background: var(--surface-3);
  margin-top: var(--s4);
  overflow: visible;
}
.potbar > i {
  display: block; height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--good));
  transition: width .5s var(--ease);
}
.pot-cap {
  position: absolute; top: -4px;
  width: 2px; height: 16px; border-radius: 1px;
  background: var(--text); transform: translateX(-1px);
}
.potscale {
  display: flex; justify-content: space-between;
  margin-top: 9px; font-size: 11px; color: var(--text-faint);
}

/* ======================== camera / light meter ===================== */

#camera { position: fixed; inset: 0; z-index: 85; background: #000; }
#camera video { width: 100%; height: 100%; object-fit: cover; }
.cam-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: calc(var(--safe-t) + var(--s6)) var(--s5) calc(var(--safe-b) + var(--s6));
  background: linear-gradient(rgba(0,0,0,.7), transparent 24%, transparent 46%, rgba(0,0,0,.82));
  text-align: center;
}
.cam-top { max-width: 340px; margin-inline: auto; }
.cam-title { font-size: 18px; font-weight: 600; letter-spacing: -.015em; }
.cam-hint { font-size: 13px; color: rgba(255,255,255,.72); margin-top: 6px; line-height: 1.45; }

.cam-meter { max-width: 340px; width: 100%; margin-inline: auto; }
.cm-scale {
  position: relative; height: 10px; border-radius: 5px;
  background: rgba(255,255,255,.16); overflow: hidden;
}
.cm-fill { height: 100%; width: 0; background: rgba(255,255,255,.72); transition: width .12s linear; }
.cm-fill.over { background: var(--good); }
.cm-target {
  position: absolute; top: -4px; bottom: -4px; width: 2px;
  background: var(--good); border-radius: 1px;
}
.cm-read { display: flex; align-items: baseline; justify-content: center; gap: 6px; margin-top: var(--s3); }
.cm-read b { font-size: 30px; font-weight: 300; letter-spacing: -.03em; }
.cm-read span { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.6); }
.cm-tint { display: inline-flex; align-items: center; gap: 5px; }
.cm-tint i { width: 10px; height: 10px; border-radius: 50%; display: block; border: 1px solid rgba(255,255,255,.35); }
.cm-tint em { font-style: normal; }

.cam-ringing {
  display: inline-block;
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--alert); border: 1px solid rgba(224,96,63,.5);
  border-radius: 999px; padding: 4px 11px; margin-bottom: var(--s3);
}
.cam-status { font-size: 13.5px; color: rgba(255,255,255,.85); margin-bottom: var(--s3); }
.cam-bottom .btn { max-width: 340px; margin-inline: auto; }
.cam-bottom .two { max-width: 340px; margin: 0 auto var(--s2); }

/* alarm: locked-out state */
.a-locked {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 12px; color: var(--text-faint); margin-top: var(--s1);
}
.a-override {
  color: var(--text-faint); font-size: 12.5px; padding: var(--s3);
  margin-top: var(--s2); text-decoration: underline; text-underline-offset: 3px;
}
.a-override.holding { color: var(--alert); text-decoration: none; }

/* ---- topbar right cluster ---- */
.topbar-right { display: flex; align-items: center; gap: var(--s2); }
.iconbtn {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  display: grid; place-items: center; color: var(--text-dim);
  border: 1px solid transparent;
}
.iconbtn:active { background: var(--surface-2); }

/* ============================ focus timer =========================== */

#focus {
  position: fixed; inset: 0; z-index: 75;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--safe-t) + var(--s6)) var(--s6) calc(var(--safe-b) + var(--s6));
  animation: fade .18s var(--ease);
}
.fc-exit {
  position: absolute; top: calc(var(--safe-t) + var(--s3)); right: var(--s4);
  color: var(--text-faint); font-size: 13.5px; padding: 10px 12px;
}
.fc-ring { position: relative; width: min(70vw, 268px); aspect-ratio: 1; }
.fc-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.fc-ring circle { fill: none; stroke-width: 3; stroke-linecap: round; }
.fc-track { stroke: var(--surface-3); }
.fc-fill  { stroke: var(--accent); transition: stroke-dashoffset .9s linear; }
.fc-time { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; }
.fc-time b {
  font-size: clamp(46px, 15vw, 62px);
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.03em;
  line-height: 1;
}
.fc-time span { color: var(--text-dim); font-size: 13px; text-align: center; padding: 0 26px; }
.fc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); width: 100%; max-width: 320px; margin-top: var(--s7); }
.fc-note { color: var(--text-faint); font-size: 12px; margin-top: var(--s4); font-variant-numeric: tabular-nums; }

/* The screen strobe that rides along with the alarm. Kept to a colour wash
   rather than black-to-white: still impossible to ignore, far less likely to
   trigger anyone photosensitive. */
body.alarm-flash #alarm { background: #2a0d06; }
body.alarm-flash .alarm-mark { background: rgba(224, 96, 63, .22); }
/* ===================== small phones (iPhone SE) ==================== */
/*
 * 375 x 667 with no safe-area insets. The previous version of this block
 * shrank type, padding and the spacing scale together, which made a busy
 * screen feel more crowded rather than less. Scrolling is free; legibility
 * is not. So only the things that genuinely overflow are touched - the
 * six-up tab bar, and display numerals big enough to wrap.
 */
@media (max-width: 380px) {
  .view { padding-left: var(--s4); padding-right: var(--s4); }
  .topbar { padding-left: var(--s4); padding-right: var(--s4); }
  .card { padding: var(--s4); }
  .card.tight { padding: 2px var(--s4); }

  /* six tabs leaves about 62px each */
  .tab { font-size: 9px; letter-spacing: 0; }
  .tab .ic { width: 18px; height: 18px; }

  /* display numerals that would otherwise wrap */
  .wh-time { font-size: 44px; }
  .hd-value { font-size: 30px; }
  .bh-pct { font-size: 44px; }
  .kc-ring { width: 108px; }
  .kc-centre b { font-size: 25px; }
  .rank-hero svg { width: 82px; height: 82px; }

  /* the rank chip is the first thing to go when the bar gets tight */
  .rank-chip { display: none; }

  .ach-ds { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  body.alarm-flash #alarm { background: var(--bg); }
}

/* ============================== alarm =============================== */

#alarm {
  position: fixed; inset: 0; z-index: 80;
  background: var(--bg);
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center;
  padding: calc(var(--safe-t) + var(--s7)) var(--s6) calc(var(--safe-b) + var(--s6));
  animation: fade .18s var(--ease);
}
.alarm-mark {
  width: 62px; height: 62px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--alert);
  border: 1px solid rgba(224, 96, 63, .45);
  margin-bottom: var(--s5);
  position: relative;
}
.alarm-mark .ic { width: 26px; height: 26px; }
.alarm-mark::after {
  content: "";
  position: absolute; inset: -1px;
  border-radius: 50%;
  border: 1px solid var(--alert);
  animation: ripple 2s var(--ease) infinite;
}
@keyframes ripple {
  0%   { transform: scale(1);   opacity: .5 }
  70%  { transform: scale(1.5); opacity: 0 }
  100% { opacity: 0 }
}
#alarm .a-kicker { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); }
#alarm h2 { margin: var(--s2) 0 5px; font-size: 26px; font-weight: 600; letter-spacing: -.025em; line-height: 1.15; }
#alarm .a-sub { color: var(--text-dim); font-size: 13.5px; }
#alarm .a-note {
  margin-top: var(--s4); font-size: 13px; color: var(--text-dim);
  border: 1px solid var(--line); padding: 9px 13px; border-radius: var(--r); max-width: 320px;
}
#alarm .a-time { font-size: 13px; margin-top: var(--s5); color: var(--text-faint); font-variant-numeric: tabular-nums; }
.a-math { margin-top: var(--s6); width: 100%; max-width: 280px; }
.a-math-q { font-size: 13px; color: var(--text-dim); margin-bottom: var(--s2); }
.a-math input {
  width: 100%; padding: 13px; text-align: center; font-size: 20px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  outline: none; color: var(--text); font-variant-numeric: tabular-nums;
}
.a-math input:focus { border-color: var(--alert); }
.alarm-actions { width: 100%; max-width: 320px; margin-top: var(--s7); display: grid; gap: var(--s2); }

/* =========================== alarm clock ============================ */

#clockmode {
  position: fixed; inset: 0; z-index: 70;
  background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--safe-t) + var(--s5)) var(--s5) calc(var(--safe-b) + var(--s5));
}
#clockmode .big {
  font-size: clamp(66px, 22vw, 124px);
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.04em;
  line-height: 1;
}
#clockmode .cm-date { color: var(--text-faint); font-size: 12.5px; letter-spacing: .12em; text-transform: uppercase; margin-top: var(--s3); }
#clockmode .cm-next { margin-top: var(--s7); color: var(--text-faint); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; text-align: center; }
#clockmode .cm-next b { display: block; color: var(--text-dim); font-size: 16px; font-weight: 450; margin-top: 6px; letter-spacing: -.01em; text-transform: none; }
#clockmode .cm-streak { margin-top: var(--s5); color: var(--text-faint); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
#clockmode .cm-streak .ic { width: 13px; height: 13px; }
#clockmode .cm-exit { position: absolute; top: calc(var(--safe-t) + var(--s3)); right: var(--s4); color: #3a4048; font-size: 13px; padding: 10px 12px; }

/* =============================== toast ============================== */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar) + var(--safe-b) + var(--s4));
  transform: translateX(-50%) translateY(10px);
  z-index: 90;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 10px 16px;
  border-radius: var(--r);
  font-size: 13.5px;
  font-weight: 450;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s var(--ease), transform .18s var(--ease);
  max-width: 88vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  *, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
