/* Design tokens (docs/web-app.md, «Дизайн»): a warm ivory ground, sage green for what you act on,
   terracotta for what matters. Every color on the page comes from here, so the dark theme is only a
   second set of values. Charts read the same variables (js/charts.js). */
:root {
    color-scheme: light;
    --bg: #f5f2ec;
    --surface: #ffffff;
    --sunken: #eeeae2;
    --line: #e6e0d5;
    --ink: #22261f;
    --ink-2: #5a6056;
    --ink-3: #767c70;
    --accent: #577862;
    --on-accent: #ffffff;
    --accent-soft: #e2eae2;
    --accent-ink: #3f5b49;
    --warm: #b9694b;
    --warm-soft: #f5e6dd;
    --danger: #b04a36;
    --shadow: rgb(60 50 30 / 0.07);
    --glass: rgb(255 255 255 / 0.86);
    --series-1: var(--accent);
    --series-2: var(--warm);
    /* One-hue sage ramp: the lightest still stands out from the empty cell. */
    --heat-0: var(--sunken);
    --heat-1: #c3d5c7;
    --heat-2: #8fb09a;
    --heat-3: #5d8a6c;
    --heat-4: #375b44;
    --radius-s: 10px;
    --radius: 14px;
    --radius-l: 20px;
    --tabbar-height: 62px;
    /* What the docked tab bar takes from the bottom of the screen; the composer and toasts sit above it. */
    --dock: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --bg: #121411;
        --surface: #1b1e1a;
        --sunken: #252924;
        --line: #2d322c;
        --ink: #ecede7;
        --ink-2: #b3b9ad;
        --ink-3: #868d80;
        --accent: #8fb39b;
        --on-accent: #132018;
        --accent-soft: #253328;
        --accent-ink: #a8c8b2;
        --warm: #de9478;
        --warm-soft: #3a2a23;
        --danger: #e57a69;
        --shadow: rgb(0 0 0 / 0.3);
        --glass: rgb(27 30 26 / 0.88);
        /* On the dark ground the ramp runs the other way: little is dark, much is light. */
        --heat-1: #2b4433;
        --heat-2: #44694f;
        --heat-3: #6e9a7b;
        --heat-4: #a8c8b2;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    overscroll-behavior: none;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.4;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 0.75rem; }
h1:focus { outline: none; }
h2 { font-size: 1.05rem; font-weight: 650; margin: 1.5rem 0 0.5rem; }

a { color: var(--accent-ink); }

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

/* Icons (Components/Icon.razor): line icons that take the color and size of the text around them. */
.icon {
    width: 1.25em;
    height: 1.25em;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: -0.25em;
}

.boot {
    display: grid;
    place-items: center;
    min-height: 100vh;
    color: var(--ink-3);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

/* Layout: a column over the whole screen, the page scrolling inside it and the tab bar its last row.
   The column is fixed so the document itself never scrolls. The status bar is opaque (index.html),
   so on iPhones the web view, and with it the column, ends at the screen's bottom edge. */
.app {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
}

.page-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
}

.shell {
    max-width: 720px;
    margin: 0 auto;
    padding: calc(env(safe-area-inset-top) + 12px) 16px 24px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.topbar-actions { display: flex; align-items: center; gap: 4px; }
.topbar .button.icon-only.on { color: var(--accent-ink); }
.topbar-note { margin: 0 0 0.75rem; padding: 10px 12px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent-ink); font-size: 0.875rem; }
.topbar-note.error { background: var(--sunken); color: var(--danger); }

.brand { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.16em; color: var(--ink-3); }

/* The tab bar reaches under the iPhone's home indicator and keeps its tabs above it. */
.tabbar {
    flex: none;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2px;
    height: var(--dock);
    padding: 0 max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left));
    border-top: 1px solid var(--line);
    background: var(--surface);
    box-shadow: 0 -4px 16px var(--shadow);
}

.tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    max-width: 110px;
    padding: 6px 0;
    border-radius: var(--radius);
    color: var(--ink-3);
    font-size: 0.68rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.15s, color 0.15s;
}

.tabbar a .icon { width: 22px; height: 22px; }
.tabbar a.active { background: var(--accent-soft); color: var(--accent-ink); }

.subtitle { color: var(--ink-2); margin: 0 0 1rem; }
.muted { color: var(--ink-3); }
.error { color: var(--danger); }

.card {
    background: var(--surface);
    border-radius: var(--radius-l);
    padding: 16px;
    box-shadow: 0 1px 2px var(--shadow), 0 4px 16px var(--shadow);
}

/* Buttons: one shape in four weights.
   .button        filled accent, the main action of a screen;
   .button.soft   a tinted pill, for secondary actions (task actions, chat buttons);
   .button.link   text only, accent colored;
   .button.icon-only / .round   a square or round button holding one icon. */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 48px;
    padding: 0 20px;
    border: none;
    border-radius: var(--radius);
    background: var(--accent);
    color: var(--on-accent);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, opacity 0.15s, transform 0.1s;
}

.button:active:not(:disabled) { transform: scale(0.97); }
.button:disabled { opacity: 0.45; cursor: default; }
.button.wide { width: 100%; }

.button.soft {
    min-height: 36px;
    padding: 0 12px;
    border-radius: var(--radius-s);
    background: var(--sunken);
    color: var(--ink);
    font-size: 0.875rem;
    font-weight: 500;
}

.button.soft .icon { width: 16px; height: 16px; }
.button.soft.danger { color: var(--danger); }

.button.link {
    min-height: 36px;
    padding: 0 4px;
    background: transparent;
    color: var(--accent-ink);
    font-size: 0.875rem;
    font-weight: 500;
}

.button.icon-only {
    width: 40px;
    min-height: 40px;
    padding: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--ink-2);
}

.button.icon-only:hover:not(:disabled) { background: var(--sunken); }
.button.icon-only .icon { width: 22px; height: 22px; }

.button.round { flex: none; width: 40px; min-height: 40px; padding: 0; border-radius: 50%; }
.button.round .icon { width: 20px; height: 20px; }

/* Fields: inputs, selects and the composer share one look. */
.field,
select {
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field:focus, select:focus, .composer-text:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field::placeholder, .composer-text::placeholder { color: var(--ink-3); }
.field:disabled, select:disabled { opacity: 0.55; }

select {
    width: 100%;
    padding-right: 36px;
    appearance: none;
    -webkit-appearance: none;
    /* The chevron of the icon set, in the muted ink of either theme (a data URL: the CSP allows it). */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23868d80' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
}

input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    margin: 0;
    flex: none;
    border: 1.75px solid var(--ink-3);
    border-radius: 7px;
    background: transparent;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

input[type="checkbox"]:checked {
    border-color: var(--accent);
    background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 14px no-repeat;
}

input[type="checkbox"]:disabled { opacity: 0.5; cursor: default; }

/* A data URL cannot read a variable: the dark theme's tick is drawn in its own on-accent ink. */
@media (prefers-color-scheme: dark) {
    input[type="checkbox"]:checked {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23132018' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
    }
}

.check-label { display: flex; align-items: center; gap: 10px; color: var(--ink-2); }

/* Chips: filters and attached files. */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 0.75rem; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-2);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
}

.chip .icon { width: 14px; height: 14px; }
.chip.selected { border-color: transparent; background: var(--accent-soft); color: var(--accent-ink); }

/* Day and month navigation. */
.week-nav { display: flex; align-items: center; gap: 4px; margin: 0.25rem 0 0.5rem; }
.week-nav .week-title { flex: 1; text-align: center; color: var(--ink-2); font-weight: 600; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 1rem; }

.week .day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 0 6px;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--ink);
    font: inherit;
    cursor: pointer;
    transition: background-color 0.15s;
}

.week .day .weekday { font-size: 0.7rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; }
.week .day .number { font-weight: 650; font-variant-numeric: tabular-nums; }
.week .day .marks { display: grid; place-items: center; min-height: 1.1rem; font-size: 0.72rem; font-weight: 600; color: var(--ink-2); }
.week .day .marks .icon { width: 14px; height: 14px; stroke-width: 2.5; }
.week .day .all-done { color: var(--accent); }
.week .day.past .number { color: var(--ink-2); }
.week .day.today .number { color: var(--accent-ink); }
.week .day.selected { background: var(--accent); color: var(--on-accent); }
.week .day.selected .weekday,
.week .day.selected .number,
.week .day.selected .marks,
.week .day.selected .all-done { color: var(--on-accent); }

.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
h2.overdue-heading { color: var(--danger); }

/* Tasks. */
.tasks { list-style: none; margin: 0; padding: 4px 16px; }

.task {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.task:last-child { border-bottom: none; }

.task button.check,
.task .check.done,
.task .check.upcoming {
    flex: none;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 50%;
}

.task button.check {
    border: 1.75px solid var(--ink-3);
    background: transparent;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}

.task button.check:hover { border-color: var(--accent); background: var(--accent-soft); }
.task button.check:disabled { opacity: 0.4; }
.task .check.done { background: var(--accent); color: var(--on-accent); }
.task .check.done .icon { width: 15px; height: 15px; stroke-width: 3; }
.task .check.upcoming { border: 1.75px dashed var(--line); }

.task button.title {
    flex: 1;
    min-width: 0;
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    overflow-wrap: anywhere;
    cursor: pointer;
}

.task button.title:disabled { cursor: default; }
.task .important { margin-right: 4px; color: var(--warm); }
.task .important .icon { width: 16px; height: 16px; }
.task .repeat { margin-left: 6px; color: var(--ink-3); }
.task .repeat .icon { width: 15px; height: 15px; }
.task .progress { margin-left: 6px; color: var(--ink-3); font-size: 0.8rem; font-variant-numeric: tabular-nums; }

.task .tag {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent-ink);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    vertical-align: 1px;
}

.task .due { color: var(--ink-2); font-size: 0.875rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.task.overdue .due { color: var(--danger); font-weight: 500; }
.task.low .title { color: var(--ink-2); }
.task.done .title { color: var(--ink-3); text-decoration: line-through; }
.task.upcoming .title, .task.upcoming .due { color: var(--ink-3); }

.task .actions {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding-left: 38px;
}

.task .actions .field { min-height: 36px; border-radius: var(--radius-s); background: var(--sunken); border-color: transparent; }
.task .actions .move-to { display: inline-flex; align-items: center; gap: 6px; }

/* min-width: 0 lets the row shrink below the add field's natural width, which pushed it past the card. */
.task .checklist { flex-basis: 100%; min-width: 0; padding-left: 38px; }
:is(.task, .shopping) .checklist ul { list-style: none; margin: 0 0 4px; padding: 0; }
:is(.task, .shopping) .checklist li { display: flex; align-items: center; gap: 8px; min-height: 40px; }
:is(.task, .shopping) .checklist label { flex: 1; display: flex; align-items: center; gap: 10px; cursor: pointer; overflow-wrap: anywhere; }
:is(.task, .shopping) .checklist li.done span { color: var(--ink-3); text-decoration: line-through; }

:is(.task, .shopping) .checklist .remove {
    flex: none;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-3);
    cursor: pointer;
}

:is(.task, .shopping) .checklist .remove .icon { width: 16px; height: 16px; }
:is(.task, .shopping) .checklist .remove:hover { color: var(--danger); background: var(--sunken); }

/* The shopping list above the day's tasks: a header that folds it, the checklist of tasks inside. */
.shopping { margin-bottom: 1rem; padding: 4px 16px; }
.shopping-head {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.shopping-head .icon { flex: none; width: 20px; height: 20px; color: var(--accent-ink); }
.shopping-title { font-weight: 600; }
.shopping-count { flex: 1; color: var(--ink-2); font-size: 0.875rem; text-align: right; }
/* A right chevron turned to point down, and up while the list is open. */
.shopping-chevron { display: inline-flex; transform: rotate(90deg); transition: transform 0.15s; }
.shopping-chevron .icon { color: var(--ink-3); }
.shopping-chevron.open { transform: rotate(-90deg); }
.shopping .checklist { padding-bottom: 8px; }
.shopping-item { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; min-width: 0; }
.shopping-quantity { color: var(--ink-2); font-size: 0.875rem; }
.shopping-recipe { flex-basis: 100%; color: var(--ink-3); font-size: 0.75rem; }
.shopping-empty { margin: 0 0 8px; font-size: 0.875rem; }

/* A row slides over its actions when swiped by touch; a mouse uses the buttons in the row instead. */
.shopping .checklist li.shopping-row { position: relative; display: block; overflow: hidden; touch-action: pan-y; }
.shopping-front {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 44px;
    background: var(--surface);
    transition: transform 0.2s ease-out;
}
.shopping-actions { position: absolute; inset: 0 0 0 auto; display: flex; width: 112px; }
.shopping-action {
    flex: 1;
    display: grid;
    place-items: center;
    padding: 0;
    border: none;
    background: var(--sunken);
    color: var(--ink-2);
    cursor: pointer;
}
.shopping-action.danger { color: var(--danger); }
.shopping-action .icon { width: 20px; height: 20px; }
@media (hover: none), (pointer: coarse) {
    .shopping .pointer-only { display: none; }
}
@media (hover: hover) and (pointer: fine) {
    .shopping-actions { display: none; }
}
.shopping-edit { display: flex; gap: 6px; align-items: center; padding: 4px 0; }
.shopping-edit .field { flex: 2; width: 0; min-width: 0; min-height: 40px; }
.shopping-edit .field.shopping-edit-quantity { flex: 1; }
.shopping-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 10px; }
.shopping-tools .button.soft { min-height: 36px; font-size: 0.875rem; }
.shopping-tools-end { display: flex; gap: 4px; margin-left: auto; }
.shopping-tools .button.link { color: var(--ink-2); font-size: 0.875rem; }

/* Departments of the shop as small headings; the bought products under their own one at the end. */
.shopping .checklist li.shopping-group {
    display: block;
    min-height: 0;
    padding: 12px 0 2px;
    color: var(--ink-3);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.shopping .checklist li.shopping-group:first-child { padding-top: 4px; }
.shopping-edit { flex-wrap: wrap; }
.shopping-edit .field.shopping-edit-department { flex: 1 1 100%; min-height: 40px; }
.shopping-edit-buttons { display: flex; gap: 6px; margin-left: auto; }
.shopping-edit .button.soft.icon-only { color: var(--accent-ink); background: var(--accent-soft); }
.shop-link { width: 100%; margin: 4px 0 6px; }

/* Products bought before: completions of the one being typed, or the frequent ones to add in a tap. */
.shopping-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 2px 0 8px; }
.shopping-chips-title { color: var(--ink-3); font-size: 0.8125rem; }
.shopping-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 0.875rem;
    cursor: pointer;
}
.shopping-chip .icon { width: 14px; height: 14px; color: var(--accent-ink); }
.shopping-chip:hover:not(:disabled) { background: var(--sunken); }

.shopping-route ol { list-style: none; margin: 0 0 8px; padding: 0; }
.shopping-route li { display: flex; align-items: center; gap: 4px; min-height: 44px; border-bottom: 1px solid var(--line); }
.shopping-route li > span { flex: 1; }
.shopping-route p { margin: 4px 0 8px; font-size: 0.875rem; }
.turn-up, .turn-down { display: inline-flex; }
.turn-up { transform: rotate(-90deg); }
.turn-down { transform: rotate(90deg); }

/* The shop mode: the list open on its own page, rows big enough for a thumb on the move. */
.shopping.shop { padding: 8px 16px 12px; }
.shopping.shop .shopping-head { min-height: 40px; }
.shopping.shop .shopping-front { min-height: 56px; font-size: 1.125rem; }
.shopping.shop .checklist input[type="checkbox"] { width: 24px; height: 24px; }
.shopping.shop .shopping-quantity { font-size: 1rem; }

/* Today's habits under the shopping list: a round mark, the habit and its count, the streak. */
.habits { margin-bottom: 1rem; padding: 4px 16px 8px; }
.habits-head { display: flex; align-items: center; gap: 10px; min-height: 48px; }
.habits-head .icon { flex: none; width: 20px; height: 20px; color: var(--accent-ink); }
.habits-title { font-weight: 600; }
.habits-count { flex: 1; color: var(--ink-2); font-size: 0.875rem; text-align: right; }
.habits ul { list-style: none; margin: 0; padding: 0; }
.habits li { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.habit-mark {
    flex: none;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1.75px solid var(--ink-3);
    border-radius: 50%;
    background: transparent;
    color: var(--on-accent);
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}
.habit-mark:hover { border-color: var(--accent); background: var(--accent-soft); }
.habit-mark:disabled { opacity: 0.4; }
.habit-mark.done, .habit-mark.done:hover { border-color: var(--accent); background: var(--accent); }
.habit-mark .icon { width: 16px; height: 16px; stroke-width: 3; }
.habit-text { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.habit-detail { color: var(--ink-2); font-size: 0.8125rem; }
.habit-detail:empty { display: none; }
.habits li.done .habit-name { color: var(--ink-2); }
.habit-streak { flex: none; display: inline-flex; align-items: center; gap: 4px; color: var(--warm); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.habit-streak .icon { width: 16px; height: 16px; }

.checklist-add { display: flex; gap: 6px; margin-bottom: 4px; }
.checklist-add .field { flex: 1; width: 0; min-width: 0; min-height: 40px; }
.checklist-add .button.soft.icon-only { width: 40px; min-height: 40px; color: var(--accent-ink); background: var(--accent-soft); }

.new-task { display: grid; gap: 8px; margin-top: 1.5rem; }
.new-task-title { display: flex; gap: 8px; }
.new-task-title .field { flex: 1; }
.new-task-title .button { flex: none; width: 48px; padding: 0; }
.new-task-title .button .icon { width: 22px; height: 22px; }
.new-task-when { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.new-task-when select { grid-column: 1 / -1; }
/* Inputs keep their intrinsic width in a grid unless allowed to shrink: date fields on iOS
   pushed the form, and the whole page with it, past the screen's edge. */
.new-task .field, .new-task-when > * { width: 100%; min-width: 0; }

details { margin-top: 1rem; }
summary { padding: 4px 0; color: var(--ink-2); font-weight: 500; cursor: pointer; }
details > .card, details > .tasks { margin-top: 8px; }

/* Toasts and the composer belong to .app, not to the scrolling page, so they stay above the bar. */
.toast {
    position: absolute;
    left: 50%;
    bottom: calc(var(--dock) + 12px);
    z-index: 20;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: calc(100% - 32px);
    padding: 6px 6px 6px 16px;
    border-radius: var(--radius);
    background: var(--ink);
    color: var(--bg);
    box-shadow: 0 8px 24px var(--shadow);
}

.toast span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast .button.link { flex: none; color: var(--bg); }

/* Calendar. */
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.month .weekday { padding-bottom: 2px; text-align: center; font-size: 0.7rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; }

.month .cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 56px;
    padding: 6px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 1px 2px var(--shadow);
}

.month .cell.blank { background: transparent; box-shadow: none; }
.month .cell .number { font-weight: 600; font-size: 0.9rem; }
.month .cell.past { background: transparent; box-shadow: none; }
.month .cell.past .number { color: var(--ink-3); }
.month .cell.today { border-color: var(--accent); }
.month .cell.today .number { color: var(--accent-ink); }
.month .counts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 0.72rem; color: var(--ink-2); }
.month .counts .left { padding: 0 5px; border-radius: 6px; background: var(--sunken); }
.month .counts .overdue { background: var(--warm-soft); color: var(--danger); }
.month .counts .done { display: inline-flex; align-items: center; color: var(--accent-ink); }
.month .counts .icon { width: 12px; height: 12px; stroke-width: 2.5; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 12px; }
.stat .value { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stat .label { font-size: 0.78rem; color: var(--ink-2); }

.heat-card { overflow-x: auto; }

.heat {
    display: grid;
    grid-template-rows: repeat(7, 12px);
    grid-auto-flow: column;
    grid-auto-columns: 12px;
    gap: 3px;
}

.heat-cell { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.heat-cell.l0 { background: var(--heat-0); }
.heat-cell.l1 { background: var(--heat-1); }
.heat-cell.l2 { background: var(--heat-2); }
.heat-cell.l3 { background: var(--heat-3); }
.heat-cell.l4 { background: var(--heat-4); }
.heat-cell.future { background: transparent; }

.heat-legend { display: flex; align-items: center; gap: 3px; margin-top: 8px; font-size: 0.75rem; color: var(--ink-3); }
.heat-legend span:first-child { margin-right: 4px; }
.heat-legend span:last-child { margin-left: 4px; }

/* Progress and food: charts, tables, macro bars. */
.chart { position: relative; height: 320px; margin-top: 1rem; padding: 12px; border-radius: var(--radius-l); background: var(--surface); box-shadow: 0 1px 2px var(--shadow), 0 4px 16px var(--shadow); }

table.data { width: 100%; margin-top: 8px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 8px; text-align: right; border-bottom: 1px solid var(--line); }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { color: var(--ink-3); font-size: 0.8rem; font-weight: 500; }

.macros { display: grid; gap: 12px; }
.macro-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 500; }
.macro-value { font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 400; }
.bar { display: block; width: 100%; height: 8px; margin-top: 6px; }
.bar .track { fill: var(--sunken); }
.bar .fill { fill: var(--series-1); }
.bar.over .fill { fill: var(--series-2); }
.macros .hint { margin: 0; font-size: 0.875rem; }
.empty { margin-top: 1rem; }

.meal-kcal { font-size: 0.875rem; font-weight: 400; margin-left: 4px; }
.food-entries { list-style: none; margin: 0; padding: 4px 16px; }

.food-entries li {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.food-entries li:last-child { border-bottom: none; }
.food-entries .kcal { font-variant-numeric: tabular-nums; font-weight: 600; }
.food-entries .pfc { grid-column: 1 / -1; font-size: 0.8rem; font-variant-numeric: tabular-nums; }

/* Diet quality (ADR 0053): the score beside its title, then its eight parts. */
.diet-quality { margin-top: 1.5rem; }
.diet-quality-head { display: flex; gap: 16px; align-items: center; }
.diet-quality-head h2 { margin: 0 0 4px; }
.diet-quality-head p { margin: 0; font-size: 0.875rem; }
.diet-parts { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.diet-parts .score-bar { margin: 6px 0 4px; }
.diet-part-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 0.8rem; }
.diet-gain { color: var(--accent-ink); font-weight: 600; }

/* Nutri-Score in the colours printed on EU labels, the same in both themes so it reads as the label. */
.nutri-score {
    display: inline-grid;
    place-items: center;
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 6px;
    border-radius: 5px;
    font-size: 0.72rem;
    font-weight: 700;
    vertical-align: 1px;
    color: #ffffff;
}
.nutri-score.a { background: #038141; }
.nutri-score.b { background: #85bb2f; }
.nutri-score.c { background: #fecb02; color: #2b2b2b; }
.nutri-score.d { background: #ee8100; }
.nutri-score.e { background: #e63e11; }

/* Sign-in pages. */
.center { max-width: 420px; margin: 15vh auto 0; text-align: center; }
.center .button { margin-top: 1.5rem; }
.brand-title { font-size: 1rem; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase; color: var(--accent-ink); }

#blazor-error-ui {
    display: none;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(env(safe-area-inset-bottom) + 12px);
    z-index: 1000;
    padding: 12px 16px;
    border-radius: var(--radius);
    background: var(--warm-soft);
    color: var(--ink);
    box-shadow: 0 8px 24px var(--shadow);
}

/* Chat (ADR 0033): the lines scroll with the page, the composer floats above the tab bar. */
.chat { padding-bottom: 72px; }
.chat-lines { display: flex; flex-direction: column; gap: 8px; }
.chat-empty { margin: 2rem 0; text-align: center; }

.bubble {
    max-width: 85%;
    padding: 9px 13px 5px;
    border-radius: 20px;
    background: var(--surface);
    box-shadow: 0 1px 2px var(--shadow);
    overflow-wrap: anywhere;
}

.bubble.mine { align-self: flex-end; border-bottom-right-radius: 6px; background: var(--accent); color: var(--on-accent); box-shadow: none; }
.bubble.theirs { align-self: flex-start; border-bottom-left-radius: 6px; }
.bubble p { margin: 0 0 6px; }
.bubble p.plain { white-space: pre-wrap; }
.bubble p.attachment { display: flex; align-items: center; gap: 6px; }
.bubble p.heading { font-weight: 650; }
.bubble ul, .bubble ol { margin: 0 0 6px; padding-left: 1.25rem; }
.bubble pre { margin: 0 0 6px; padding: 8px; border-radius: 8px; background: var(--sunken); overflow-x: auto; }
.bubble code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; }
.bubble a { color: inherit; }
.bubble-time { display: block; text-align: right; font-size: 0.7rem; color: var(--ink-3); }
.bubble.mine .bubble-time { color: var(--on-accent); opacity: 0.7; }
.bubble-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.bubble-buttons .button.soft { background: var(--accent-soft); color: var(--accent-ink); }
.bubble.typing { color: var(--ink-3); padding-bottom: 9px; }

.composer {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: calc(var(--dock) + 8px);
    z-index: 10;
    max-width: 560px;
    margin: 0 auto;
}

.composer-row {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: 0 8px 24px var(--shadow);
}

.composer-row .button.icon-only { border-radius: 50%; }
.composer-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.composer-files .chip { cursor: default; box-shadow: 0 2px 8px var(--shadow); }

.chip-remove {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    margin-right: -6px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: none;
    color: inherit;
    cursor: pointer;
}

.chip-remove .icon { width: 14px; height: 14px; }

.composer-text {
    flex: 1;
    min-width: 0;
    min-height: 40px;
    max-height: 160px;
    padding: 9px 6px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    resize: none;
    field-sizing: content;
}

.composer-text:focus { box-shadow: none; }

.recording { flex: 1; display: flex; align-items: center; gap: 8px; align-self: center; color: var(--danger); font-weight: 500; }
.recording-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse {
    50% { opacity: 0.3; }
}

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

/* Six tabs fit a phone only when they shrink a little. */
@media (max-width: 420px) {
    .tabbar { gap: 0; padding-left: max(4px, env(safe-area-inset-left)); padding-right: max(4px, env(safe-area-inset-right)); }
    .tabbar a { font-size: 0.6rem; letter-spacing: -0.01em; }
}

@media (max-width: 360px) {
    .tabbar a { font-size: 0.56rem; }
}

/* Health (ADR 0038). */
.health-lock { display: grid; justify-items: center; gap: 12px; text-align: center; padding: 24px 16px; }
.health-lock > .icon { width: 32px; height: 32px; color: var(--accent-ink); }
.health-lock p { margin: 0; color: var(--ink-2); }
.health-lock .error { color: var(--danger); }

.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; margin-bottom: 1rem; padding: 3px; border-radius: 12px; background: var(--sunken); }
.segmented button { min-width: 0; padding: 7px 2px; border: none; border-radius: 9px; background: none; color: var(--ink-2); font: inherit; font-size: 0.8rem; letter-spacing: -0.01em; font-weight: 500; cursor: pointer; }
.segmented button.selected { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px var(--shadow); }

.health-group { margin: 1rem 0 0.4rem; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); }
.health-list { list-style: none; margin: 0; padding: 4px 16px; }
.health-list li { display: grid; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.health-list li:last-child { border-bottom: none; }
.health-list li.past .title { color: var(--ink-2); }
.health-list .muted { font-size: 0.85rem; }
.health-list .notes { font-size: 0.875rem; color: var(--ink-2); }

.row-button {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 12px;
    width: 100%;
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.row-button .muted { grid-column: 1; }
.row-button .value { grid-row: 1; grid-column: 2; font-variant-numeric: tabular-nums; font-weight: 600; }
.row-button.selected .title { color: var(--accent-ink); font-weight: 600; }
.documents .row-button { grid-template-columns: auto 1fr auto; align-items: center; }
.documents .row-button .icon { width: 20px; height: 20px; color: var(--ink-3); }
.documents .row-button .icon:first-child { grid-row: 1 / span 2; }
.documents .row-button .title { grid-column: 2; overflow-wrap: anywhere; }
.documents .row-button .muted { grid-column: 2; }
.documents .row-button .icon:last-child { grid-row: 1 / span 2; grid-column: 3; color: var(--accent-ink); }

.value.out, tr.out td:nth-child(2) { color: var(--warm); font-weight: 600; }
.table-card { padding: 4px 8px; overflow-x: auto; }
.lab-table .button.link { padding: 0; min-height: 0; text-align: left; }
.hint { font-size: 0.85rem; }

/* Out of sight while the app is in the background: the app switcher shows no results. */
html.veiled main { visibility: hidden; }

/* Workouts (ADR 0041): the journal, attendance by month, sets per muscle group. */
.workouts { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 8px; }
.workout { padding: 0; }
.workout summary { display: grid; gap: 2px; padding: 12px 16px; cursor: pointer; list-style: none; }
.workout summary::-webkit-details-marker { display: none; }
.workout-title { display: flex; align-items: center; gap: 6px; color: var(--ink); font-weight: 600; }
.workout-meta { font-size: 0.85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.workout-groups { font-size: 0.8rem; color: var(--accent-ink); }
.record { display: inline-grid; place-items: center; color: var(--warm); }
.record .icon { width: 15px; height: 15px; }
.workout-exercises { list-style: none; margin: 0; padding: 0 16px 8px; border-top: 1px solid var(--line); }
.workout-exercises li { display: grid; gap: 4px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.workout-exercises li:last-child { border-bottom: none; }
.exercise-name { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.exercise-sets { display: flex; flex-wrap: wrap; gap: 4px; }
.exercise-sets .set { padding: 2px 8px; border-radius: 999px; background: var(--sunken); font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.exercise-sets .set.warmup { background: transparent; color: var(--ink-3); border: 1px dashed var(--line); }
.workout-notes { margin: 0; padding: 0 16px 12px; color: var(--ink-2); font-size: 0.875rem; }

.month-bars { padding: 14px 12px 10px; }
.month-chart { display: block; width: 100%; height: auto; max-width: 520px; margin: 0 auto; overflow: visible; }
.month-axis { stroke: var(--line); stroke-width: 1; }
.month-goal { stroke: var(--warm); stroke-width: 1.5; stroke-dasharray: 4 4; opacity: 0.8; }
.month-fill { fill: var(--heat-2); }
.month-fill.met { fill: var(--accent); }
/* A halo of the card's colour keeps a count readable where the goal line passes behind it. */
.month-count { font-size: 12px; font-weight: 600; fill: var(--ink-2); text-anchor: middle; font-variant-numeric: tabular-nums; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.month-name { font-size: 11px; fill: var(--ink-3); text-anchor: middle; }
.month-legend { display: flex; align-items: center; gap: 6px; margin: 6px 4px 0; font-size: 0.75rem; color: var(--ink-3); }
.month-legend-goal { width: 16px; border-top: 1.5px dashed var(--warm); }

.muscles { list-style: none; margin: 0 0 0.75rem; padding: 4px 16px; }
.muscles li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.muscles li:last-child { border-bottom: none; }
.muscle-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 500; }
.muscle-value { color: var(--ink-2); font-weight: 400; font-variant-numeric: tabular-nums; }
.muscle-bar .range { fill: var(--accent-soft); }
.muscle-bar.low .fill { fill: var(--warm); }
.muscle-last { display: block; margin-top: 4px; font-size: 0.8rem; color: var(--ink-3); }

/* Workouts: the program and its next day. */
.segmented.five { grid-template-columns: repeat(5, auto); }
.segmented.five button { padding-inline: 6px; font-size: 0.75rem; }
.program-name { margin-bottom: 0.25rem; }
.next-day { padding: 12px 16px; margin-bottom: 1rem; }
.next-day-head { display: flex; align-items: baseline; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.next-day-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent-ink); }
.next-day-name { font-weight: 650; }
.targets { list-style: none; margin: 0; padding: 0; }
.targets li { display: grid; gap: 4px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.targets li:last-child { border-bottom: none; }
.target-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.target-value { font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.target-last { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 0.8rem; color: var(--ink-3); }
.target-last .set { padding: 1px 6px; border-radius: 999px; background: var(--sunken); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.target-last .set.warmup { background: transparent; border: 1px dashed var(--line); color: var(--ink-3); }
.target-notes { font-size: 0.82rem; color: var(--ink-2); }
.step { flex: none; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: var(--sunken); color: var(--ink-2); }
.step-increase { background: var(--accent-soft); color: var(--accent-ink); }
.step-decrease { background: var(--warm-soft); color: var(--warm); }
.next-mark { padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: 0.72rem; font-weight: 600; }

/* Workouts: today's workout, marked set by set. */
.session-since { margin-left: auto; }
.session-days { margin: 10px 0 0; }
.session-days .chip { min-height: 30px; font-size: 0.8rem; }
.session-error, .session-notice { margin: 10px 0 0; font-size: 0.875rem; }
.session-notice { color: var(--accent-ink); }
.session-exercises li.left-out { opacity: 0.7; }
.session-exercises li.left-out .exercise-name { text-decoration: line-through; color: var(--ink-2); }
.set-rows { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 6px; }
.targets .set-rows li { display: flex; align-items: center; gap: 8px; padding: 0; border: none; }
.set-number { flex: none; width: 18px; color: var(--ink-3); font-size: 0.8rem; font-variant-numeric: tabular-nums; text-align: center; }
.set-fields { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0; }
.set-field {
    flex: 1 1 0;
    width: 0;
    min-width: 0;
    min-height: 40px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-s);
    background: var(--sunken);
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: center;
    -moz-appearance: textfield;
    appearance: textfield;
}
.set-field::-webkit-outer-spin-button, .set-field::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.set-field::placeholder { color: var(--ink-3); font-weight: 400; font-size: 0.8rem; }
.set-field:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.set-field.rpe { flex: 0.8 1 0; font-weight: 500; color: var(--ink-2); }
.set-times { flex: none; color: var(--ink-3); }
.set-row.done .set-field { background: var(--accent-soft); color: var(--accent-ink); }
.set-row.done.warmup .set-field { background: transparent; border: 1px dashed var(--line); color: var(--ink-2); }
.set-check {
    flex: none;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 2px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--ink-3);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.set-check .icon { width: 20px; height: 20px; }
.set-check:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-ink); }
.set-check:active:not(:disabled) { transform: scale(0.94); }
.set-check.checked { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.set-check:disabled { opacity: 0.6; cursor: default; }
/* Drops a row not marked yet: small and quiet, so it is not hit instead of the check. */
.set-drop {
    flex: none;
    display: grid;
    place-items: center;
    width: 24px;
    height: 40px;
    margin: 0 -4px;
    padding: 0;
    border: none;
    background: none;
    color: var(--ink-3);
    cursor: pointer;
}
.set-drop .icon { width: 16px; height: 16px; }
.set-drop:hover { color: var(--ink); }
.session-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.session-tools .button.link { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; }
.session-tools .button.link .icon { width: 14px; height: 14px; }
.session-tools .button.link.quiet { color: var(--ink-3); }
.session-add { display: grid; gap: 8px; margin-top: 10px; }
.session-add-row { display: flex; gap: 8px; }
.session-add-row .field { flex: 1; width: 0; min-width: 0; min-height: 40px; }
.session-add-row .button.icon-only { width: 40px; min-height: 40px; }
.session-choices { margin: 0; }
.session-choices .chip small { color: var(--ink-3); font-size: 0.72rem; }
.session-add-open { margin-top: 10px; }
.session-finish { margin-top: 12px; }

/* Workouts: the rest between sets, above the tab bar like the toast. */
.rest-timer {
    position: absolute;
    left: 50%;
    bottom: calc(var(--dock) + 12px);
    z-index: 20;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    width: min(420px, calc(100% - 32px));
    padding: 6px 6px 6px 16px;
    overflow: hidden;
    border-radius: var(--radius);
    background: var(--ink);
    color: var(--bg);
    box-shadow: 0 8px 24px var(--shadow);
}
.rest-progress { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 3px; }
.rest-progress-fill { fill: var(--accent); }
.rest-label { flex: 1; font-size: 0.875rem; }
.rest-time { font-size: 1.25rem; font-weight: 650; font-variant-numeric: tabular-nums; margin-right: 4px; }
.rest-timer.over .rest-label, .rest-timer.over .rest-time { color: var(--accent-soft); }
.rest-button {
    flex: none;
    min-width: 40px;
    min-height: 36px;
    padding: 0 6px;
    border: none;
    border-radius: var(--radius-s);
    background: color-mix(in srgb, var(--bg) 14%, transparent);
    color: var(--bg);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}
.rest-button.icon { display: grid; place-items: center; background: none; }
.rest-button .icon { width: 18px; height: 18px; }

/* Сводка: the life score (ADR 0044). */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 0.75rem; }
.page-head h1 { margin: 0; }
.back-link { display: inline-flex; align-items: center; gap: 2px; margin-bottom: 4px; color: var(--accent-ink); font-size: 0.9rem; text-decoration: none; }
.back-link .icon { width: 18px; height: 18px; }

.score-hero { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 20px 16px 16px; margin-bottom: 12px; }
.score-help { position: absolute; top: 8px; right: 8px; color: var(--accent-ink); }
.score-ring { position: relative; flex: none; }
.score-ring svg { display: block; }
.score-ring-track { stroke: var(--sunken); }
.score-ring-fill { stroke: var(--accent); }
.score-ring-number { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.score-ring-number b { font-size: 3rem; line-height: 1; letter-spacing: -0.02em; }
.score-ring-number small { margin-top: 4px; color: var(--ink-3); font-size: 0.8125rem; }
.score-band { margin: 10px 0 2px; font-weight: 600; font-size: 1.05rem; }
.score-sub { margin: 0; color: var(--ink-3); font-size: 0.8125rem; }
.score-delta { color: var(--accent-ink); font-weight: 600; }
.score-delta.down { color: var(--warm); }

.score-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 1rem; }
.score-tile { display: flex; flex-direction: column; padding: 12px 14px; color: inherit; text-decoration: none; min-width: 0; }
.score-tile-name { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 0.8125rem; }
.score-tile-name .icon { width: 16px; height: 16px; color: var(--accent-ink); flex: none; }
.score-tile b { margin: 4px 0 2px; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.score-tile small { color: var(--ink-3); font-size: 0.75rem; overflow-wrap: anywhere; }
.score-tile b.low, .score-pillar-head b.low, .score-rows b.low { color: var(--warm); }

.score-tips { list-style: none; margin: 0 0 1rem; padding: 0; }
.score-tips li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 0.9rem; }
.score-tips li:first-child { border-top: none; }
.score-tips li span { display: flex; flex-direction: column; min-width: 0; }
.score-tips small { color: var(--ink-3); font-size: 0.75rem; }
.observations { list-style: none; margin: 0 0 1rem; padding: 0; }
.observations li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 0.9rem; }
.observations li:first-child { border-top: none; }
.observations li > .icon { width: 20px; height: 20px; flex: none; color: var(--accent-ink); }
.observations li > span { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.observations small { color: var(--ink-3); font-size: 0.75rem; }
.observations li > .button { flex: none; }
.score-gain { flex: none; min-width: 42px; padding: 3px 0; border-radius: 8px; background: var(--accent-soft); color: var(--accent-ink); font-size: 0.8125rem; text-align: center; }
.score-gain.note { background: var(--warm-soft); color: var(--warm); }

.score-trend { padding: 14px 16px 10px; margin-bottom: 12px; }
.score-trend-head { display: flex; justify-content: space-between; margin-bottom: 6px; color: var(--ink-2); font-size: 0.8125rem; }
.score-trend-chart { display: block; width: 100%; height: 96px; overflow: visible; }
.score-trend-guide { stroke: var(--line); stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.score-trend-line { stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.score-trend-dot { fill: var(--accent); }

.score-pillar { padding: 14px 16px; margin-bottom: 10px; scroll-margin-top: 16px; }
.score-pillar-head { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.score-pillar-head .icon { width: 20px; height: 20px; color: var(--accent-ink); flex: none; }
.score-pillar-head b { margin-left: auto; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.score-source { display: inline-block; margin-left: 4px; padding: 1px 6px; border-radius: 6px; background: var(--sunken); color: var(--ink-3); font-size: 0.6875rem; font-weight: 400; white-space: nowrap; }
.score-bar { display: block; width: 100%; height: 8px; margin: 8px 0 10px; border-radius: 4px; overflow: hidden; }
.score-bar-track { fill: var(--sunken); }
.score-bar-fill { fill: var(--accent); }
.score-bar-fill.low { fill: var(--warm); }
.score-rows { list-style: none; margin: 0; padding: 0; }
.score-rows li { display: flex; align-items: baseline; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 0.875rem; }
.score-row-name { flex: 1; min-width: 0; }
.score-row-value { color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; }
.score-rows b { width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.score-rows li.na .score-row-name, .score-rows li.na b { color: var(--ink-3); }
.score-foot { margin: 6px 4px 0; font-size: 0.75rem; line-height: 1.45; }

.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgb(0 0 0 / 0.35); }
.sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 21;
    max-width: 720px;
    max-height: 85vh;
    margin: 0 auto;
    padding: 12px 20px calc(24px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: var(--radius-l) var(--radius-l) 0 0;
    background: var(--surface);
    box-shadow: 0 -8px 30px var(--shadow);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-head h2 { margin: 0; font-size: 1.15rem; }
.sheet p { margin: 6px 0 10px; color: var(--ink-2); font-size: 0.875rem; line-height: 1.45; }
.score-bands { display: flex; gap: 6px; margin: 4px 0 12px; }
.score-bands span { flex: 1; padding: 5px 0; border-radius: 8px; background: var(--sunken); color: var(--ink-2); font-size: 0.72rem; text-align: center; }
.score-rules { margin: 0; }
.score-rules dt { display: flex; justify-content: space-between; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); font-weight: 600; font-size: 0.9rem; }
.score-rules dt span { color: var(--accent-ink); font-weight: 500; font-size: 0.75rem; }
.score-rules dd { margin: 2px 0 10px; color: var(--ink-2); font-size: 0.8125rem; line-height: 1.4; }
.score-bands span.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

/* «Действия»: the agents' action log and the user's rules (ADR 0045). */
.segmented.two { grid-template-columns: repeat(2, 1fr); }
.segmented.three { grid-template-columns: repeat(3, 1fr); }
.segmented.four { grid-template-columns: repeat(4, auto); }
.action-list, .rule-list { list-style: none; margin: 0; padding: 4px 16px; }
.action-list li, .rule-list li { border-bottom: 1px solid var(--line); }
.action-list li:last-child, .rule-list li:last-child { border-bottom: none; }
.action-row { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 10px; width: 100%; padding: 10px 0; border: none; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.action-row .time { color: var(--ink-3); font-size: 0.85rem; font-variant-numeric: tabular-nums; padding-top: 1px; }
.action-row .what { display: grid; gap: 2px; min-width: 0; }
.action-row .summary { color: var(--ink-2); font-size: 0.875rem; overflow-wrap: anywhere; }
.action-row .muted { font-size: 0.8rem; }
.outcome { padding: 2px 8px; border-radius: 999px; background: var(--sunken); color: var(--ink-2); font-size: 0.75rem; white-space: nowrap; }
.outcome.bad { background: var(--warm-soft); color: var(--danger); }
.outcome.waiting { background: var(--warm-soft); color: var(--warm); }
.outcome.good { background: var(--accent-soft); color: var(--accent-ink); }
.action-rule { display: grid; gap: 6px; padding: 0 0 12px; }
.action-rule .muted { font-size: 0.85rem; }
.rule-list li { display: grid; gap: 8px; padding: 12px 0; }
.rule-list .muted { font-size: 0.85rem; }
.rule-switch { margin-bottom: 0; }
.rule-switch button { padding-inline: 6px; font-size: 0.75rem; }
.rule-note { font-size: 0.85rem; margin: 0 0 0.5rem; }
.action-list li.open > .button.soft { margin-bottom: 10px; }

/* Память (ADR 0046): facts by agent and category, each with its own actions. */
.memory-search { display: flex; gap: 8px; margin-bottom: 1rem; }
.memory-search .field { flex: 1; width: 0; min-width: 0; }
.memory-locked { display: flex; align-items: center; gap: 10px; margin-bottom: 1rem; padding: 12px 16px; color: var(--ink-2); font-size: 0.9rem; }
.memory-locked > .icon { flex: none; width: 20px; height: 20px; color: var(--accent-ink); }
.memory-locked > span { flex: 1; }
.fact-category { margin: 0.75rem 0 0.4rem; color: var(--ink-3); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.fact-list { list-style: none; margin: 0 0 0.5rem; padding: 4px 16px; }
.fact-list li { display: grid; gap: 4px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.fact-list li:last-child { border-bottom: none; }
.fact-text { overflow-wrap: anywhere; }
.fact-list .muted { font-size: 0.8rem; }
.fact-list textarea.field { width: 100%; padding: 10px 12px; resize: vertical; }
.fact-actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 4px; }
.memory-export { display: grid; gap: 12px; padding: 16px; }
.memory-export p { margin: 0; color: var(--ink-2); font-size: 0.9rem; }
.memory-export .button { justify-self: start; }

/* Calendar events in the day (ADR 0049): read from the user's calendar, greyed, never checkable. */
.events { list-style: none; margin: 0 0 12px; padding: 4px 16px; }
.event { display: flex; align-items: baseline; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--ink-2); }
.event:last-child { border-bottom: none; }
.event .when { flex: none; min-width: 88px; font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.event .what { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.event .where { color: var(--ink-3); font-size: 0.8rem; }
.event.free .title { color: var(--ink-3); }
.page-head-actions { display: inline-flex; gap: 6px; }

/* Linked calendars. */
.calendar-list { list-style: none; margin: 0 0 1rem; padding: 4px 16px; }
.calendar-list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.calendar-list li:last-child { border-bottom: none; }
.calendar-list .what { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.calendar-list .state { color: var(--ink-3); font-size: 0.8rem; }
.calendar-list .state.error { color: var(--danger); }
.calendar-form { display: flex; flex-direction: column; gap: 8px; padding: 16px; }
.calendar-help { color: var(--ink-2); font-size: 0.875rem; }
.calendar-help summary { cursor: pointer; }

/* Apple Health (ADR 0048) */
.apple-health-card { display: flex; flex-direction: column; gap: 8px; padding: 16px; margin-bottom: 1rem; }
.apple-health-card h2 { margin: 0; }
.apple-health-card p { margin: 0; }
.apple-health-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.apple-health-secret { display: flex; align-items: center; gap: 8px; }
.apple-health-secret code { flex: 1; min-width: 0; overflow-wrap: anywhere; padding: 8px; border-radius: var(--radius); background: var(--sunken); font-size: 0.8rem; }
.join-form { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.join-form .field { text-align: center; letter-spacing: 0.1em; text-transform: uppercase; }

/* Devices: the QR code of a link that enrols a passkey elsewhere, light on dark themes too, so cameras read it. */
.device-link-card { display: flex; flex-direction: column; gap: 12px; }
.passkey-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.passkey-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.passkey-list .muted { font-size: 0.85rem; }
.badge { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; background: var(--surface-2, rgba(127,127,127,.15)); color: var(--ink-2, inherit); }
.device-qr { width: min(240px, 100%); align-self: center; border-radius: var(--radius); }
.device-qr .light { fill: #fff; }
.device-qr .dark { fill: #000; }
.apple-health-steps { margin: 8px 0; padding-left: 1.25rem; display: flex; flex-direction: column; gap: 6px; }
.apple-health-steps code { overflow-wrap: anywhere; font-size: 0.8rem; }
.health-link { display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 1rem; color: inherit; text-decoration: none; }
.health-link .what { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.health-link .state { color: var(--ink-3); font-size: 0.8rem; }
.health-link .state.error { color: var(--danger); }

/* Workouts: a program day changed by hand. */
.program-exercise-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.program-exercise-tools { display: flex; gap: 2px; flex: none; }
.button.icon-only.small { width: 32px; min-height: 32px; }
.button.icon-only.small .icon { width: 18px; height: 18px; }
.button.icon-only.small.selected { background: var(--accent-soft); color: var(--accent-ink); }
.program-form { display: grid; gap: 10px; margin-top: 6px; padding: 12px; border-radius: var(--radius-s); background: var(--sunken); }
.program-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px; }
.program-field { display: grid; gap: 4px; font-size: 0.75rem; color: var(--ink-3); }
.program-field .field { min-height: 40px; width: 100%; min-width: 0; background: var(--surface); font-variant-numeric: tabular-nums; }
.program-field textarea.field { resize: vertical; font: inherit; font-size: 0.875rem; }
.program-form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.program-form-actions .program-remove { margin-left: auto; }
.program-form-actions .button.link .icon, .program-day-tools .button .icon { width: 14px; height: 14px; }
.program-day-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 0 16px 12px; }
.program-day-tools .session-add { flex: 1; margin-top: 0; }
.program-day-tools .button.link { display: inline-flex; align-items: center; gap: 4px; }
.program-error { margin: 0; padding: 0 16px 8px; font-size: 0.875rem; }
.session-tools { flex-wrap: wrap; column-gap: 12px; }
.session-tools-group { display: flex; flex-wrap: wrap; align-items: center; column-gap: 12px; min-width: 0; }
.set-row.warmup .set-number { color: var(--ink-3); }
.set-row.warmup:not(.done) .set-field { background: transparent; border: 1px dashed var(--line); }
.session-replace { display: grid; gap: 8px; margin-top: 6px; padding: 12px; border-radius: var(--radius-s); background: var(--sunken); }
.session-replace-title { font-size: 0.85rem; color: var(--ink-2); }
.session-replace .session-add { margin-top: 0; }
.session-replace .field { background: var(--surface); }
.session-replace .muted { margin: 0; font-size: 0.85rem; }

/* Tasks: the tags of a new task, the user's own as chips and a field for a new one. */
.tag-picker { grid-column: 1 / -1; display: grid; gap: 8px; }
.tag-picker .chips { margin-bottom: 0; }
.tag-picker-new { display: flex; gap: 8px; }
.tag-picker-new .field { flex: 1; }
.tag-picker-new .button { flex: none; }
.tag-picker .chip:disabled { opacity: 0.45; cursor: default; }
.new-task-when .check-label { grid-column: 1 / -1; }
.task .task-tags { flex-basis: 100%; display: grid; gap: 8px; padding-left: 38px; margin-top: 4px; }
.task-tags-buttons { display: flex; gap: 6px; }

/* The cycle tab (ADR 0055): bleeding in terracotta, what is only expected in its outline, the fertile
   window in sage. Colors come from the tokens, so the dark theme needs nothing more. */
.cycle-start { display: grid; gap: 12px; padding: 16px; }
.cycle-start h2, .cycle-start p { margin: 0; }
.cycle-field { display: grid; gap: 4px; font-size: 0.85rem; color: var(--ink-2); }
.cycle-today { display: grid; gap: 4px; padding: 16px; margin-bottom: 0.75rem; }
.cycle-mode { display: grid; gap: 8px; padding: 12px 16px; margin-block: 0.75rem; }
.cycle-conception { display: grid; gap: 6px; margin-bottom: 0.75rem; }
.cycle-conception p { margin: 0; }
.cycle-conception .chart { height: 220px; margin-top: 0.5rem; box-shadow: none; padding: 0; }
.cycle-sharing { display: grid; gap: 4px; padding: 12px 16px; margin-block: 0.75rem; }
.cycle-day { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
.cycle-phase { font-weight: 600; color: var(--ink-2); }
.cycle-phase.phase-menstrual, .cycle-phase.phase-late { color: var(--warm); }
.cycle-phase.phase-fertile { color: var(--accent-ink); }
.cycle-calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 0.5rem; }
.cycle-calendar .weekday { text-align: center; font-size: 0.7rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; }
.cycle-cell {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}
.cycle-cell:disabled { cursor: default; color: var(--ink-3); }
.cycle-cell.kind-period { background: var(--warm); color: var(--on-accent); }
.cycle-cell.kind-spotting { background: var(--warm-soft); color: var(--warm); }
.cycle-cell.kind-expectedperiod { border: 1.5px dashed var(--warm); color: var(--warm); }
.cycle-cell.kind-fertile { background: var(--accent-soft); color: var(--accent-ink); }
.cycle-cell.kind-ovulation { background: var(--accent); color: var(--on-accent); }
.cycle-cell.today .number { font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.cycle-cell.selected { box-shadow: 0 0 0 2px var(--ink); }
.cycle-cell .dot { position: absolute; bottom: 3px; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.cycle-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 1rem; font-size: 0.8rem; }
.cycle-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 4px; border-radius: 50%; vertical-align: -1px; }
.cycle-legend .kind-period::before { background: var(--warm); }
.cycle-legend .kind-expectedperiod::before { border: 1.5px dashed var(--warm); }
.cycle-legend .kind-fertile::before { background: var(--accent-soft); }
.cycle-editor { display: grid; gap: 4px; padding: 16px; margin-bottom: 1rem; }
.cycle-editor h2 { margin: 0 0 4px; }
.cycle-editor .health-group { margin-top: 0.5rem; }
.cycle-editor .chips { margin-bottom: 0.25rem; }
.cycle-editor textarea { margin: 8px 0; }
.cycle-row { display: flex; gap: 12px; margin-bottom: 6px; }

/* The cycle report for a gynecologist (ADR 0055): on screen a page of its own, on paper only it. */
.cycle-report h3 { margin: 1rem 0 0.25rem; font-size: 1rem; }
.report-actions { display: flex; gap: 8px; justify-content: space-between; margin-bottom: 0.75rem; }
@media print {
    body * { visibility: hidden; }
    .cycle-report, .cycle-report * { visibility: visible; }
    .cycle-report { position: absolute; inset: 0 auto auto 0; width: 100%; color: #000; }
    .no-print { display: none; }
}

/* The household's shared space (ADR 0057). */
.space-card { padding: 16px; margin-bottom: 1rem; }
.space-card .calendar-list { padding: 0; margin: 0; }
.space-card h2 { margin: 0; }
.space-rename { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.space-rename .field { flex: 1; min-width: 160px; }

/* A task the household shares (ADR 0057): who does it, and the controls to share and assign it. */
.task .tag.shared { background: var(--warm-soft); color: var(--ink-2); }
.task .tag.shared .icon { width: 12px; height: 12px; vertical-align: -1px; }
.task-sharing { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.task-sharing select.field { width: auto; }
