/* Reset, shell, shared content patterns, sheets, toasts. Screen CSS lives in css/screens/. */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }   /* no sideways jump when a sheet locks the scroll */
/* keyboard focus scrolls a control clear of the corner on top and the floating tab bar below, never under them */
html { scroll-padding-top: calc(var(--safe-t) + 72px); scroll-padding-bottom: var(--bottom-space); }
body {
  font: 400 var(--t-body)/1.45 var(--f-sans);
  color: var(--fg);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
  caret-color: var(--accent);
  overflow-x: hidden;
  overscroll-behavior-y: none;
}
/* The purchase screen stays visible while the tracker checks the account. */
.tracker-access { position: relative; z-index: 1; display: grid; align-content: center; justify-items: start; gap: 16px; min-height: 100dvh; max-width: 560px; margin: auto; padding: 24px; }
.tracker-access h1 { font: 600 clamp(24px, 7vw, 40px)/1.15 var(--f-sans); }
.tracker-access__actions { display: flex; gap: 8px; flex-wrap: wrap; }
body[data-tracker-locked] > :not(.tracker-access):not(.silk):not(.silk-veil) { display: none; }
::selection { background: var(--accent); color: #fff; }
/* Focus rings: one look everywhere. Drawn inside the element (never past its edges) and rounded by the element's own
   radius; a square see-through row gets a soft 10px radius while it shows the ring (app.js marks it data-ring-r).
   A see-through row or link whose text or icon runs right up to its own edge (no padding of its own) would have the
   ring line cut through the first letter, so app.js marks it data-ring-out: its ring floats 3px outside instead,
   in the empty space around it (never on the content, never under a clipping edge: app.js checks there is room).
   On a filled accent button the ring turns white so it still shows. */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ring, var(--accent)); outline-offset: -2px; }
[data-ring-r]:focus-visible { border-radius: 10px; }
[data-ring-out]:focus-visible { outline-offset: 3px !important; }   /* wins over a screen's own inside offset: only set where inside would cut the content */
.btn--accent:focus-visible, .glass--accent:focus-visible, .glass--cta:focus-visible { --ring: rgb(255 255 255 / 0.92); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: none; }   /* fields show their own inner accent edge */
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
img, svg { display: block; }
a { color: inherit; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- silk background ---------- */
.silk { position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%; pointer-events: none; }
.silk-veil { position: fixed; inset: 0; z-index: 0; pointer-events: none; background: radial-gradient(120% 80% at 50% 0%, transparent 40%, rgb(var(--bg-rgb) / 0.55)); }

/* ---------- shell ---------- */
.app { position: relative; z-index: 1; min-height: 100dvh; }
.screen {
  width: 100%; max-width: var(--content-max); margin: 0 auto;
  padding: calc(var(--safe-t) + 18px) max(var(--pad), var(--safe-r)) var(--bottom-space) max(var(--pad), var(--safe-l));
  animation: screen-in 360ms var(--ease-out) both;
  overflow-x: clip;   /* decorative light (stone glow) never causes sideways scrolling */
}
.screen--wide { max-width: var(--wide-max); }
.screen--full { max-width: none; padding: 0; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }

/* top bar used by every screen: title left, actions right */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin-bottom: 20px; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }
.title { font-size: var(--t-title); line-height: 1.02; font-weight: 700; letter-spacing: -0.035em; text-wrap: balance; }
.title em, .serif { font: inherit; letter-spacing: inherit; }
/* The serif italic is reserved for two identity moments: Today's "Day N of 90" and Setup's "A rough stone." */
.serif-moment { font-family: var(--f-serif); font-style: italic; font-weight: 400; letter-spacing: -0.01em; }
.eyebrowless { margin-top: 6px; color: var(--muted); font-size: var(--t-small); }

/* pill used in headers (score, sparks) */
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 16px; border: 0; border-radius: var(--r-pill);
  font: 600 15px/1 var(--f-sans); letter-spacing: -0.01em; cursor: pointer; white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease-out);
}
.pill:active { transform: scale(0.95); }
.pill svg { width: 16px; height: 16px; }
.pill small { font-size: 12px; font-weight: 500; color: var(--muted); }

/* ---------- content patterns (not glass) ---------- */
.section { margin-top: 36px; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.section__title { font-size: var(--t-h2); font-weight: 650; letter-spacing: -0.025em; }

.section__meta { font-size: var(--t-small); color: var(--muted); }
.card { background: rgb(var(--fg-rgb) / 0.04); border-radius: var(--r-l); padding: var(--s5); box-shadow: inset 0 0 0 1px var(--line); }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); min-height: 56px; }
.row__main { flex: 1; min-width: 0; }
.row__title { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; overflow-wrap: anywhere; }
.row__sub { margin-top: 2px; font-size: var(--t-small); color: var(--muted); overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num { font-variant-numeric: tabular-nums; }
.label { font-size: 12px; font-weight: 500; letter-spacing: 0.01em; color: var(--muted); }
.big-num { font-size: 44px; font-weight: 700; letter-spacing: -0.045em; line-height: 1; }
.divider { height: 1px; background: var(--line); border: 0; margin: 20px 0; }
.stack > * + * { margin-top: var(--s3); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
@media (max-width: 520px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* bars */
.bar { height: 8px; border-radius: var(--r-pill); background: rgb(var(--fg-rgb) / 0.1); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--fg); transform-origin: left; transition: width 600ms var(--ease-out); }
.bar--accent > i { background: var(--accent); }
.bar--over > i { background: var(--orange); }

/* dots (the site's signature) */
.dots { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1.5px var(--faint); }
.dot.on { background: var(--fg); box-shadow: none; }
.dot.accent { background: var(--accent); box-shadow: none; }

/* ---------- form fields ---------- */
.field { display: block; }
.field > span { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 500; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 12px 16px;
  border: 0; border-radius: var(--r-m);
  background: rgb(var(--fg-rgb) / 0.06);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 16px; font-weight: 500; letter-spacing: -0.01em; color: var(--fg);
  outline: none;
  transition: box-shadow var(--dur) var(--ease-out), background var(--dur);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { box-shadow: inset 0 0 0 2px var(--accent); background: rgb(var(--fg-rgb) / 0.08); }
.input[aria-invalid="true"] { box-shadow: inset 0 0 0 1.5px var(--red); }
.textarea { min-height: 96px; resize: vertical; line-height: 1.4; }
.input--bare { background: none; box-shadow: none; padding: 8px 0; border-radius: 0; border-bottom: 1px solid var(--line); }
.input--bare:focus { background: none; box-shadow: none; border-bottom-color: var(--fg); }
input[type="time"].input { font-variant-numeric: tabular-nums; }
input[type="time"]::-webkit-calendar-picker-indicator { filter: invert(var(--invert, 1)); opacity: 0.5; }
:root[data-theme="light"] { --invert: 0; }
.err { margin-top: 6px; font-size: 12px; color: var(--red); }

/* ---------- sheet (ui/sheet.js) ---------- */
.scrim { position: fixed; inset: 0; z-index: 80; background: var(--scrim); opacity: 0; transition: opacity 280ms var(--ease-out); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.scrim.is-open { opacity: 1; }
.sheet {
  position: fixed; z-index: 80; /* paired scrims and sheets stack in DOM order */
  background: rgb(var(--sheet-rgb) / 0.9) !important;
  -webkit-backdrop-filter: blur(40px) saturate(160%) !important;
  backdrop-filter: blur(40px) saturate(160%) !important;
  left: max(8px, var(--safe-l)); right: max(8px, var(--safe-r)); bottom: calc(8px + var(--safe-b));
  max-height: calc(100dvh - var(--safe-t) - 40px);
  display: flex; flex-direction: column;
  border-radius: var(--r-xl);
  transform: translateY(calc(100% + 40px));
  transition: transform var(--spring-dur) var(--spring), filter var(--spring-dur) var(--spring);
  outline: none;
}
.sheet.is-open { transform: none; }
.sheet__grab { width: 40px; height: 5px; border-radius: 5px; background: var(--line-strong); margin: 8px auto 0; flex: none; }
.sheet__grab, .sheet__head { touch-action: none; }   /* the drag-down-to-close gesture is ours, not the page's scroll */
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 6px 22px; flex: none; }
.sheet__title { font-size: var(--t-h2); font-weight: 700; letter-spacing: -0.03em; }
.sheet__title em { font: inherit; }
.sheet__body { padding: 8px 22px 24px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
@media (min-width: 720px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: min(560px, calc(100vw - 48px)); max-height: min(780px, calc(100dvh - 80px)); transform: translate(-50%, -46%) scale(0.94); opacity: 0; filter: blur(8px); transition: transform var(--spring-dur) var(--spring), opacity 220ms var(--ease-out), filter var(--spring-dur) var(--spring); }
  .sheet.is-open { transform: translate(-50%, -50%); opacity: 1; filter: none; }
  .sheet--wide { width: min(760px, calc(100vw - 48px)); }
  .sheet__grab { display: none; }
}

/* ---------- shared components (ui/shared.js) ---------- */
.water__top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-size: var(--t-small); }
.water__label { color: var(--muted); font-weight: 500; }
.water__n { font-weight: 600; font-variant-numeric: tabular-nums; }
.water__row { display: grid; grid-template-columns: repeat(auto-fill, minmax(22px, 1fr)); gap: 6px; max-width: 420px; }
.water__glass { height: 30px; border: 0; padding: 0; cursor: pointer; border-radius: 4px 4px 7px 7px; background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-strong); transition: background var(--dur) var(--ease-out), box-shadow var(--dur), transform var(--dur-fast) var(--ease-out); }
.water__glass[aria-pressed="true"] { background: var(--fg); box-shadow: none; }
.water__glass:active { transform: scale(0.9); }
.water__glass.is-extra:not([aria-pressed="true"]) { box-shadow: inset 0 0 0 1.5px var(--line); }
.notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.notice__text { flex: 1 1 220px; font-size: 15px; font-weight: 500; letter-spacing: -0.01em; }
.notice__actions { display: flex; align-items: center; gap: 8px; }
.notice__x { width: 34px; height: 34px; border: 0; border-radius: 50%; background: none; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
@media (hover: hover) { .notice__x:hover { background: var(--hover); color: var(--fg); } }
.notice__x svg { width: 16px; height: 16px; }
.reward { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.reward__price { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.reward__name { font-size: 16px; font-weight: 550; overflow-wrap: anywhere; }
.reward__actions { display: flex; align-items: center; gap: 6px; }
.reward__need { font-size: var(--t-small); color: var(--muted); white-space: nowrap; }

/* ---------- toast (ui/toast.js) ---------- */
.toasts { position: fixed; z-index: 90; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--tabbar-gap) + var(--safe-b) + 14px); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 14px;
  min-height: 48px; padding: 6px 8px 6px 20px; border-radius: var(--r-pill);
  font-size: 14px; font-weight: 500; letter-spacing: -0.01em;
  max-width: 520px;
  animation: toast-in var(--spring-dur) var(--spring) both;
}
.toast.is-leaving { animation: toast-out 220ms var(--ease-out) forwards; }
.toast__undo { min-height: 36px; padding: 0 14px; border: 0; border-radius: var(--r-pill); background: rgb(var(--fg-rgb) / 0.12); color: var(--fg); font: 600 13px var(--f-sans); cursor: pointer; }
.toast:not(:has(.toast__undo)) { padding-right: 20px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.92); filter: blur(6px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(0.96); filter: blur(4px); } }
body.focus-mode .toasts, body[data-screen="setup"] .toasts { bottom: calc(24px + var(--safe-b)); }   /* no tab bar to clear */

/* ---------- empty / locked ---------- */
.empty { padding: 28px 0; text-align: left; }
.empty h3 { font-size: 19px; font-weight: 650; letter-spacing: -0.02em; }
.empty p { margin-top: 6px; color: var(--muted); max-width: 46ch; }
.empty .btn, .empty .gbtn { margin-top: 14px; }
.locked { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: var(--t-small); }
.locked svg { width: 16px; height: 16px; flex: none; }

@media (max-width: 420px) { :root { --pad: 16px; --t-title: 30px; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}
/* reduce motion gives every element a 1 ms transition: a label then still had its old size when the tab bar measured it (js/app.js fitTabs) */
.tabbar .tab > span { transition: none !important; }

/* scroll-edge: content fades out under the floating tab bar instead of colliding with it */
body::after { content: ""; position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + var(--tabbar-gap) + var(--safe-b) + 40px); z-index: 39; pointer-events: none;
  background: linear-gradient(to top, rgb(var(--bg-rgb)) 0%, rgb(var(--bg-rgb)) calc(100% - 40px), rgb(var(--bg-rgb) / 0) 100%);
  transition: opacity var(--dur); }
body[data-screen="setup"]::after, body.focus-mode::after { opacity: 0; }

/* with a sheet open, toasts sit at the top so they never cover the sheet's buttons */
body.sheet-open .toasts { bottom: auto; top: calc(var(--safe-t) + 12px); z-index: 95; }

/* with a sheet open the top 76px stay free for the single toast */
body.sheet-open .sheet { max-height: calc(100dvh - var(--safe-t) - 84px); }
@media (min-width: 720px) { body.sheet-open .sheet { max-height: min(780px, calc(100dvh - 2 * 76px)); } }
body.sheet-open .toasts .toast:not(:last-child) { display: none; }

.toast { max-width: min(520px, calc(100vw - 32px)); }
.toast > span { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; min-width: 0; overflow-wrap: anywhere; }

/* Arabic: the interface mirrors, charts keep their left-to-right axes (labels stay inside the plot) */
[dir="rtl"] svg { direction: ltr; }

/* ---------- corner: fire + sparks capsule and the gear, fixed top-right on every screen (app.js) ----------
   Placed by the shell only (#app-corner wins over any screen rule), so it never moves between screens.
   Phone: the content edge. Desktop: the edge of the widest layout (Today's), the same on every screen. */
.screen { padding-top: calc(var(--safe-t) + 72px); }       /* large titles sit under the corner, as on iOS */
body[data-screen="setup"] .screen { padding-top: calc(var(--safe-t) + 18px); }
:root { --corner-top: calc(var(--safe-t) + 14px); --corner-right: max(var(--pad), env(safe-area-inset-right, 0px)); --corner-h: 42px; }
@media (min-width: 1024px) { :root { --corner-right: max(calc(2 * var(--pad)), calc((100vw - 1560px) / 2 + var(--pad))); } }
#app-corner {
  position: fixed; z-index: 40; top: var(--corner-top); right: var(--corner-right); left: auto;
  display: flex; align-items: center; gap: 6px; margin: 0;
}
.corner[hidden] { display: none !important; }
.corner__group { display: flex; align-items: center; height: var(--corner-h); padding: 3px; border-radius: var(--r-pill); }
.corner__btn {
  display: inline-flex; align-items: center; gap: 6px; height: calc(var(--corner-h) - 6px); padding: 0 13px 0 12px;
  border: 0; border-radius: var(--r-pill); background: transparent; color: var(--fg); cursor: pointer; white-space: nowrap;
  font: 600 15px/1 var(--f-sans); letter-spacing: -0.01em; -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
@media (hover: hover) { .corner__btn:hover { background: var(--hover); } }
.corner__btn:active { transform: scale(0.94); background: var(--press); }
.corner__sep { flex: none; width: 1px; height: 18px; background: var(--line-strong); }
.corner__num { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.corner__spark { font-size: 15px; line-height: 1; color: var(--spark, var(--fg)); display: inline-flex; }   /* v6: the sparks colour (Settings) */
.corner__sparks small { font-size: 12px; font-weight: 500; color: var(--muted); }
.corner__sparks.is-neg .corner__num { color: var(--orange); }
.corner__fire { gap: 5px; padding: 0 11px 0 10px; }
.corner__flame { display: inline-flex; color: var(--faint); transition: color var(--dur) var(--ease-out), filter var(--dur) var(--ease-out); }
.corner__flame .ico { width: 18px; height: 18px; stroke-width: 1.8; }
.corner__flame .ico path { fill: transparent; transition: fill var(--dur) var(--ease-out); }
.corner__fnum { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--muted); min-width: 1ch; text-align: center; transition: color var(--dur) var(--ease-out); }
.corner__fire.is-lit .corner__flame { color: var(--fire, var(--orange)); filter: drop-shadow(0 0 6px color-mix(in srgb, var(--fire, var(--orange)) 45%, transparent)); }
.corner__fire.is-lit .corner__flame .ico path { fill: currentColor; }
.corner__fire.is-lit .corner__fnum { color: var(--fg); }
.corner__fire.is-pop .corner__flame { animation: fire-pop 520ms var(--ease-out); }
@keyframes fire-pop { 0% { transform: scale(0.7); } 55% { transform: scale(1.22); } 100% { transform: none; } }
#app-corner .corner__gear { width: var(--corner-h); min-height: var(--corner-h); height: var(--corner-h); padding: 0; }
.corner__gear svg { width: 20px; height: 20px; }
.corner__gear[aria-current] { color: var(--accent); }
body.focus-mode .corner { display: none; }
:root[data-theme="light"] .corner__sep { background: var(--line); }

/* fire sheet (app.js openFire) */
.fire-sheet { display: grid; justify-items: center; text-align: center; padding: 6px 0 4px; text-wrap: balance; }
.fire-sheet__hero { display: flex; align-items: center; justify-content: center; gap: 10px; }
.fire-sheet__flame { display: inline-flex; color: var(--faint); }
.fire-sheet__flame .ico { width: 44px; height: 44px; stroke-width: 1.5; }
.fire-sheet.is-lit .fire-sheet__flame { color: var(--fire, var(--orange)); filter: drop-shadow(0 0 14px color-mix(in srgb, var(--fire, var(--orange)) 45%, transparent)); }
.fire-sheet.is-lit .fire-sheet__flame .ico path { fill: currentColor; }
.fire-sheet__n { font-size: 64px; font-weight: 700; letter-spacing: -0.05em; line-height: 1; font-variant-numeric: tabular-nums; }
.fire-sheet__line { margin-top: 12px; font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.fire-sheet__state { margin-top: 6px; font-size: var(--t-small); color: var(--muted); max-width: 40ch; }
.fire-sheet__how { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); width: 100%; font-size: var(--t-small); line-height: 1.5; color: var(--muted); }

/* a soft fade under the corner, so the floating pills never sit on top of readable text while scrolling */
body::before {
  content: ''; position: fixed; z-index: 35; left: 0; right: 0; top: 0; height: calc(var(--safe-t) + 66px); pointer-events: none;
  background: linear-gradient(rgb(var(--bg-rgb) / 0.92), rgb(var(--bg-rgb) / 0.6) 60%, rgb(var(--bg-rgb) / 0));
}
body[data-screen="setup"]::before, body.focus-mode::before { display: none; }

/* "‹ Back" above the title on screens that are not tabs */
.back-link { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 6px -6px; padding: 6px 8px 6px 4px; border: 0; background: none; color: var(--muted); font: 500 14px var(--f-sans); border-radius: 10px; cursor: pointer; }
@media (hover: hover) { .back-link:hover { color: var(--fg); } }
.back-link .ico { width: 18px; height: 18px; }


/* a filled water glass is the same colour as the ring (Graphite): the ring gets a dark band under it, still inside */
.water__glass[aria-pressed="true"]:focus-visible { outline: 2px solid var(--fg); outline-offset: -2px; box-shadow: inset 0 0 0 4px rgb(var(--bg-rgb)); }
/* a water glass is small to look at but easy to hit: its tap area reaches into the gaps and 7px above and below (44px) */
.water__glass { position: relative; }
.water__glass::after { content: ''; position: absolute; inset: -7px -3px; }
/* a notice's button whose words take two lines on a narrow phone keeps comfortable room inside its pill */
.notice__actions .btn { white-space: normal; text-align: center; line-height: 1.25; min-height: 36px; padding-top: 7px; padding-bottom: 7px; padding-inline: 18px; }
/* a screen title the keyboard was brought to (after a button led to this screen): no ring, it is not a control */
h1[tabindex="-1"]:focus-visible, .title[tabindex="-1"]:focus-visible { outline: none; }
h2[tabindex="-1"]:focus-visible, h3[tabindex="-1"]:focus-visible { outline: none; }
#screen[tabindex="-1"]:focus, #screen[tabindex="-1"]:focus-visible { outline: none; }
/* water (v5): the glasses in the water colour (blue by default, or the app colour), a little larger, with the amount in
   litres and a way to change the number and size of the glasses */
.water { --water: #2d5bff; }
.water__top { align-items: center; gap: 10px; }
.water__label { display: inline-flex; align-items: center; gap: 6px; }
.water__label svg { width: 16px; height: 16px; color: var(--water); fill: color-mix(in srgb, var(--water) 30%, transparent); }
.water__n { margin-left: auto; }
.water__edit { flex: none; display: grid; place-items: center; width: 32px; height: 32px; margin: -6px -6px -6px 0; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.water__edit svg { width: 16px; height: 16px; }
@media (hover: hover) { .water__edit:hover { color: var(--fg); background: var(--hover); } }
.water__row { grid-template-columns: repeat(auto-fill, minmax(26px, 1fr)); gap: 7px; }
.water__glass { height: 34px; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--water) 45%, transparent); }
.water__glass[aria-pressed="true"] { background: var(--water); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.25), 0 4px 12px -6px var(--water); }
.water__glass.is-extra:not([aria-pressed="true"]) { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--water) 22%, transparent); }
.water__glass[aria-pressed="true"]:focus-visible { outline-color: var(--fg); }

/* v5: the app colour (--cta-rgb: blue for Graphite) on the things a person looks at most, not only on big buttons */
.td-plan__check[aria-pressed="true"] .td-token, .td-habit[aria-pressed="true"] .td-token { background: rgb(var(--cta-rgb)) !important; color: #fff !important; box-shadow: 0 3px 10px -4px rgb(var(--cta-rgb) / 0.8) !important; }
.pl-check[aria-pressed="true"] { background: rgb(var(--cta-rgb)) !important; color: #fff; }
.sx-card__icon { background: rgb(var(--cta-rgb) / 0.15) !important; color: rgb(var(--cta-rgb)) !important; }
.fd-macro__bar > i { background: rgb(var(--cta-rgb)) !important; }

/* ---------- v6: every section screen is one centred column on a computer, like Sport ----------
   The same width as Sport (720px of content), centred on the screen, so it lines up with the tab bar and the title
   does not jump sideways between tabs. Phones are unchanged (the column is the screen). Plan, Focus: their own css. */
:root { --col-max: 720px; }
.screen[data-screen="notes"], .screen[data-screen="section"] { max-width: calc(var(--col-max) + 2 * var(--pad)); }
.screen[data-screen="section"] .sc-wrap { max-width: none; }

/* ---------- v6: Today ---------- */
/* a plan added on a day that already counts: one quiet line under the plans (rows.js countedNote) */
[data-screen="today"] .td-plans__counted { margin: 10px 0 2px; font-size: var(--t-small); line-height: 1.4; color: var(--muted); text-wrap: pretty; }
/* Sleep: after "I fell asleep" the fields show tonight; a small caption says so */
[data-screen="today"] .td-night { margin: 2px 0 -8px; font-size: 12px; font-weight: 600; letter-spacing: 0.02em; color: var(--muted); }

/* ---------- v6: the bottom bar that scrolls (settings.tabOverflow 'scroll', app.js renderTabs) ----------
   Every section stays in the bar; it scrolls sideways, half a tab peeks out and soft fades at the edges show there
   is more. The fades go away at the start and at the end. */
.tabbar.is-scroll { padding-left: 5px; padding-right: 5px; }
.tabbar__strip {
  --fl: 26px; --fr: 26px;
  display: flex; align-items: stretch; flex: 1 1 auto; min-width: 0;
  overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scroll-snap-type: x proximity;
  scrollbar-width: none; border-radius: inherit;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--fl), #000 calc(100% - var(--fr)), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 var(--fl), #000 calc(100% - var(--fr)), transparent 100%);
}
.tabbar__strip::-webkit-scrollbar { display: none; }
.tabbar__strip.at-start { --fl: 0px; }
.tabbar__strip.at-end { --fr: 0px; }
[dir="rtl"] .tabbar__strip { -webkit-mask-image: linear-gradient(to left, transparent 0, #000 var(--fl), #000 calc(100% - var(--fr)), transparent 100%); mask-image: linear-gradient(to left, transparent 0, #000 var(--fl), #000 calc(100% - var(--fr)), transparent 100%); }
.tabbar.is-scroll .tab { flex: 0 0 calc(100% / var(--tab-vis, 4.5)); scroll-snap-align: start; }

/* v6 corner: a bigger fire and spark, and a keyboard ring that stays inside its own half (it used to touch the divider
   and the pill's rounded ends) */
.corner__num { font-size: 18px; }
/* 2026-11-16 (owner: "значки огня и искры больше"): the flame and the spark a size up; the numbers stay 18 px and sit on
   the same middle line (the icons are centred boxes, so a bigger icon never moves its number up or down) */
.corner__flame svg, .corner__flame .ico { width: 25px; height: 25px; }
.corner__flame { width: 25px; height: 25px; align-items: center; justify-content: center; }
.corner__spark { position: relative; font-size: 23px; width: 22px; height: 25px; align-items: center; justify-content: center; line-height: 1; }
/* rewards waiting to be claimed: a small number on the spark (app.js; a tap opens them in the sparks window) */
.corner__badge {
  position: absolute; top: -8px; right: -12px; min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box; border-radius: 8px;
  display: inline-grid; place-items: center; background: rgb(var(--cta-rgb)); color: #fff; box-shadow: 0 0 0 2px rgb(var(--bg-rgb));
  font: 700 10px/1 var(--f-sans); letter-spacing: 0; font-variant-numeric: tabular-nums; pointer-events: none;
}
.corner__badge[hidden] { display: none; }
.corner__sparks.has-rewards { gap: 12px; }
.corner__sep { margin: 0 3px; }
.corner__btn:focus-visible { outline: 2px solid var(--ring, var(--accent)); outline-offset: -4px; }

/* v6 (owner, later): icons are plain (white / dark) like the bottom bar, not the app colour. Was: icons glow in the app colour everywhere, the way a running Focus did in the bar: the bar, the rows on
   Today, Settings rows, section titles. Words stay their normal colour; buttons filled with the app colour keep white icons. */
/* bar icons: plain by default (as before); Settings can give them one colour or a colour each (--tab-ic on the tab) */
.btn--accent svg, .glass--accent svg, .glass--cta svg { color: currentColor; }



/* v6 (owner): in the scrolling bar a two-line label ("Экранное время") used to lift every icon up ("the buttons look
   raised"). Icons now sit exactly where they do in the bar with "More" (same centre line); a long label just takes its
   second line lower down. */
.tabbar.is-scroll.is-two-line .tab { padding-top: 8.5px; gap: 1px; }   /* icon centre 20.5 px from the tab top, as a centred one-line tab */
.tabbar.is-scroll.is-two-line .tab span { line-height: 1; flex: none; }

/* v6 (owner): rearranging the bar and "More" by holding and dragging */
.tabbar .tab, .more-list .more-item { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.tabbar:not(.is-scroll) .tab { touch-action: none; }
.tabbar .tab { transition: transform 180ms var(--ease-out), color var(--dur) var(--ease-out); }
.tabbar.is-arranging .tab.is-lifted, .more-list li.is-lifted { transition: none; z-index: 5; position: relative; }
.tabbar .tab.is-lifted { color: var(--fg); background: rgb(var(--fg-rgb) / 0.10); }
.tabbar .tab[data-tab="more"].is-drop { color: var(--fg); background: rgb(var(--accent-rgb) / 0.22); box-shadow: inset 0 0 0 2px var(--accent); }
.more-list li { transition: transform 180ms var(--ease-out); touch-action: none; }
.more-list li.is-lifted .more-item { background: rgb(var(--fg-rgb) / 0.10); border-radius: 14px; }
.more-hint { margin: 0 0 10px; font-size: var(--t-small); color: var(--muted); line-height: 1.35; }
.more-back { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; margin-bottom: 10px; border-radius: 16px;
  border: 1.5px dashed rgb(var(--fg-rgb) / 0.25); color: var(--muted); font-weight: 600; font-size: 14px; }
.more-back.is-on { border-color: rgb(var(--fg-rgb) / 0.45); color: var(--fg); }
.more-back.is-drop { border-color: var(--accent); color: var(--fg); background: rgb(var(--accent-rgb) / 0.14); }
.more-back svg { width: 20px; height: 20px; flex: none; }
.more-back span { text-align: start; }
/* a lifted item is solid, so its words never mix with the ones under it */
.tabbar .tab.is-lifted { background: color-mix(in srgb, rgb(var(--fg-rgb)) 14%, rgb(var(--bg-rgb))); box-shadow: 0 8px 22px rgb(0 0 0 / 0.35); }
.more-list li.is-lifted .more-item { background: color-mix(in srgb, rgb(var(--fg-rgb)) 12%, rgb(var(--bg-rgb))); box-shadow: 0 10px 26px rgb(0 0 0 / 0.35); }

/* v6 (owner): the Shop button in the corner — a bag, and the word where there is room */
.corner__shop { gap: 6px; padding: 0 12px 0 10px; }
.corner__shop svg, .corner__shop .ico { width: 19px; height: 19px; }
.corner__shoplabel { font-size: 13px; font-weight: 600; }
@media (max-width: 720px) { .corner__shoplabel { display: none; } .corner__shop { padding: 0 9px; } .corner__sparks small { display: none; } }
@media (max-width: 360px) { #app-corner { gap: 4px; } .corner__btn, .corner__fire, .corner__shop { padding: 0 7px; gap: 4px; } .corner__num { font-size: 15px; } .corner__sep { margin: 0 1px; } }
@media (max-width: 360px) { .corner__flame, .corner__flame svg, .corner__flame .ico { width: 22px; height: 22px; } .corner__spark { font-size: 20px; width: 19px; } .corner__sparks.has-rewards { gap: 10px; } }



/* v6 (owner): icons and labels are the same size whatever the bar does ("More" or scrolling, few or many tabs):
   switching the mode used to make them jump between 22 and 24 px and between 9.5 and 10.5 px */
.tabbar.tabbar.tabbar.tabbar .tab svg { width: 24px; height: 24px; flex: none; }   /* outranks the :has(.tab:nth-child(6)) rules */
.tabbar.tabbar.tabbar.tabbar .tab { font-size: 10.5px; letter-spacing: 0.01em; }
@media (max-width: 420px) { .tabbar.tabbar.tabbar.tabbar .tab { font-size: 10px; letter-spacing: 0; } }
@media (max-width: 374px) { .tabbar.tabbar.tabbar.tabbar .tab { font-size: 9px; letter-spacing: -0.01em; } }   /* a narrow phone: the same smaller size in both modes */
.tabbar.tabbar.tabbar.tabbar.is-tight .tab { font-size: 9px; letter-spacing: -0.01em; }
.tabbar.tabbar.tabbar.tabbar.is-tight.is-tighter .tab { font-size: 8.5px; letter-spacing: -0.04em; }

/* 2026-11-19 (owner): the corner shows only the atom and the number; the word «искры» lives inside (sparks window, shop) */
.corner__sparks small { display: none; }

/* ---------- touch phones: 16px inputs (no iOS auto-zoom) and ~44px hit areas ---------- */
@media (pointer: coarse) {
  :root { --corner-h: 44px; }
  :root .corner__btn { min-width: 44px; justify-content: center; }
  :root [data-screen="focus"] .fc-custom, :root .st-select, :root .st-habit__name { font-size: 16px; }
  :root .corner__btn, :root .back-link, :root .df-face, :root .st-swatch, :root .st-habit__tool, :root .sx-tool, :root .water__edit, :root .segmented button { position: relative; }
  :root .corner__btn::after { content: ""; position: absolute; inset: -3px 0; }
  :root .back-link::after, :root .df-face::after, :root .st-swatch::after, :root .st-habit__tool::after, :root .sx-tool::after, :root .water__edit::after {
    content: ""; position: absolute; inset: -6px -4px;
  }
  :root .segmented button::after { content: ""; position: absolute; inset: -6px 0; }
  :root .btn--s, :root .btn--ghost, :root .gbtn--s, :root .chip, :root [data-screen="focus"] .fc-amb, :root .select { min-height: 44px; }
  :root .st-cpick__opt { min-height: 44px; }
  :root [data-screen="today"] .td-plans__fold { min-height: 44px; }
  :root [data-screen="sport"] .sx-ai__go { min-height: 44px; }
  :root [data-screen="focus"] .fc-custom { min-height: 44px; }
}
