/* Stepwise design tokens and layout.
   Everything is local: no CDN, so the MAUI app works fully offline.
   Themes are plain CSS variables - the root carries data-theme="light"|"dark",
   and with no attribute the system preference decides. */

:root {
    --brand: #534AB7;
    --brand-strong: #423a9c;
    --brand-soft: #ece9fb;

    --bg: #f6f6f9;
    --surface: #ffffff;
    --surface-2: #f0f0f5;
    --border: #e0e0e8;
    --text: #1c1c22;
    --text-muted: #6b6b7b;

    --done: #2e9e5b;
    --missed: #d24b4b;
    --skipped: #9a9aa8;
    --warn: #d98324;

    --radius: 12px;
    --radius-sm: 8px;
    --gap: 16px;
    --shadow: 0 1px 3px rgba(20, 20, 40, 0.08);

    --nav-width: 220px;
    --bottom-nav-height: 60px;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --brand: #8b80ff;
        --brand-strong: #a79eff;
        --brand-soft: #2a2740;

        --bg: #16161c;
        --surface: #1f1f27;
        --surface-2: #272731;
        --border: #33333f;
        --text: #ececf2;
        --text-muted: #9a9aab;

        --done: #4cc47c;
        --missed: #e46b6b;
        --skipped: #6c6c7d;
        --warn: #e5a352;

        --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);

        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --brand: #8b80ff;
    --brand-strong: #a79eff;
    --brand-soft: #2a2740;

    --bg: #16161c;
    --surface: #1f1f27;
    --surface-2: #272731;
    --border: #33333f;
    --text: #ececf2;
    --text-muted: #9a9aab;

    --done: #4cc47c;
    --missed: #e46b6b;
    --skipped: #6c6c7d;
    --warn: #e5a352;

    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);

    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
    overscroll-behavior-y: none;
}

/* Chrome on Android and the iOS web view both put a callout or a selection handle on
   a long press; neither makes sense on a checkbox or a nav item. */
button,
.nav__link,
.goal,
.heat {
    -webkit-touch-callout: none;
    user-select: none;
}

input,
textarea {
    user-select: text;
}

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

h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

a {
    color: var(--brand);
    text-decoration: none;
}

/* ---------- application shell ---------- */

.app {
    min-height: 100vh;
    min-height: 100dvh;
}

.app__body {
    padding: var(--gap);
    padding-top: calc(var(--gap) + env(safe-area-inset-top, 0px));
    padding-bottom: calc(var(--bottom-nav-height) + var(--gap) + env(safe-area-inset-bottom, 0px));
    padding-left: calc(var(--gap) + env(safe-area-inset-left, 0px));
    padding-right: calc(var(--gap) + env(safe-area-inset-right, 0px));
    max-width: 1400px;
    margin: 0 auto;
}

/* Side menu on wide screens, bottom bar on phones. One breakpoint, 768px. */

.nav {
    position: fixed;
    inset: auto 0 0 0;
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    display: flex;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 20;
}

.nav__brand {
    display: none;
}

.nav__link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 6px 2px;
}

.nav__link.active {
    color: var(--brand);
}

.nav__icon {
    width: 22px;
    height: 22px;
    display: block;
}

@media (min-width: 768px) {
    .app {
        display: grid;
        grid-template-columns: var(--nav-width) 1fr;
    }

    .app__body {
        padding: 24px;
        padding-top: calc(24px + env(safe-area-inset-top, 0px));
        padding-bottom: 24px;
    }

    .nav {
        padding-top: calc(20px + env(safe-area-inset-top, 0px));
    }

    .nav {
        position: sticky;
        top: 0;
        inset: 0 auto 0 0;
        height: 100vh;
        height: 100dvh;
        flex-direction: column;
        width: var(--nav-width);
        border-top: none;
        border-right: 1px solid var(--border);
        padding: 20px 12px;
        gap: 4px;
    }

    .nav__brand {
        display: block;
        font-size: 1.2rem;
        font-weight: 600;
        color: var(--brand);
        padding: 0 10px 16px;
    }

    .nav__link {
        flex: 0 0 auto;
        flex-direction: row;
        justify-content: flex-start;
        gap: 12px;
        font-size: 0.95rem;
        padding: 10px 12px;
        border-radius: var(--radius-sm);
    }

    .nav__link.active {
        background: var(--brand-soft);
    }
}

/* The admin entry only fits the side menu; on a phone it lives in settings. */
.nav__link--wide {
    display: none;
}

@media (min-width: 768px) {
    .nav__link--wide {
        display: flex;
    }
}

/* ---------- surfaces ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--gap);
}

.card + .card {
    margin-top: var(--gap);
}

.card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.card__header h2 {
    margin: 0;
}

.muted {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.empty {
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 12px 0;
    text-align: center;
}

/* Dashboard: three columns on wide screens, stacked blocks on a phone. */

.dashboard {
    display: grid;
    gap: var(--gap);
    grid-template-columns: 1fr;
}

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

@media (min-width: 1200px) {
    .dashboard {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.dashboard__column {
    min-width: 0;
}

/* ---------- controls ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    padding: 8px 14px;
    cursor: pointer;
    min-height: 40px;
}

.btn:hover {
    border-color: var(--brand);
}

.btn--primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.btn--primary:hover {
    background: var(--brand-strong);
    border-color: var(--brand-strong);
}

.btn--danger {
    color: var(--missed);
    border-color: var(--missed);
    background: transparent;
}

.btn--small {
    padding: 4px 10px;
    min-height: 32px;
    font-size: 0.8rem;
}

.btn--icon {
    padding: 6px;
    min-width: 44px;
    min-height: 44px;
    font-size: 1.3rem;
    line-height: 1;
}

.btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: var(--gap);
}

.field {
    display: block;
    margin-bottom: 14px;
}

.field__label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.field input[type="text"],
.field input[type="search"],
.field input[type="date"],
.field input[type="time"],
.field input[type="number"],
.field select,
.field textarea {
    width: 100%;
    font: inherit;
    font-size: 0.95rem;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 11px;
    min-height: 42px;
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 1px;
}

.field textarea {
    min-height: 84px;
    resize: vertical;
}

.field--error input,
.field--error select {
    border-color: var(--missed);
}

.field__error {
    color: var(--missed);
    font-size: 0.8rem;
    margin-top: 4px;
}

.field-row {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
}

@media (min-width: 560px) {
    .field-row {
        grid-template-columns: 1fr 1fr;
    }
}

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

.chip {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    padding: 6px 14px;
    cursor: pointer;
    min-height: 36px;
}

.chip--on {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

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

.tab {
    border: none;
    background: none;
    font: inherit;
    font-size: 0.9rem;
    color: var(--text-muted);
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.tab--on {
    color: var(--brand);
    border-bottom-color: var(--brand);
}

/* ---------- goals ---------- */

.goal {
    display: block;
    color: inherit;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

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

.goal__head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.goal__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.goal__title {
    font-weight: 500;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.goal__meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
}

.bar {
    height: 8px;
    border-radius: 999px;
    background: var(--surface-2);
    overflow: hidden;
    margin-top: 8px;
}

.bar__fill {
    height: 100%;
    border-radius: 999px;
    background: var(--brand);
    transition: width 0.2s ease;
}

.bar--thin {
    height: 5px;
}

.behind {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--warn);
    font-size: 0.85rem;
    margin-top: 6px;
}

/* ---------- task list ---------- */

.tasks {
    display: flex;
    flex-direction: column;
}

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

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

.task__check {
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.task__check:hover {
    border-color: var(--brand);
}

.task__check--done {
    background: var(--done);
    border-color: var(--done);
    color: #fff;
}

.task__check--missed {
    border-color: var(--missed);
}

.task__check--skipped {
    border-style: dashed;
    border-color: var(--skipped);
}

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

.task__title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task--done .task__title {
    color: var(--text-muted);
    text-decoration: line-through;
}

.task__sub {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.task__actions {
    display: flex;
    gap: 4px;
    flex: 0 0 auto;
}

.priority-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
}

.priority-dot--high { background: var(--missed); }
.priority-dot--normal { background: var(--brand); }
.priority-dot--low { background: var(--skipped); }

/* ---------- history heat map ---------- */

.heatmap {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(26px, 1fr));
    gap: 5px;
}

.heatmap--month {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 5px;
}

.heatmap--month .heat {
    font-size: 0.8rem;
}

.heat {
    aspect-ratio: 1;
    border: none;
    border-radius: 4px;
    background: var(--surface-2);
    cursor: pointer;
    padding: 0;
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

.heat--l1 { background: color-mix(in srgb, var(--done) 25%, var(--surface-2)); }
.heat--l2 { background: color-mix(in srgb, var(--done) 50%, var(--surface-2)); }
.heat--l3 { background: color-mix(in srgb, var(--done) 75%, var(--surface-2)); }
.heat--l4 { background: var(--done); color: #fff; }
.heat--today { outline: 2px solid var(--brand); outline-offset: 1px; }

.heatmap__legend {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.heatmap__legend span.heat {
    width: 12px;
    height: 12px;
    aspect-ratio: auto;
    cursor: default;
}

.weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    margin-bottom: 5px;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
}

/* ---------- day screen ---------- */

.day-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: var(--gap);
}

.day-nav__label {
    font-weight: 500;
    text-align: center;
    flex: 1;
}

.mood {
    display: flex;
    gap: 6px;
}

.mood__item {
    flex: 1;
    border: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
    padding: 6px 0;
    cursor: pointer;
    min-height: 44px;
}

.mood__item--on {
    border-color: var(--brand);
    background: var(--brand-soft);
}

/* ---------- weekly chart ---------- */

.chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 150px;
    overflow-x: auto;
}

.chart__col {
    flex: 1 0 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    height: 100%;
}

.chart__track {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-end;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.chart__fill {
    width: 100%;
    min-height: 3px;
    background: var(--brand);
    border-radius: var(--radius-sm);
    transition: height 0.2s ease;
}

.chart__label {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Long lists scroll inside their card rather than pushing the page down forever. */

.tasks--scroll {
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---------- toggle ---------- */

.toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    cursor: pointer;
}

.toggle input {
    width: 22px;
    height: 22px;
    accent-color: var(--brand);
}

.field input[type="time"] {
    width: 100%;
    font: inherit;
    font-size: 0.95rem;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 11px;
    min-height: 42px;
}

.field input:disabled {
    opacity: 0.5;
}

/* ---------- sync indicator ---------- */

.sync {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 6px 0;
    flex-wrap: wrap;
}

.sync__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--skipped);
    flex: 0 0 auto;
}

.sync--ok .sync__dot { background: var(--done); }
.sync--failed .sync__dot { background: var(--warn); }
.sync--syncing .sync__dot { background: var(--brand); animation: sync-pulse 1s ease-in-out infinite; }

.sync--compact {
    font-size: 0.75rem;
    font-weight: 400;
    padding: 4px 0 0;
}

/* The problem strip: thin, warm, and gone again once a round succeeds. */
.sync--banner {
    background: color-mix(in srgb, var(--warn) 14%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--border));
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 6px 12px;
    margin-bottom: var(--gap);
}

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

@media (prefers-reduced-motion: reduce) {
    .sync--syncing .sync__dot { animation: none; }
}

.auth {
    max-width: 420px;
    margin: 0 auto;
}

/* ---------- misc ---------- */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: var(--gap);
    flex-wrap: wrap;
}

.stat {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0;
    font-size: 0.9rem;
}

.stat__value {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.badge {
    display: inline-block;
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-muted);
}

.badge--missed { background: color-mix(in srgb, var(--missed) 18%, transparent); color: var(--missed); }
.badge--done { background: color-mix(in srgb, var(--done) 18%, transparent); color: var(--done); }

/* ---------- greeting, quote ---------- */

.greeting {
    font-size: 1.05rem;
    color: var(--text-muted);
    margin: -8px 0 var(--gap);
}

.greeting strong {
    color: var(--text);
}

.quote {
    font-style: italic;
    color: var(--text);
    border-left: 3px solid var(--brand);
    padding: 4px 0 4px 12px;
    margin: 0;
}

/* ---------- messages ---------- */

.message {
    border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--border));
    background: color-mix(in srgb, var(--brand) 6%, var(--surface));
}

.message__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.message__text {
    font-size: 1.1rem;
    white-space: pre-wrap;
    margin: 0 0 10px;
}

.message__photo {
    display: block;
    width: 100%;
    max-height: 420px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    margin-bottom: 10px;
}

.thread {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 0;
}

.bubble {
    max-width: 85%;
    padding: 6px 10px;
    border-radius: 12px;
    background: var(--surface-2);
    font-size: 0.9rem;
    white-space: pre-wrap;
}

.bubble--mine {
    align-self: flex-end;
    background: var(--brand);
    color: #fff;
}

.bubble__meta {
    display: block;
    font-size: 0.7rem;
    opacity: 0.75;
    margin-top: 2px;
}

.reply-box {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.reply-box textarea {
    flex: 1;
    min-height: 42px;
    font: inherit;
    font-size: 0.95rem;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    resize: vertical;
}

/* ---------- streak, badges, stats ---------- */

.streak {
    display: flex;
    align-items: center;
    gap: 14px;
}

.streak__flame {
    font-size: 2.2rem;
    line-height: 1;
}

.streak__count {
    font-size: 1.6rem;
    font-weight: 600;
}

.badges {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.badge-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    text-align: center;
    background: var(--surface-2);
}

.badge-card--locked {
    opacity: 0.55;
    filter: grayscale(1);
}

.badge-card__icon {
    font-size: 1.8rem;
}

.badge-card__title {
    font-weight: 500;
    font-size: 0.9rem;
    margin-top: 4px;
}

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
}

.tile {
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.tile__value {
    font-size: 1.5rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.tile__label {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ---------- mood chart ---------- */

.mood-chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 80px;
}

.mood-chart__bar {
    flex: 1;
    min-width: 4px;
    border-radius: 3px 3px 0 0;
    background: var(--surface-2);
}

.mood-chart__bar--1 { background: #d24b4b; }
.mood-chart__bar--2 { background: #e0873a; }
.mood-chart__bar--3 { background: #c9b33a; }
.mood-chart__bar--4 { background: #7bb54a; }
.mood-chart__bar--5 { background: var(--done); }

/* ---------- goal conditions ---------- */

.condition {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

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

.condition__mark {
    width: 22px;
    text-align: center;
}

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

.badge--waiting {
    background: color-mix(in srgb, var(--warn) 18%, transparent);
    color: var(--warn);
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
    margin-top: 10px;
}

.inline-form .field {
    margin-bottom: 0;
    flex: 1 1 140px;
}

/* The time of day in front of a task's title. */
.task__time {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--brand);
    background: color-mix(in srgb, var(--brand) 12%, transparent);
    border-radius: 6px;
    padding: 1px 6px;
    margin-right: 6px;
    font-variant-numeric: tabular-nums;
}

/* A form section: what a goal or task waits for. */
.dependencies {
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 12px;
    margin: 4px 0 14px;
}

.dependencies > .muted {
    margin: 2px 0 8px;
}

.dependencies .chips {
    margin-top: 10px;
}

.inline-form .field--narrow {
    flex: 0 1 110px;
}

.condition__mark input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--done);
}

.condition--met {
    text-decoration: line-through;
    color: var(--text-muted);
}

.small {
    font-size: 0.8rem;
}

/* ---------- admin ---------- */

.user-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    color: inherit;
}

.user-row:last-child {
    border-bottom: none;
}

.avatar {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 600;
}

.photo-preview {
    max-width: 180px;
    max-height: 180px;
    border-radius: var(--radius-sm);
    display: block;
    margin: 6px 0;
}

/* ---------- confetti ---------- */

.confetti {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 100;
}

.confetti i {
    position: absolute;
    top: -12px;
    width: 8px;
    height: 14px;
    border-radius: 2px;
    animation-name: confetti-fall;
    animation-timing-function: ease-in;
    animation-fill-mode: forwards;
}

@keyframes confetti-fall {
    to {
        transform: translateY(105vh) rotate(720deg);
        opacity: 0.6;
    }
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--bottom-nav-height) + 20px);
    transform: translateX(-50%);
    background: var(--text);
    color: var(--bg);
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 0.9rem;
    z-index: 101;
    box-shadow: var(--shadow);
}

@media (min-width: 768px) {
    .toast {
        bottom: 24px;
    }
}

/* ---------- pace and task strips ---------- */

.pace {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 6px;
}

.pace--behind { color: var(--missed); }
.pace--ahead,
.pace--ontrack { color: var(--done); }

.strip-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

.strip {
    display: grid;
    grid-template-columns: repeat(14, 1fr);
    gap: 3px;
    flex: 1;
    max-width: 320px;
}

.strip__cell {
    aspect-ratio: 1;
    border-radius: 3px;
    background: var(--surface-2);
}

.strip__cell--done { background: var(--done); }
.strip__cell--missed { background: var(--missed); }
.strip__cell--skipped { background: var(--skipped); opacity: 0.5; }
.strip__cell--pending { outline: 2px solid var(--brand); outline-offset: -2px; }
.strip__cell--notplanned { background: transparent; border: 1px dashed var(--border); }

.strip__rate {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--done);
    min-width: 42px;
    text-align: right;
}

.strip__rate--low { color: var(--missed); }

/* ---------- progress ring ---------- */

.ring {
    position: relative;
    width: 96px;
    height: 96px;
    flex: none;
}

.ring--small {
    width: 64px;
    height: 64px;
}

.ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring circle {
    fill: none;
    stroke-width: 3.2;
}

.ring__track {
    stroke: var(--surface-2);
}

.ring__fill {
    stroke: var(--brand);
    stroke-linecap: round;
    transition: stroke-dasharray 0.6s ease;
}

.ring__label {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.1;
}

.ring__label strong {
    font-size: 1.15rem;
}

.ring--small .ring__label strong {
    font-size: 0.9rem;
}

.ring__label span {
    font-size: 0.6rem;
    color: var(--text-muted);
    max-width: 70%;
}

/* ---------- day screen ---------- */

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

.week-strip__day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 0 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

.week-strip__day--today {
    border-color: var(--brand);
}

.week-strip__day--on {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.week-strip__name {
    font-size: 0.7rem;
    opacity: 0.8;
}

.week-strip__num {
    font-weight: 700;
}

.week-strip__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: transparent;
}

.week-strip__dot--full { background: var(--done); }
.week-strip__dot--part { background: color-mix(in srgb, var(--done) 50%, var(--warn)); }
.week-strip__dot--missed { background: var(--missed); }
.week-strip__dot--open { background: var(--skipped); }
.week-strip__day--on .week-strip__dot--open { background: #fff; }

.day-hero {
    display: flex;
    align-items: center;
    gap: 18px;
    background: linear-gradient(135deg, var(--brand-soft), var(--surface) 70%);
}

.day-hero__text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.day-hero__text strong {
    font-size: 1.1rem;
}

.day-hero__now,
.day-hero__next {
    font-size: 0.85rem;
    padding: 3px 8px;
    border-radius: 6px;
    align-self: flex-start;
}

.day-hero__now {
    background: color-mix(in srgb, var(--done) 16%, transparent);
    color: var(--done);
    font-weight: 600;
}

.day-hero__next {
    background: var(--surface-2);
}

.day-part .card__header h2 {
    font-size: 1rem;
}

/* The goal's colour as a stripe at the row's edge. */
.task[style*="--task-color"] {
    border-left: 4px solid var(--task-color);
    padding-left: 10px;
    margin-left: -4px;
}

.task--now {
    background: color-mix(in srgb, var(--done) 10%, transparent);
    border-radius: var(--radius-sm);
}

/* ---------- stat tiles ---------- */

.stat-tiles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: var(--gap);
}

.stat-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 12px 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-tile strong {
    font-size: 1.35rem;
}

.stat-tile span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stat-tile--done strong { color: var(--done); }
.stat-tile--missed strong { color: var(--missed); }
.stat-tile--skipped strong { color: var(--skipped); }

/* ---------- goal cards ---------- */

.goal-cards {
    display: grid;
    gap: 12px;
}

@media (min-width: 900px) {
    .goal-cards {
        grid-template-columns: 1fr 1fr;
    }
}

.goal-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 6px solid var(--goal-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: inherit;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.goal-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(20, 20, 40, 0.12);
}

.goal-card--done {
    background: linear-gradient(135deg, color-mix(in srgb, var(--goal-color) 12%, var(--surface)), var(--surface));
}

.goal-card__main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.goal-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.goal-card__title {
    font-weight: 700;
    font-size: 1.05rem;
}

.goal-card__facts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    font-size: 0.82rem;
}

.goal-card__fact--done {
    color: var(--done);
    font-weight: 600;
}

.goal-card .ring {
    width: 72px;
    height: 72px;
}

.sparkline {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 28px;
}

.sparkline__bar {
    flex: 1;
    border-radius: 2px;
    min-height: 3px;
}

.sparkline__bar--empty {
    height: 3px;
    background: var(--surface-2);
}

.empty-hero {
    text-align: center;
}

.empty-hero__icon {
    font-size: 3rem;
}

/* ---------- history ---------- */

.month-hero {
    display: flex;
    align-items: center;
    gap: 18px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--done) 14%, var(--surface)), var(--surface) 70%);
    margin-bottom: var(--gap);
}

.month-hero .ring__fill {
    stroke: var(--done);
}

.month-hero__text {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.month-hero__text strong {
    font-size: 1.15rem;
}

.delta {
    font-size: 0.85rem;
    font-weight: 600;
}

.delta--up { color: var(--done); }
.delta--down { color: var(--missed); }

.stat-tiles--3 {
    grid-template-columns: repeat(3, 1fr);
}

.heat--selected {
    outline: 2px solid var(--text);
    outline-offset: 1px;
}

.day-peek {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
}

.day-peek h3 {
    margin: 0;
    font-size: 1rem;
}

.day-peek__mood {
    font-size: 1.5rem;
}

.day-peek__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0 6px 10px;
    border-left: 4px solid var(--task-color);
    margin: 4px 0;
}

.day-peek__status {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    background: var(--skipped);
    flex: none;
}

.day-peek__status--done { background: var(--done); }
.day-peek__status--missed { background: var(--missed); }
.day-peek__status--pending { background: var(--surface-2); color: var(--text-muted); }

.day-peek__note {
    margin: 10px 0;
    padding: 8px 12px;
    border-left: 3px solid var(--brand);
    background: var(--surface-2);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.weekday-bars {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    align-items: end;
}

.weekday-bars__col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.weekday-bars__value {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.weekday-bars__track {
    width: 100%;
    height: 90px;
    background: var(--surface-2);
    border-radius: 6px;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
}

.weekday-bars__fill {
    width: 100%;
    background: color-mix(in srgb, var(--brand) 70%, transparent);
    border-radius: 6px;
    transition: height 0.5s ease;
}

.weekday-bars__col--best .weekday-bars__fill {
    background: var(--done);
}

.weekday-bars__col--best .weekday-bars__name {
    font-weight: 700;
    color: var(--done);
}

.weekday-bars__name {
    font-size: 0.75rem;
}

.goal-month {
    padding: 8px 0;
}

.goal-month__head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

/* ---------- admin: a user's goals and tasks ---------- */

.admin-goal {
    border-left: 4px solid var(--goal-color);
    padding: 10px 0 10px 12px;
    margin: 10px 0;
}

.admin-goal__head,
.admin-task {
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-goal__head .goal__title,
.admin-task__body {
    flex: 1;
    min-width: 0;
}

.admin-task {
    padding: 6px 0 6px 10px;
    border-top: 1px solid var(--border);
    margin-top: 6px;
}

.admin-task__body {
    display: flex;
    flex-direction: column;
}

.admin-actions {
    display: flex;
    gap: 4px;
    flex: none;
}

.admin-edit {
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 10px;
    margin: 6px 0;
}

/* ---------- settings ---------- */

.settings-hero {
    display: flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(135deg, var(--brand-soft), var(--surface) 70%);
    margin-bottom: var(--gap);
}

.settings-hero__text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.settings-hero__text strong {
    font-size: 1.15rem;
}

.avatar--big {
    width: 52px;
    height: 52px;
    font-size: 1.3rem;
    flex: none;
}

.shortcuts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
    margin-bottom: var(--gap);
}

.shortcut {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: inherit;
    text-decoration: none;
    font-size: 0.85rem;
    text-align: center;
}

.shortcut:hover {
    border-color: var(--brand);
}

.shortcut__icon {
    font-size: 1.5rem;
}

.shortcut--admin {
    border-color: var(--brand);
    color: var(--brand);
    font-weight: 600;
}

.admin-day-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.admin-day-row:last-child {
    border-bottom: none;
}

.admin-day-row__title {
    flex: 1 1 140px;
    min-width: 0;
}

/* ---------- diary under a task ---------- */

.diary-line {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 0 8px 36px;
    flex-wrap: wrap;
}

.diary {
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin: 0 0 10px 36px;
}

.diary .photo-preview {
    margin: 6px 0;
}

.day-peek__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.day-peek__body .photo-preview {
    max-width: 140px;
    margin-top: 4px;
}

/* ---------- habits with a weekly quota ---------- */

.habit {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

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

.habit__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.habit__title {
    font-weight: 600;
    color: inherit;
    text-decoration: none;
}

.habit__dots {
    display: flex;
    gap: 4px;
}

.habit__dot {
    width: 14px;
    height: 8px;
    border-radius: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.habit__dot--on {
    background: var(--done);
    border-color: var(--done);
}

.habit--met .habit__title {
    color: var(--done);
}

/* ---------- steps of a goal ---------- */

.stage {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.stage:last-of-type {
    border-bottom: none;
}

.stage__check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--done);
}

.stage__body {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.stage__number {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.stage--done .stage__title {
    text-decoration: line-through;
    color: var(--text-muted);
}

.stage--done .stage__number {
    background: color-mix(in srgb, var(--done) 20%, transparent);
    color: var(--done);
}

.stage__actions {
    display: flex;
    gap: 4px;
    flex: none;
}

/* ---------- a goal walked with someone ---------- */

.together {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0 10px;
}

.together__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ---------- a newer build is out ---------- */

.update-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    margin-bottom: var(--gap);
    border-radius: var(--radius);
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 600;
}

.update-banner__actions {
    display: flex;
    gap: 6px;
}
