/* Schweitzer Day design system. Light and dark themes follow the system unless the device overrides it
   (html[data-theme]). Member colors arrive as inline custom properties: --mc / --mt (light) and --mc-d / --mt-d (dark). */

:root {
    color-scheme: light;
    --bg: #f6f7f8;
    --surface: #ffffff;
    --surface-2: #eef1f3;
    --surface-3: #e2e7ea;
    --text: #15191d;
    --text-2: #4b5560;
    --text-3: #6b7580;
    --border: #d5dbe0;
    --accent: #0b7a7a;
    --accent-strong: #08605f;
    --accent-soft: #d9f1f1;
    --on-accent: #ffffff;
    --family: #12a3a3;
    --danger: #b3261e;
    --danger-soft: #fde7e6;
    --warning: #8a5300;
    --warning-soft: #fff1d6;
    --success: #1e7a3c;
    --success-soft: #e2f5e8;
    --focus: #1a5fd0;
    --gridline: #e4e8eb;
    --gridline-strong: #cfd6db;
    --now: #d93025;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.08), 0 4px 16px rgb(0 0 0 / 0.08);
    --radius: 12px;
    --radius-s: 8px;
    --nav-h: 64px;
    --header-h: 56px;
    --hour-h: 56px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1215;
    --surface: #171b1f;
    --surface-2: #20252a;
    --surface-3: #2b3238;
    --text: #eef1f3;
    --text-2: #b9c2ca;
    --text-3: #949ea8;
    --border: #353d44;
    --accent: #4cc9c9;
    --accent-strong: #7ad9d9;
    --accent-soft: #123b3b;
    --on-accent: #062424;
    --family: #4cc9c9;
    --danger: #ff8a80;
    --danger-soft: #3d1a18;
    --warning: #ffc266;
    --warning-soft: #3a2a0d;
    --success: #7fd69a;
    --success-soft: #133220;
    --focus: #8ab4ff;
    --gridline: #242a30;
    --gridline-strong: #343c43;
    --now: #ff6b5e;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 16px rgb(0 0 0 / 0.4);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0f1215;
        --surface: #171b1f;
        --surface-2: #20252a;
        --surface-3: #2b3238;
        --text: #eef1f3;
        --text-2: #b9c2ca;
        --text-3: #949ea8;
        --border: #353d44;
        --accent: #4cc9c9;
        --accent-strong: #7ad9d9;
        --accent-soft: #123b3b;
        --on-accent: #062424;
        --family: #4cc9c9;
        --danger: #ff8a80;
        --danger-soft: #3d1a18;
        --warning: #ffc266;
        --warning-soft: #3a2a0d;
        --success: #7fd69a;
        --success-soft: #133220;
        --focus: #8ab4ff;
        --gridline: #242a30;
        --gridline-strong: #343c43;
        --now: #ff6b5e;
        --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 16px rgb(0 0 0 / 0.4);
    }
}

/* Member color resolution: light by default, the dark variant in dark mode. */
.member-color {
    --c: var(--mc, var(--family));
    --t: var(--mt, #ffffff);
}

:root[data-theme="dark"] .member-color {
    --c: var(--mc-d, var(--mc, var(--family)));
    --t: var(--mt-d, var(--mt, #000000));
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .member-color {
        --c: var(--mc-d, var(--mc, var(--family)));
        --t: var(--mt-d, var(--mt, #000000));
    }
}

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

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4 {
    line-height: 1.2;
    margin: 0 0 0.5rem;
}

h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

h1:focus { outline: none; }

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

a:hover {
    color: var(--accent-strong);
}

img {
    max-width: 100%;
}

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

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: 0.5rem;
    top: -3rem;
    z-index: 100;
    background: var(--surface);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-s);
}

.skip-link:focus {
    top: 0.5rem;
}

/* App shell: a sidebar on wide screens, bottom tabs on phones. */

.shell {
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: var(--header-h);
    padding: env(safe-area-inset-top) 1rem 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.app-header .brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    text-decoration: none;
    margin-right: auto;
}

.app-main {
    padding: 1rem;
    padding-bottom: calc(var(--nav-h) + 1.5rem + env(safe-area-inset-bottom));
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    min-width: 0;
}

.app-nav {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 30;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}

.app-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
}

.app-nav li.nav-settings {
    display: none;
}

.app-nav a {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: var(--nav-h);
    color: var(--text-2);
    text-decoration: none;
    font-size: 0.75rem;
}

.app-nav a.active {
    color: var(--accent);
    font-weight: 600;
}

.app-nav .icon {
    font-size: 1.35rem;
    line-height: 1;
}

.nav-badge {
    position: absolute;
    top: 6px;
    left: calc(50% + 6px);
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: var(--danger);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@media (min-width: 900px) {
    .shell {
        grid-template-columns: 220px 1fr;
        grid-template-rows: auto 1fr;
    }

    .app-header {
        grid-column: 1 / -1;
    }

    .app-nav {
        position: sticky;
        top: var(--header-h);
        inset: auto;
        height: calc(100dvh - var(--header-h));
        border-top: 0;
        border-right: 1px solid var(--border);
        padding: 1rem 0.5rem;
    }

    .app-nav ul {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }

    .app-nav li.nav-settings {
        display: block;
    }

    .app-nav a {
        flex-direction: row;
        justify-content: flex-start;
        gap: 0.75rem;
        min-height: 44px;
        padding: 0 0.75rem;
        border-radius: var(--radius-s);
        font-size: 0.95rem;
    }

    .app-nav a.active {
        background: var(--accent-soft);
    }

    .nav-badge {
        position: static;
        margin-left: auto;
    }

    .app-main {
        padding: 1.5rem 2rem 2rem;
    }
}

/* Status banners. */

.banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
}

.banner.offline {
    background: var(--warning-soft);
    color: var(--warning);
}

.banner.error {
    background: var(--danger-soft);
    color: var(--danger);
}

.sync-status {
    font-size: 0.8rem;
    color: var(--text-3);
    white-space: nowrap;
}

/* Controls. */

button, .button {
    font: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0 1rem;
    border-radius: var(--radius-s);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

button:hover:not(:disabled), .button:hover {
    background: var(--surface-2);
    color: var(--text);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button.primary, .button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
}

button.primary:hover:not(:disabled), .button.primary:hover {
    background: var(--accent-strong);
    color: var(--on-accent);
}

button.danger {
    color: var(--danger);
    border-color: var(--danger);
}

button.danger:hover:not(:disabled) {
    background: var(--danger-soft);
}

button.ghost, .button.ghost {
    border-color: transparent;
    background: transparent;
}

button.icon-button {
    width: 44px;
    padding: 0;
}

button.small, .button.small {
    min-height: 32px;
    padding: 0 0.6rem;
    font-size: 0.875rem;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.button-row.end {
    justify-content: flex-end;
}

input, select, textarea {
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    width: 100%;
}

textarea {
    min-height: 6rem;
    resize: vertical;
}

input[type="checkbox"], input[type="radio"] {
    width: 1.25rem;
    height: 1.25rem;
    min-height: 0;
    accent-color: var(--accent);
}

input[type="color"] {
    width: 3rem;
    padding: 0.2rem;
}

input[type="file"] {
    padding: 0.5rem;
}

input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
    border-color: var(--danger);
}

.field {
    display: grid;
    gap: 0.3rem;
    margin-bottom: 1rem;
}

.field > label, .field > .label {
    font-weight: 600;
    font-size: 0.9rem;
}

.field .hint {
    font-size: 0.85rem;
    color: var(--text-3);
}

.field .error, .form-error {
    font-size: 0.875rem;
    color: var(--danger);
}

.check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
}

.field-row {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin: 0 0 1rem;
}

legend {
    font-weight: 600;
    padding: 0 0.25rem;
}

/* Segmented control (radio-like buttons). */

.segmented {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-s);
    overflow: hidden;
    background: var(--surface);
}

.segmented button {
    border: 0;
    border-radius: 0;
    min-height: 40px;
}

.segmented button + button {
    border-left: 1px solid var(--border);
}

.segmented button[aria-pressed="true"] {
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
}

/* Surfaces. */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.card > h2:first-child, .card > h3:first-child {
    margin-top: 0;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.page-header h1 {
    margin: 0 auto 0 0;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.muted {
    color: var(--text-3);
}

.small-text {
    font-size: 0.875rem;
}

.empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-3);
}

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

.list > li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
    min-height: 52px;
}

.list > li:last-child {
    border-bottom: 0;
}

.list .grow {
    flex: 1;
    min-width: 0;
}

.grid-cards {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
    overflow-x: auto;
}

.tabs a, .tabs button {
    border: 0;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--text-2);
    text-decoration: none;
    padding: 0 0.9rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.tabs a.active, .tabs button[aria-selected="true"] {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 32px;
    padding: 0 0.7rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.875rem;
}

button.chip[aria-pressed="true"] {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--text);
    font-weight: 600;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--surface-3);
    color: var(--text-2);
}

.badge.accent { background: var(--accent-soft); color: var(--accent-strong); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.success { background: var(--success-soft); color: var(--success); }

.notice {
    border-radius: var(--radius-s);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background: var(--surface-2);
}

.notice.warning { background: var(--warning-soft); color: var(--warning); }
.notice.danger { background: var(--danger-soft); color: var(--danger); }
.notice.success { background: var(--success-soft); color: var(--success); }

.secret {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    word-break: break-all;
    background: var(--surface-2);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-s);
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

table.data th, table.data td {
    text-align: left;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.table-scroll {
    overflow-x: auto;
}

/* Avatars: a member's color with initials; pets carry a pattern (stripes for dogs, dots for cats). */

.avatar {
    --size: 36px;
    width: var(--size);
    height: var(--size);
    flex: none;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: var(--c);
    color: var(--t);
    font-weight: 700;
    font-size: calc(var(--size) * 0.38);
    line-height: 1;
    letter-spacing: -0.02em;
    position: relative;
    user-select: none;
}

.avatar.small { --size: 24px; }
.avatar.large { --size: 64px; }
.avatar.xlarge { --size: 96px; }

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar .initials {
    position: relative;
    z-index: 1;
    padding: 0.1em 0.2em;
    border-radius: 4px;
}

.avatar.pattern-striped .initials, .avatar.pattern-polkadot .initials {
    background-color: var(--c);
}

.pattern-striped {
    background-image: repeating-linear-gradient(135deg, transparent 0 5px, rgb(255 255 255 / 0.38) 5px 9px);
}

.pattern-polkadot {
    background-image: radial-gradient(circle, rgb(255 255 255 / 0.45) 22%, transparent 24%);
    background-size: 9px 9px;
}

.member-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

/* Event color stripes: at most 4 (or 3 and "+N"). Each stripe keeps its pattern so color isn't the only cue. */

.stripes {
    display: flex;
    flex-direction: column;
    gap: 1px;
    width: 8px;
    flex: none;
    align-self: stretch;
    border-radius: 3px;
    overflow: hidden;
}

.stripes.horizontal {
    flex-direction: row;
    width: auto;
    height: 6px;
    min-width: 12px;
}

.stripe {
    flex: 1;
    min-height: 4px;
    min-width: 4px;
    background-color: var(--c);
}

.stripe.family {
    --c: var(--family);
    background-image: repeating-linear-gradient(90deg, transparent 0 2px, rgb(255 255 255 / 0.5) 2px 3px);
}

.stripe.more {
    background: var(--surface-3);
    color: var(--text-2);
    font-size: 0.6rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
}

.stripes:not(.horizontal) .stripe.more {
    writing-mode: vertical-rl;
    min-height: 16px;
}

/* Events. */

.event-card {
    display: flex;
    gap: 0.6rem;
    align-items: stretch;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-s);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    min-height: 44px;
    font: inherit;
    cursor: pointer;
    white-space: normal;
    justify-content: flex-start;
}

.event-card:hover {
    background: var(--surface-3);
}

.event-card .event-text {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.event-card .event-title {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-card .event-meta {
    font-size: 0.8rem;
    color: var(--text-2);
}

.event-card.meal {
    background: var(--accent-soft);
}

.event-card.pending {
    border-style: dashed;
}

.event-card.cancelled .event-title {
    text-decoration: line-through;
}

/* Day view: a 24-hour scrollable grid with 30-minute lines and a live time line. */

.day-view {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.all-day {
    display: grid;
    gap: 0.35rem;
}

.day-scroll {
    position: relative;
    height: min(70dvh, 720px);
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overscroll-behavior: contain;
}

.day-grid {
    position: relative;
    height: calc(var(--hour-h) * 24);
    margin-left: 3.75rem;
    border-left: 1px solid var(--gridline-strong);
}

.hour-row {
    position: absolute;
    left: 0;
    right: 0;
    height: var(--hour-h);
    border-top: 1px solid var(--gridline-strong);
}

.hour-row::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    border-top: 1px dashed var(--gridline);
}

.hour-label {
    position: absolute;
    left: -3.75rem;
    width: 3.4rem;
    top: -0.55rem;
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-3);
}

.hour-row:first-child .hour-label {
    top: 0.1rem;
}

.block {
    position: absolute;
    padding: 1px 2px;
    min-height: 22px;
}

.block .event-card {
    height: 100%;
    min-height: 0;
    padding: 0.2rem 0.4rem;
    overflow: hidden;
    font-size: 0.85rem;
}

.now-line {
    position: absolute;
    left: -0.4rem;
    right: 0;
    height: 0;
    border-top: 2px solid var(--now);
    z-index: 5;
    pointer-events: none;
}

.now-line::before {
    content: "";
    position: absolute;
    left: -5px;
    top: -6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--now);
}

/* Week view. */

.week-view {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: 1fr;
}

@media (min-width: 700px) {
    .week-view {
        grid-template-columns: repeat(var(--days, 7), minmax(0, 1fr));
    }
}

.week-day {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-height: 8rem;
}

.week-day.today {
    border-color: var(--accent);
    box-shadow: inset 0 3px 0 var(--accent);
}

.week-day h3 {
    font-size: 0.9rem;
    margin: 0;
}

.week-day h3 a {
    color: inherit;
    text-decoration: none;
}

/* Month view. */

.month-grid {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.month-grid th {
    font-size: 0.8rem;
    color: var(--text-3);
    font-weight: 600;
    padding: 0.25rem;
}

.month-grid td {
    border: 1px solid var(--border);
    vertical-align: top;
    padding: 0;
    height: 5.5rem;
    background: var(--surface);
}

.month-grid td.other-month {
    background: var(--surface-2);
}

.month-day {
    width: 100%;
    height: 100%;
    min-height: 5.5rem;
    border: 0;
    border-radius: 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 0.25rem;
    padding: 0.3rem;
    white-space: normal;
}

.month-day .date-number {
    font-weight: 600;
    font-size: 0.85rem;
}

.month-day.today .date-number {
    background: var(--accent);
    color: var(--on-accent);
    border-radius: 999px;
    padding: 0 0.4rem;
}

.month-day .count {
    font-size: 0.75rem;
    color: var(--text-2);
}

@media (max-width: 600px) {
    .month-grid td {
        height: 3.75rem;
    }

    .month-day {
        min-height: 3.75rem;
        padding: 0.2rem;
    }

    .month-day .count {
        display: none;
    }
}

/* Dialogs and sheets. */

.dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgb(0 0 0 / 0.45);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.dialog {
    background: var(--surface);
    color: var(--text);
    width: 100%;
    max-width: 640px;
    max-height: 92dvh;
    overflow-y: auto;
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: var(--shadow);
    padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
}

.dialog.wide {
    max-width: 960px;
}

.dialog-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.dialog-header h2 {
    margin: 0 auto 0 0;
}

@media (min-width: 700px) {
    .dialog-backdrop {
        align-items: center;
        padding: 1rem;
    }

    .dialog {
        border-radius: var(--radius);
    }
}

/* Toasts. */

.toasts {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom));
    z-index: 60;
    display: grid;
    gap: 0.5rem;
    width: min(560px, calc(100% - 2rem));
}

@media (min-width: 900px) {
    .toasts {
        bottom: 1.5rem;
    }
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.5rem 0.5rem 1rem;
    border-radius: var(--radius-s);
    background: #20262b;
    color: #f3f5f7;
    box-shadow: var(--shadow);
}

.toast .message {
    flex: 1;
}

.toast button {
    min-height: 40px;
    background: transparent;
    border-color: transparent;
    color: #8ee3e3;
    font-weight: 700;
}

.toast button:hover:not(:disabled) {
    background: rgb(255 255 255 / 0.1);
    color: #8ee3e3;
}

.toast.error {
    background: #5c1813;
}

.toast.warning {
    background: #4a3203;
}

/* Recipes. */

.recipe-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: var(--text);
}

.recipe-card:hover {
    color: var(--text);
    box-shadow: var(--shadow);
}

.recipe-card .thumb {
    aspect-ratio: 4 / 3;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: var(--text-3);
}

.recipe-card .thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.recipe-card .body {
    padding: 0.75rem;
    display: grid;
    gap: 0.35rem;
}

.recipe-card .name {
    font-weight: 600;
}

.recipe-hero {
    width: 100%;
    max-height: 360px;
    object-fit: cover;
    border-radius: var(--radius);
}

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

.ingredients li {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
}

.ingredients .qty {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.steps {
    padding-left: 1.25rem;
}

.steps li {
    margin-bottom: 0.75rem;
}

.stars {
    display: inline-flex;
    gap: 0.1rem;
}

.stars button {
    min-width: 40px;
    padding: 0;
    font-size: 1.35rem;
    border: 0;
    background: transparent;
    color: var(--text-3);
}

.stars button[aria-pressed="true"] {
    color: #e0a100;
}

.compare {
    display: grid;
    grid-template-columns: 8rem 1fr 1fr;
    gap: 0;
    font-size: 0.9rem;
}

.compare > div {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
    overflow-wrap: anywhere;
}

.compare .head {
    font-weight: 700;
    background: var(--surface-2);
}

.compare .diff {
    background: var(--warning-soft);
}

/* Cooking mode: big text, one step at a time, timers always visible. */

.cooking {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cooking .step-text {
    font-size: clamp(1.5rem, 4vw, 2.25rem);
    line-height: 1.35;
    margin: 0;
}

.cooking .step-count {
    color: var(--text-3);
    font-size: 1.1rem;
}

.cooking .nav-buttons button {
    min-height: 56px;
    font-size: 1.15rem;
    flex: 1;
}

.timers {
    display: grid;
    gap: 0.5rem;
}

.timer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-s);
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.timer .remaining {
    font-size: 1.6rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    min-width: 5.5rem;
}

.timer .name {
    flex: 1;
    min-width: 8rem;
}

.timer.finished {
    background: var(--danger-soft);
    border-color: var(--danger);
}

.timer.finished .remaining {
    color: var(--danger);
}

/* Meal plan. */

.meal-week {
    display: grid;
    gap: 0.75rem;
}

.meal-day {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
}

.meal-day.today {
    border-color: var(--accent);
    box-shadow: inset 3px 0 0 var(--accent);
}

.meal-day.past {
    opacity: 0.75;
}

.meal-day header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.meal-day header h2 {
    font-size: 1rem;
    margin: 0 auto 0 0;
}

.dish {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
}

.placeholder {
    font-style: italic;
    color: var(--text-2);
}

/* Shopping. */

.shopping-group h2 {
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-2);
    margin: 1rem 0 0.25rem;
}

.shop-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 52px;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border);
}

.shop-item .text {
    flex: 1;
    min-width: 0;
}

.shop-item .title {
    font-weight: 500;
}

.shop-item .from {
    font-size: 0.8rem;
    color: var(--text-3);
}

.shop-item.checked .title {
    text-decoration: line-through;
    color: var(--text-3);
}

.shop-item .url-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
}

.shopping-mode .shop-item {
    min-height: 72px;
}

.shopping-mode .shop-toggle {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 68px;
    font-size: 1.15rem;
    text-align: left;
    white-space: normal;
    justify-content: flex-start;
    border: 0;
    background: transparent;
    padding: 0 0.25rem;
}

.shopping-mode .box {
    width: 2rem;
    height: 2rem;
    flex: none;
    border: 2px solid var(--text-2);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.shopping-mode .checked .box {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}

.presence {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Loading. */

.spinner {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    border: 3px solid var(--surface-3);
    border-top-color: var(--accent);
    animation: spin 0.9s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.center-screen {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.center-screen .card {
    max-width: 420px;
    width: 100%;
    text-align: center;
}

.apple-button {
    background: #000000;
    color: #ffffff;
    border-color: #000000;
    width: 100%;
    font-weight: 600;
    min-height: 50px;
}

.apple-button:hover:not(:disabled) {
    background: #222222;
    color: #ffffff;
}

:root[data-theme="dark"] .apple-button {
    background: #ffffff;
    color: #000000;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .apple-button {
        background: #ffffff;
        color: #000000;
    }
}

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--surface-3);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text::after {
    content: var(--blazor-load-percentage-text, "Loading");
}

#blazor-error-ui {
    background: var(--warning-soft);
    color: var(--warning);
    bottom: 0;
    box-shadow: 0 -1px 2px rgb(0 0 0 / 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    position: absolute;
    right: 0.75rem;
    top: 0.25rem;
    min-height: 36px;
}

@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;
    }
}

@media print {
    .app-nav, .app-header, .toasts, .banner {
        display: none;
    }
}

/* ---- Additions: forms, details, utilities ---- */
.field-error {
    display: block;
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 4px;
}

.pre-wrap {
    white-space: pre-wrap;
}

.event-details p {
    margin: 0 0 8px;
}

.sticky-actions {
    position: sticky;
    bottom: calc(-1 * var(--dialog-pad, 16px));
    background: var(--surface);
    padding-block: 12px;
    border-top: 1px solid var(--border);
    margin-top: 16px;
}

label.button:focus-within {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.inline-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.danger-text {
    color: var(--danger);
}

.success-text {
    color: var(--success);
}

.right {
    margin-left: auto;
}

/* Shared form helpers. */

.notice.error { background: var(--danger-soft); color: var(--danger); }

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

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.checkbox, .radio {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
}

.inline-field {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0;
}

.inline-field select, .inline-field input { width: auto; }

.qty-input { max-width: 6.5rem; }

.unit-input { max-width: 7rem; }

.chip.static { cursor: default; }

.secret { font-family: inherit; }

.secret label { font-weight: 600; font-size: 0.9rem; }

.secret input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; }

.secret + .secret { margin-top: 0.5rem; }

/* Shell. */

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

.avatar-link {
    display: inline-flex;
    border-radius: 999px;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
}

/* Home. */

.home-header { gap: 1rem; }

.home-layout {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1fr);
}

.meal-list > li { padding: 0; }

.meal-row {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    width: 100%;
    padding: 0.6rem 0;
    color: var(--text);
    text-decoration: none;
}

.meal-row:hover .meal-day-name { color: var(--accent); }

.meal-day-name {
    flex: 0 0 6.5rem;
    font-weight: 600;
}

@media (min-width: 1000px) {
    .home-layout { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }

    .home-meals { align-self: start; position: sticky; top: calc(var(--header-h) + 1rem); }
}

/* Calendar. */

.calendar-toolbar { justify-content: space-between; }

.ocr-review {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1fr);
}

.ocr-source {
    width: 100%;
    max-height: 60vh;
    object-fit: contain;
    border-radius: var(--radius-s);
    background: var(--surface-2);
}

@media (min-width: 800px) {
    .ocr-review { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
}

/* Recipes. */

.recipe-filters .field { margin-bottom: 0; }

.recipe-form .form-rows {
    list-style: none;
    margin: 0 0 0.75rem;
    padding: 0;
    display: grid;
    gap: 0.5rem;
}

.ingredient-row, .step-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.ingredient-row input, .ingredient-row select { width: auto; flex: 1 1 7rem; }

.ingredient-row .qty-input, .ingredient-row .unit-input { flex: 0 1 6rem; }

.ingredient-row .grow { flex: 2 1 10rem; }

.step-row textarea { flex: 1 1 100%; }

.timer-row { align-items: end; }

.variant-group { display: grid; gap: 0.5rem; }

.image-picker {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.image-picker li {
    border: 2px solid var(--border);
    border-radius: var(--radius-s);
    padding: 0.4rem;
}

.image-picker li.selected { border-color: var(--accent); }

.image-picker img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: var(--radius-s);
}

.recipe-detail { display: grid; gap: 1rem; }

.recipe-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    color: var(--text-2);
}

.meta-part + .meta-part::before {
    content: "·";
    margin-right: 0.75rem;
    color: var(--text-3);
}

.recipe-columns {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 900px) {
    .recipe-columns { grid-template-columns: minmax(260px, 1fr) minmax(0, 2fr); }
}

.scale-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.custom-timer { align-items: end; margin-top: 0.75rem; }

/* Meal plan wishes and pickers. */

.wishes .list > li { flex-wrap: wrap; }

.picker {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 50vh;
    overflow-y: auto;
}

/* Shopping. */

.add-item .tabs { margin-top: -0.25rem; }

/* Settings. */

.profile {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.profile .field { margin-bottom: 0.5rem; }

.settings-links a {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 44px;
    color: var(--text);
    text-decoration: none;
}

.settings-links a::after {
    content: "›";
    margin-left: auto;
    color: var(--text-3);
    font-size: 1.3rem;
}

.settings-links a:hover { color: var(--accent); }

.member-colors label { font-weight: 600; }

.sign-ins > li.card { display: block; }

.audit-filters .field-row { align-items: end; }

.audit-log > li { display: block; }

.audit-entry p { margin: 0.15rem 0; }

.audit-entry.failed { border-left: 3px solid var(--danger); padding-left: 0.75rem; }

/* Sign in. */

.signin-card {
    max-width: 420px;
    margin: 2rem auto;
    text-align: center;
}

.signin-card .button-row { flex-direction: column; align-items: stretch; }

.banner.dead-letter .message {
    flex: 1;
}
