:root {
    --bg: #000;
    --text: #f2f2f2;
    --muted: #8f8f8f;   /* secondary text: never darker than this on black */
    --line: #2b2b2b;
    --line-strong: #5a5a5a;
    --on-text: #000;
    --panel: #0a0a0a;
    --field: #000;
    --hover: rgba(255, 255, 255, 0.1);
    --font: 'Sora', 'Helvetica Neue', Arial, sans-serif;
    --w: 300;                                  /* general text weight, set from the settings */
    --w-lo: clamp(100, calc(var(--w) - 100), 800);
    --w-hi: clamp(100, calc(var(--w) + 100), 800);
    --p0: #ffffff;
    --p1: #d6c8ed;
    --p2: #ad90da;
    --p3: #8458c8;
    --p4: #5b21b6;
    color-scheme: dark;
}

:root:is([data-theme="light"], [data-theme="paper"], [data-theme="vanilla"], [data-theme="olive"]) {
    --bg: #fff;
    --text: #111;
    --muted: #6b6b6b;   /* 5.3:1 on white, 4.9:1 on the slightly darker panels and fields */
    --line: #e4e4e4;
    --line-strong: #bdbdbd;
    --on-text: #fff;
    --panel: #f6f6f6;
    --field: #fff;
    --hover: rgba(0, 0, 0, 0.06);
    color-scheme: light;
}

:root[data-font="mono"] .clock,
:root[data-font="mono"] .realtime {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-weight: 200;
    letter-spacing: -0.04em;
}

:root[data-font="inter"] .clock,
:root[data-font="inter"] .realtime {
    font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
    font-weight: var(--clock-weight, 700);
    letter-spacing: -0.03em;
}

:root[data-font="dmsans"] .clock,
:root[data-font="dmsans"] .realtime {
    font-family: 'DM Sans', 'Helvetica Neue', Arial, sans-serif;
    font-weight: var(--clock-weight, 400);
    letter-spacing: -0.03em;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 0 20px 48px;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-weight: var(--w);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

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

button { font-family: var(--font); cursor: pointer; }
button, input, select { font-weight: inherit; }

/* ---------- Top bar: logo, the four tabs, Calendar and Settings ---------- */
.topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 1280px;
    margin-top: 24px;
    padding: 0 12px;
}

.brand {
    justify-self: start;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.125rem;
    letter-spacing: -0.03em;
}

.brand svg { display: block; flex: none; width: 26px; height: 26px; }
.brand path { stroke: var(--text); }
.brand circle { fill: var(--cal-acc); }

.nav {
    display: inline-flex;
    gap: 2px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
}

.nav-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 13px;
    background: transparent;
    color: var(--muted);
    border: 0;
    border-radius: 999px;
    font-size: 0.8125rem;
    transition: background-color 0.2s, color 0.2s;
}

.nav-button svg { flex: none; width: 18px; height: 18px; }
.nav-button:hover { color: var(--text); }
.nav-label { display: none; }

/* The active tab shows its icon and name, the others only the icon */
.nav-button.active {
    padding: 9px 18px;
    background: var(--text);
    color: var(--on-text);
}

.nav-button.active svg { width: 16px; height: 16px; }
.nav-button.active .nav-label { display: inline; }

.topbar-right { position: relative; justify-self: end; display: flex; }

/* The account avatar: your Google initial, or an outline person when signed out */
.avatar-btn {
    display: grid;
    place-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 50%;
    font-size: 0.875rem;
    transition: color 0.2s, border-color 0.2s;
}

.avatar-btn:hover { color: var(--text); border-color: var(--line-strong); }
.avatar-person { width: 18px; height: 18px; }
.avatar-btn.signed { background: var(--cal-acc); color: var(--on-acc, #fff); border-color: var(--cal-acc); }
.avatar-btn.signed .avatar-person { display: none; }

.account-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 280px;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
    text-align: left;
}

.account-menu[hidden] { display: none; }
.am-who { font-size: 0.9rem; overflow-wrap: anywhere; }
.am-note { margin: -6px 0 0; font-size: 0.75rem; color: var(--muted); line-height: 1.5; }
.am-sync { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 12px; background: var(--hover); }
.am-sync[hidden] { display: none; }
.am-when { font-size: 0.7rem; color: var(--muted); }
.am-action { width: 100%; padding: 9px 16px; font-size: 0.85rem; }

/* Under "Continue with Google": the Terms and Privacy line, gone with the button once signed in */
.am-legal { margin: -4px 0 0; font-size: 0.7rem; line-height: 1.5; color: var(--muted); text-align: center; }
#am-signin[hidden] + .am-legal { display: none; }
.am-legal a { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); text-underline-offset: 2px; }
.am-legal a:hover { color: var(--text); }

/* Install as an app (js/pwa.js): a quiet text button at the bottom of the account menu */
.am-install {
    align-self: center;
    padding: 2px 4px;
    border: 0;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 0.75rem;
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
    text-underline-offset: 2px;
    cursor: pointer;
}
.am-install:hover { color: var(--text); }
.am-install[hidden], .am-install-hint[hidden] { display: none; }
.am-install-hint { margin: 0; font-size: 0.7rem; line-height: 1.5; color: var(--muted); text-align: center; }

/* ---------- Toasts (js/core/toast.js): every notification of the app ----------
   Centred 14 px under the tab bar (the script sets `top`), over the page; at most 3, newest on top.
   Phone: at the top, full width with a 10 px margin. Aesthetic mode: top centre, timer events only. */
.toasts {
    --t-success: #3fb27f;
    --t-info: var(--cal-acc);
    --t-warning: #e0a33a;
    --t-error: #e5484d;
    position: fixed;
    top: 14px;
    left: 50%;
    z-index: 50;
    width: min(380px, calc(100vw - 32px));
    transform: translateX(-50%);
    pointer-events: none;
}

.toast {
    --tc: var(--t-info);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    padding: 11px 8px 11px 12px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    text-align: left;
    /* older ones: dimmer but still solid, so the page never shows through */
    filter: brightness(var(--o, 1));
    transform: translateY(var(--y, 0)) scale(var(--s, 1));
    transform-origin: top center;
    transition: transform 0.25s ease-out, opacity 0.25s ease-out, filter 0.25s ease-out;
    pointer-events: auto;
}

.toast-success { --tc: var(--t-success); }
.toast-warning { --tc: var(--t-warning); }
.toast-error { --tc: var(--t-error); }
/* Slides down 12 px while fading in, and the same way out */
.toast.in,
.toast.out { opacity: 0; transform: translateY(calc(var(--y, 0px) - 12px)) scale(var(--s, 1)); }
.toast.out { pointer-events: none; }
.toast-link { cursor: pointer; }
.toast-link:hover { border-color: var(--text); }

.toast-icon {
    flex: none;
    display: grid;
    place-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--tc) 18%, transparent);
    color: var(--tc);
}

.toast-icon svg { width: 14px; height: 14px; }
.toast-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.toast-title { overflow: hidden; font-size: 0.85rem; text-overflow: ellipsis; white-space: nowrap; }
.toast-sub { overflow: hidden; font-size: 0.72rem; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }

.toast-action {
    flex: none;
    padding: 6px 8px;
    background: none;
    color: var(--cal-acc);
    border: 0;
    border-radius: 8px;
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
}

.toast-action:hover { background: var(--hover); }

.toast-close {
    flex: none;
    display: grid;
    place-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: none;
    color: var(--muted);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.toast-close:hover { background: var(--hover); color: var(--text); }
.toast-close svg { width: 14px; height: 14px; }
/* The time left: a thin line at the bottom (pauses while the mouse is over the toast) */
.toast-bar { position: absolute; left: 14px; right: 14px; bottom: 0; height: 2px; }
.toast-bar i { display: block; height: 100%; border-radius: 2px; background: var(--tc); transform-origin: left; }

/* Aesthetic mode: only timer events; the rest wait hidden */
body.aesthetic .toast:not(.toast-timer) { display: none; }
/* Animations off: they just appear and disappear */
.toasts.still .toast { transition: none; }

/* Read aloud by screen readers, not shown */
.toast-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Read by screen readers, never shown and taking no room (e.g. the tab's <h1>) */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
}

@media (max-width: 600px) {
    .toasts { top: calc(10px + env(safe-area-inset-top)); width: calc(100vw - 20px); }
}

/* Phone: only the logo and the two round buttons on top, the four tabs in a bar at the bottom */
@media (max-width: 600px) {
    body { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
    .topbar { grid-template-columns: 1fr auto; margin-top: 16px; padding: 0; }
    .brand-name { display: none; }

    .nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 20;
        justify-content: space-between;
        padding: 12px 10px calc(12px + env(safe-area-inset-bottom));
        background: var(--bg);
        border: 0;
        border-top: 1px solid var(--line);
        border-radius: 0;
    }

    .nav-button,
    .nav-button.active {
        flex: 1;
        flex-direction: column;
        gap: 5px;
        min-width: 0;
        padding: 0 2px;
        background: none;
        color: var(--muted);
        font-size: 0.5625rem;
    }

    .nav-button svg,
    .nav-button.active svg { width: 20px; height: 20px; }
    .nav-label,
    .nav-button.active .nav-label { display: inline; }
    .nav-button.active { color: var(--text); }
}

/* ---------- Clock ---------- */
.clock {
    font-size: clamp(4.5rem, 22vw, 10rem);
    font-weight: var(--clock-weight, 500);
    letter-spacing: -0.045em;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    margin: clamp(36px, 9vh, 80px) 0 28px;
    transition: color 0.4s;
}

body[data-mode="break"] .clock { color: var(--muted); }

.realtime {
    display: none;
    font-size: max(3rem, min(14rem, calc((100vw - 40px) / var(--fit, 5.4))));
    font-weight: var(--clock-weight, 500);
    letter-spacing: -0.045em;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.rt-seconds { color: var(--muted); }

/* Digit motion (digit-motion.js): only the digit that changes moves. The old digit blurs and fades out while the
   new one comes in blurred and sharpens, both in the same place: nothing slides and every digit keeps its line. */
.dm { position: relative; display: inline-block; }
.dm-go {
    -webkit-text-fill-color: transparent;   /* the real glyph waits; the two layers below draw the change */
    animation: dm-hold 0.35s linear;
}
.dm-go::before,
.dm-go::after {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    text-align: center;
    -webkit-text-fill-color: currentColor;
    pointer-events: none;
}
.dm-go::before { content: attr(data-old); animation: dm-out 0.35s ease-out forwards; }
.dm-go::after { content: attr(data-new); animation: dm-in 0.35s ease-out both; }
@keyframes dm-hold { from { opacity: 1; } to { opacity: 1; } }
@keyframes dm-in { from { opacity: 0; filter: blur(0.06em); } to { opacity: 1; filter: blur(0); } }
@keyframes dm-out { from { opacity: 1; filter: blur(0); } to { opacity: 0; filter: blur(0.06em); } }

.rt-ampm {
    margin-left: 0.6em;
    font-size: 0.2em;
    font-weight: var(--w-hi);
    letter-spacing: 0;
    color: var(--muted);
}

.rt-ampm:empty { display: none; }

.stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.below {
    width: 100%;
    display: flex;
    justify-content: center;
}

/* Clock and Focus tabs: the clock sits in the middle of the screen */
body[data-tab="clock"],
body[data-tab="focus"] {
    height: 100vh;
    height: 100dvh;
    padding: 0 20px;
    overflow: hidden;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
    justify-items: center;
}

body[data-tab="clock"] .topbar,
body[data-tab="focus"] .topbar { align-self: start; justify-self: center; }
body[data-tab="clock"] .stage,
body[data-tab="focus"] .stage { width: auto; max-width: 100%; }

.progress {
    width: min(100%, 520px);
    height: 1px;
    background: var(--line);
}

.progress-bar {
    height: 100%;
    width: 100%;
    background: var(--text);
    transition: width 0.25s linear;
}

/* ---------- Focus panel ---------- */
.focus-container { display: block; }

.status {
    margin: 22px 0 24px;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.btn {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 10px 26px;
    font-size: 0.9rem;
    transition: background-color 0.2s, border-color 0.2s, opacity 0.2s;
}

.btn:hover:not(:disabled) { background: var(--hover); }

.btn.primary {
    background: var(--text);
    color: var(--on-text);
    border-color: var(--text);
}

.btn.primary:hover:not(:disabled) { background: var(--text); opacity: 0.85; }

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

.settings {
    margin-top: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    color: var(--muted);
    font-size: 0.85rem;
}

.preset,
.range-btn {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 16px;
    font-size: 0.8rem;
    transition: color 0.2s, border-color 0.2s;
}

.preset:hover,
.range-btn:hover { color: var(--text); }

.preset.active,
.range-btn.active {
    color: var(--text);
    border-color: var(--text);
}

.custom {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 24px;
}

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

.custom input {
    width: 60px;
    padding: 4px 0;
    background: transparent;
    color: var(--text);
    border: 0;
    border-bottom: 1px solid var(--line-strong);
    border-radius: 0;
    text-align: center;
    font: inherit;
    -moz-appearance: textfield;
}

.custom input::-webkit-outer-spin-button,
.custom input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ---------- To do ---------- */
.todo-container {
    display: none;
    width: min(100%, 680px);   /* room for the date chip and "Set as top priority" on one line */
    margin-top: 36px;
}

/* To do tab: the focus line above the list is as wide as the list */
body[data-tab="todo"] .progress { width: min(100%, 680px); }

.todo-input {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
}

.todo-input input {
    flex: 1;
    min-width: 0;
    padding: 10px 18px;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    font: inherit;
}

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

.todo-list {
    list-style: none;
    margin: 0;
    padding: 0;
    text-align: left;
}

.todo-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.todo-item label {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    overflow-wrap: anywhere;
}

.todo-item input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    flex: none;
    display: grid;
    place-content: center;
    width: 18px;
    height: 18px;
    margin: 0;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.todo-item input[type="checkbox"]::after {
    content: '';
    width: 8px;
    height: 4px;
    margin-top: -1px;
    border-left: 1.5px solid var(--on-text);
    border-bottom: 1.5px solid var(--on-text);
    transform: rotate(-45deg) scale(0);
    transition: transform 0.15s;
}

.todo-item input[type="checkbox"]:checked {
    background: var(--text);
    border-color: var(--text);
}

.todo-item input[type="checkbox"]:checked::after { transform: rotate(-45deg) scale(1); }

.todo-item.done span {
    text-decoration: line-through;
    color: var(--muted);
}

.delete-btn,
.edit-btn {
    background: transparent;
    color: var(--muted);
    border: 0;
    padding: 4px 8px;
    font-size: 0.8rem;
    transition: color 0.2s;
}

.delete-btn:hover,
.edit-btn:hover { color: var(--text); }

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

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

/* ---------- Settings button + panel ---------- */
.icon-btn {
    position: fixed;
    top: 24px;
    right: 20px;
    z-index: 10;
    display: grid;
    place-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 50%;
    transition: color 0.2s, border-color 0.2s;
}

.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); }

.icon-btn.small {
    position: static;
    width: 32px;
    height: 32px;
    font-size: 1.3rem;
    line-height: 1;
}

.overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.overlay.open { opacity: 1; pointer-events: auto; }

.panel {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 30;
    width: min(340px, 88vw);
    height: 100vh;
    height: 100dvh;
    padding: 24px;
    overflow-y: auto;
    background: var(--panel);
    border-left: 1px solid var(--line);
    text-align: left;
    visibility: hidden;
    transform: translateX(100%);
    transition: transform 0.3s ease, visibility 0s 0.3s;
}

.panel.open {
    visibility: visible;
    transform: none;
    transition: transform 0.3s ease, visibility 0s;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.panel h2 { margin: 0; font-size: 1rem; font-weight: var(--w-hi); }

.panel-section { margin-bottom: 28px; }

.panel-section h3 {
    margin: 0 0 12px;
    font-size: 0.75rem;
    font-weight: var(--w-hi);
    letter-spacing: 0.08em;
    color: var(--muted);
}

.btn.full { width: 100%; }

.panel-note {
    margin: 10px 0 0;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--muted);
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
    font-size: 0.85rem;
}

.panel select {
    background: var(--field);
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 6px 12px;
    font: inherit;
    font-size: 0.8rem;
}

.switch {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    flex: none;
    width: 34px;
    height: 20px;
    margin: 0;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    cursor: pointer;
}

.switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform 0.2s, background-color 0.2s;
}

.switch:checked::after { transform: translateX(14px); background: var(--text); }

.panel :disabled { opacity: 0.4; cursor: default; }


.account-email {
    margin: 0 0 12px;
    font-size: 0.85rem;
    overflow-wrap: anywhere;
}

/* ---------- Drag to reorder + shortcuts ---------- */
.todo-item {
    -webkit-user-select: none;
    user-select: none;
}

.drag-handle {
    flex: none;
    padding: 4px 2px;
    font-size: 1rem;
    line-height: 1;
    color: var(--muted);
    opacity: 0.6;
    cursor: grab;
    touch-action: none;
    transition: opacity 0.2s;
}

.todo-item:hover .drag-handle { opacity: 1; }

.todo-item.dragging {
    position: relative;
    z-index: 2;
    background: var(--bg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.todo-list.is-dragging,
.todo-list.is-dragging * { cursor: grabbing; }

.todo-item.drop-before { box-shadow: inset 0 2px 0 var(--text); }
.todo-item.drop-after { box-shadow: 0 2px 0 var(--text); }

kbd {
    font: inherit;
    font-size: 0.75rem;
    color: var(--muted);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    padding: 2px 8px;
}


/* ---------- Inline task editing ---------- */
.edit-input {
    flex: 1;
    min-width: 0;
    padding: 2px 0;
    background: transparent;
    color: var(--text);
    border: 0;
    border-bottom: 1px solid var(--line-strong);
    border-radius: 0;
    font: inherit;
    -webkit-user-select: text;
    user-select: text;
}

.edit-input:focus-visible {
    outline: none;
    border-bottom-color: var(--text);
}

/* ---------- Stats dashboard ---------- */
.stats-container {
    display: none;
    width: min(100%, 820px);
    margin-top: 36px;
    text-align: left;
}

.stats-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.stats-title {
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.stats-range { display: flex; gap: 8px; }

.stat-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card,
.stat-panel {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 20px;
}

.stat-card { flex: 1 1 150px; min-width: 0; }
.stat-panel { margin-bottom: 20px; }
/* No focus session yet (stats.js): one quiet line and a button, above the zero figures */
.stats-first { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; padding: 14px 16px 14px 20px; }
.stats-first[hidden] { display: none; }
.stats-first p { margin: 0; font-size: 0.85rem; color: var(--muted); text-align: left; }
.stats-first .btn { flex: none; padding: 8px 18px; font-size: 0.8rem; }

.stat-label,
.stat-sub,
.stat-panel-head {
    font-size: 0.75rem;
    color: var(--muted);
}

.stat-value {
    margin: 6px 0;
    font-size: clamp(1.6rem, 7vw, 2.75rem);
    font-weight: var(--w-lo);
    letter-spacing: -0.04em;
    white-space: nowrap;
}

.stat-panel-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.chart {
    height: 150px;
    margin-top: 16px;
    display: flex;
    align-items: flex-end;
    gap: 14px;
}

.chart.month { gap: 3px; }

.chart-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    font-size: 0.65rem;
    color: var(--muted);
}

.chart-bar {
    width: 100%;
    margin: 4px 0;
    background: var(--line-strong);
    border-radius: 4px;
}

.chart-lbl { height: 1em; line-height: 1; white-space: nowrap; }
.chart.month .chart-val { display: none; }
.chart-col.today { color: var(--text); }
.chart-col.today .chart-bar { background: var(--text); }

@media (max-width: 420px) {
    .stat-card, .stat-panel { padding: 16px; }
}

/* ---------- Focus map (heatmap) ---------- */
.l0 { background: var(--p0); }
.l1 { background: var(--p1); }
.l2 { background: var(--p2); }
.l3 { background: var(--p3); }
.l4 { background: var(--p4); }
:root:is([data-theme="light"], [data-theme="paper"], [data-theme="vanilla"], [data-theme="olive"]) .l0 { box-shadow: inset 0 0 0 1px var(--line-strong); }

.map-box { position: relative; margin-top: 16px; }
.map-wrap { overflow-x: auto; padding-bottom: 4px; }
/* The squares stretch to fill the card, so desktop needs no scrollbar; narrow screens still scroll */
.map-grid {
    display: grid;
    grid-template-columns: 28px repeat(53, minmax(0, 1fr));
    gap: 3px;
    align-items: center;
    min-width: 700px;
}

.map-month {
    grid-row: 1;
    padding-bottom: 3px;
    font-size: 0.65rem;
    line-height: 1;
    color: var(--muted);
    white-space: nowrap;
}

.map-dow {
    grid-column: 1;
    font-size: 0.65rem;
    line-height: 1;
    color: var(--muted);
}

.map-cell { width: 100%; aspect-ratio: 1; border-radius: 2px; }

.map-legend i {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.map-cell:hover { outline: 1px solid var(--text); outline-offset: 1px; }

.map-legend {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
    font-size: 0.65rem;
    color: var(--muted);
}

.map-tip {
    position: absolute;
    z-index: 3;
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--text);
    color: var(--on-text);
    font-size: 0.7rem;
    white-space: nowrap;
    pointer-events: none;
}

.map-tip[hidden] { display: none; }

.map-tip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: var(--arrow, 50%);
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--text);
}

/* ---------- Accent color setting ---------- */
.setting-block {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
    font-size: 0.85rem;
}

.setting-top { display: flex; justify-content: space-between; align-items: center; }

.new-badge {
    padding: 2px 8px;
    border: 1px solid var(--text);
    border-radius: 999px;
    font-size: 0.65rem;
}

.swatches { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 4px 6px; }

.swatch {
    position: relative;
    display: block;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--c);
}

.swatch.active { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--text); }

.swatch-custom {
    border: 1px dashed var(--muted);
    background: transparent;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
}

.swatch-custom.has-color {
    border-color: transparent;
    background: var(--c);
    color: transparent;
}

.swatch-custom input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    opacity: 0;
    cursor: pointer;
}

.palette-preview { display: flex; justify-content: space-between; margin-top: 12px; }

.palette-preview div {
    text-align: center;
    font-size: 0.65rem;
    color: var(--muted);
}

.palette-preview span {
    display: block;
    width: 30px;
    height: 30px;
    margin-bottom: 4px;
    border-radius: 6px;
}

/* ---------- Streak ---------- */
.streak-card {
    display: flex;
    flex-direction: column;
    border-color: var(--p3);
}

.streak-card.out { border-color: var(--line); }

.stat-top { display: flex; justify-content: space-between; align-items: center; }

.stat-unit {
    font-size: 0.875rem;
    font-weight: var(--w);
    letter-spacing: 0;
    color: var(--muted);
}

.flame { flex: none; fill: var(--p3); stroke: var(--p1); }
.flame.risk { fill: none; stroke: var(--p3); stroke-dasharray: 3 2.5; }
.flame.out { fill: none; stroke: var(--line-strong); }
:root:is([data-theme="light"], [data-theme="paper"], [data-theme="vanilla"], [data-theme="olive"]) .flame { stroke: var(--p4); }
:root:is([data-theme="light"], [data-theme="paper"], [data-theme="vanilla"], [data-theme="olive"]) .flame.risk { stroke: var(--p3); }
:root:is([data-theme="light"], [data-theme="paper"], [data-theme="vanilla"], [data-theme="olive"]) .flame.out { stroke: var(--line-strong); }

.streak-dots {
    display: flex;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 14px;
}

.streak-day {
    text-align: center;
    font-size: 0.625rem;
    color: var(--muted);
}

.streak-dot {
    display: block;
    width: 10px;
    height: 10px;
    margin: 0 auto 4px;
    box-sizing: border-box;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
}

.streak-dot.on { background: var(--p3); border-color: var(--p3); }
.streak-dot.today { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--text); }

.map-cell.s { box-shadow: 0 0 0 1.5px var(--text); }

.map-legend .s-key {
    background: transparent;
    box-shadow: 0 0 0 1.5px var(--text);
    margin-right: 4px;
}

.s-label { margin-right: 14px; }

@media (max-width: 700px) {
    .stat-value { font-size: clamp(1.6rem, 5.2vw, 2.75rem); }
}

/* ---------- Records (Stats tab, between the top cards and the focus map) ---------- */
.records { margin-bottom: 20px; }

.records-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 0.75rem;
    color: var(--muted);
}

.records-title {
    margin: 0;
    font-size: 1rem;
    font-weight: var(--w);
    letter-spacing: 0;
    color: var(--text);
}

.records-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.rec-card .stat-value { font-size: clamp(1.5rem, 4vw, 2rem); }
.rec-card.new { border-color: var(--p3); }
.rec-card.empty,
.rec-more { border-style: dashed; }

.rec-new {
    display: none;
    padding: 1px 8px;
    border: 1px solid var(--p3);
    border-radius: 999px;
    font-size: 0.6rem;
    letter-spacing: 0.08em;
    color: var(--text);
}

.rec-card.new .rec-new { display: inline-block; }

.rec-more {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--muted);
}

.rec-short { display: none; }

@media (max-width: 700px) {
    .records-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .rec-long { display: none; }
    .rec-short { display: inline; }
}

/* The app opens on the Clock tab: keep the timer parts hidden until the script runs */
body[data-tab="clock"] .clock,
body[data-tab="clock"] .progress,
body[data-tab="clock"] .focus-container { display: none; }
body[data-tab="clock"] .realtime { display: block; }

/* ---------- Focus tab: big clock in the middle, controls right below ---------- */
body[data-tab="focus"] .clock {
    font-size: clamp(5rem, 24vw, 14rem);
    margin: 0 0 28px;
}

body[data-tab="clock"] .below,
body[data-tab="focus"] .below {
    min-height: 0;
    align-items: flex-start;
    padding: 28px 0 16px;
    overflow-y: auto;
}

body[data-tab="focus"] .status { margin: 0 0 20px; }
body[data-tab="focus"] .settings { margin-top: 28px; }

[hidden] { display: none !important; }

/* ---------- Current task ---------- */
.current-line {
    display: block;
    max-width: min(80vw, 480px);
    margin: -8px auto 20px;
    padding: 0;
    background: none;
    border: 0;
    overflow: hidden;
    color: var(--muted);
    font: inherit;
    font-size: 0.8rem;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.2s;
}

.current-line b { font-weight: var(--w-hi); color: var(--text); }
.current-line:hover { color: var(--text); }

.cur-btn {
    flex: none;
    display: grid;
    place-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.cur-btn svg { width: 20px; height: 20px; }
.cur-btn path { stroke: var(--line-strong); transition: stroke 0.2s; }
.cur-btn circle { fill: var(--line-strong); transition: fill 0.2s; }
.cur-btn:hover:not(:disabled) path { stroke: var(--text); }
.cur-btn:disabled { opacity: 0.25; cursor: default; }
.todo-item.current .cur-btn path { stroke: var(--text); }
.todo-item.current .cur-btn circle { fill: var(--p3); }
.todo-item.current label span { font-weight: var(--w-hi); }

/* ---------- Clean mode ---------- */
.topbar, .below { transition: opacity 0.35s ease; }

body.clean .topbar,
body.clean .below {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s ease, visibility 0s 0.35s;
}

.icon-btn.clean-btn {
    top: auto;
    bottom: 24px;
    opacity: 0.6;
    transition: opacity 0.3s, color 0.2s, border-color 0.2s;
}

.icon-btn.clean-btn:hover { opacity: 1; }
body:not([data-tab="clock"]):not([data-tab="focus"]) .clean-btn { display: none; }
body.clean .clean-btn { opacity: 0; pointer-events: none; }
body.clean.show-exit .clean-btn { opacity: 0.85; pointer-events: auto; }

/* ---------- Task days (To do list) ---------- */
:root { --cal-acc: var(--p3); }
:root:is([data-theme="light"], [data-theme="paper"], [data-theme="vanilla"], [data-theme="olive"]) { --cal-acc: var(--p4); }

.todo-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
}

.todo-main label { flex: 1 1 160px; min-width: 0; }

/* The date chip of a task ("Today", "Fri 20"), or "+ Set date" */
.due-btn {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 26px;
    padding: 0 10px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}

.due-btn:hover { color: var(--text); border-color: var(--text); }
.due-btn.add { color: var(--text); border-color: var(--cal-acc); }
.due-btn.add:hover { background: color-mix(in srgb, var(--cal-acc) 14%, transparent); border-color: var(--cal-acc); }
/* Next to the date chip, the top priority task shows only its flag (as in the design), so the text keeps one line */
.todo-item.top .prio-btn.on .prio-text { display: none; }

/* ---------- Calendar tab: the month on the left, the selected day on the right ---------- */
.cal-container {
    display: none;
    width: min(100%, 1040px);
    margin-top: 36px;
    text-align: left;
}

.cal-card {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    padding: 28px;
    background: color-mix(in srgb, var(--panel) 85%, transparent);
    border: 1px solid var(--line);
    border-radius: 24px;
}

.cal-month { min-width: 0; padding-right: 28px; }

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

.cal-title {
    margin: 0;
    font-size: clamp(1.25rem, 3vw, 1.6rem);
    font-weight: var(--w-lo);
    letter-spacing: -0.03em;
    white-space: nowrap;
}

.cal-year { color: var(--muted); }
.cal-nav { display: flex; align-items: center; gap: 8px; flex: none; }

.cal-arrow {
    display: grid;
    place-content: center;
    width: 32px;
    height: 32px;
    padding: 0 0 2px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    font-size: 1.2rem;
    line-height: 1;
    transition: color 0.2s, border-color 0.2s;
}

.cal-arrow:hover { color: var(--text); border-color: var(--text); }

.cal-dow,
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.cal-dow span {
    padding-bottom: 10px;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: center;
}

.cal-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 0;
    height: 54px;
    padding: 0;
    background: color-mix(in srgb, var(--text) 6%, transparent);
    color: var(--text);
    border: 1px solid transparent;
    border-radius: 12px;
    font-size: 0.85rem;
    transition: background-color 0.15s, border-color 0.15s;
}

.cal-cell:hover { background: color-mix(in srgb, var(--text) 11%, transparent); }
.cal-cell.out { background: transparent; color: var(--muted); }   /* other months: the grey alone sets them apart (no opacity, still 4.5:1) */
.cal-cell.sel { border-color: color-mix(in srgb, var(--text) 75%, transparent); }

.cal-num {
    display: grid;
    place-content: center;
    min-width: 26px;
    height: 26px;
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
}

.cal-cell.today .cal-num { background: var(--cal-acc); color: var(--on-acc, #fff); font-weight: var(--w-hi); }

/* One dot per task: open ones in the accent color, done ones grey */
.cal-dots { display: flex; justify-content: center; gap: 3px; height: 5px; }
.dot { display: block; width: 5px; height: 5px; border-radius: 50%; background: var(--cal-acc); }
.dot.done { background: var(--line-strong); }

/* The selected day */
.cal-day {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding-left: 28px;
    border-left: 1px solid var(--line);
}

.day-head { margin-bottom: 16px; }

.day-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: var(--w-lo);
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.day-date { display: block; margin-top: 4px; font-size: 0.75rem; color: var(--muted); }
.day-date-short { display: none; }

.day-tasks {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.day-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    font-size: 0.85rem;
}

.day-item label { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.day-text { min-width: 0; overflow-wrap: anywhere; }
.day-item.top { border-color: var(--cal-acc); background: color-mix(in srgb, var(--cal-acc) 10%, transparent); }
.day-item.done { border-color: transparent; }
.day-item.done .day-text { color: var(--muted); text-decoration: line-through; }

.day-item input[type="checkbox"],
.day-circle {
    -webkit-appearance: none;
    appearance: none;
    flex: none;
    display: block;
    width: 16px;
    height: 16px;
    margin: 0;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.day-item input[type="checkbox"]:checked { background: var(--cal-acc); border-color: var(--cal-acc); }

.day-flag { flex: none; display: inline-flex; color: var(--text); }
.day-flag svg { width: 14px; height: 14px; }

.day-chip {
    flex: none;
    padding: 2px 8px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    font-size: 0.68rem;
    color: var(--muted);
    white-space: nowrap;
}

.day-empty { margin: 0 0 12px; font-size: 0.85rem; color: var(--muted); }
/* An empty day from today on: the add field stands out a little more (calendar.js) */
.day-add.prominent { border-style: solid; border-color: color-mix(in srgb, var(--text) 45%, transparent); }
.day-add.prominent .day-add-plus,
.day-add.prominent input::placeholder { color: var(--text); }

/* Overdue: one quiet line, one button. No red. */
.cal-overdue {
    margin-bottom: 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
}

.cal-overdue-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 0.8rem;
}

.cal-link {
    flex: none;
    padding: 2px 0;
    background: none;
    color: var(--text);
    border: 0;
    font-size: 0.78rem;
}

.cal-link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Add a task for this day */
.day-add {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px dashed var(--line-strong);
    border-radius: 12px;
    transition: border-color 0.2s;
}

.day-add:focus-within { border-color: var(--text); border-style: solid; }
.day-add-plus { flex: none; width: 16px; color: var(--muted); text-align: center; }

.day-add input {
    flex: 1;
    min-width: 0;
    padding: 0;
    background: transparent;
    color: var(--text);
    border: 0;
    font: inherit;
    font-size: 0.85rem;
}

.day-add input:focus-visible { outline: none; }
.day-add input::placeholder { color: var(--muted); }

/* Pick from your To do list */
.day-pick-btn {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 8px;
    margin-top: 14px;
    padding: 2px 0;
    background: none;
    color: var(--muted);
    border: 0;
    font-size: 0.8rem;
    transition: color 0.2s;
}

.day-pick-btn svg { width: 16px; height: 16px; }
.day-pick-btn:hover,
.day-pick-btn.on { color: var(--text); }

.day-pick {
    margin-top: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
}

.day-pick-title { margin-bottom: 10px; font-size: 0.85rem; }
.day-pick-hint { margin: 10px 0 0; font-size: 0.72rem; color: var(--muted); }
.day-item.pick { padding: 0; border: 0; }

.day-pick-item {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 10px 12px;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 12px;
    font: inherit;
    font-size: 0.85rem;
    text-align: left;
    transition: border-color 0.2s, background-color 0.2s;
}

.day-pick-item:hover { border-color: var(--cal-acc); background: color-mix(in srgb, var(--cal-acc) 8%, transparent); }

/* Focus time: one line at the bottom; the full picture lives in Stats */
.day-focus {
    margin: 0;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    font-size: 0.75rem;
    color: var(--muted);
}

.day-spacer { flex: 1 0 24px; }

/* ---------- Date picker ---------- */
.pk-backdrop { position: fixed; inset: 0; z-index: 60; }
.pk-backdrop.dim { background: rgba(0, 0, 0, 0.5); }

.pk {
    position: fixed;
    z-index: 61;
    width: 320px;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    padding: 16px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    text-align: left;
}

.pk.sheet {
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 88vh;
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
}

.pk button { font-family: var(--font); }
.pk-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.pk-chip {
    padding: 6px 11px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.76rem;
    font-variant-numeric: tabular-nums;
    transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}

.pk-chip:hover:not(:disabled) { color: var(--text); border-color: var(--line-strong); }
.pk-chip.on { background: var(--text); color: var(--on-text); border-color: var(--text); }
.pk-chip:disabled { opacity: 0.35; cursor: default; }

.pk-month-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 14px 0 6px;
    font-size: 0.85rem;
}

.pk-arrow {
    width: 30px;
    height: 30px;
    padding: 0 0 2px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 50%;
    font-size: 1.1rem;
    line-height: 1;
}

.pk-arrow:hover { color: var(--text); border-color: var(--line-strong); }

.pk-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 2px;
}

.pk-dow { padding: 4px 0; font-size: 0.62rem; color: var(--muted); text-align: center; }

.pk-day {
    position: relative;
    height: 36px;
    padding: 0;
    background: transparent;
    color: var(--text);
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
}

.pk-day:hover { background: var(--hover); }
.pk-day.out,
.pk-day.past { color: var(--muted); }
.pk-day.today { border-color: var(--cal-acc); }
.pk-day.on { background: var(--text); color: var(--on-text); border-color: var(--text); }
.pk-day.busy::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 4px;
    width: 4px;
    height: 4px;
    margin-left: -2px;
    border-radius: 50%;
    background: var(--cal-acc);
}
.pk-day.on.busy::after { background: var(--on-text); }

@media (max-width: 600px) {
    /* room for the bottom tab bar (these come after the Clock / Focus layout rules, so they win) */
    body[data-tab="clock"],
    body[data-tab="focus"] { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
    .icon-btn.clean-btn { bottom: calc(84px + env(safe-area-inset-bottom)); }
    /* the day goes on its own line under the task text */
    .todo-main label { flex-basis: 0; }
    .todo-main:has(.due-btn.set) label { flex-basis: 100%; }
    .todo-main .due-btn.set { margin-left: 32px; }
}

/* Narrow screens: the day goes under the month */
/* Wide screens: the card fills the page height below the tab bar (--cal-fill, set by calendar.js), and the weeks
   grow to fill it; the day panel on the right stretches with it. A busy day can still make the card taller. */
@media (min-width: 901px) {
    .cal-card { min-height: var(--cal-fill, auto); }
    .cal-month { display: flex; flex-direction: column; }
    .cal-grid { flex: 1; grid-auto-rows: minmax(54px, 1fr); }
    .cal-cell { height: auto; }
}

@media (max-width: 900px) {
    .cal-card { grid-template-columns: minmax(0, 1fr); }
    .cal-month { padding-right: 0; }
    .cal-day { margin-top: 20px; padding: 20px 0 0; border-left: 0; border-top: 1px solid var(--line); }
}

/* Phone: "November" with the arrows, a compact month, then "Today · 15 Nov" */
@media (max-width: 600px) {
    .cal-container { margin-top: 16px; }
    .cal-card { padding: 16px 12px; border-radius: 20px; }
    .cal-head { margin-bottom: 14px; }
    .cal-year,
    .cal-today { display: none; }
    .cal-dow,
    .cal-grid { gap: 4px; }
    .cal-dow span { padding-bottom: 6px; font-size: 0.58rem; letter-spacing: 0.02em; }
    .cal-cell { height: 42px; gap: 3px; border-radius: 9px; font-size: 0.78rem; }
    .cal-num { min-width: 22px; height: 22px; }
    .cal-dots { height: 4px; gap: 2px; }
    .dot { width: 4px; height: 4px; }
    .cal-day { margin-top: 14px; padding-top: 14px; }
    .day-head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 12px; }
    .day-title { font-size: 1.15rem; }
    .day-date { margin: 0; }
    .day-date-long { display: none; }
    .day-date-short { display: inline; }
}

/* ---------- Goals (Stats tab) ---------- */
.goals { margin-bottom: 36px; }

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

.goals-title {
    margin: 0;
    font-size: 1.6rem;
    font-weight: var(--w-lo);
    letter-spacing: -0.03em;
}

.goal-label {
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.goals-empty {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.goals-empty p { margin: 6px 0 0; max-width: 46ch; font-size: 0.85rem; color: var(--muted); line-height: 1.5; }

.goal-rings {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.goal-card {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 20px;
    transition: border-color 0.4s;
}

.goal-card.reached { border-color: var(--cal-acc); }
.goal-card.rest { opacity: 0.55; }
.goal-card-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.goal-ring { position: relative; flex: none; width: 96px; height: 96px; }
.goal-ring.small { width: 88px; height: 88px; }
.goal-ring svg { display: block; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line); }
.ring-fg { fill: none; stroke: var(--cal-acc); stroke-linecap: round; transition: stroke-dasharray 0.6s ease; }

.goal-ring-num {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    font-size: 1.15rem;
    font-weight: var(--w);
    font-variant-numeric: tabular-nums;
}

.goal-card.rest .goal-ring-num { font-size: 0.8rem; color: var(--muted); }

.goal-value {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: var(--w-lo);
    letter-spacing: -0.04em;
    white-space: nowrap;
}

.goal-of { font-size: 0.85rem; letter-spacing: 0; color: var(--muted); }
.goal-sub { font-size: 0.75rem; color: var(--muted); }
.goal-card.reached .goal-sub { color: var(--cal-acc); }

.goal-week-row {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    gap: 16px;
}

.goal-week { margin: 0; border-radius: 20px; padding: 24px; }
.gw-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.gw-head-text { min-width: 0; }
.gw-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.gw-last {
    padding: 2px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.68rem;
    color: var(--muted);
}

.gw-last.hit { color: var(--cal-acc); border-color: var(--cal-acc); }

.gw-value {
    margin: 8px 0 4px;
    font-size: clamp(2rem, 5vw, 2.75rem);
    font-weight: var(--w-lo);
    letter-spacing: -0.04em;
    white-space: nowrap;
}

.goal-ring.small.reached .ring-fg { stroke: var(--cal-acc); }

.gw-bars {
    position: relative;
    display: flex;
    gap: 12px;
    margin-top: 22px;
    height: 176px;
}

.gw-line {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px dashed var(--line-strong);
    pointer-events: none;
}

.gw-line span {
    position: absolute;
    right: 0;
    bottom: 3px;
    font-size: 0.62rem;
    color: var(--muted);
    background: var(--bg);
    padding-left: 6px;
}

.gw-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
}

.gw-bar-wrap { display: flex; align-items: flex-end; width: 100%; height: 150px; }
.gw-bar { width: 100%; border-radius: 6px 6px 2px 2px; transition: height 0.5s ease; }
.gw-bar.on { background: var(--cal-acc); }
.gw-bar.low { background: var(--p1); }
.gw-bar.now { background: var(--cal-acc); opacity: 0.55; }
.gw-bar.rest { background: var(--line-strong); }
.gw-bar.empty { height: 10px; background: none; border: 1px dashed var(--line-strong); border-radius: 6px; }
:root:is([data-theme="light"], [data-theme="paper"], [data-theme="vanilla"], [data-theme="olive"]) .gw-bar.low { background: var(--p2); }
.gw-day { font-size: 0.7rem; color: var(--muted); }
.gw-col.today .gw-day { color: var(--text); font-weight: var(--w-hi); }

.goal-side { display: flex; flex-direction: column; gap: 16px; }
.goal-small { flex: 1; margin: 0; border-radius: 20px; padding: 22px; }
.gs-head { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); }

.gs-value {
    margin: 6px 0 14px;
    font-size: 1.9rem;
    font-weight: var(--w-lo);
    letter-spacing: -0.04em;
}

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

.gs-dot {
    display: grid;
    place-content: center;
    width: 24px;
    height: 24px;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
}

.gs-dot svg { width: 14px; height: 14px; color: var(--on-acc, #fff); }
.gs-dot.hit { background: var(--cal-acc); border-color: var(--cal-acc); }
.gs-dot.today { border-color: var(--text); }
.gs-dot.future { border-style: dashed; }

.gs-track { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.gs-fill { height: 100%; border-radius: 999px; background: var(--cal-acc); transition: width 0.5s ease; }

/* Calendar: a violet dot on days the goal was reached */
.cal-num { position: relative; }

.cal-goal {
    position: absolute;
    top: -1px;
    right: -5px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cal-acc);
    box-shadow: 0 0 0 2px var(--bg);
}

.cal-legend .cal-goal { position: static; display: inline-block; box-shadow: none; }

/* ---------- Focus tab: the quiet line under the timer ---------- */
.goal-line {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(300px, 80vw);
    margin: 28px auto 0;
    padding: 6px 0;
    background: none;
    color: var(--muted);
    border: 0;
    font: inherit;
    font-size: 0.75rem;
    cursor: pointer;
}

.goal-line-label { display: inline-flex; justify-content: center; align-items: center; gap: 6px; }
.goal-line-label svg { width: 14px; height: 14px; }
.goal-line-track { display: block; height: 4px; border-radius: 999px; background: var(--line); overflow: hidden; }
.goal-line-fill { display: block; height: 100%; border-radius: 999px; background: var(--cal-acc); transition: width 0.6s ease; }
.goal-line-nums { display: flex; justify-content: space-between; font-size: 0.7rem; font-variant-numeric: tabular-nums; }
.goal-line.reached .goal-line-label { color: var(--cal-acc); }
.goal-line.rest { opacity: 0.6; }
.goal-line:hover { color: var(--text); }

/* ---------- Goals editor ---------- */
body.modal-open { overflow: hidden; }

.goals-modal {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.6);
}

.ge-card {
    width: min(100%, 460px);
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    padding: 26px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: 22px;
    text-align: left;
}

.ge-title { margin: 0; font-size: 1.3rem; font-weight: var(--w); letter-spacing: -0.02em; }
.ge-intro { margin: 4px 0 18px; font-size: 0.85rem; color: var(--muted); }

.ge-sec {
    margin: 18px 0 10px;
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.ge-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
    font-size: 0.9rem;
}

.ge-row > span:first-child,
.ge-week > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ge-row small,
.ge-week small { font-size: 0.7rem; color: var(--muted); }

.ge-step { display: inline-flex; align-items: center; gap: 6px; flex: none; }

.ge-step button {
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    font-size: 1.05rem;
}

.ge-step button:hover { background: var(--hover); }

.ge-step output {
    min-width: 72px;
    font-size: 1.15rem;
    font-weight: var(--w-lo);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.ge-days { display: flex; justify-content: space-between; gap: 6px; }

.ge-day {
    width: 42px;
    height: 42px;
    padding: 0;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    font-size: 0.8rem;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.ge-day.on { background: var(--cal-acc); color: var(--on-acc, #fff); border-color: var(--cal-acc); }
.ge-note { margin: 10px 0 0; font-size: 0.72rem; color: var(--muted); }

.ge-week {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--hover);
    font-size: 0.9rem;
}

.ge-week b { font-size: 1.6rem; font-weight: var(--w-lo); letter-spacing: -0.03em; }

.ge-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

.ge-actions-right { display: flex; gap: 8px; margin-left: auto; }

.ge-off {
    padding: 6px 0;
    background: none;
    color: var(--muted);
    border: 0;
    font-size: 0.78rem;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ge-off:hover { color: var(--text); }

@media (max-width: 800px) {
    .goal-rings { grid-template-columns: minmax(0, 1fr); gap: 10px; }
    .goal-card { padding: 14px 16px; gap: 14px; }
    .goal-card .goal-ring { width: 64px; height: 64px; }
    .goal-card .goal-ring svg { width: 64px; height: 64px; }
    .goal-card .goal-ring-num { font-size: 0.85rem; }
    .goal-week-row { grid-template-columns: minmax(0, 1fr); }
    .goal-side { flex-direction: row; }
}

@media (max-width: 480px) {
    .goal-side { flex-direction: column; }
    .goal-week { padding: 18px; }
    .gw-bars { gap: 6px; }
    .goal-ring.small { width: 72px; height: 72px; }
    .goal-ring.small svg { width: 72px; height: 72px; }
    .ge-card { padding: 20px; }
    .ge-day { width: 36px; height: 36px; }
}

/* ---------- Themes: Graphite and Paper (Light rules also apply to Paper) ---------- */
:root[data-theme="graphite"] {
    --bg: #1c1c1e;
    --text: #f2f2f2;
    --muted: #a0a0a5;
    --line: #333336;
    --line-strong: #5c5c60;
    --on-text: #1c1c1e;
    --panel: #242426;
    --field: #1c1c1e;
    --hover: rgba(255, 255, 255, 0.08);
}

:root[data-theme="paper"] {
    --bg: #f4efe6;
    --text: #2a2620;
    --muted: #6e665a;
    --line: #e2d9c8;
    --line-strong: #bfb39f;
    --on-text: #f4efe6;
    --panel: #ede6d9;
    --field: #f8f4ec;
    --hover: rgba(42, 38, 32, 0.06);
    color-scheme: light;
}

/* ---------- Colour themes: Blush, Vanilla, Olive, Forest, Deep Sea ----------
   A solid background and a text colour; borders, panels and hovers are the text colour with transparency.
   [data-bg] is always "solid" now (the background comes only from the theme).
   Each theme's two colours are set once here (--th-*), and the page, the Settings card and its two dots all read them. */
:root {
    --th-dark-bg: #000; --th-dark-text: #f2f2f2;
    --th-light-bg: #fff; --th-light-text: #111;
    --th-graphite-bg: #1c1c1e; --th-graphite-text: #f2f2f2;
    --th-paper-bg: #f4efe6; --th-paper-text: #2a2620;
    --th-blush-bg: #7b3b4b; --th-blush-text: #dfd4d8;          /* Raspberry Wine, Blush Breeze */
    --th-vanilla-bg: #f0e7d5; --th-vanilla-text: #212842;
    --th-olive-bg: #d2db76; --th-olive-text: #2d371d;
    --th-forest-bg: #00311f; --th-forest-text: #fff7e6;        /* Pine, Beige */
    --th-deep-sea-bg: #156874; --th-deep-sea-text: #ede6e6;    /* Deep Sea, Steam */
}
:root[data-theme="blush"][data-bg] { --bg: var(--th-blush-bg); --text: var(--th-blush-text); color-scheme: dark; }
:root[data-theme="vanilla"][data-bg] { --bg: var(--th-vanilla-bg); --text: var(--th-vanilla-text); color-scheme: light; }
:root[data-theme="olive"][data-bg] { --bg: var(--th-olive-bg); --text: var(--th-olive-text); color-scheme: light; }
:root[data-theme="forest"][data-bg] { --bg: var(--th-forest-bg); --text: var(--th-forest-text); color-scheme: dark; }
:root[data-theme="deep-sea"][data-bg] { --bg: var(--th-deep-sea-bg); --text: var(--th-deep-sea-text); color-scheme: dark; }

:root:is([data-theme="blush"], [data-theme="vanilla"], [data-theme="olive"], [data-theme="forest"], [data-theme="deep-sea"])[data-bg] {
    --muted: color-mix(in srgb, var(--text) 64%, var(--bg));
    --line: color-mix(in srgb, var(--text) 16%, transparent);
    --line-strong: color-mix(in srgb, var(--text) 38%, transparent);
    --on-text: var(--bg);
    --panel: color-mix(in srgb, var(--text) 6%, var(--bg));
    --field: var(--bg);
    --hover: color-mix(in srgb, var(--text) 10%, transparent);
    --cal-acc: var(--p4);            /* the accent itself (by default the text colour) */
}
/* Grey text at least 4.5:1 on each theme (on its background and on its glass): more of the text colour where needed */
:root[data-theme="blush"][data-bg] { --muted: var(--text); }   /* the text itself is only ~5:1 here */
:root[data-theme="vanilla"][data-bg] { --muted: color-mix(in srgb, var(--text) 80%, var(--bg)); }
:root[data-theme="olive"][data-bg] { --muted: color-mix(in srgb, var(--text) 88%, var(--bg)); }
:root[data-theme="deep-sea"][data-bg] { --muted: var(--text); }   /* the text itself is only ~5:1 here */

:root:is([data-theme="blush"], [data-theme="vanilla"], [data-theme="olive"], [data-theme="forest"], [data-theme="deep-sea"])[data-bg] body {
    background: var(--bg);
}

/* Text and icons drawn on the accent take the background colour, so they stay readable on a text-coloured accent */
:root:is([data-theme="blush"], [data-theme="vanilla"], [data-theme="olive"], [data-theme="forest"], [data-theme="deep-sea"]) :is(.cal-cell.today .cal-num, .avatar-btn.signed, .ge-day.on, .set-avatar, .gs-dot svg) {
    color: var(--on-acc, var(--bg));
}
:root:is([data-theme="blush"], [data-theme="vanilla"], [data-theme="olive"], [data-theme="forest"], [data-theme="deep-sea"]) .set-toggle:checked::after { background: var(--bg); }

/* Aesthetic mode: the video stays; the theme colours only the interface (text, panels, widget) */
:root:is([data-theme="blush"], [data-theme="vanilla"], [data-theme="olive"], [data-theme="forest"], [data-theme="deep-sea"]) .aes { color: var(--text); }
:root:is([data-theme="blush"], [data-theme="vanilla"], [data-theme="olive"], [data-theme="forest"], [data-theme="deep-sea"]) .aes-widget {
    background: color-mix(in srgb, var(--bg) 72%, transparent);
}
:root:is([data-theme="blush"], [data-theme="vanilla"], [data-theme="olive"], [data-theme="forest"], [data-theme="deep-sea"]) .aes-btn {
    background: color-mix(in srgb, var(--text) 10%, transparent);
    color: var(--text);
}
:root:is([data-theme="blush"], [data-theme="vanilla"], [data-theme="olive"], [data-theme="forest"], [data-theme="deep-sea"]) .aes-btn:hover { background: color-mix(in srgb, var(--text) 18%, transparent); }
:root:is([data-theme="blush"], [data-theme="vanilla"], [data-theme="olive"], [data-theme="forest"], [data-theme="deep-sea"]) .aes-label { color: color-mix(in srgb, var(--text) 65%, transparent); }
:root:is([data-theme="blush"], [data-theme="vanilla"], [data-theme="olive"], [data-theme="forest"], [data-theme="deep-sea"]) :is(.aes-ring-base, .aes-mini-base) { stroke: color-mix(in srgb, var(--text) 16%, transparent); }
:root:is([data-theme="blush"], [data-theme="vanilla"], [data-theme="olive"], [data-theme="forest"], [data-theme="deep-sea"]) :is(.aes-ring-fill, .aes-mini-fill) { stroke: var(--cal-acc); }
:root:is([data-theme="blush"], [data-theme="vanilla"], [data-theme="olive"], [data-theme="forest"], [data-theme="deep-sea"]) .aes-widget[data-state="break"] :is(.aes-ring-fill, .aes-mini-fill) { stroke: color-mix(in srgb, var(--cal-acc) 55%, transparent); }
:root:is([data-theme="blush"], [data-theme="vanilla"], [data-theme="olive"], [data-theme="forest"], [data-theme="deep-sea"]) .aes-hint {
    color: color-mix(in srgb, var(--text) 75%, transparent);
    text-shadow: 0 1px 6px color-mix(in srgb, var(--bg) 60%, transparent);
}

/* ---------- Settings tab ---------- */
.settings-container {
    display: none;
    width: min(100%, 1040px);
    margin-top: 36px;
    text-align: left;
}

.set-layout {
    display: flex;
    align-items: flex-start;
    gap: 32px;
}

.set-nav {
    position: sticky;
    top: 24px;
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 210px;
}

.set-title { display: none; }

.set-nav-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    background: transparent;
    color: var(--muted);
    border: 0;
    border-radius: 12px;
    font-size: 0.9rem;
    text-align: left;
    transition: background-color 0.2s, color 0.2s;
}

.set-nav-item:hover { color: var(--text); }
.set-nav-item.on { background: var(--hover); color: var(--text); }
.set-nav-sum { display: none; }
.set-version { margin: 0; padding: 22px 16px 0; font-size: 0.7rem; color: var(--muted); }

.set-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.set-card {
    padding: 26px 28px 8px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--bg);
    scroll-margin-top: 24px;
}

.set-back { display: none; }

.set-card-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.set-card-head h3 { margin: 0; font-size: 1.25rem; font-weight: var(--w); letter-spacing: -0.02em; }
.set-card-head span { font-size: 0.75rem; color: var(--muted); }

.set-label {
    margin: 22px 0 12px;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.set-label .new-badge,
.set-row-text .new-badge {
    margin-left: 6px;
    padding: 2px 7px;
    border-color: var(--cal-acc);
    color: var(--text);   /* the accent stays on the outline; the word is the text colour so it reads on every theme */
    font-size: 0.56rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    vertical-align: middle;
}

/* Theme and Aesthetic mode tiles */
.set-tiles { display: flex; gap: 14px; }

.set-tile {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0;
    background: none;
    color: var(--muted);
    border: 0;
    font-size: 0.75rem;
}

.set-prev {
    display: grid;
    place-content: center;
    height: 92px;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    font-size: 1.25rem;
    font-weight: 200;
    letter-spacing: -0.03em;
    background-size: cover;
    background-position: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.set-tile:hover .set-prev { border-color: var(--muted); }
.set-tile.on { color: var(--text); }
.set-tile.on .set-prev { border-color: var(--cal-acc); box-shadow: inset 0 0 0 1px var(--cal-acc); }

/* Each card and its two dots read the theme's own colours (--th-*, set with the colour themes above) */
[data-theme-choice="dark"] { --tb: var(--th-dark-bg); --tt: var(--th-dark-text); }
[data-theme-choice="light"] { --tb: var(--th-light-bg); --tt: var(--th-light-text); }
[data-theme-choice="graphite"] { --tb: var(--th-graphite-bg); --tt: var(--th-graphite-text); }
[data-theme-choice="paper"] { --tb: var(--th-paper-bg); --tt: var(--th-paper-text); }
[data-theme-choice="blush"] { --tb: var(--th-blush-bg); --tt: var(--th-blush-text); }
[data-theme-choice="vanilla"] { --tb: var(--th-vanilla-bg); --tt: var(--th-vanilla-text); }
[data-theme-choice="olive"] { --tb: var(--th-olive-bg); --tt: var(--th-olive-text); }
[data-theme-choice="forest"] { --tb: var(--th-forest-bg); --tt: var(--th-forest-text); }
[data-theme-choice="deep-sea"] { --tb: var(--th-deep-sea-bg); --tt: var(--th-deep-sea-text); }
.set-themes .set-prev { background: var(--tb); color: var(--tt); }

/* Rows */
.set-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 18px 0;
    border-bottom: 1px solid var(--line);
}

.set-row:last-child { border-bottom: 0; }
.set-row[hidden] { display: none; }
.set-row-text { min-width: 0; font-size: 0.9rem; }
.set-row-text label { cursor: pointer; }
.set-row-text p { margin: 3px 0 0; font-size: 0.75rem; color: var(--muted); line-height: 1.5; }
.set-tiles + .set-row,
.set-themes + .set-row,
.set-anim + .set-row { margin-top: 6px; }

.set-row .swatches { flex: none; margin: 0; gap: 10px; }
.set-row .swatch { width: 28px; height: 28px; }
.set-row .swatch.active { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--text); }
.set-row .swatch-custom { line-height: 26px; }

/* Sliders: Thin to Bold */
.set-range { flex: none; width: 240px; }

.set-range input {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    height: 16px;
    margin: 4px 0 6px;
    background: transparent;
    cursor: pointer;
}

.set-range input::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(to right, var(--cal-acc) var(--pct, 0%), var(--line) var(--pct, 0%));
}

.set-range input::-moz-range-track { height: 4px; border-radius: 999px; background: var(--line); }
.set-range input::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--cal-acc); }

.set-range input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    margin-top: -6px;
    border: 0;
    border-radius: 50%;
    background: var(--text);
}

.set-range input::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--text); }
.set-range-ends { display: flex; justify-content: space-between; font-size: 0.65rem; color: var(--muted); }

/* Toggle */
.set-toggle {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    flex: none;
    width: 44px;
    height: 26px;
    margin: 0;
    border-radius: 999px;
    background: var(--line-strong);
    cursor: pointer;
    transition: background-color 0.2s;
}

.set-toggle::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--text);
    transition: transform 0.2s;
}

.set-toggle:checked { background: var(--cal-acc); }
.set-toggle:checked::after { transform: translateX(18px); background: #f2f2f2; }

/* Clock font tiles */
.font-tiles { flex: none; display: flex; gap: 10px; }

.font-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 92px;
    padding: 14px 18px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    font-size: 0.7rem;
    transition: border-color 0.2s;
}

.font-tile:hover { border-color: var(--muted); }
.font-tile.on { color: var(--text); border-color: var(--cal-acc); box-shadow: inset 0 0 0 0.5px var(--cal-acc); }
.font-prev { color: var(--text); font-size: 1.6rem; font-weight: 300; letter-spacing: -0.02em; }
.f-sora { font-family: 'Sora', sans-serif; }
.f-mono { font-family: 'JetBrains Mono', monospace; font-weight: 200; }
.f-inter { font-family: 'Inter', sans-serif; }
.f-dmsans { font-family: 'DM Sans', sans-serif; }

/* 12h / 24h */
.seg { flex: none; display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; }

.seg button {
    padding: 6px 16px;
    background: transparent;
    color: var(--muted);
    border: 0;
    border-radius: 999px;
    font-size: 0.8rem;
}

.seg button.on { background: var(--text); color: var(--on-text); }

/* Shortcuts */
.set-keys {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 40px;
    margin: 0;
    padding: 10px 0 20px;
}

.set-keys div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 0;
    border-bottom: 1px solid var(--line);
    font-size: 0.8rem;
}

.set-keys dt { color: var(--muted); }
.set-keys dd { margin: 0; }

/* Account and data */
.set-account { flex: none; display: inline-flex; align-items: center; gap: 10px; }

.set-avatar {
    display: grid;
    place-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--cal-acc);
    color: var(--on-acc, #fff);
    font-size: 0.9rem;
}

.set-row .btn { flex: none; padding: 8px 18px; font-size: 0.8rem; }
.set-muted-btn { color: var(--muted); }

/* Danger zone: delete the account (delete-account.js). The same red on every theme. */
.set-danger {
    --danger: #e5484d;
    margin-top: 18px;
    padding: 4px 18px;
    border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--line));
    border-radius: 14px;
    background: color-mix(in srgb, var(--danger) 4%, transparent);
}

/* Red words: a red that reads at 4.5:1 on each kind of background (the red of borders and fills stays #e5484d) */
:root { --danger-text: #ff8a8d; }
:root[data-theme="animated"] { --danger-text: #ffb0b2; }
:root:is([data-theme="light"], [data-theme="paper"], [data-theme="vanilla"], [data-theme="olive"]) { --danger-text: #951a1f; }
:root:is([data-theme="blush"], [data-theme="forest"], [data-theme="deep-sea"]) { --danger-text: var(--text); }
.set-danger-title { padding-top: 14px; font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--danger-text); }
.set-danger .set-row { padding: 14px 0 16px; }
.set-danger-btn { flex: none; border-color: color-mix(in srgb, var(--danger) 70%, transparent); color: var(--danger-text); }
.set-danger-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 12%, transparent); }

/* The "Delete your account?" dialog (frame: .goals-modal / .ge-card) */
.del-card { --danger: #e5484d; }
.del-label { display: block; margin-bottom: 8px; font-size: 0.75rem; color: var(--muted); }
.del-label strong { font-weight: 600; color: var(--text); }

.del-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid color-mix(in srgb, var(--danger) 55%, var(--line));
    border-radius: 12px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    letter-spacing: 0.04em;
}

.del-input:focus { outline: none; border-color: var(--danger); }
.del-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.del-confirm { border-color: var(--danger); background: var(--danger); color: #fff; }
.del-confirm:hover:not(:disabled) { background: var(--danger); opacity: 0.88; }
.del-error { margin: 12px 0 0; font-size: 0.8rem; color: var(--danger-text); text-align: right; }

.sync-pill { flex: none; display: inline-flex; align-items: center; gap: 8px; font-size: 0.75rem; color: var(--muted); }
.sync-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.sync-pill[data-state="ok"] { color: var(--cal-acc); }
.sync-pill[data-state="ok"] i { background: var(--cal-acc); }
.sync-pill[data-state="busy"] i { background: var(--muted); }

/* Narrow desktop: tiles wrap */
@media (max-width: 960px) {
    .font-tiles { flex-wrap: wrap; justify-content: flex-end; }
    .font-tile { min-width: 80px; padding: 12px 14px; }
}

/* Phone: the list opens one category at a time */
@media (max-width: 700px) {
    .settings-container { margin-top: 28px; }
    .set-layout { display: block; }
    .set-nav { position: static; width: auto; gap: 0; }
    .set-title { display: block; margin: 0 0 8px; font-size: 1.15rem; font-weight: var(--w); }

    .set-nav-item {
        padding: 16px 4px;
        border-bottom: 1px solid var(--line);
        border-radius: 0;
        color: var(--text);
        font-size: 0.9rem;
    }

    .set-nav-item.on { background: none; }
    .set-nav-sum { display: inline; color: var(--muted); font-size: 0.75rem; }
    .set-nav-sum::after { content: " \203A"; }
    .set-version { padding: 28px 0 0; text-align: center; }

    .set-main { display: none; }
    .set-card { display: none; padding: 0; border: 0; background: none; }
    .settings-container[data-open] .set-nav { display: none; }
    .settings-container[data-open] .set-main { display: block; }
    .settings-container[data-open="appearance"] #set-appearance,
    .settings-container[data-open="clock"] #set-clock,
    .settings-container[data-open="shortcuts"] #set-shortcuts,
    .settings-container[data-open="account"] #set-account { display: block; }

    .set-back {
        display: inline-block;
        margin: 0 0 14px;
        padding: 6px 0;
        background: none;
        color: var(--muted);
        border: 0;
        font-size: 0.85rem;
    }

    .set-back:hover { color: var(--text); }
    .set-tiles { flex-wrap: wrap; gap: 10px; }
    .set-tile { flex: 1 1 calc(33% - 10px); }
    .set-prev { height: 72px; font-size: 1rem; }
    .set-row { flex-wrap: wrap; gap: 12px; }
    .set-row .swatches { flex-wrap: wrap; }
    .set-range { width: 100%; }
    .font-tiles { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
    .set-keys { grid-template-columns: 1fr; }
}

/* ---------- Top priority (To do) ---------- */
.prio-btn {
    flex: none;
    display: none;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 10px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    font-size: 0.72rem;
    white-space: nowrap;
    transition: color 0.2s, border-color 0.2s;
}

.prio-btn svg { flex: none; width: 14px; height: 14px; }
.todo-item:hover .prio-btn,
.todo-item:focus-within .prio-btn,
.prio-btn.on { display: inline-flex; }
.prio-btn:hover { color: var(--text); border-color: var(--text); }
.prio-btn[hidden] { display: none !important; }

/* The flag on the current one: "TOP PRIORITY", click to remove */
.prio-btn.on {
    gap: 5px;
    padding: 0 2px;
    border-color: transparent;
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.prio-btn.on svg { color: var(--cal-acc); }
.prio-btn.on:hover { border-color: transparent; }

/* The box reaches a little outside the list, so its text lines up with the rows below */
.todo-item.top {
    margin: 4px -14px;
    padding: 14px 13px;
    border: 1px solid var(--cal-acc);
    border-radius: 14px;
    background: color-mix(in srgb, var(--cal-acc) 8%, transparent);
}

.todo-item.top .drag-handle { display: none; }

/* Touch screens have no hover: a small flag stays visible on every open task */
@media (hover: none) {
    .prio-btn { display: inline-flex; padding: 0 6px; border-color: transparent; }
    .prio-btn:not(.on) .prio-text { display: none; }
}

@media (max-width: 700px) {
    .todo-item.top { margin: 4px 0; }
    .prio-btn .prio-text { display: none; }   /* the box and the flag say it; the task keeps the room */
}

/* Settings › Notifications: rows that wait for the switch above them */
/* A row that cannot be used right now: its controls dim, its label and explanation stay readable */
.set-row.off { pointer-events: none; }
.set-row.off > :not(.set-row-text) { opacity: 0.45; }

/* ---------- Aesthetic mode (key A) ---------- */
/* Focus tab: Clean mode and Aesthetic mode, right under the top bar (out of the flow, so the timer stays centred) */
.mode-pills {
    display: none;
    position: absolute;
    top: 82px;                 /* top bar: 24px margin + 46px nav + 12px gap */
    left: 0;
    right: 0;
    z-index: 5;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 16px;
    pointer-events: none;      /* only the buttons take clicks, not the empty row */
    transition: opacity 0.35s ease;
}

.mode-pills > * { pointer-events: auto; }

body[data-tab="focus"] .mode-pills { display: flex; }

body.clean .mode-pills {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s ease, visibility 0s 0.35s;
}

.mode-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px 6px 13px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}

.mode-pill svg { flex: none; width: 14px; height: 14px; }
.mode-pill kbd { padding: 0 6px; font-size: 0.62rem; line-height: 1.5; border-radius: 5px; }
.mode-pill:hover { color: var(--text); border-color: var(--muted); }
.aes-pill { color: var(--text); border-color: var(--cal-acc); }
.aes-pill kbd { border-color: var(--cal-acc); }
.aes-pill:hover { border-color: var(--cal-acc); background: color-mix(in srgb, var(--cal-acc) 14%, transparent); }

@media (max-width: 600px) {
    .mode-pill kbd { display: none; }
    .mode-pills { top: 66px; }   /* phone: the tabs move to the bottom; the top bar is 16px + 38px */
}

/* The full-screen layer (the top bar and the page stay underneath; reminders show above it) */
.aes {
    position: fixed;
    inset: 0;
    z-index: 35;
    overflow: hidden;
    background: #05050a;
    color: #f2f2f2;
    color-scheme: dark;
}

.aes-bg { position: absolute; inset: 0; overflow: hidden; }

.aes-bg::before,
.aes-bg::after {
    content: "";
    position: absolute;
    inset: -25%;
    will-change: transform;
}

.aes-bg.still::before,
.aes-bg.still::after { animation-play-state: paused !important; }

.aes-dim { position: absolute; inset: 0; background: #000; pointer-events: none; }

.aes-hint {
    position: absolute;
    right: 28px;
    bottom: 26px;
    display: flex;
    gap: 18px;
    font-size: 0.7rem;
    color: rgba(242, 242, 242, 0.78);
    pointer-events: none;
}

/* Video backgrounds: the picture sits behind the video (poster, and the still image when Animations is off) */
.aes-bg[data-scene="autumn"],
.prev-autumn { background: #2a1408 url("../backgrounds/autumn.jpg") center / cover no-repeat; }
.aes-bg[data-scene="winter"],
.prev-winter { background: #10141c url("../backgrounds/winter.jpg") center / cover no-repeat; }
.aes-bg[data-scene="cherry-grove"],
.prev-cherry-grove { background: #e9a6c8 url("../backgrounds/cherry-grove.jpg") center / cover no-repeat; }
.aes-bg[data-scene="rainy-garden"],
.prev-rainy-garden { background: #0d1a1a url("../backgrounds/rainy-garden.jpg") center / cover no-repeat; }
.aes-bg[data-scene="samurai"],
.prev-samurai { background: #0c0c0e url("../backgrounds/samurai.jpg") center / cover no-repeat; }
.aes-bg[data-scene="lofi-coffee"],
.prev-lofi-coffee { background: #12261a url("../backgrounds/lofi-coffee.jpg") center / cover no-repeat; }
.aes-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.prev-soon { border-style: dashed; color: var(--muted); font-size: 0.75rem; font-weight: var(--w); letter-spacing: 0; }
.set-tile:disabled { cursor: default; }
.set-tile:disabled:hover .set-prev { border-color: var(--line-strong); }

/* The widget at the bottom left */
.aes-widget {
    position: absolute;
    left: 28px;
    bottom: 28px;
    display: flex;
    align-items: center;
    gap: 16px;
    width: min(390px, calc(100vw - 32px));
    height: 99px;
    padding: 0 18px;
    background: rgba(12, 12, 16, 0.55);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    border-radius: 31px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1), height 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.aes-ring {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
    transition: opacity 0.25s;
}

.aes-ring path { fill: none; stroke-width: 2.6; stroke-linecap: round; }
.aes-ring-base { stroke: rgba(255, 255, 255, 0.12); }
.aes-ring-fill,
.aes-mini-fill { stroke: var(--p3); transition: stroke-dashoffset 0.3s linear, stroke 0.4s; }
.aes-widget[data-state="break"] .aes-ring-fill,
.aes-widget[data-state="break"] .aes-mini-fill { stroke: color-mix(in srgb, var(--p2) 65%, transparent); }

.aes-btn {
    position: relative;
    flex: none;
    display: grid;
    place-content: center;
    width: 49px;
    height: 49px;
    padding: 0;
    background: rgba(255, 255, 255, 0.08);
    color: #f2f2f2;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s, opacity 0.25s;
}

.aes-btn:hover { background: rgba(255, 255, 255, 0.16); }
.aes-btn svg { width: 21px; height: 21px; }
.aes-widget.playing .i-play,
.aes-widget:not(.playing) .i-pause { display: none; }

.aes-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: opacity 0.25s;
}

.aes-label {
    max-width: 100%;
    overflow: hidden;
    font-size: 0.8rem;
    color: rgba(242, 242, 242, 0.6);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aes-time {
    font-size: 2.73rem;
    font-weight: var(--clock-weight, 500);
    letter-spacing: -0.045em;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    transition: opacity 0.3s;
}

:root[data-font="mono"] .aes-time { font-family: 'JetBrains Mono', 'Courier New', monospace; font-weight: 200; letter-spacing: -0.04em; }
:root[data-font="inter"] .aes-time { font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif; font-weight: var(--clock-weight, 700); letter-spacing: -0.03em; }
:root[data-font="dmsans"] .aes-time { font-family: 'DM Sans', 'Helvetica Neue', Arial, sans-serif; font-weight: var(--clock-weight, 400); letter-spacing: -0.03em; }

.aes-widget[data-state="paused"] .aes-time { opacity: 0.5; }

/* Time is up: "Session 2 complete · Take 5 minutes", a full glowing ring and the accent play button */
.aes-widget.ended { box-shadow: 0 0 0 1px color-mix(in srgb, var(--p3) 60%, transparent), 0 0 34px color-mix(in srgb, var(--p3) 45%, transparent), 0 12px 40px rgba(0, 0, 0, 0.35); }
#aes-widget.ended .aes-ring-fill { stroke: var(--p3); }
.aes-widget.ended .aes-label { color: rgba(242, 242, 242, 0.75); }
.aes-widget.ended .aes-info .aes-time { max-width: 100%; overflow: hidden; font-size: 1.6rem; letter-spacing: -0.02em; text-overflow: ellipsis; white-space: nowrap; }
.aes-widget.ended #aes-play { background: var(--p3); color: #fff; }
.aes-widget.ended #aes-play:hover { background: color-mix(in srgb, var(--p3) 85%, #fff); }

/* Minimised: ring and time only */
.aes-mini {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 21px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.aes-mini .aes-time { font-size: 1.95rem; }
.aes-mini-ring { flex: none; width: 29px; height: 29px; transform: rotate(-90deg); }
.aes-mini-ring circle { fill: none; stroke-width: 2.5; }
.aes-mini-base { stroke: rgba(255, 255, 255, 0.15); }
.aes-mini-fill { stroke-dasharray: 100; stroke-linecap: round; }

.aes-widget.min { width: 218px; height: 73px; }
.aes-widget.min > .aes-btn,
.aes-widget.min > .aes-info,
.aes-widget.min > .aes-ring { opacity: 0; pointer-events: none; }
.aes-widget.min > .aes-btn { visibility: hidden; transition: opacity 0.25s, visibility 0s 0.25s; }
.aes-widget.min .aes-mini { opacity: 1; transition-delay: 0.15s; }

/* Ambient sound (ambient-sound.js): the speaker sits above the widget; hover or focus shows the name and volume */
.aes-sound-wrap { position: absolute; left: 0; bottom: calc(100% + 12px); transition: opacity 0.25s; }
.aes-sound-wrap[hidden] { display: none; }
.aes-widget.min .aes-sound-wrap { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.25s, visibility 0s 0.25s; }

.aes-sound {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    background: rgba(12, 12, 16, 0.55);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    color: rgba(242, 242, 242, 0.7);
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s;
}

.aes-sound:hover { background: rgba(28, 28, 34, 0.7); color: #f2f2f2; }
.aes-sound.on { color: #f2f2f2; }
.aes-sound svg { width: 16px; height: 16px; }
.aes-sound.on .i-sound-off,
.aes-sound:not(.on) .i-sound-on { display: none; }

.aes-sound-pop {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 230px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(12, 12, 16, 0.75);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    color: #f2f2f2;
    font-size: 0.78rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0s 0.2s;
}

.aes-sound-pop[hidden] { display: none; }
.aes-sound-wrap:hover .aes-sound-pop,
.aes-sound-wrap:focus-within .aes-sound-pop { opacity: 1; visibility: visible; transition: opacity 0.2s; }
.aes-sound-pop::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 10px; }   /* keeps hover across the gap */
.aes-sound-full { display: flex; align-items: center; gap: 7px; }
.aes-sound-full svg { flex: none; width: 15px; height: 15px; }
.aes-sound-vol { display: flex; align-items: center; gap: 10px; color: rgba(242, 242, 242, 0.7); }
.aes-sound-vol input { flex: 1; min-width: 0; accent-color: var(--p3); }

.set-muted-text { flex: none; font-size: 0.8rem; color: var(--muted); }

@media (max-width: 600px), (hover: none) {
    .aes-hint { display: none; }
    .aes-widget { left: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); }
}

/* ---------- Calendar: Month | List, dragging tasks between days, Move to…, Undo ---------- */
.cal-views button { padding: 5px 13px; font-size: 0.78rem; transition: color 0.2s, background-color 0.2s; }
.cal-views button:not(.on):hover { color: var(--text); }

/* One view at a time (the last one used is remembered) */
.cal-container[data-view="list"] .cal-card { display: none; }
.cal-container:not([data-view="list"]) .up-card { display: none; }

/* The grip of a task: drag it to another day, or click it for "Move to…" */
.mv-grip {
    flex: none;
    display: grid;
    place-content: center;
    width: 24px;
    height: 24px;
    margin: -4px -6px -4px 0;
    padding: 0;
    background: none;
    color: var(--muted);
    border: 0;
    border-radius: 6px;
    cursor: grab;
    touch-action: none;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.up-group .mv-grip { margin: -4px 0 -4px -6px; opacity: 0.45; }
.mv-grip svg { width: 14px; height: 14px; }
.day-item:hover .mv-grip,
.day-item:focus-within .mv-grip,
.mv-grip:focus-visible { opacity: 1; }
.mv-grip:hover { color: var(--text); }

@media (hover: none) {
    .mv-grip { opacity: 0.7; }
}

/* While dragging: the row stays faint in place, a copy follows the pointer */
body.mv-dragging { cursor: grabbing; -webkit-user-select: none; user-select: none; }
body.mv-dragging * { cursor: grabbing !important; }
.day-item.mv-src { opacity: 0.35; }

.mv-ghost {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 70;
    margin: 0;
    list-style: none;
    background: var(--panel);
    color: var(--text);
    border-color: var(--cal-acc);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.mv-ghost .day-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-ghost .mv-grip { opacity: 1; color: var(--text); }
.mv-ghost .day-chip { display: none; }

/* The day under the pointer lights up */
.cal-cell.drop {
    background: color-mix(in srgb, var(--cal-acc) 22%, transparent);
    border-color: var(--cal-acc);
}

/* "Wed 18 · 2 tasks → 3" */
.mv-badge {
    position: fixed;
    z-index: 71;
    padding: 4px 10px;
    background: var(--text);
    color: var(--on-text);
    border-radius: 999px;
    font-size: 0.7rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    pointer-events: none;
}

/* Move to…: a small window next to the grip; on a phone, a sheet from the bottom */
.mv-backdrop { position: fixed; inset: 0; z-index: 60; }
.mv-backdrop.dim { background: rgba(0, 0, 0, 0.5); }

.mv-sheet {
    position: fixed;
    z-index: 61;
    width: 270px;
    padding: 14px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    text-align: left;
}

.mv-sheet.sheet {
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
    border-bottom: 0;
    border-radius: 20px 20px 0 0;
}

.mv-sheet button { font-family: var(--font); }
.mv-handle { display: none; }
.mv-sheet.sheet .mv-handle { display: block; width: 36px; height: 4px; margin: 0 auto 14px; border-radius: 999px; background: var(--line-strong); }
.mv-task { font-size: 0.9rem; overflow-wrap: anywhere; }
.mv-sub { margin: 2px 0 10px; font-size: 0.72rem; color: var(--muted); }

.mv-opt {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-top: 6px;
    padding: 11px 14px;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 12px;
    font-size: 0.85rem;
    text-align: left;
    transition: border-color 0.2s, background-color 0.2s;
}

.mv-opt:hover { border-color: var(--cal-acc); background: color-mix(in srgb, var(--cal-acc) 8%, transparent); }
.mv-opt.on { border-color: var(--cal-acc); }
.mv-opt-side { display: inline-flex; color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.mv-opt-side svg { width: 16px; height: 16px; }

/* ---------- Calendar, List view: "Upcoming", the tasks grouped by date ---------- */
.up-card {
    width: min(100%, 720px);
    margin: 0 auto;
    padding: 28px;
    background: color-mix(in srgb, var(--panel) 85%, transparent);
    border: 1px solid var(--line);
    border-radius: 24px;
}

.up-done-btn {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 16px;
    font-size: 0.8rem;
    transition: color 0.2s, border-color 0.2s;
}

.up-done-btn:hover { color: var(--text); }
.up-done-btn.on { color: var(--text); border-color: var(--text); }

.up-add { margin: 0 0 14px; }
.up-hint { flex: none; font-size: 0.7rem; color: var(--muted); white-space: nowrap; }

.up-group {
    margin: 8px -10px 0;
    padding: 8px 10px 10px;
    border: 1px solid transparent;
    border-radius: 14px;
    transition: border-color 0.15s, background-color 0.15s;
}

.up-group.drop { border-color: var(--cal-acc); background: color-mix(in srgb, var(--cal-acc) 10%, transparent); }

.up-group-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin-bottom: 10px;
    font-size: 0.7rem;
}

.up-group-name { letter-spacing: 0.1em; text-transform: uppercase; color: var(--text); }
.up-group-date,
.up-group-count { color: var(--muted); }
.up-drop { display: none; color: var(--cal-acc); }
.up-group.drop .up-drop { display: inline; }
.up-all { margin-left: auto; }
.up-empty { margin: 0; font-size: 0.8rem; color: var(--muted); }

/* Settings › Notifications: "Stay quiet when nothing is planned" is always on */
.set-toggle:disabled { opacity: 0.55; cursor: default; }

/* Phone: the list keeps only the switch */
@media (max-width: 600px) {
    .up-card { padding: 16px 12px; border-radius: 20px; }
    .up-done-btn,
    .up-hint { display: none; }
    .cal-views button { padding: 4px 10px; font-size: 0.72rem; }
}

/* ---------- Goal reached: a quiet animation (goal-reached.js) ---------- */
/* "goal reached ✓" on the Today bar and "Week goal reached ✓" in Goals */
.goal-line-nums svg,
.gw-reached svg { width: 11px; height: 11px; margin-left: 3px; vertical-align: -1px; }
.goal-line.reached .goal-line-nums span:last-child { color: var(--text); }
.gw-reached { color: var(--cal-acc); }

/* The light crosses the bar once; a soft glow and "Goal reached" under it, then they fade.
   Out of the flow, so nothing moves. */
.goal-line { position: relative; }
.goal-line-track { position: relative; }
.goal-line.fx .goal-line-track { overflow: visible; }

.goal-fx-light {
    position: absolute;
    top: 50%;
    left: 0;
    width: 56px;
    height: 10px;
    margin: -5px 0 0 -28px;
    border-radius: 999px;
    background: radial-gradient(closest-side, #fff, color-mix(in srgb, #fff 45%, transparent) 45%, transparent);
    filter: blur(1px);
    opacity: 0;
    pointer-events: none;
}

.goal-fx-glow {
    position: absolute;
    left: 50%;
    top: 22px;
    width: 120%;
    height: 70px;
    transform: translateX(-50%);
    background: radial-gradient(closest-side, color-mix(in srgb, var(--cal-acc) 38%, transparent), transparent);
    opacity: 0;
    pointer-events: none;
}

.goal-fx-msg {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    margin-top: 2px;
    color: var(--cal-acc);
    font-size: 0.7rem;
    text-align: center;
    opacity: 0;
    pointer-events: none;
}

/* Aesthetic mode: the halo around the widget, like a breath */
.aes-halo {
    position: absolute;
    inset: -6px;
    border-radius: 37px;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--p3) 55%, transparent), 0 0 46px 10px color-mix(in srgb, var(--p3) 45%, transparent);
    opacity: 0;
    pointer-events: none;
}

/* Settings › Notifications: Reduce motion follows the system */
.ga-system { flex: none; font-size: 0.8rem; color: var(--muted); }

/* ---------- Task notes and search (task-notes.js) ---------- */
/* Search on top of the list, and the filters */
.tn-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 0 14px 0 16px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    transition: border-color 0.2s;
}

.tn-search:focus-within { border-color: var(--cal-acc); }
.tn-search > svg { flex: none; width: 16px; height: 16px; color: var(--muted); }

.tn-search input {
    flex: 1;
    min-width: 0;
    padding: 10px 0;
    background: transparent;
    color: var(--text);
    border: 0;
    font: inherit;
    font-size: 0.9rem;
}

.tn-search input:focus-visible { outline: none; }
.tn-search input::placeholder { color: var(--muted); }
.tn-search input::-webkit-search-cancel-button { display: none; }
.tn-key { flex: none; padding: 0 6px; font-size: 0.7rem; line-height: 1.6; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--muted); }
.tn-search:focus-within .tn-key,
.tn-search:has(.tn-clear:not([hidden])) .tn-key { display: none; }

.tn-clear {
    flex: none;
    padding: 0 4px;
    background: none;
    color: var(--muted);
    border: 0;
    font-size: 1.1rem;
    line-height: 1;
}

.tn-clear:hover { color: var(--text); }

.tn-filters { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 18px; }

.tn-filters button {
    padding: 5px 12px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.75rem;
    transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}

.tn-filters button:hover { color: var(--text); border-color: var(--line-strong); }
.tn-filters button.on { background: var(--text); color: var(--on-text); border-color: var(--text); }

.tn-count {
    margin-bottom: 4px;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: left;
}

.tn-hint { margin: 16px 0 0; font-size: 0.75rem; color: var(--muted); }

/* What matched */
.tn-mark { padding: 0 1px; background: color-mix(in srgb, var(--cal-acc) 32%, transparent); color: inherit; border-radius: 3px; }
.tn-hit { background: color-mix(in srgb, var(--cal-acc) 18%, transparent); border-radius: 3px; }

/* Searching or filtering: the order cannot be changed, so no grip */
.todo-list.filtered .drag-handle { visibility: hidden; }

/* The note line under a task: a small icon and the first line */
.todo-note {
    flex: 1 1 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    margin: -2px 0 0 32px;
    padding: 0;
    background: none;
    color: var(--muted);
    border: 0;
    font: inherit;
    font-size: 0.75rem;
    text-align: left;
    cursor: pointer;
}

.todo-note svg { flex: none; width: 13px; height: 13px; }
.todo-note-text { min-width: 0; overflow: hidden; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.todo-note:hover { color: var(--text); }

/* The Note button (with Edit and Delete), and the open row */
.note-btn {
    background: transparent;
    color: var(--muted);
    border: 0;
    padding: 4px 8px;
    font-size: 0.8rem;
    transition: color 0.2s;
}

.note-btn:hover,
.todo-item.open .note-btn { color: var(--text); }
.todo-item.open {
    background: color-mix(in srgb, var(--text) 5%, transparent);
    box-shadow: -14px 0 0 color-mix(in srgb, var(--text) 5%, transparent), 14px 0 0 color-mix(in srgb, var(--text) 5%, transparent);
}

/* Side panel: the task and its note */
.tn-panel {
    position: fixed;
    top: 96px;
    right: calc(max(0px, (100vw - 1280px) / 2) + 20px);
    bottom: 24px;
    z-index: 30;
    display: flex;
    flex-direction: column;
    width: min(380px, calc(100vw - 32px));
    max-height: 560px;
    box-sizing: border-box;
    padding: 22px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    text-align: left;
}

body:not([data-tab="todo"]) .tn-panel { display: none; }
.tn-panel-head { display: flex; justify-content: space-between; align-items: center; }
.tn-panel-kicker { font-size: 0.65rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--cal-acc); }

.tn-panel-close {
    padding: 0 4px;
    background: none;
    color: var(--muted);
    border: 0;
    font-size: 1.3rem;
    line-height: 1;
}

.tn-panel-close:hover { color: var(--text); }
.tn-panel-title { margin: 10px 0 12px; font-size: 1.15rem; font-weight: var(--w); letter-spacing: -0.02em; overflow-wrap: anywhere; }
.tn-panel-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tn-panel-chips:empty { display: none; }
.tn-chip { padding: 3px 10px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 0.72rem; color: var(--muted); }
.tn-panel-label { margin: 20px 0 8px; font-size: 0.65rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }

.tn-panel-note,
.focus-note textarea,
.aes-note textarea {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    font: inherit;
    font-size: 0.85rem;
    line-height: 1.55;
    resize: none;
    transition: border-color 0.2s;
}

.tn-panel-note { flex: 1; min-height: 200px; }
.tn-panel-note:focus,
.focus-note textarea:focus { outline: none; border-color: var(--cal-acc); }
.tn-panel-note::placeholder,
.focus-note textarea::placeholder { color: var(--muted); }
.tn-panel-foot { display: flex; justify-content: space-between; margin-top: 10px; font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Wide screens: the list moves aside to make room for the panel */
@media (min-width: 1180px) {
    .todo-container,
    body[data-tab="todo"] .progress { transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1); }
    body.tn-open[data-tab="todo"] .todo-container,
    body.tn-open[data-tab="todo"] .progress { transform: translateX(-200px); }
}

/* Phone: the panel opens full screen */
@media (max-width: 600px) {
    .tn-panel { inset: 0; z-index: 70; width: auto; max-height: none; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); border: 0; border-radius: 0; }
    .tn-key { display: none; }
    .todo-main .todo-note { order: 1; }
    .todo-main .due-btn { order: 2; }
}

/* Focus tab: the task name with its note badge, and the note under the timer */
.cur-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    max-width: min(86vw, 520px);
    margin: -8px auto 20px;
}

.cur-row .current-line { min-width: 0; margin: 0; }

.note-badge {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 22px;
    padding: 0 7px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    font-size: 0.7rem;
    font-variant-numeric: tabular-nums;
    transition: color 0.2s, border-color 0.2s;
}

.note-badge svg { width: 12px; height: 12px; }
.note-badge:hover { color: var(--text); border-color: var(--text); }
.note-badge.on { color: var(--text); border-color: var(--cal-acc); }

.focus-note { width: min(86vw, 360px); margin: -8px auto 20px; }
.focus-note textarea { max-height: 120px; padding: 10px 12px; border-color: var(--cal-acc); text-align: left; }

/* Aesthetic mode: the badge on the task chip, the note as a small glass panel above the widget */
.aes-label-row { display: flex; justify-content: center; align-items: center; gap: 6px; max-width: 100%; min-width: 0; }
.aes-note-badge { height: 18px; padding: 0 6px; color: rgba(242, 242, 242, 0.7); border-color: rgba(255, 255, 255, 0.22); }
.aes-note-badge:hover,
.aes-note-badge.on { color: #f2f2f2; border-color: rgba(255, 255, 255, 0.5); }

.aes-note {
    position: absolute;
    left: 28px;
    bottom: 139px;
    width: min(390px, calc(100vw - 32px));
    box-sizing: border-box;
    padding: 10px;
    background: rgba(12, 12, 16, 0.55);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.aes-note textarea { color: #f2f2f2; border-color: rgba(255, 255, 255, 0.16); }
.aes-note textarea:focus { outline: none; border-color: rgba(255, 255, 255, 0.4); }
.aes-note textarea::placeholder { color: rgba(242, 242, 242, 0.78); }

@media (max-width: 600px), (hover: none) {
    .aes-note { left: 16px; bottom: calc(131px + env(safe-area-inset-bottom)); }
}

/* ---------- Home tab (home.js): clock, date, Up next, chips. One centered column, nothing to scroll ---------- */
:root {
    --home-acc: #d14a6f;
    --home-acc-lt: #f2a3b9;
    --home-icon: var(--home-acc-lt);
    --home-fill: color-mix(in srgb, var(--text) 4%, transparent);
    --home-border: color-mix(in srgb, var(--text) 13%, transparent);
}
:root:is([data-theme="light"], [data-theme="paper"], [data-theme="vanilla"], [data-theme="olive"]) { --home-icon: var(--home-acc); }

.rt-date,
.home-container { display: none; }

/* Topbar, then the clock and everything under it, centred together in the space left */
body[data-tab="clock"] { grid-template-rows: minmax(0, 1fr) auto auto minmax(0, 1fr); }
body[data-tab="clock"] .rt-date { display: block; }
body[data-tab="clock"] .home-container { display: flex; }
body[data-tab="clock"] .below { padding: 0; overflow: visible; }

/* 190 px; with seconds or 12h the width is the limit, so it shrinks a little to fit */
body[data-tab="clock"] .realtime {
    font-size: max(3rem, min(190px, 26vh, calc((100vw - 40px) / var(--fit, 5.4))));
}

.rt-date {
    margin-top: 2px;
    font-size: 13px;
    font-weight: var(--w-lo);
    color: var(--muted);
    letter-spacing: 0.01em;
}

.home-container {
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: 100%;
    margin-top: 28px;
}

/* The Up next capsule */
.home-cap {
    display: flex;
    align-items: center;
    gap: 22px;
    max-width: min(100%, 620px);
    padding: 10px 12px 10px 26px;
    background: var(--home-fill);
    border: 1px solid var(--home-border);
    border-radius: 999px;
    text-align: left;
}

.hc-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hc-label {
    font-size: 9.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}
.hc-task {
    overflow: hidden;
    font-size: 15px;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.hc-time { font-variant-numeric: tabular-nums; }
.home-cap.live .hc-label { color: var(--home-icon); }

.hc-actions { flex: none; display: flex; align-items: center; gap: 8px; }

.hc-primary,
.hc-ghost {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 36px;
    padding: 0 18px;
    border-radius: 999px;
    font: inherit;
    font-size: 13px;
    white-space: nowrap;
    transition: background-color 0.2s, border-color 0.2s, opacity 0.2s;
}
.hc-primary {
    background: var(--text);
    color: var(--on-text);
    border: 1px solid var(--text);
    font-weight: var(--w-hi);
}
.hc-primary:hover { opacity: 0.88; }
.hc-primary svg { width: 13px; height: 13px; }
.hc-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--home-border);
}
.hc-ghost:hover { border-color: color-mix(in srgb, var(--text) 35%, transparent); }
.hc-ghost svg { width: 14px; height: 14px; }
.hc-dur { padding: 0 12px 0 16px; gap: 4px; }

.hc-note {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 280px;
    padding: 8px 16px;
    border: 1px solid var(--home-border);
    border-radius: 999px;
    font-size: 13px;
    color: var(--muted);
}
.hc-note span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.hc-note svg { flex: none; width: 13px; height: 13px; color: var(--home-icon); }

/* The duration menu: 25, 50, 60 and custom */
.hc-dur-wrap { position: relative; }
.hc-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 132px;
    padding: 6px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
.hc-opt {
    padding: 8px 12px;
    background: transparent;
    color: var(--text);
    border: 0;
    border-radius: 10px;
    font: inherit;
    font-size: 13px;
    text-align: left;
}
.hc-opt:hover { background: var(--hover); }
.hc-opt.on { color: var(--home-icon); font-weight: var(--w-hi); }
.hc-custom {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px 2px 12px;
    font-size: 13px;
    color: var(--muted);
}
.hc-custom input {
    width: 100%;
    min-width: 0;
    padding: 6px 8px;
    background: var(--field);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    font-size: 13px;
}
.hc-custom.on input { border-color: var(--home-icon); }

/* The chips: up to 4, a chip with no data is hidden */
.home-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    max-width: 100%;
}
.home-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: 100%;
    padding: 7px 14px;
    background: var(--home-fill);
    color: var(--text);
    border: 1px solid var(--home-border);
    border-radius: 999px;
    font: inherit;
    font-size: 12px;
    white-space: nowrap;
    transition: border-color 0.2s, box-shadow 0.4s;
}
.home-chip:hover { border-color: color-mix(in srgb, var(--text) 32%, transparent); }
.home-chip svg { flex: none; width: 13px; height: 13px; color: var(--home-icon); }
.home-chip > span { overflow: hidden; text-overflow: ellipsis; }
.hc-chip-task { display: inline-block; max-width: 180px; overflow: hidden; vertical-align: bottom; text-overflow: ellipsis; }
/* Goal reached: the quiet glow from the Goal reached design */
.home-chip.reached {
    border-color: color-mix(in srgb, var(--home-acc) 55%, transparent);
    box-shadow: 0 0 22px color-mix(in srgb, var(--home-acc) 30%, transparent);
}

/* Aesthetic look: the video behind the page, glass surfaces, light text */
.home-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: #05050a; }
body.home-aes {
    --bg: #05050a;
    --text: #f2f2f2;
    --muted: rgba(242, 242, 242, 0.62);
    --line: rgba(255, 255, 255, 0.16);
    --line-strong: rgba(255, 255, 255, 0.3);
    --on-text: #000;
    --panel: rgba(16, 16, 22, 0.92);
    --field: rgba(0, 0, 0, 0.3);
    --hover: rgba(255, 255, 255, 0.1);
    --home-icon: var(--home-acc-lt);
    --home-fill: rgba(255, 255, 255, 0.07);
    --home-border: rgba(255, 255, 255, 0.16);
    color-scheme: dark;
    background: transparent;
}
body.home-aes :is(.home-cap, .home-chip, .nav, .hc-menu) {
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
}
body.home-aes .nav { background: rgba(255, 255, 255, 0.06); }

/* Phone: same page, smaller. The capsule becomes a card, the chips go in two columns */
@media (max-width: 600px) {
    body[data-tab="clock"] .realtime { font-size: min(92px, calc((100vw - 40px) / var(--fit, 5.4))); }
    .home-container { width: min(100%, 360px); }
    .home-cap {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        width: 100%;
        padding: 14px 16px;
        border-radius: 20px;
    }
    .hc-actions { flex-wrap: wrap; }
    .hc-note { max-width: 100%; }
    .home-chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 10px; }
    .home-chip { justify-content: flex-start; }
    .hc-menu { right: auto; left: 0; }
    body.home-aes .nav { background: rgba(5, 5, 10, 0.55); }
}

/* ---------- Settings › Appearance: the themes in two rows, Classic and Colors ---------- */
.set-themes {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px 12px;
}
.set-sublabel {
    grid-column: 1 / -1;
    margin: 2px 0 -2px;
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}
.set-sublabel ~ .set-sublabel { margin-top: 10px; }
.set-themes .set-tile { gap: 7px; text-align: left; }
.set-themes .set-prev {
    position: relative;
    justify-items: center;
    gap: 7px;
    height: auto;
    aspect-ratio: 1.75;
    border-radius: 12px;
}
.prev-time { line-height: 1; }
/* The accent line under the clock: half filled, like a timer on its way */
.prev-line {
    width: 56%;
    height: 3px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--p3) 50%, color-mix(in srgb, currentColor 22%, transparent) 50%);
}
/* The active theme: accent border and a check */
:is(.set-themes, .set-anim) .set-tile.on .set-prev::after,
:is(.set-themes, .set-anim) .set-tile.on .set-prev::before {
    content: "";
    position: absolute;
    top: 7px;
    right: 7px;
    width: 18px;
    height: 18px;
}
:is(.set-themes, .set-anim) .set-tile.on .set-prev::after { border-radius: 50%; background: var(--cal-acc); }
:is(.set-themes, .set-anim) .set-tile.on .set-prev::before {
    z-index: 1;
    background: #fff;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 11px no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 11px no-repeat;
}
/* Colour themes: the accent is the text colour, so the check takes the background colour */
:root:is([data-theme="blush"], [data-theme="vanilla"], [data-theme="olive"], [data-theme="forest"], [data-theme="deep-sea"]) :is(.set-themes, .set-anim) .set-tile.on .set-prev::before { background: var(--bg); }

/* Phone: two cards per row, same order, same check */
@media (max-width: 700px) {
    .set-themes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .set-sublabel { display: none; }
    .set-themes .set-prev { font-size: 1.15rem; }
}

/* The theme's two colours next to its name: left the background, right the text */
.set-tile-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.set-tile-row .set-tile-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.set-dots { flex: none; display: inline-flex; gap: 3px; }
.set-dots i {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--tb);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 28%, transparent);   /* visible on any page colour */
}
.set-dots i + i { background: var(--tt); }

/* ---------- Animated theme (animated-theme.js): the chosen video behind the whole site, colours of Dark ---------- */
[data-theme-choice="animated"] { --tb: #05050a; --tt: #f2f2f2; }
.theme-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: #05050a; }
.theme-bg-dim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); pointer-events: none; }
/* The background fades in once its picture is ready (animated-theme.js); the page never waits for it */
#theme-bg-scene { transition: opacity 0.4s ease-out; }
#theme-bg-scene.loading { opacity: 0; }
:root[data-animations="off"] #theme-bg-scene { transition: none; }

/* The Animated card: the chosen background (set by the script), "Live" and "your video" */
.set-themes .prev-animated { background-size: cover; background-position: center; }
.prev-live {
    position: absolute;
    top: 7px;
    left: 7px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    font-size: 0.5rem;
    font-weight: var(--w-hi);
    letter-spacing: 0.1em;
    line-height: 1.3;
    text-transform: uppercase;
}
.prev-live svg { width: 7px; height: 7px; }
.set-tile-note { flex: none; font-size: 0.65rem; color: var(--muted); white-space: nowrap; }

/* Animated background: one row under the themes, dimmed while another theme is on */
.set-anim-label {
    margin: 20px 0 10px;
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}
.set-anim-label span { margin-left: 8px; font-size: 0.68rem; letter-spacing: 0; text-transform: none; }
.set-anim {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px 12px;
}
.set-anim .set-tile { gap: 7px; text-align: left; transition: opacity 0.25s; }
.set-anim .set-prev { position: relative; height: auto; aspect-ratio: 1.75; border-radius: 12px; }
/* Another theme is on: the pictures dim, the names stay readable (a tap still picks the background) */
.set-anim.off .set-prev { opacity: 0.42; }
.set-anim.off .set-tile:hover .set-prev { opacity: 0.7; }

@media (max-width: 700px) {
    .set-anim { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .set-anim-label span { display: block; margin: 3px 0 0; }
}

/* ---------- Animated theme: everything stands out more over the video ----------
   Only with the Animated theme. Brighter lines and secondary text; cards and buttons get a darker see-through fill
   with a light blur and thicker, brighter borders. :where() keeps these rules weak, so the existing hover, active and
   selected states (the primary button, the open tab, a chosen tile...) look the same as before. */
:root[data-theme="animated"] {
    --muted: rgba(242, 242, 242, 0.78);
    --line: rgba(255, 255, 255, 0.3);
    --line-strong: rgba(255, 255, 255, 0.52);
    --hover: rgba(255, 255, 255, 0.14);
    --panel: rgba(10, 10, 14, 0.78);
    --field: rgba(0, 0, 0, 0.35);
}
/* Home's glass (home.js) sets its own values on the body: the same, stronger here */
:root[data-theme="animated"] body.home-aes {
    --muted: rgba(242, 242, 242, 0.8);
    --line: rgba(255, 255, 255, 0.3);
    --line-strong: rgba(255, 255, 255, 0.52);
    --home-fill: rgba(8, 8, 12, 0.5);
    --home-border: rgba(255, 255, 255, 0.36);
}

/* Cards and panels */
:where(:root[data-theme="animated"]) :is(.set-card, .cal-card, .up-card, .stat-card, .stat-panel, .goal-card,
    .cal-overdue, .day-pick, .account-menu, .ge-card, .pk, .mv-sheet, .toast, .tn-panel, .hc-menu) {
    background: rgba(8, 8, 12, 0.6);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

/* Buttons, fields and the navigation bars */
:where(:root[data-theme="animated"]) :is(.nav, .btn, .range-btn, .seg, .mode-pill, .avatar-btn, .icon-btn, .cal-arrow,
    .due-btn, .prio-btn, .up-done-btn, .tn-filters button, .day-chip, .day-item, .day-pick-item, .day-add, .pk-chip,
    .pk-arrow, .mv-opt, .ge-step button, .ge-day, .font-tile, .note-badge, .gw-last, .tn-search, .todo-input input, .hc-ghost) {
    background: rgba(8, 8, 12, 0.45);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

/* Thicker borders (on lines drawn on one side, only that side shows) */
:where(:root[data-theme="animated"]) :is(.set-card, .cal-card, .up-card, .stat-card, .stat-panel, .goal-card, .cal-overdue,
    .day-pick, .account-menu, .ge-card, .pk, .mv-sheet, .toast, .tn-panel, .hc-menu, .home-cap, .home-chip,
    .nav, .btn, .range-btn, .seg, .mode-pill, .avatar-btn, .icon-btn, .cal-arrow, .due-btn, .prio-btn, .up-done-btn,
    .tn-filters button, .day-chip, .day-item, .day-pick-item, .day-add, .pk-chip, .pk-arrow, .mv-opt, .ge-step button,
    .ge-day, .font-tile, .note-badge, .gw-last, .tn-search, .todo-input input, .hc-ghost, .set-prev,
    .todo-item, .set-row, .ge-row, .set-keys div, .day-focus, .cal-day, .am-action) {
    border-width: 1.5px;
}

/* The timer's progress line */
:where(:root[data-theme="animated"]) .progress { height: 2px; }

/* ---------- Accent glow (Settings › Appearance › Glow; appearance.js sets data-glow) ----------
   A soft light at the bottom of Home and Focus, in the accent colour. Only with Dark, Light, Graphite and Paper
   (with other themes data-glow is "off"). Never in Aesthetic mode, nor on To do, Calendar, Stats and Settings.
   Strength: Strong 1, Soft 0.5; a bit weaker on light themes so text stays readable. */
.glow-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(ellipse 90% 60% at 50% 115%, color-mix(in srgb, var(--p4) 60%, transparent), transparent 70%);
    opacity: 0;
    transition: opacity 0.45s ease;
    --glow-level: 0;
    --glow-theme: 1;
}
:root[data-glow="soft"] .glow-bg { --glow-level: 0.5; }
:root[data-glow="strong"] .glow-bg { --glow-level: 1; }
:root:is([data-theme="light"], [data-theme="paper"]) .glow-bg { --glow-theme: 0.55; }
body:is([data-tab="clock"], [data-tab="focus"]):not(.aesthetic) .glow-bg { opacity: calc(var(--glow-level) * var(--glow-theme)); }

/* ---------- Animated background: six per row, "Coming soon", and the Christmas Specials row ---------- */
.set-anim-label + .set-anim { margin-bottom: 4px; }
.set-anim + .set-anim-label { margin-top: 16px; }

/* The sixth card of the first row: empty, dashed, dimmed, not tappable */
.set-anim .prev-coming { gap: 2px; text-align: center; }
.prev-coming b { font-size: 0.56rem; font-weight: var(--w-hi); letter-spacing: 0.12em; text-transform: uppercase; }
.prev-coming small { font-size: 0.6rem; opacity: 0.8; }

/* A background that is not available yet: dimmed, a small "Soon" tag, not tappable */
.set-anim .set-tile:disabled,
.set-anim .set-tile:disabled:hover { opacity: 0.45; }
.set-xmas .set-tile:disabled .set-prev::before {
    content: "Soon";
    position: absolute;
    left: 7px;
    bottom: 6px;
    padding: 1px 6px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    border-radius: 999px;
    font-size: 0.5rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* Christmas Specials: placeholder pictures until each video's .jpg is on the site (the script then shows the .jpg) */
.prev-christmas { background: radial-gradient(#ffffffb0 1px, transparent 1.6px) 0 0 / 14px 14px, linear-gradient(160deg, #23324d, #5a7fa8); }
.prev-minecraft-fireplace { background: radial-gradient(#f5d56bcc 1.2px, transparent 1.8px) 0 0 / 14px 14px, linear-gradient(160deg, #0e2a1c, #1f5a3a); }
.prev-adventure-time { background: radial-gradient(ellipse at 50% 110%, #f08a3c, #8a2a12 55%, #2a0d08); }
.prev-forest-snowfall { background: radial-gradient(#ffffffb0 1px, transparent 1.6px) 0 0 / 13px 13px, linear-gradient(170deg, #9aa3a8, #2c3b3d 70%, #142022); }
.prev-winter-evening { background: radial-gradient(circle at 75% 55%, #ffcf8a99, transparent 22%), radial-gradient(#ffffffa0 1px, transparent 1.6px) 0 0 / 14px 14px, linear-gradient(170deg, #2a3150, #4b5578 60%, #c9ccd8); }
.prev-northern-landscape { background: linear-gradient(170deg, #cfe3ea 0%, #2f6a7a 35%, #123845 70%, #0a1e26); }
