/*
 * pre.red base styles and components. Every value comes from tokens.css.
 * Type floor: text 13px or larger, pills and caps labels 12px or larger (docs/DESIGN.md).
 */

/* Base */

*,
*::before,
*::after {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--ink);
    font: 400 15px/1.45 var(--font-ui);
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
    margin: 0;
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

img,
svg {
    display: block;
    max-width: 100%;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Type */

.display {
    font-family: var(--font-display);
    font-weight: 400;
    line-height: 1.05;
}

.label {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

/* Seal: the logo and the dose mark */

.seal {
    --seal-size: 40px;
    width: var(--seal-size);
    aspect-ratio: 1;
    padding: calc(var(--seal-size) * 0.075);
    border-radius: calc(var(--seal-size) * 0.125);
    background: var(--accent);
    transform: rotate(-3deg);
}

.seal--lg {
    --seal-size: 72px;
}

.seal__face {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    border: 1.5px solid color-mix(in srgb, var(--accent-ink) 80%, transparent);
    border-radius: calc(var(--seal-size) * 0.075);
    color: var(--accent-ink);
    font: 400 calc(var(--seal-size) * 0.31) / 0.95 var(--font-display);
    text-align: center;
}

/* Holding and error pages */

.holding {
    min-height: 100dvh;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 18px;
    padding: 24px;
    text-align: center;
}

.holding__title {
    margin-top: 6px;
    font: 400 clamp(48px, 9vw, 72px) / 1 var(--font-display);
    letter-spacing: -0.01em;
}

.holding__title--sm {
    margin-top: 0;
    font-size: clamp(34px, 6vw, 48px);
}

.holding__line {
    max-width: 32ch;
    font-size: 17px;
    color: var(--muted);
}

/* Type scale (board 00): display 62, title 30, heading 18/650, body 15/22, label 12 mono */

.t-display {
    font: 400 clamp(44px, 6vw, 62px) / 1 var(--font-display);
}

.t-title {
    font: 400 30px / 1.15 var(--font-display);
}

.t-heading {
    font-size: 18px;
    font-weight: 650;
    line-height: 1.3;
}

.t-body {
    font-size: 15px;
    line-height: 1.47;
    color: var(--ink-2);
}

.label--accent {
    color: var(--accent-text);
}

.icon {
    flex: none;
}

/* Cards */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 12px 14px;
}

.card--lead {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

/* Buttons. Hover tints with the text colour, so it works on every fill in both themes. */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 18px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--ink);
    font: 600 14px / 1 var(--font-ui);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.btn:hover {
    box-shadow: inset 0 0 0 999px color-mix(in srgb, currentColor 8%, transparent);
}

.btn:active {
    translate: 0 1px;
}

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

.btn--primary {
    background: var(--ink);
    color: var(--bg);
}

.btn--accent {
    background: var(--accent);
    color: var(--accent-ink);
}

.btn--secondary {
    padding: 0 16px;
    background: var(--surface);
    border: 1px solid var(--line);
}

.btn--seal {
    padding: 0 16px;
    border: 1.5px dashed var(--accent);
    color: var(--accent-text);
}

.btn--quiet {
    padding: 0 12px;
    color: var(--muted);
    font-weight: 500;
}

.btn--sm {
    height: 32px;
    padding: 0 14px;
    border-radius: var(--radius-pill);
    font-size: 13px;
}

.btn--icon {
    width: 40px;
    padding: 0;
}

/* Chips */

.chip {
    --chip-bg: var(--surface-2);
    --chip-fg: var(--ink);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 12px;
    border-radius: var(--radius-pill);
    background: var(--chip-bg);
    color: var(--chip-fg);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.chip--plain {
    font-weight: 500;
    box-shadow: inset 0 0 0 1px var(--line);
}

.chip--lg {
    height: 36px;
    padding: 0 16px;
    font-size: 14.5px;
    font-weight: 500;
    --chip-bg: var(--surface);
    box-shadow: inset 0 0 0 1px var(--line);
}

.chip--good {
    --chip-bg: var(--good-soft);
    --chip-fg: var(--good);
}

.chip--warn {
    --chip-bg: var(--warn-soft);
    --chip-fg: var(--warn);
}

.chip--info {
    --chip-bg: var(--info-soft);
    --chip-fg: var(--info);
}

.chip--accent {
    --chip-bg: var(--accent-soft);
    --chip-fg: var(--accent-text);
}

/* Segmented control: buttons with aria-pressed */

.segmented {
    display: inline-flex;
    padding: 3px;
    border-radius: 11px;
    background: var(--surface-2);
    border: 1px solid var(--line);
}

.segmented > button {
    height: 30px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
}

.segmented > [aria-pressed="true"] {
    background: var(--surface);
    color: var(--ink);
    font-weight: 600;
    box-shadow: var(--shadow);
}

/* Switch: <button role="switch" aria-checked> */

.switch {
    position: relative;
    flex: none;
    width: 46px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 14px;
    background: var(--surface-3);
    cursor: pointer;
}

.switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--knob);
    box-shadow: var(--knob-shadow);
    transition: translate 0.15s ease;
}

.switch[aria-checked="true"] {
    background: var(--good);
}

.switch[aria-checked="true"]::after {
    translate: 18px 0;
}

/* Round check: <button aria-pressed>. The hit area is 44px even though it looks 26px. */

.check {
    position: relative;
    flex: none;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 2px solid var(--faint);
    border-radius: 50%;
    background: transparent;
    color: transparent;
    cursor: pointer;
}

.check::before {
    content: "";
    position: absolute;
    inset: -9px;
}

.check[aria-pressed="true"] {
    border-color: var(--ink);
    background: var(--ink);
    color: var(--bg);
}

/* Stepper */

.stepper {
    display: inline-flex;
    align-items: center;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
}

.stepper > button {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
}

.stepper__value {
    min-width: 76px;
    text-align: center;
    font-size: 13.5px;
    font-weight: 600;
}

/* Keyboard hint */

.kbd {
    padding: 3px 6px;
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--muted);
    font: 500 12px / 1 var(--font-mono);
}

/* Tell bar */

.tell {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 52px;
    padding: 0 7px 0 14px;
    border: 1.5px solid var(--ink);
    border-radius: 16px;
    background: var(--surface);
}

.tell:focus-within {
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.tell__spark {
    color: var(--accent);
}

.tell__input {
    flex: 1;
    min-width: 0;
    height: 38px;
    padding: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--ink);
    font-size: 15px;
}

.tell__input::placeholder {
    color: var(--muted);
}

.tell__tool {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.tell__tool--speak {
    background: var(--accent);
    color: var(--accent-ink);
}

.tell__tool:hover {
    color: var(--ink);
}

/* The camera button is the label of a hidden file input (2.4b); the input keeps the keyboard focus,
   shown on the button. */
.tell__file:focus-visible + .tell__tool {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* Phones have no keyboard shortcut; give the room to the text. */
@media (max-width: 640px), (pointer: coarse) {
    .tell .kbd {
        display: none;
    }
}

/* Dose seal: due, sealed, sealed late, skipped, missed */

.dose {
    position: relative;
    flex: none;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 5px;
}

.dose--due {
    border: 2px dashed var(--accent);
    color: var(--accent-text);
}

.dose--sealed,
.dose--late {
    padding: 3px;
    background: var(--accent);
    color: var(--accent-ink);
    rotate: -6deg;
}

.dose--late {
    rotate: 4deg;
}

.dose__face {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    border: 1.5px solid color-mix(in srgb, var(--accent-ink) 80%, transparent);
    border-radius: 3px;
    font: 400 14px / 1 var(--font-display);
}

.dose__late {
    position: absolute;
    right: -8px;
    bottom: -8px;
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--warn);
    color: var(--bg);
}

.dose--skipped {
    border: 2px solid var(--faint);
}

.dose--skipped::after {
    content: "";
    width: 18px;
    height: 2px;
    background: var(--faint);
}

.dose--missed {
    border: 2px solid var(--warn);
}

/* Timeline: time, marker, title, action. The NOW row carries the accent line. */

.timeline {
    position: relative;
    padding: 4px 0;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 85px;
    top: 10px;
    bottom: 10px;
    width: 2px;
    background: var(--line-2);
}

.timeline__row {
    position: relative;
    display: grid;
    grid-template-columns: 56px 24px minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 10px;
    min-height: 48px;
    padding: 0 12px 0 8px;
}

.timeline__time {
    font-size: 13px;
    text-align: right;
}

.timeline__time--past {
    color: var(--muted);
}

.timeline__mark {
    justify-self: center;
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    background: var(--surface);
}

.timeline__text {
    min-width: 0;
    font-size: 14px;
}

.timeline__text b {
    font-weight: 600;
}

.timeline__text span {
    color: var(--muted);
}

.timeline__row--now {
    min-height: 34px;
}

.timeline__row--now .timeline__time {
    color: var(--accent-text);
    font-weight: 700;
}

.timeline__now {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent-text);
    font: 500 12px / 1 var(--font-mono);
    letter-spacing: 0.12em;
}

.timeline__now::after {
    content: "";
    flex: 1;
    height: 2px;
    background: var(--accent);
}

/* Markers (timeline, legends) */

.mark {
    --mark: var(--food);
    width: 11px;
    height: 11px;
    border: 2.5px solid var(--mark);
    border-radius: 50%;
}

.mark--prep {
    border-radius: 3px;
}

.mark--move {
    --mark: var(--move);
}

.mark--mind {
    --mark: var(--mind);
}

.mark--sleep {
    --mark: var(--sleep);
}

.mark--water {
    --mark: var(--info);
}

.mark--vital {
    --mark: var(--vit);
}

.mark--note {
    --mark: var(--muted);
    border-radius: 3px;
}

.mark--dose {
    width: 12px;
    height: 12px;
    border: 1.5px dashed var(--accent);
    border-radius: 2px;
}

.mark--sealed {
    width: 12px;
    height: 12px;
    border: 0;
    border-radius: 2px;
    background: var(--accent);
    rotate: -6deg;
}

.mark--now {
    width: 12px;
    height: 12px;
    border: 3px solid var(--accent);
    background: var(--surface);
}

/* Nutrient tile and meter. Colour and widths are data: style="--c: var(--vit)" and "--w: 5%". */

.nutrient {
    --c: var(--macro);
    display: flex;
    flex-direction: column;
    min-height: 112px;
    padding: 9px 10px;
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--c) 14%, var(--surface));
}

.nutrient__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.nutrient__symbol {
    font: 400 34px / 1 var(--font-display);
}

.nutrient__pct {
    font-size: 12px;
    font-weight: 700;
}

.nutrient__name {
    margin-top: 4px;
    font-size: 12px;
    color: var(--ink-2);
}

.meter {
    position: relative;
    display: flex;
    height: 6px;
    margin-top: auto;
    border-radius: 3px;
    background: var(--surface);
    overflow: hidden;
}

.meter__food {
    width: var(--w);
    background: var(--c);
}

.meter__supp {
    width: var(--w);
    background: repeating-linear-gradient(45deg, var(--c) 0 2px, transparent 2px 4px);
}

.meter__due {
    width: var(--w);
    border: 1px dashed var(--c);
    border-left: 0;
}

/* Water cups */

.cups {
    display: flex;
    gap: 5px;
}

.cups > span {
    flex: 1;
    height: 10px;
    border-radius: 5px;
    background: var(--line);
}

.cups > .is-full {
    background: var(--info);
}

/* Progress ring (SVG). The dash array is computed by PHP. */

.ring {
    position: relative;
    display: grid;
    place-items: center;
}

.ring__track {
    stroke: var(--line);
}

.ring__value {
    stroke: var(--food);
}

.ring__label {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 17px;
    font-weight: 700;
}

.ring__label small {
    font-size: 12px;
    font-weight: 400;
    color: var(--muted);
}

/* Forms */

.field {
    display: grid;
    gap: 6px;
}

.field__label {
    font-size: 13px;
    font-weight: 650;
}

.input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    font-size: 16px;
}

.input:focus-visible {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.btn--block {
    width: 100%;
    height: 46px;
}

.alert {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
}

.alert--warn {
    background: var(--warn-soft);
    color: var(--warn);
}

.alert--good {
    background: var(--good-soft);
    color: var(--good);
}

/* Sign-in and the second factor: one centred card */

.auth {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
}

.auth__card {
    display: grid;
    gap: 18px;
    width: min(100%, 400px);
    padding: 28px 28px 24px;
}

.auth__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.auth__wordmark {
    font: 400 30px / 1 var(--font-display);
}

.wordmark__dot {
    color: var(--accent);
}

.auth__form {
    display: grid;
    gap: 16px;
}

/* Turnstile's flexible widget is 65px tall: hold the space so nothing jumps when it loads. */
.auth__check {
    min-height: 65px;
}

.auth__note {
    font-size: 13px;
    color: var(--muted);
    text-align: center;
}

.auth__card--wide {
    width: min(100%, 460px);
}

.input--code {
    font: 500 22px / 1 var(--font-mono);
    letter-spacing: 0.18em;
    text-align: center;
}

/* Two-factor set-up */

.setup-steps {
    display: grid;
    gap: 18px;
    margin: 0;
    padding-left: 22px;
    font-size: 14px;
    line-height: 1.5;
}

.setup-steps > li::marker {
    font-weight: 700;
}

.setup-steps .btn {
    margin-top: 10px;
}

.qr-box {
    width: fit-content;
    margin-top: 10px;
    padding: 6px;
    border-radius: var(--radius-md);
    background: var(--qr-light);
    border: 1px solid var(--line);
}

.qr__light {
    fill: var(--qr-light);
}

.qr__dark {
    fill: var(--qr-dark);
}

.setup-key {
    display: block;
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--surface-2);
    font: 500 16px / 1.3 var(--font-mono);
    letter-spacing: 0.06em;
    word-spacing: 0.2em;
}

.backup-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 16px;
    margin: 0;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    list-style: none;
    font: 500 16px / 1.4 var(--font-mono);
    letter-spacing: 0.04em;
}

/*
 * App shell (board 01). Phones first: the header and the tab bar. From 760px wide: the rail and the
 * top bar. One document for both; .wide-only and .narrow-only pick the right words.
 */

.skip {
    position: absolute;
    top: -100px;
    left: 12px;
    z-index: 20;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: var(--ink);
    color: var(--bg);
    font-weight: 600;
    text-decoration: none;
}

.skip:focus {
    top: 12px;
}

.shell {
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 1fr auto;
}

.shell__main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.rail,
.wide-only {
    display: none;
}

.topbar {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 22px 16px 4px 20px;
}

.topbar__titles {
    flex: 1;
    min-width: 0;
}

.topbar__title {
    font: 400 36px / 1 var(--font-display);
}

.topbar__sub {
    margin-top: 6px;
    font-size: 13px;
    color: var(--muted);
}

.topbar__tell {
    display: none;
}

.topbar__theme {
    display: flex;
}

.iconbtn {
    width: 44px;
    height: 44px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
}

.iconbtn:hover {
    box-shadow: inset 0 0 0 999px color-mix(in srgb, currentColor 6%, transparent);
}

/* The switch offers the other theme: the moon in light, the sun in dark (whatever decided it). */
.theme-to-light,
:root[data-theme="dark"] .theme-to-dark {
    display: none;
}

:root[data-theme="dark"] .theme-to-light {
    display: grid;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .theme-to-light {
        display: grid;
    }

    :root:not([data-theme]) .theme-to-dark {
        display: none;
    }
}

.avatar {
    width: 44px;
    height: 44px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--ink);
    color: var(--bg);
    font: 400 19px / 1 var(--font-display);
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.avatar::-webkit-details-marker {
    display: none;
}

.avatar--lg {
    font-size: 22px;
    cursor: default;
}

.menu {
    position: relative;
}

.menu__panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 10;
    width: 248px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
}

.menu__who {
    margin-bottom: 4px;
    padding: 8px 10px 10px;
    border-bottom: 1px solid var(--line-2);
}

.menu__who b {
    display: block;
    font-weight: 650;
}

.menu__who span {
    display: block;
    font-size: 13px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.menu__item {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink);
    font-size: 15px;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.menu__item:hover,
.menu__item[aria-current="page"] {
    background: var(--surface-2);
}

.menu__item .icon {
    color: var(--muted);
}

.page {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 14px 24px;
}

.page:focus {
    outline: none;
}

/* Small buttons, and the water widget's, keep a 44px touch target on phones (Codex V45.3). */
@media (max-width: 759px) {
    .page .btn--sm,
    .page .water__actions .btn {
        height: 44px;
    }
}

.tabbar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: center;
    min-height: 66px;
    padding: 4px 8px max(10px, env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
}

.tabbar__link {
    min-height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--muted);
    font-size: 13px;
    text-decoration: none;
}

.tabbar__link[aria-current="page"] {
    color: var(--ink);
    font-weight: 650;
}

.tabbar__tell {
    justify-self: center;
    width: 58px;
    height: 58px;
    margin-top: -22px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: var(--accent);
    color: var(--accent-ink);
    transform: rotate(-3deg);
    box-shadow: 0 0 0 5px var(--surface), var(--float);
}

@media (min-width: 760px) {
    .shell {
        grid-template-columns: 80px minmax(0, 1fr);
        grid-template-rows: auto;
    }

    .wide-only {
        display: inline;
    }

    .narrow-only,
    .tabbar,
    .menu--header {
        display: none;
    }

    .rail {
        position: sticky;
        top: 0;
        height: 100dvh;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 20px 0 18px;
        background: var(--surface-2);
        border-right: 1px solid var(--line);
    }

    .rail__logo {
        display: block;
        margin-bottom: 16px;
        border-radius: var(--radius-xs);
    }

    .rail__logo .seal {
        display: block;
    }

    .rail__link {
        width: 62px;
        height: 58px;
        flex: none;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        border-radius: var(--radius-md);
        color: var(--muted);
        font-size: 13px;
        font-weight: 500;
        text-decoration: none;
    }

    .rail__link:hover {
        color: var(--ink);
    }

    .rail__link[aria-current="page"] {
        background: var(--surface);
        box-shadow: var(--shadow);
        color: var(--ink);
        font-weight: 650;
    }

    .rail__link--end {
        margin-top: auto;
    }

    .menu--rail {
        margin-top: 8px;
    }

    .menu--rail .avatar {
        width: 34px;
        height: 34px;
        font-size: 17px;
    }

    .menu--rail .menu__panel {
        top: auto;
        right: auto;
        bottom: 0;
        left: calc(100% + 12px);
    }

    .topbar {
        height: 66px;
        flex: none;
        align-items: center;
        gap: 12px;
        padding: 0 22px 0 26px;
        border-bottom: 1px solid var(--line);
    }

    .topbar__titles {
        display: flex;
        align-items: baseline;
        gap: 12px;
    }

    .topbar__title {
        font-size: 34px;
        white-space: nowrap;
    }

    .topbar__sub {
        margin-top: 0;
        font-size: 13.5px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .topbar__tell {
        width: min(330px, 34vw);
        height: 38px;
        flex: none;
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 0 8px 0 12px;
        border: 1px solid var(--line);
        border-radius: var(--radius-sm);
        background: var(--surface);
        color: var(--muted);
        font-size: 13.5px;
        text-decoration: none;
    }

    .topbar__tell .icon {
        color: var(--accent);
    }

    .iconbtn {
        width: 38px;
        height: 38px;
        border-radius: var(--radius-sm);
    }

    .page {
        gap: 14px;
        padding: 20px 24px 24px 26px;
    }
}

/* Section pages: what each one will hold, until it is built */

.tile {
    width: 30px;
    height: 30px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: color-mix(in srgb, var(--tone, var(--accent)) 16%, var(--surface));
    color: var(--tone, var(--accent));
}

.tile--lg {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
}

.empty {
    max-width: 640px;
    display: grid;
    justify-items: start;
    gap: 10px;
    padding: 20px 20px 22px;
}

.empty__title {
    font: 400 34px / 1.05 var(--font-display);
}

.empty__text {
    max-width: 52ch;
    color: var(--ink-2);
}

.help-line {
    max-width: 640px;
    display: grid;
    gap: 8px;
    padding: 16px 20px 18px;
}

.help-line__text {
    color: var(--ink-2);
}

.help-line__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Today (board 01, Phase 2.2): the day's timeline, the glance tiles and the water widget. On a
   phone the glance and the water come first, as on the board. */

.today,
.today__main,
.today__side {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    align-content: start;
}

.today__side {
    order: -1;
}

.day {
    display: grid;
    gap: 4px;
    padding: 14px 4px 16px;
}

.day__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding: 0 16px 6px;
}

.day__note,
.day__later {
    padding: 0 16px;
    font-size: 13.5px;
    color: var(--ink-2);
}

.day__later {
    font-size: 13px;
    color: var(--muted);
}

ol.timeline,
.timeline__folded {
    margin: 0;
    padding: 4px 0;
    list-style: none;
}

.timeline__folded {
    padding: 0;
}

.timeline__summary {
    display: grid;
    grid-template-columns: 56px 24px minmax(0, 1fr);
    align-items: center;
    column-gap: 10px;
    min-height: 48px;
    padding: 0 12px 0 8px;
    cursor: pointer;
    list-style: none;
}

.timeline__summary::-webkit-details-marker {
    display: none;
}

.timeline__summary:hover b {
    text-decoration: underline;
}

.timeline__chevron {
    justify-self: center;
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--surface);
    color: var(--muted);
    transition: rotate 0.15s ease;
}

details[open] > .timeline__summary .timeline__chevron {
    rotate: 90deg;
}

.timeline__note {
    grid-column: 3 / -1;
    margin: -2px 0 10px;
    font-size: 13.5px;
    color: var(--ink-2);
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.timeline__note--lost {
    color: var(--muted);
    font-style: italic;
}

.timeline__zone {
    font: 500 12px / 1 var(--font-mono);
    letter-spacing: 0.08em;
    color: var(--muted);
}

.glance {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
}

.glance__tile {
    display: grid;
    align-content: start;
    gap: 2px;
    min-width: 0;
    padding: 10px 10px 12px;
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--tone) 12%, var(--surface));
}

.glance__value {
    font: 400 28px / 1.05 var(--font-display);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.glance__name {
    font-size: 13px;
    color: var(--ink-2);
}

.glance__aside {
    font-size: 13px;
    color: var(--muted);
}

.water {
    display: grid;
    gap: 10px;
    padding: 16px;
}

.water__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.water__volume,
.water__note {
    font-size: 13px;
    color: var(--muted);
}

.water__value {
    color: var(--ink-2);
}

.water__value b {
    margin-right: 4px;
    font: 400 34px / 1 var(--font-display);
    color: var(--ink);
}

.water__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.water__error {
    font-size: 13.5px;
    color: var(--warn);
}

/* The Tell bar and its confirm card (Phase 2.3, D-065; the Daybook board's sheet): chips, the bar,
   then the owner's words, what pre.red will add, and the buttons. No JavaScript: each item's values
   open with <details>, whose "Edit" sits at the end of the item's line. */

.tell-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 16px 16px 14px;
}

.tell-panel--open {
    box-shadow: var(--shadow);
}

.tell-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tell-chips__chip {
    border: 0;
    cursor: pointer;
}

.tell-chips__chip:hover {
    box-shadow: inset 0 0 0 1px var(--ink);
}

.tell__send {
    display: grid;
    place-items: center;
    flex: none;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 11px;
    background: var(--accent);
    color: var(--accent-ink);
    cursor: pointer;
}

/* The photo form has no box of its own: its status line and, without scripts, its button sit in the
   panel's column (2.4b). */
.tell-photo {
    display: contents;
}

.tell-photo__fallback {
    display: grid;
    gap: 8px;
}

.tell-photo__status,
.tell-panel__note,
.tell-card__fine,
.tell-card__notices {
    font-size: 13.5px;
    color: var(--muted);
}

.tell-panel__error,
.tell-card__error {
    font-size: 13.5px;
    color: var(--warn);
}

.tell-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
}

.tell-card__said {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 14px 16px;
    border-radius: 18px;
    background: var(--surface-2);
}

.tell-card__drafted {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--accent-text);
}

.tell-card__photo {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    color: var(--muted);
}

.tell-card__photo svg {
    flex: none;
}

.tell-card__spark {
    flex: none;
    display: inline-flex;
    padding-top: 1px;
}

.tell-card__said blockquote {
    margin: 0;
    font: italic 400 21px / 1.25 var(--font-display);
    overflow-wrap: anywhere;
}

.tell-card__crisis {
    display: grid;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 18px;
    background: var(--accent-soft);
    font-size: 14px;
}

.tell-card__crisis-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tell-card__notices {
    display: grid;
    gap: 4px;
    margin: 0;
    padding-left: 18px;
}

.tell-card__form {
    display: grid;
    gap: 10px;
}

.tell-card__add {
    margin-top: 4px;
}

.tell-items {
    margin: 0;
    padding: 0;
    list-style: none;
}

.tell-item {
    position: relative;
    display: grid;
    grid-template-columns: 26px 40px minmax(0, 1fr) 44px;
    column-gap: 12px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line-2);
}

.tell-item__pick {
    position: relative;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
}

.tell-item__pick::before {
    content: "";
    position: absolute;
    inset: -9px;
}

.tell-item__pick input {
    appearance: none;
    position: relative;
    width: 26px;
    height: 26px;
    margin: 0;
    border: 2px solid var(--faint);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}

.tell-item__pick input:checked {
    border-color: var(--ink);
    background: var(--ink);
}

.tell-item__pick input:checked::after {
    content: "";
    position: absolute;
    left: 7px;
    top: 3px;
    width: 6px;
    height: 11px;
    border: solid var(--bg);
    border-width: 0 2.5px 2.5px 0;
    rotate: 45deg;
}

.tell-item__mark {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--surface-2);
}

.tell-item__mark .mark {
    scale: 1.25;
}

.tell-item__text {
    display: grid;
    gap: 2px;
    min-width: 0;
    font-size: 13px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.tell-item__text b {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
}

.tell-item__aside {
    color: var(--ink-2);
}

.tell-item--off .tell-item__text,
.tell-item--off .tell-item__mark {
    opacity: 0.6;
}

.tell-item__edit {
    grid-column: 1 / -1;
}

.tell-item__edit summary {
    position: absolute;
    top: 12px;
    right: 0;
    display: grid;
    place-items: center;
    min-width: 44px;
    height: 40px;
    padding: 0 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    list-style: none;
    cursor: pointer;
}

.tell-item__edit summary::-webkit-details-marker {
    display: none;
}

.tell-item__edit[open] summary {
    color: var(--ink);
}

.tell-item__fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    padding: 12px 0 4px;
}

.tell-item__fields > *,
.tell-item__fields .input {
    min-width: 0;
    max-width: 100%;
}

.tell-item__fields .field:has(textarea),
.tell-choice {
    grid-column: 1 / -1;
}

.tell-item__note {
    height: auto;
    min-height: 88px;
    padding: 10px 14px;
    resize: vertical;
}

.tell-item__problem {
    margin-top: 2px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--accent-text);
}

.tell-item__problem--error {
    color: var(--warn);
}

.tell-choice {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    border: 0;
}

.tell-choice legend {
    width: 100%;
    margin-bottom: 6px;
    padding: 0;
}

.tell-choice__option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    border-radius: var(--radius-pill);
    background: var(--surface);
    box-shadow: inset 0 0 0 1px var(--line);
    font-size: 14px;
    cursor: pointer;
}

.tell-choice__option:has(input:checked) {
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1.5px var(--accent);
}

.tell-choice__option input {
    margin: 0;
    accent-color: var(--accent);
}

.tell-choice__aside {
    color: var(--muted);
}

.tell-card__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

/* Every control of the bar and the card keeps a 44px touch target on phones. */
@media (max-width: 759px) {
    .tell-chips__chip,
    .tell-card__actions .btn,
    .tell-choice__option {
        min-height: 44px;
        height: auto;
    }

    .tell__send {
        width: 44px;
        height: 44px;
    }

    .tell-item__edit summary {
        height: 44px;
        top: 10px;
    }
}

@media (min-width: 1000px) {
    .today {
        grid-template-columns: minmax(0, 1fr) 336px;
        gap: 20px;
        align-items: start;
    }

    .today__side {
        order: 0;
    }

    .glance__value {
        font-size: 24px;
    }
}

/* Settings (board 08) */

.settings,
.settings__body,
.settings__grid,
.settings__stack {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    min-width: 0;
}

.settings__nav {
    display: none;
}

.settings__link {
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
    border-radius: 12px;
    text-decoration: none;
}

.settings__link:hover {
    background: var(--surface-2);
}

.settings__link b {
    display: block;
    font-size: 13.5px;
    font-weight: 650;
}

.settings__link b + span {
    display: block;
    max-width: 160px;
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.settings__foot {
    margin-top: 8px;
    padding: 10px 10px 2px;
    border-top: 1px solid var(--line-2);
    font-size: 13px;
    color: var(--muted);
}

.profile {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
}

.profile__who {
    flex: 1;
    min-width: 0;
}

.profile__name {
    font-size: 15px;
    font-weight: 700;
}

.profile__meta {
    font-size: 13px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.settings-card {
    padding: 14px 16px 6px;
    scroll-margin-top: 20px;
}

.settings-card__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.settings-card__note {
    font-size: 13px;
    color: var(--muted);
}

.settings-card__text,
.settings-card__fine {
    padding: 8px 0;
    font-size: 13.5px;
    color: var(--muted);
}

.settings-card__fine {
    border-top: 1px solid var(--line-2);
}

.settings-card__error {
    padding: 8px 0;
    font-size: 13.5px;
    color: var(--warn);
}

/* AI reading in Settings (2.4a): the key form, then the model and the cap side by side. */
.ai-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-items: start;
    gap: 10px;
    padding: 12px 0;
    border-top: 1px solid var(--line-2);
}

.ai-form .field {
    width: 100%;
}

.ai-form__help {
    font-size: 13px;
    color: var(--muted);
}

@media (min-width: 760px) {
    .ai-form--choices {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        align-items: end;
    }

    .ai-form--choices .btn,
    .ai-form__wide {
        grid-column: 1 / -1;
    }
}

.themes__set {
    margin: 12px 0 10px;
    padding: 0;
    border: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.theme-card {
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 7px;
    text-align: left;
    cursor: pointer;
}

.mini {
    height: 78px;
    display: flex;
    overflow: hidden;
    border: 1.5px solid var(--line);
    border-radius: 12px;
}

.theme-card[aria-pressed="true"] .mini {
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.mini__screen {
    flex: 1;
    display: flex;
    background: var(--bg);
}

.mini__rail {
    width: 16px;
    flex: none;
    display: flex;
    justify-content: center;
    padding-top: 7px;
    background: var(--surface-2);
    border-right: 1px solid var(--line);
}

.mini__seal {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    background: var(--accent);
}

.mini__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 8px;
}

.mini__title {
    width: 55%;
    height: 6px;
    border-radius: 3px;
    background: var(--ink);
}

.mini__card {
    height: 22px;
    border-radius: 5px;
    background: var(--surface);
    border: 1px solid var(--line);
}

.mini__card--short {
    height: 14px;
}

.theme-card__name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
}

.radio-dot {
    width: 14px;
    height: 14px;
    flex: none;
    border: 1.5px solid var(--faint);
    border-radius: 50%;
}

.theme-card[aria-pressed="true"] .radio-dot {
    border: 4px solid var(--accent);
}

.setting-row {
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--line-2);
}

.setting-row__label {
    min-width: 74px;
    font-size: 13.5px;
    font-weight: 600;
}

.setting-row__label--wide {
    flex: 1;
    min-width: 0;
    padding: 6px 0;
}

.setting-row__label span {
    display: block;
    font-size: 13px;
    font-weight: 400;
    color: var(--muted);
}

.setting-row__value {
    margin-left: auto;
    font-size: 13px;
    color: var(--muted);
}

.swatches {
    display: flex;
    gap: 2px;
}

.swatch {
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: transparent;
    cursor: pointer;
}

.swatch__dot {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--swatch);
    color: var(--accent-ink);
}

.swatch .icon {
    visibility: hidden;
}

.swatch[aria-pressed="true"] .icon {
    visibility: visible;
}

.swatch[aria-pressed="true"] .swatch__dot {
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--swatch);
}

@media (min-width: 760px) {
    .settings {
        grid-template-columns: 236px minmax(0, 1fr);
        gap: 18px;
    }

    .settings__nav {
        position: sticky;
        top: 20px;
        display: flex;
        flex-direction: column;
        gap: 2px;
        padding: 12px;
        border-radius: var(--radius-lg);
    }
}

@media (min-width: 1100px) {
    .settings__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
