/*
 * Colours (dark mode). Every colour in this file is a token here: the light
 * value on :root, its dark value in the prefers-color-scheme block below. To
 * add a colour, add a token to both blocks (a dark value only when it differs)
 * and use var(--name); never a literal. *-rgb tokens are bare channels for
 * translucent tints: rgb(var(--color-primary-rgb) / 0.1).
 */
:root {
    color-scheme: light dark;
    /* Brand */
    --color-primary: #007bff;
    --color-primary-hover: #0056b3;
    --color-primary-rgb: 0 123 255;
    --color-on-primary: #fff;
    --color-focus-ring: rgba(0, 123, 255, 0.5);
    --color-row-band: rgba(0, 123, 255, 0.07);
    --color-row-band-edge: rgba(0, 123, 255, 0.28);
    --color-link: #0b5ed7;
    --color-link-strong: #0062cc;

    /* Page and surfaces */
    --color-bg: #f5f5f5;
    --color-bg-rgb: 245 245 245;
    --color-surface: #fff;
    --color-surface-raised: #fff;
    --color-sheet-rgb: 255 255 255;
    --color-surface-hover: #f5f5f5;
    --color-surface-subtle: #f2f2f2;
    --color-surface-sunken: #f0f0f0;
    --color-press: rgba(0, 0, 0, 0.06);
    --color-backdrop: rgba(0, 0, 0, 0.5);

    /* Text */
    --color-text: #333;
    --color-text-strong: #1f2328;
    --color-text-body: #374151;
    --color-text-secondary: #555;
    --color-text-meta-strong: #4b5563;
    --color-text-muted: #666;
    --color-text-meta: #6b7280;
    --color-text-subtle: #777;
    --color-text-faint: #888;
    --color-text-state: #8a8f98;
    --color-placeholder: #999;
    --color-fate: #8a8a8a;

    /* Lines and controls */
    --color-border: #e0e0e0;
    --color-border-strong: #ddd;
    --color-separator: #ccc;
    --color-divider: #f0f0f0;
    --color-divider-soft: #eef0f3;
    --color-check-border: #8a9099;
    --color-active-bg: #e3f2fd;
    --color-active-border: #90caf9;
    --color-active-text: #1976d2;
    --color-suggestion-hover: #f0f7ff;

    /* Day page */
    --color-dot: #9a9a9a;
    --color-leftover: #c27014;
    --color-routine-mark: #a3a3a3;
    --color-warn-bg: #fdf0de;
    --color-warn-text: #9a5a0f;
    --color-pending: #5a6b80;
    --color-error-text: #b3261e;
    --color-info-bg: #e8f2ff;
    --color-info-text: #0b3d75;
    --color-toast-bg: #222;
    --color-toast-text: #fff;
    --color-toast-ring: transparent;
    --color-toast-action: rgba(255, 255, 255, 0.16);

    /* Messages and status */
    --color-success-bg: #d4edda;
    --color-success-text: #155724;
    --color-error-bg: #f8d7da;
    --color-error-strong: #721c24;
    --color-warning-bg: #fff3cd;
    --color-warning-text: #856404;
    --color-notice-bg: #cce5ff;
    --color-notice-text: #004085;
    --color-danger: #dc3545;
    --color-danger-hover: #c82333;
    --color-on-danger: #fff;
    --color-danger-fg: #dc3545;
    --color-danger-rgb: 220 53 69;
    --color-status-ok: #28a745;
    --color-status-wait: #ffc107;
    --color-status-sync: #17a2b8;
    --color-status-error: #dc3545;
    --color-status-off: #6c757d;
    --color-on-status: #fff;
    --color-reauth: #0070f3;
    --color-reauth-hover: #0060d3;

    /* Sign-in buttons */
    --color-github-bg: #1f2328;
    --color-github-hover: #32383f;
    --color-github-border: #1f2328;
    --color-github-hover-border: #32383f;
    --color-github-focus: #1f2328;
    --color-on-github: #fff;

    /* Talk it out */
    --color-record: #e03131;
    --color-record-rgb: 224 49 49;
    --color-badge: #f59f00;
    --color-fab-ring: #fff;
    --talk-fab-offline: #8a929b;
    --talk-backdrop: rgba(17, 24, 39, 0.38);
    --talk-grip: #d9dce1;
    --talk-close-hover: #f2f4f7;
    --talk-field-bg: #fafbfc;
    --talk-field-focus-bg: #fff;
    --talk-field-border: #d0d5dd;
    --talk-rec-bg: #fffafa;
    --talk-rec-border: #f3c4c4;
    --talk-notice: #9a4f00;
    --talk-primary-disabled: #c4d3e6;
    --talk-primary-disabled-text: #fff;
    --talk-link-hover: #f0f5ff;
    --talk-spinner-track: #dbe6f5;
    --talk-label-faint: #7b8490;
    --talk-rows-bg: #fff;
    --talk-rows-border: #e5e7eb;
    --talk-row-press: #f7f9fc;
    --talk-check-border: #c3c8cf;
    --talk-verb: #5c6670;
    --talk-verb-add: #1c6fd1;
    --talk-verb-complete: #2b8a3e;
    --talk-verb-pull: #7048e8;
    --talk-verb-move: #c26a00;
    --talk-verb-note: #0c8599;
    --talk-new-bg: #eef4ff;
    --talk-new-text: #1d4ed8;
    --talk-last-bg: #f3f5f8;
    --talk-error: #b42318;
}

@media (prefers-color-scheme: dark) {
    :root {
        /* Brand */
        --color-primary: #5ba3ff;
        --color-primary-hover: #85bbff;
        --color-primary-rgb: 91 163 255;
        --color-on-primary: #0b1424;
        --color-focus-ring: #5ba3ff;
        --color-row-band: rgba(91, 163, 255, 0.12);
        --color-row-band-edge: #4f8fe0;
        --color-link: #74b2ff;
        --color-link-strong: #80b9ff;

        /* Page and surfaces */
        --color-bg: #111418;
        --color-bg-rgb: 17 20 24;
        --color-surface: #1b1f25;
        --color-surface-raised: #242a32;
        --color-sheet-rgb: 36 42 50;
        --color-surface-hover: #272d35;
        --color-surface-subtle: #2b313a;
        --color-surface-sunken: #2e353e;
        --color-press: rgba(255, 255, 255, 0.08);
        --color-backdrop: rgba(0, 0, 0, 0.65);

        /* Text */
        --color-text: #e3e6ea;
        --color-text-strong: #eef0f3;
        --color-text-body: #ccd2d9;
        --color-text-secondary: #c3c9d1;
        --color-text-meta-strong: #b9c0c9;
        --color-text-muted: #a9b1bb;
        --color-text-meta: #a3abb6;
        --color-text-subtle: #9ea6b1;
        --color-text-faint: #98a0ab;
        --color-text-state: #98a0ab;
        --color-placeholder: #939ba7;
        --color-fate: #98a0ab;

        /* Lines and controls */
        --color-border: #353c46;
        --color-border-strong: #6e7785;
        --color-separator: #5d6672;
        --color-divider: #2a3038;
        --color-divider-soft: #383f49;
        --color-check-border: #8a93a0;
        --color-active-bg: #1c3352;
        --color-active-border: #4a7fc0;
        --color-active-text: #a9cdff;
        --color-suggestion-hover: #22324a;

        /* Day page */
        --color-dot: #848d99;
        --color-leftover: #e39a4a;
        --color-routine-mark: #848d99;
        --color-warn-bg: #3a2c17;
        --color-warn-text: #f3c27e;
        --color-pending: #a3b4ca;
        --color-error-text: #ff9a92;
        --color-info-bg: #17283e;
        --color-info-text: #c0dbff;
        --color-toast-bg: #323944;
        --color-toast-text: #f1f3f5;
        --color-toast-ring: #4f5866;
        --color-toast-action: rgba(255, 255, 255, 0.12);

        /* Messages and status */
        --color-success-bg: #173222;
        --color-success-text: #a6deb6;
        --color-error-bg: #3d1d21;
        --color-error-strong: #f9b8be;
        --color-warning-bg: #3a3114;
        --color-warning-text: #f1d58b;
        --color-notice-bg: #17283e;
        --color-notice-text: #c0dbff;
        --color-danger-fg: #ff8f8f;
        --color-danger-rgb: 255 143 143;
        --color-status-ok: #3fb75c;
        --color-status-sync: #2fb8cd;
        --color-status-error: #f0606c;
        --color-reauth: var(--color-primary);
        --color-reauth-hover: var(--color-primary-hover);

        /* Sign-in buttons */
        --color-github-bg: #2d333b;
        --color-github-hover: #3a414a;
        --color-github-border: #768390;
        --color-github-hover-border: #8b98a5;
        --color-github-focus: #c5ced8;

        /* Talk it out */
        --color-record: #ff6b6b;
        --color-record-rgb: 255 107 107;
        --color-fab-ring: #111418;
        --talk-fab-offline: #a3abb6;
        --talk-backdrop: rgba(0, 0, 0, 0.6);
        --talk-grip: #4a525e;
        --talk-close-hover: #2e353e;
        --talk-field-bg: #1b1f25;
        --talk-field-focus-bg: #171a1f;
        --talk-field-border: #757e8c;
        --talk-rec-bg: #271b1e;
        --talk-rec-border: #8a464c;
        --talk-notice: #f3b06a;
        --talk-primary-disabled: #2f3d50;
        --talk-primary-disabled-text: #94a3b8;
        --talk-link-hover: #22324a;
        --talk-spinner-track: #2c3a4e;
        --talk-label-faint: #9ea6b1;
        --talk-rows-bg: #2a3038;
        --talk-rows-border: #3d444f;
        --talk-row-press: #323943;
        --talk-check-border: #8a93a0;
        --talk-verb: #a3abb6;
        --talk-verb-add: #6eaaff;
        --talk-verb-complete: #62c97c;
        --talk-verb-pull: #ab95ff;
        --talk-verb-move: #f0a356;
        --talk-verb-note: #4cc5d8;
        --talk-new-bg: #1d3152;
        --talk-new-text: #adc9ff;
        --talk-last-bg: #2b313a;
        --talk-error: #ff9a92;
    }

    /* Plain links keep the browser default in light mode; on dark that blue
       is unreadable. :where() keeps it weaker than any class rule. */
    :where(a) {
        color: var(--color-link);
    }

    ::placeholder {
        color: var(--color-placeholder);
    }

    /* The default hr is a light grey bevel; on dark it glares. */
    :where(hr) {
        border: 0;
        border-top: 1px solid var(--color-border);
    }
}

/* Base styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
        sans-serif;
    line-height: 1.4;
    color: var(--color-text);
    background-color: var(--color-bg);
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 0;
    margin-bottom: 2rem;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

header h1 a {
    color: inherit;
    text-decoration: none;
}

/* Editable document title */
header h1[contenteditable] {
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    margin: -0.25rem -0.5rem; /* Offset padding so text stays aligned */
    outline: none;
}

header h1[contenteditable]:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 0;
}

header nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

header nav a {
    color: var(--color-text-muted);
    text-decoration: none;
}

header nav a:hover {
    color: var(--color-text);
}

header nav span {
    color: var(--color-text-muted);
}

/* Breadcrumb navigation */
.breadcrumb-nav {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    min-width: 0; /* Allow flex item to shrink */
}

.breadcrumb-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    text-decoration: none;
    padding: 0.375rem;
    margin: -0.375rem;
    border-radius: 4px;
    transition:
        color 0.15s ease,
        background-color 0.15s ease,
        box-shadow 0.15s ease;
    flex-shrink: 0;
    line-height: 0; /* Prevents underscore from whitespace */
}

.breadcrumb-back:hover {
    color: var(--color-primary);
    background: rgb(var(--color-primary-rgb) / 0.08);
}

.breadcrumb-back:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgb(var(--color-primary-rgb) / 0.3);
    color: var(--color-primary);
}

.breadcrumb-back:focus-visible {
    box-shadow: 0 0 0 2px var(--color-focus-ring);
}

.breadcrumb-back:active {
    background: rgb(var(--color-primary-rgb) / 0.15);
}

.breadcrumb-back svg {
    display: block;
    flex-shrink: 0;
}

.breadcrumb-separator {
    color: var(--color-separator);
    flex-shrink: 0;
    display: block;
}

.breadcrumb-nav h1 {
    font-size: 1.25rem;
    font-weight: 600;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
}

/* User avatar dropdown */
.user-menu {
    position: relative;
    margin-left: auto;
}

.user-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--color-primary);
    color: var(--color-on-primary);
    border: none;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease;
}

.user-avatar:hover {
    background: var(--color-primary-hover);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--color-surface-raised);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-0.5rem);
    transition:
        opacity 0.15s ease,
        transform 0.15s ease,
        visibility 0.15s ease;
    z-index: 1000;
}

.user-menu.open .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
    color: var(--color-text-muted);
    word-break: break-all;
}

.user-dropdown-item {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--color-text);
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.user-dropdown-item:hover {
    background: var(--color-surface-hover);
}

/* Main content */
main {
    background: var(--color-surface);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    border: none;
    font-size: 1rem;
    transition: background-color 0.15s ease;
}

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

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

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border-strong);
}

.btn-secondary:hover {
    background: var(--color-surface-hover);
}

.btn-danger {
    background: var(--color-danger);
    color: var(--color-on-danger);
}

.btn-danger:hover {
    background: var(--color-danger-hover);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: 4px;
    transition:
        color 0.15s ease,
        background-color 0.15s ease;
}

.btn-icon:hover {
    color: var(--color-danger-fg);
    background: rgb(var(--color-danger-rgb) / 0.1);
}

.btn-icon:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgb(var(--color-danger-rgb) / 0.3);
}

.btn-icon svg {
    flex-shrink: 0;
}

.btn-google {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border-strong);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-google:hover {
    background: var(--color-surface-hover);
}

.btn-github {
    background: var(--color-github-bg);
    color: var(--color-on-github);
    border: 1px solid var(--color-github-border);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-github:focus-visible {
    outline: 2px solid var(--color-github-focus);
    outline-offset: 2px;
}

.btn-github svg {
    flex-shrink: 0;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--color-border-strong);
    border-radius: 6px;
    font-size: 1rem;
    background: var(--color-surface);
}

.form-group select {
    padding: 0.75rem;
    border: 1px solid var(--color-border-strong);
    border-radius: 6px;
    font-size: 1rem;
    background: var(--color-surface);
    cursor: pointer;
}

.form-group input[type="text"]:focus,
.form-group input[type="email"]:focus,
.form-group input[type="password"]:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.form-group input[type="checkbox"] {
    width: auto;
}

.form-group:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group:has(input[type="checkbox"]) label {
    display: inline;
    margin-bottom: 0;
}

/* Messages */
.messages {
    margin-bottom: 1rem;
    list-style: none;
}

.messages li {
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

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

.messages .error {
    background: var(--color-error-bg);
    color: var(--color-error-strong);
}

.messages .warning {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
}

.messages .info {
    background: var(--color-notice-bg);
    color: var(--color-notice-text);
}

.errorlist {
    color: var(--color-error-strong);
    list-style: none;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* ── Allauth pages ─────────────────────────────────────────────────────────
   django-allauth renders its pages (login cancelled, third-party login
   failure, social signup/connect, password reset, email + connection
   management) with bare semantic HTML via its {% element %} tags. The
   `.auth-page` body class — set by allauth/layouts/base.html — lets us brand
   that markup to match the hand-built account templates without overriding
   each template individually. */
.auth-page main h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Section headings (e.g. "Add a Third-Party Account") render via bare
   {% element h2 %}. Keep them clearly subordinate to the page h1 and give
   them room so they don't collide with the preceding section. */
.auth-page main h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
}

.auth-page main h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.auth-page main p {
    line-height: 1.5;
    margin-bottom: 1rem;
}

.auth-page main a {
    color: var(--color-primary);
    text-decoration: none;
}

.auth-page main a:hover {
    text-decoration: underline;
}

.auth-page main form {
    margin-top: 1.5rem;
}

/* allauth fields render via {{ form.as_p }}: <p><label>…</label><input></p> */
.auth-page main form p {
    margin-bottom: 1rem;
}

.auth-page main label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.auth-page main input[type="text"],
.auth-page main input[type="email"],
.auth-page main input[type="password"],
.auth-page main input[type="number"],
.auth-page main input:not([type]),
.auth-page main select,
.auth-page main textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--color-border-strong);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--color-surface);
}

.auth-page main input:focus,
.auth-page main select:focus,
.auth-page main textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* checkboxes/radios stay inline with their label */
.auth-page main input[type="checkbox"],
.auth-page main input[type="radio"] {
    width: auto;
    margin-right: 0.5rem;
}

.auth-page main input[type="checkbox"] + label,
.auth-page main input[type="radio"] + label {
    display: inline;
    font-weight: 400;
}

/* allauth submit buttons are bare <button type="submit"> — give them the
   primary button treatment used everywhere else. */
.auth-page main button {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    border: none;
    background: var(--color-primary);
    color: var(--color-on-primary);
    transition: background-color 0.15s ease;
}

.auth-page main button:hover {
    background: var(--color-primary-hover);
}

.auth-page main button + button {
    margin-left: 0.5rem;
}

/* Destructive actions (e.g. "Remove" a connected account) are tagged
   `danger` by allauth; the button element override emits that as a class so
   they get the brand's danger red instead of primary blue. */
.auth-page main button.danger {
    background: var(--color-danger);
}

.auth-page main button.danger:hover {
    background: var(--color-danger-hover);
}

/* provider list (<ul><li><a>) on the social connect/signup pages. The
   provider element override gives each link the branded social-button look
   used on the login page (dark GitHub, white Google). */
.auth-page main ul:not(.errorlist) {
    list-style: none;
    margin-top: 1rem;
}

.auth-page main ul:not(.errorlist) li {
    margin-bottom: 0.5rem;
}

.auth-page main ul.provider-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 320px;
}

.auth-page main ul.provider-list li {
    margin-bottom: 0;
}

.auth-page main ul.provider-list a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--color-border-strong);
    border-radius: 6px;
    background: var(--color-surface);
    color: var(--color-text);
    font-weight: 500;
    text-decoration: none;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease;
}

.auth-page main ul.provider-list a:hover {
    background: var(--color-surface-hover);
    text-decoration: none;
}

.auth-page main ul.provider-list a svg {
    flex-shrink: 0;
}

.auth-page main ul.provider-list a.provider-github {
    background: var(--color-github-bg);
    border-color: var(--color-github-border);
    color: var(--color-on-github);
}

.auth-page main ul.provider-list a.provider-github:hover {
    background: var(--color-github-hover);
    border-color: var(--color-github-hover-border);
}

/* Document list */
.document-list {
    list-style: none;
}

.document-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.document-list-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.document-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    margin-bottom: 0.75rem;
    background: var(--color-surface);
    transition: border-color 0.15s ease;
}

.document-item:hover {
    border-color: var(--color-primary);
}

.document-item a {
    color: var(--color-text);
    text-decoration: none;
    font-weight: 500;
    flex: 1;
}

.document-item a:hover {
    color: var(--color-primary);
}

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

.document-item-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

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

.empty-state p {
    margin-bottom: 1rem;
}

.document-list-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Day pages (#185): header link to the documents list, day header, week strip */
.header-docs-link {
    color: var(--color-text-muted);
    font-weight: 500;
    text-decoration: none;
    padding: 0.5rem 0.25rem;
    margin: -0.5rem -0.25rem;
    border-radius: 6px;
}

.header-docs-link:hover {
    color: var(--color-primary);
}

.header-docs-link:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--color-focus-ring);
}

.day-header {
    margin-bottom: 1rem;
}

.day-nav {
    display: flex;
    align-items: center;
    gap: 2px;
}

.day-nav-btn {
    width: 44px;
    height: 44px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 12px;
    color: var(--color-text-muted);
    text-decoration: none;
    transition:
        color 0.15s ease,
        background-color 0.15s ease;
}

a.day-nav-btn:hover {
    color: var(--color-primary);
    background: rgb(var(--color-primary-rgb) / 0.08);
}

a.day-nav-btn:active {
    background: rgb(var(--color-primary-rgb) / 0.15);
}

a.day-nav-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--color-focus-ring);
}

.day-nav-btn svg {
    width: 20px;
    height: 20px;
    display: block;
}

.day-nav-prev {
    transform: rotate(180deg);
}

.day-go-today {
    color: var(--color-primary);
}

.day-title {
    flex: 1;
    min-width: 0;
    text-align: center;
}

.day-title-main {
    display: block;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
}

.day-title-rest {
    display: block;
    margin-top: 0.125rem;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--color-text-muted);
}

.day-relative.is-today {
    color: var(--color-primary);
    font-weight: 600;
}

.week-strip {
    display: grid;
    /* 7 days, then the Daily routine slot (#189) */
    grid-template-columns: repeat(7, 1fr) minmax(40px, 0.85fr);
    gap: 2px;
    margin-top: 0.5rem;
}

.week-day {
    min-height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    border-radius: 14px;
    color: var(--color-text-muted);
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.week-day:hover {
    background: rgb(var(--color-primary-rgb) / 0.06);
}

.week-day:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--color-focus-ring);
}

.week-day-name {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.week-day-num {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.1;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}

.week-day.is-today .week-day-name,
.week-day.is-today .week-day-num {
    color: var(--color-primary);
}

/* Dot under the date (#187): the day has to-dos; amber when a past day
   still has open ones ("From earlier" will ask about them). */
.week-day-dot {
    width: 5px;
    height: 5px;
    margin-top: 2px;
    border-radius: 50%;
    background: transparent;
}

.week-day.has-items .week-day-dot {
    background: var(--color-dot);
}

.week-day.is-today.has-items .week-day-dot {
    background: var(--color-primary);
}

.week-day.has-leftover .week-day-dot {
    background: var(--color-leftover);
}

.week-day.is-selected {
    background: var(--color-surface-hover);
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.06),
        0 0 0 1px var(--color-border);
}

/* Empty page: the server-rendered placeholder, and once Tiptap mounts, a
   placeholder on the empty editor (a lone empty paragraph). That paragraph is
   the tap target that starts editing (#205): there's no Edit button. */
.day-placeholder,
.tiptap > p:only-child:has(> br.ProseMirror-trailingBreak:only-child)::before {
    color: var(--color-placeholder);
}

.tiptap > p:only-child:has(> br.ProseMirror-trailingBreak:only-child)::before {
    content: "Tap to start writing";
    float: left;
    height: 0;
    pointer-events: none;
}

.day-page .tiptap > p:only-child:has(> br.ProseMirror-trailingBreak:only-child)::before {
    content: "Tap to start this day\2019s list";
}

.day-page:has(.day-relative.is-today) .tiptap > p:only-child:has(> br.ProseMirror-trailingBreak:only-child)::before {
    content: "Tap to start today\2019s list";
}

/* Daily routine (#189) ------------------------------------------------- */

/* Week strip end slot: opens the routine page. */
.week-routine {
    color: var(--color-primary);
}

.week-routine-icon {
    width: 20px;
    height: 20px;
    display: block;
}

/* The routine block above a day's editor: no card. Each row is the same as
   an editor task row (the gutter, box, text column, sizes and checked look
   share the task-row rules and --task-* sizes below), so the routine reads as
   the top of the day's list; only the loop mark after the text says it
   repeats. A row is one wide button: a tap anywhere on it checks it and never
   focuses the editor. */
.routine-block[hidden] {
    display: none;
}

.routine-list {
    list-style: none;
}

.routine-item form {
    display: contents;
}

.routine-check {
    width: 100%;
    display: flex;
    align-items: stretch;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    line-height: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* The editor's gutter feedback, on the routine row's gutter. */
.routine-check:active .routine-gutter {
    background: var(--color-press);
}

@media (hover: hover) {
    .routine-check:hover .routine-box {
        border-color: var(--color-primary);
    }
}

.routine-body {
    flex: 1;
    min-width: 0;
    padding: var(--task-pad) 0;
    overflow-wrap: anywhere;
}

.routine-item[data-checked="true"] .routine-box {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-on-primary);
}

.routine-item[data-checked="true"] .routine-text {
    text-decoration: line-through;
    color: var(--color-text-muted);
}

/* "Repeats daily": small and quiet, just after the text. */
.routine-mark {
    display: inline-block;
    width: 15px;
    height: 15px;
    margin-left: 0.375rem;
    vertical-align: -2px;
    color: var(--color-routine-mark);
}

.routine-mark svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* A heading first in the day's text keeps the space it has after a list. */
.routine-block:not([hidden]) ~ .editor-container .tiptap > h1:first-child {
    margin-top: 1rem;
}

.routine-block:not([hidden]) ~ .editor-container .tiptap > h2:first-child {
    margin-top: 0.75rem;
}

.routine-block:not([hidden]) ~ .editor-container .tiptap > h3:first-child,
.routine-block:not([hidden]) ~ .editor-container .tiptap > h4:first-child,
.routine-block:not([hidden]) ~ .editor-container .tiptap > h5:first-child,
.routine-block:not([hidden]) ~ .editor-container .tiptap > h6:first-child {
    margin-top: 0.5rem;
}

/* An empty day under its routine: the list has begun, so add to it. */
.day-page:has(.routine-block:not([hidden])) .tiptap > p:only-child:has(> br.ProseMirror-trailingBreak:only-child)::before {
    content: "Tap to add to this day\2019s list";
}

.day-page:has(.day-relative.is-today):has(.routine-block:not([hidden])) .tiptap > p:only-child:has(> br.ProseMirror-trailingBreak:only-child)::before {
    content: "Tap to add to today\2019s list";
}

/* Wider screens frame the editor's text in a box: the routine rows sit in
   the same box, as its first rows. */
@media (min-width: 641px) {
    .routine-block:not([hidden]) {
        padding: 1rem 1rem 0;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-bottom: 0;
        border-radius: 6px 6px 0 0;
    }

    .routine-block:not([hidden]) ~ .editor-container > .editor-content {
        /* Keeps a first heading's top margin inside the box. */
        display: flow-root;
        border-top: 0;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
        padding-top: 0;
    }
}

/* The routine page: task gutters show the routine mark, not a check box,
   and can't be checked (CheckTaskItem's routineMarks; routine.ts also
   resets any check). */
.task-gutter.is-routine-mark {
    cursor: default;
}

.task-gutter.is-routine-mark:active {
    background: none;
}

.task-gutter.is-routine-mark .task-box,
.tiptap li[data-checked="true"] > .task-gutter.is-routine-mark .task-box {
    border: 0;
    background: none;
    color: var(--color-primary);
}

.task-gutter.is-routine-mark .task-box svg {
    width: 100%;
    height: 100%;
}

.routine-page .tiptap li[data-checked="true"] p {
    text-decoration: none;
    color: inherit;
}

.routine-page .tiptap > p:only-child:has(> br.ProseMirror-trailingBreak:only-child)::before {
    content: "Tap to add the things you do every day";
}

/* From earlier (#188) --------------------------------------------------- */

/* The card at the top of today: open tasks left on past days, asked about
   once. Server-rendered forms; from-earlier.ts adds fetch + the fold. */
.from-earlier {
    margin-bottom: 1rem;
    padding: 0.25rem 0.375rem 0.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* `hidden` must win over the display rules below (the fold line, the
   collapse button and emptied day groups toggle it). */
.from-earlier[hidden],
.from-earlier [hidden] {
    display: none !important;
}

.from-earlier button {
    font: inherit;
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.from-earlier form {
    margin: 0;
}

.fe-head {
    display: flex;
    align-items: center;
    gap: 2px;
    padding-left: 0.625rem;
}

.fe-title {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.4375rem;
    font-size: 1.0625rem;
    font-weight: 600;
    white-space: nowrap;
}

.fe-n {
    display: inline-block;
    padding: 0 0.5rem;
    border-radius: 999px;
    background: var(--color-warn-bg);
    color: var(--color-warn-text);
    font-size: 0.8125rem;
    font-weight: 700;
    line-height: 20px;
    font-variant-numeric: tabular-nums;
}

.from-earlier .fe-all {
    min-height: 44px;
    padding: 0 0.4375rem;
    border-radius: 10px;
    color: var(--color-primary);
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
}

.from-earlier .fe-min {
    width: 40px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: var(--color-text-faint);
}

.fe-min-chevron {
    width: 18px;
    height: 18px;
    transform: rotate(-90deg);
}

.from-earlier .fe-all:active,
.from-earlier .fe-min:active {
    background: var(--color-surface-sunken);
}

.fe-day-label {
    margin: 0.375rem 0 0;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.fe-day-label a {
    display: inline-block;
    min-height: 32px;
    padding: 0.5rem 0.625rem 0.25rem;
    color: var(--color-text-subtle);
    text-decoration: none;
}

.fe-rows {
    list-style: none;
}

.fe-row + .fe-row {
    border-top: 1px solid var(--color-divider);
}

.fe-form {
    display: flex;
    align-items: center;
    min-height: 52px;
}

.from-earlier .fe-check {
    flex: 0 0 48px;
    align-self: stretch;
    display: grid;
    place-items: center;
    border-radius: 12px;
}

.from-earlier .fe-check:active {
    background: var(--color-surface-sunken);
}

.fe-box {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border: 2px solid var(--color-check-border);
    border-radius: 6px;
    background: var(--color-surface);
    color: transparent;
}

.fe-box svg {
    width: 15px;
    height: 15px;
}

@media (hover: hover) {
    .fe-check:hover .fe-box {
        border-color: var(--color-primary);
        color: rgb(var(--color-primary-rgb) / 0.35);
    }
}

.fe-text {
    flex: 1;
    min-width: 0;
    padding: 0.375rem 0.25rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.fe-text code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.86em;
    padding: 1px 4px;
    border-radius: 5px;
    background: var(--color-surface-sunken);
}

.fe-ctx,
.fe-sub {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.78rem;
    color: var(--color-text-subtle);
}

.fe-ctx {
    display: block;
    margin-bottom: 1px;
}

.fe-sub {
    margin-top: 2px;
}

.from-earlier .fe-btn {
    flex: none;
    min-height: 40px;
    margin-left: 0.25rem;
    padding: 0 0.625rem 0 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 650;
    position: relative;
}

/* A slightly bigger hit area than the pill. */
.from-earlier .fe-btn::after {
    content: "";
    position: absolute;
    inset: -4px -2px;
}

.fe-btn svg {
    width: 18px;
    height: 18px;
    flex: none;
}

.from-earlier .fe-pull {
    background: rgb(var(--color-primary-rgb) / 0.1);
    color: var(--color-link-strong);
}

.from-earlier .fe-letgo {
    margin-right: 2px;
    background: var(--color-surface-subtle);
    color: var(--color-text-muted);
}

.from-earlier .fe-btn:active {
    opacity: 0.75;
}

.from-earlier button:focus-visible,
.fe-day-label a:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--color-focus-ring);
}

.fe-more {
    padding: 0.5rem 0.625rem 0;
    font-size: 0.8125rem;
    color: var(--color-text-subtle);
}

/* Narrow phones: icon-only Pull / Let go would hide the words; keep them
   and tighten the padding instead. */
@media (max-width: 360px) {
    .from-earlier .fe-btn {
        padding: 0 0.4375rem;
    }

    .fe-btn svg {
        display: none;
    }
}

/* Folded to one line: "3 from earlier ›" (JS only). */
.from-earlier.is-collapsed {
    padding: 0;
}

.from-earlier.is-collapsed > :not(.fe-line) {
    display: none;
}

.from-earlier .fe-line {
    width: 100%;
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.875rem;
    font-size: 0.9375rem;
    font-weight: 600;
    text-align: left;
}

.fe-line-chevron {
    width: 18px;
    height: 18px;
    margin-left: auto;
    color: var(--color-text-faint);
}

/* Keeps coming back: a quiet count, not a nag. */
.boomerang {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 0 0.4375rem 0 0.3125rem;
    border-radius: 999px;
    background: var(--color-warn-bg);
    color: var(--color-warn-text);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 20px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.boomerang svg {
    width: 13px;
    height: 13px;
}

/* Offline (#190) ---------------------------------------------------------- */

/* A row whose answer is waiting in the offline queue: it stays, quieted,
   with "Waiting to sync · Pull" until the server confirms. */
.fe-row.is-pending .fe-main,
.fe-row.is-pending .fe-ctx,
.fe-row.is-pending .fe-sub {
    opacity: 0.55;
}

.fe-row.is-pending .fe-btn,
.fe-row.is-pending .fe-check {
    opacity: 0.35;
    pointer-events: none;
}

.fe-pending,
.fe-row-msg {
    display: flex;
    align-items: center;
    gap: 0.3125rem;
    margin-top: 3px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.3;
}

.fe-pending {
    color: var(--color-pending);
}

.fe-pending svg {
    width: 16px;
    height: 16px;
    flex: none;
}

/* Refused on replay (the task changed or is gone): says why. */
.fe-row-msg {
    color: var(--color-error-text);
}

/* The offline shell's card is a saved copy. */
.fe-stale {
    margin: 0.125rem 0.625rem 0.375rem;
    font-size: 0.78rem;
    color: var(--color-text-subtle);
}

.fe-stale a {
    color: var(--color-primary);
    font-weight: 600;
}

/* A task an offline operation (Move to tomorrow, Restore) is waiting on. */
.tiptap li.is-pending > .task-body > p::after {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: 0.375rem;
    vertical-align: -3px;
    background-color: var(--color-pending);
    -webkit-mask: url("../icons/svg/pending.0bafe9a66b4b.svg") center / contain no-repeat;
    mask: url("../icons/svg/pending.0bafe9a66b4b.svg") center / contain no-repeat;
}

/* Left open past midnight: offer the new today. */
.new-day-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.625rem 0.875rem;
    border-radius: 12px;
    background: var(--color-info-bg);
    color: var(--color-info-text);
}

.new-day-banner span {
    flex: 1;
}

.new-day-link {
    font-weight: 700;
    color: var(--color-link-strong);
    text-decoration: none;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
}

/* After a no-JS operation: what happened, with Undo. */
.op-notice {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.25rem 0.375rem 0.25rem 0.875rem;
    border-radius: 12px;
    background: var(--color-info-bg);
    color: var(--color-info-text);
}

.op-notice-text {
    flex: 1;
}

.op-notice-undo {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    min-height: 40px;
    padding: 0 0.75rem;
    border: 0;
    border-radius: 10px;
    background: rgb(var(--color-primary-rgb) / 0.12);
    color: var(--color-link-strong);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.op-notice-undo svg {
    width: 18px;
    height: 18px;
}

/* Toast with an optional Undo (toast.ts). Sits clear of the bottom edge (and, while editing, the toolbar). */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(80px + env(safe-area-inset-bottom));
    z-index: 300;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    /* Without this, left: 50% would shrink it to half the screen. */
    width: max-content;
    max-width: calc(100vw - 32px);
    padding: 0.625rem 1rem;
    border-radius: 12px;
    background: var(--color-toast-bg);
    /* A hairline so the toast stands off a dark page; transparent in light. */
    box-shadow: inset 0 0 0 1px var(--color-toast-ring);
    color: var(--color-toast-text);
    font-size: 0.9375rem;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 12px);
    transition:
        opacity 0.2s ease,
        transform 0.2s ease;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.toast.has-action {
    pointer-events: auto;
    padding: 0.25rem 0.375rem 0.25rem 1rem;
}

.toast-undo {
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem;
    min-height: 40px;
    padding: 0 0.75rem;
    border: 0;
    border-radius: 10px;
    background: var(--color-toast-action);
    color: inherit;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.toast-undo svg {
    width: 18px;
    height: 18px;
}

.is-editing .toast {
    bottom: calc(72px + var(--kb-inset, 0px) + env(safe-area-inset-bottom));
}

@media (prefers-reduced-motion: reduce) {
    .toast {
        transition: none;
    }
}

/* Task fates on a day page (#188). The NodeView sets data-fate on the row
   and draws the gutter mark; the server render gets the same look. */
.tiptap li[data-fate="pulled"] > .task-body > p,
.tiptap li[data-fate="pulled"] > div > p,
.tiptap li[data-fate="let_go"] > .task-body > p,
.tiptap li[data-fate="let_go"] > div > p {
    color: var(--color-fate);
}

.tiptap li[data-fate="let_go"] > .task-body > p,
.tiptap li[data-fate="let_go"] > div > p {
    opacity: 0.75;
}

.tiptap li[data-fate] > .task-gutter .task-box,
.tiptap li[data-fate][data-checked="true"] > .task-gutter .task-box {
    border: 0;
    background: none;
    color: var(--color-fate);
}

.tiptap li[data-fate] > .task-gutter .task-box svg {
    width: 100%;
    height: 100%;
}

.tiptap li[data-fate="let_go"] > .task-gutter .task-box svg {
    width: 90%;
    height: 90%;
}

.task-meta {
    flex: none;
    align-self: flex-start;
    display: flex;
    align-items: center;
    min-height: var(--task-first-line, 1.6rem);
    padding-left: 0.375rem;
    user-select: none;
    -webkit-user-select: none;
}

.task-meta[hidden],
/* Sub-tasks that went with a pulled parent: the parent's link says it. */
.tiptap li[data-fate="pulled"] li[data-fate="pulled"] > .task-meta {
    display: none;
}

/* Long words keep at least half the row; the link gives way. */
.tiptap li[data-task-row] > .task-body {
    min-width: 50%;
}

.task-meta {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
}

.task-meta .ghost-link {
    overflow: hidden;
    text-overflow: ellipsis;
}

.ghost-link {
    position: relative;
    font-size: 0.8125rem;
    color: var(--color-text-subtle);
    white-space: nowrap;
    text-decoration: underline;
    text-decoration-color: var(--color-separator);
    text-underline-offset: 3px;
}

/* Easier to hit than the small text. */
.ghost-link::after {
    content: "";
    position: absolute;
    inset: -12px -8px;
}

.ghost-link:hover {
    color: var(--color-primary);
}

/* A ghost's jump lands here: flash the live copy. */
.tiptap li.is-flashing > .task-body {
    border-radius: 8px;
    animation: task-flash 1.6s ease-out;
}

@keyframes task-flash {
    0%,
    30% {
        background: rgb(var(--color-primary-rgb) / 0.14);
        box-shadow: 0 0 0 6px rgb(var(--color-primary-rgb) / 0.14);
    }

    100% {
        background: transparent;
        box-shadow: 0 0 0 6px transparent;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tiptap li.is-flashing > .task-body {
        animation: none;
        background: rgb(var(--color-primary-rgb) / 0.12);
    }
}

.editor-toolbar-btn svg {
    width: 20px;
    height: 20px;
    display: block;
    margin: 0 auto;
}

/* Data Export page */
.export-section {
    margin-bottom: 2rem;
}

.export-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.document-export-list {
    list-style: none;
}

.document-export-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    background: var(--color-surface);
}

.document-export-item .document-title {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 1rem;
}

/* Editor */
.editor-container {
    margin-bottom: 1rem;
}

.editor-content {
    min-height: 400px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 1rem;
    background: var(--color-surface);
}

.editor-content:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* Tiptap editor styles */
.tiptap {
    min-height: 400px;
    outline: none;
}

.tiptap p {
    margin-bottom: 0.25rem;
}

.tiptap ul,
.tiptap ol {
    padding-left: 1.5rem;
    margin-bottom: 0.25rem;
}

.tiptap ul[data-type="taskList"] {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

.tiptap ul[data-type="taskList"] li {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.125rem;
}

/* The label/checkbox rules below style Tiptap's default task markup
   (renderHTML: <li><label><input></label><div>…</div></li>), e.g. HTML
   rendered without the editor. The live editor uses the check gutter. */
.tiptap ul[data-type="taskList"] li > label {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    /* Align checkbox with first line of text using translateY */
    transform: translateY(0.15em);
}

.tiptap ul[data-type="taskList"] li > label input[type="checkbox"] {
    cursor: pointer;
    pointer-events: auto;
    accent-color: var(--color-primary);
}

.tiptap ul[data-type="taskList"] li > div {
    flex: 1;
}

/*
 * Strike through only the checked item's OWN paragraph(s), not its nested
 * child task list. Targeting `> div` instead of `> div > p` made the
 * line-through/grey colour bleed onto every descendant, so checking a parent
 * crossed out its sub-items even when their own checkboxes were unchecked.
 */
.tiptap ul[data-type="taskList"] li[data-checked="true"] > div > p {
    text-decoration: line-through;
    color: var(--color-text-muted);
}

/*
 * Check gutter (issue #186). Task rows rendered by the CheckTaskItem NodeView
 * (check-mode.ts) are [wide check gutter][text]. The gutter is the tap target
 * in both check and edit mode; it never focuses the editor. Visual state comes
 * only from data-* attributes the NodeView sets. The day page's routine rows
 * (.routine-gutter / .routine-box) share these sizes and rules, so they line
 * up with the editor's rows exactly.
 */
.tiptap,
.routine-block {
    --task-gutter: 2rem; /* tap target width */
    --task-bleed: 0.375rem; /* how far the gutter reaches into the margin */
    --task-box: 18px;
    --task-pad: 0.125rem; /* vertical padding on each task line */
    --task-gap: 0.25rem; /* gutter space right of the box: a near-miss still toggles */
    --task-nest-pull: 0.25rem;
    --task-first-line: calc(1.4rem + 2 * var(--task-pad));
}

@media (pointer: coarse) {
    .tiptap,
    .routine-block {
        --task-gutter: 52px;
        --task-bleed: 12px;
        --task-box: 22px;
        --task-pad: 9px;
        --task-gap: 6px;
        --task-nest-pull: 10px;
    }
}

.tiptap ul[data-type="taskList"] li[data-task-row] {
    align-items: stretch;
    gap: 0;
    margin-bottom: 0;
}

.task-gutter,
.routine-gutter {
    flex: 0 0 calc(var(--task-gutter) + var(--task-gap));
    padding-right: var(--task-gap);
    margin-left: calc(-1 * var(--task-bleed));
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: calc((var(--task-first-line) - var(--task-box)) / 2);
    border-radius: 8px;
    cursor: pointer;
    outline: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* A parent item toggles from its first line only, so taps beside its
   children don't hit it. */
.tiptap li[data-has-children="true"] > .task-gutter {
    align-self: flex-start;
    height: var(--task-first-line);
}

/* The focus ring goes round the box itself, the same gap on every side. The
   gutter is uneven around the box (the near-miss gap on its right, and it
   runs the row's full height), so a ring on the gutter looked lopsided. An
   outline follows the box's rounded corners and survives forced colors. */
.task-gutter:focus-visible .task-box,
.routine-check:focus-visible .routine-box {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

@media (forced-colors: active) {
    .task-gutter:focus-visible .task-box,
    .routine-check:focus-visible .routine-box {
        outline-color: CanvasText;
    }
}

.task-gutter:active {
    background: var(--color-press);
}

.task-box,
.routine-box {
    width: var(--task-box);
    height: var(--task-box);
    flex: none;
    display: grid;
    place-items: center;
    border: 2px solid var(--color-check-border);
    border-radius: 5px;
    background: var(--color-surface);
    color: transparent;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease;
}

.task-box svg,
.routine-box svg {
    width: 85%;
    height: 85%;
}

.tiptap li[data-checked="true"] > .task-gutter .task-box {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-on-primary);
}

@media (hover: hover) {
    .task-gutter:hover .task-box {
        border-color: var(--color-primary);
    }
}

.tiptap ul[data-type="taskList"] li[data-task-row] > .task-body {
    flex: 1;
    min-width: 0;
    padding-left: 0;
    overflow-wrap: anywhere;
}

.tiptap li[data-task-row] > .task-body > p {
    padding: var(--task-pad) 0;
    margin-bottom: 0;
}

.tiptap li[data-task-row] > .task-body > ul[data-type="taskList"] {
    margin-left: calc(-1 * var(--task-nest-pull));
}

/* Before the editor has loaded (#201): the server's rows are the same as the
   editor's, but their gutters work only once early-check.ts has taken them
   over (never without JavaScript). */
.ssr-render .task-gutter[aria-disabled="true"] {
    cursor: default;
}

.ssr-render .task-gutter[aria-disabled="true"]:active {
    background: none;
}

/* The collapse toggle's place on the server's headings: not a control. */
.ssr-render .section-toggle {
    cursor: default;
    pointer-events: none;
}

/* A tap on the text before the editor loaded: this field holds the focus
   (and iOS's keyboard) at the tap until the editor takes over. */
.early-caret {
    position: absolute;
    width: 1px;
    height: 1.4em;
    margin: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    font-size: 16px; /* no iOS zoom on focus */
    pointer-events: none;
    transform: translateY(-50%);
}

/* Check mode: the text reads as a page, not a text field. */
[data-editor-mode="check"] .tiptap {
    cursor: text;
    caret-color: transparent;
}

/* Blank space under the last line: a tap there edits at the end (#205).
   While editing, room for the toolbar + keyboard. */
[data-editor-mode="check"] .editor-container {
    cursor: text;
    padding-bottom: max(4.5rem, 25vh);
}

.is-editing .editor-container {
    padding-bottom: 50vh;
}

/*
 * Which mode you're in, at a glance. Editing frames the text in blue with an
 * "Editing" tab, and the rest of the page (header, From earlier, routine)
 * steps back. An outline, so nothing moves: a tap's caret lands where the
 * finger was. The label's text is decoration; body's data-editor-mode is the
 * state.
 */
.editor-content {
    position: relative;
    /* Wider screens: the frame replaces the box's own border. Phones have no
       box, so it stands off the text. */
    --edit-frame-gap: -1px;
    transition:
        outline-color 0.15s ease,
        box-shadow 0.15s ease;
    outline: 2px solid transparent;
    outline-offset: var(--edit-frame-gap);
}

@media (max-width: 640px) {
    .editor-content {
        --edit-frame-gap: 6px;
    }
}

/* Specific enough to round the corners the routine's box squares off. */
body.is-editing .editor-container > .editor-content {
    outline-color: var(--color-primary);
    border-radius: 6px;
    box-shadow: 0 8px 28px rgba(0, 80, 180, 0.12);
}

/* On the frame's top edge at the right, where lines rarely reach. */
.is-editing .editor-content::before {
    content: "Editing";
    position: absolute;
    top: calc(-1 * var(--edit-frame-gap));
    right: 0.75rem;
    transform: translateY(-50%);
    z-index: 1;
    padding: 0.125rem 0.5rem;
    border-radius: 6px;
    background: var(--color-primary);
    color: var(--color-on-primary);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.1rem;
    pointer-events: none;
}

/* With a keyboard, Escape finishes (phones use the toolbar's check). */
@media (hover: hover) and (pointer: fine) {
    .is-editing .editor-content::before {
        content: "Editing \00B7  Esc to finish";
    }
}

body > header,
.day-header,
.op-notice,
.from-earlier,
.routine-block {
    transition: opacity 0.2s ease;
}

.is-editing > header,
.is-editing .day-header,
.is-editing .op-notice,
.is-editing .from-earlier,
.is-editing .routine-block {
    opacity: 0.4;
}

@media (forced-colors: active) {
    body.is-editing .editor-container > .editor-content {
        outline-color: Highlight;
    }

    .is-editing .editor-content::before {
        border: 1px solid CanvasText;
    }
}

/* A checkbox with keyboard focus (Tab) bands its whole row, which is easier
   to find than the ring alone. The band reaches into the gutter's bleed;
   the margin and padding cancel, so nothing moves. */
.tiptap li[data-task-row]:has(> .task-gutter:focus-visible),
.routine-item:has(.routine-check:focus-visible) {
    margin-left: calc(-1 * var(--task-bleed));
    padding-left: var(--task-bleed);
    border-radius: 8px;
    background: var(--color-row-band);
    box-shadow: inset 0 0 0 1px var(--color-row-band-edge);
}

@media (prefers-reduced-motion: reduce) {
    .editor-content,
    body > header,
    .day-header,
    .op-notice,
    .from-earlier,
    .routine-block {
        transition: none;
    }
}

/*
 * Reorder by long-press and drag (#213, reorder.ts). On touch screens a long
 * press in check mode lifts an item, so it mustn't select words or open the
 * callout menu (edit mode still selects text as usual).
 */
@media (pointer: coarse) {
    [data-editor-mode="check"] .tiptap {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
        -webkit-tap-highlight-color: transparent;
    }
}

/* While an item is lifted: no text selection anywhere, a grabbing cursor. */
.is-reorder-dragging,
.is-reorder-dragging * {
    -webkit-user-select: none !important;
    user-select: none !important;
    cursor: grabbing !important;
}

/* The rest of the list dims a little; the item's old place dims more. */
.tiptap.is-reordering > * {
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.tiptap.is-reordering .is-drag-source {
    opacity: 0.35;
}

/* The lifted copy that follows the finger (outside the editor DOM). */
.tiptap.reorder-ghost {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 400;
    min-height: 0;
    margin: 0;
    padding: 0;
    border-radius: 10px;
    background: var(--color-surface);
    box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.18),
        0 2px 6px rgba(0, 0, 0, 0.12);
    /* The drop line shows through where it crosses the copy. */
    opacity: 0.94;
    pointer-events: none;
    transform-origin: 24px 50%;
    will-change: transform;
}

.reorder-ghost > ul,
.reorder-ghost > ol {
    margin: 0;
    padding-left: 1.5rem;
}

.reorder-ghost > ul[data-type="taskList"] {
    padding-left: 0;
}

/* The drop line, its left end (a dot) at the depth the item would land. */
.reorder-line {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 401;
    height: 3px;
    margin-top: -1.5px;
    border-radius: 2px;
    background: var(--color-primary);
    pointer-events: none;
}

.reorder-line::before {
    content: "";
    position: absolute;
    left: -5px;
    top: -3.5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--color-primary);
    background: var(--color-surface);
    box-sizing: border-box;
}

@media (prefers-reduced-motion: reduce) {
    .tiptap.is-reordering > * {
        transition: none;
    }
}

/* Heading spacing */
.tiptap h1 {
    margin-top: 1rem;
    margin-bottom: 0.25rem;
}

.tiptap h2 {
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
}

.tiptap h3,
.tiptap h4,
.tiptap h5,
.tiptap h6 {
    margin-top: 0.5rem;
    margin-bottom: 0.125rem;
}

/* First heading should have no top margin */
.tiptap > h1:first-child,
.tiptap > h2:first-child,
.tiptap > h3:first-child,
.tiptap > h4:first-child,
.tiptap > h5:first-child,
.tiptap > h6:first-child {
    margin-top: 0;
}

/* Section collapse/expand */
.tiptap h1,
.tiptap h2,
.tiptap h3,
.tiptap h4,
.tiptap h5,
.tiptap h6 {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Heading content container - ensure cursor visibility in empty headings */
.heading-content {
    flex: 1;
    min-width: 1px; /* Prevents collapse when empty, allows cursor to be visible */
}

.section-toggle {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    color: var(--color-text-muted);
    transition:
        color 0.15s ease,
        background-color 0.15s ease;
}

.section-toggle:hover {
    background: var(--color-border);
    color: var(--color-text);
}

.section-toggle::before {
    content: "";
    width: 0;
    height: 0;
    border-left: 5px solid currentColor;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform 0.15s ease;
    transform: rotate(90deg);
}

.section-toggle.collapsed::before {
    transform: rotate(0deg);
}

.section-collapsed {
    opacity: 0.7;
}

/* Hidden section content (CSS-based hiding preserves Yjs sync) */
.section-content-hidden,
.tiptap .section-content-hidden,
.tiptap > .section-content-hidden {
    display: none !important;
}

/* Section content hiding is now managed by JavaScript via the
   section-content-hidden class. This allows proper hierarchical collapsing
   where sub-headings (and their content) are hidden when a parent heading
   is collapsed, but the next same-level heading is not affected. */

/* Connection status */
.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: default;
}

.connection-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.connection-status .status-dot.connected {
    background: var(--color-status-ok);
}

.connection-status .status-dot.connecting {
    background: var(--color-status-wait);
}

.connection-status .status-dot.syncing {
    background: var(--color-status-sync);
}

.connection-status .status-dot.disconnected {
    background: var(--color-status-error);
}

.connection-status .status-dot.offline {
    background: var(--color-status-off);
}

.connection-status .status-dot.unauthenticated {
    background: var(--color-status-error);
}

/* Re-auth modal (session expired) */
.reauth-modal {
    position: fixed;
    inset: 0;
    background: var(--color-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
}

.reauth-modal-dialog {
    background: var(--color-surface-raised);
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.reauth-modal-dialog h2 {
    margin: 0 0 0.75rem;
    font-size: 1.25rem;
}

.reauth-modal-dialog p {
    margin: 0 0 1.25rem;
    color: var(--color-text-secondary);
}

.reauth-modal-button {
    display: inline-block;
    background: var(--color-reauth);
    color: var(--color-on-primary);
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
}

.reauth-modal-button:hover,
.reauth-modal-button:focus {
    background: var(--color-reauth-hover);
}

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

/* Offline banner */
.offline-banner {
    background: var(--color-status-off);
    color: var(--color-on-status);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    text-align: center;
}

/* Utility classes */
.flex {
    display: flex;
}

.flex-gap {
    gap: 1rem;
}

.mt-1 {
    margin-top: 1rem;
}

.mt-2 {
    margin-top: 2rem;
}

.mb-1 {
    margin-bottom: 1rem;
}

.mb-2 {
    margin-bottom: 2rem;
}

.mb-3 {
    margin-bottom: 3rem;
}

.mt-3 {
    margin-top: 3rem;
}

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

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

/* Loading spinner */
.loading {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Keyboard shortcuts overlay */
.shortcuts-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.shortcuts-modal {
    background: var(--color-surface-raised);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    outline: none;
}

.shortcuts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.shortcuts-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.shortcuts-close {
    width: 2rem;
    height: 2rem;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        background-color 0.15s ease,
        color 0.15s ease;
}

.shortcuts-close:hover {
    background: var(--color-surface-sunken);
    color: var(--color-text);
}

.shortcuts-content {
    padding: 1rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.shortcuts-category {
    margin-bottom: 1.5rem;
}

.shortcuts-category:last-child {
    margin-bottom: 0;
}

.shortcuts-category-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

.shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.375rem 0;
}

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

.shortcut-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.375rem;
    background: var(--color-surface-hover);
    border: 1px solid var(--color-border-strong);
    border-radius: 4px;
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text);
}

/* "? Shortcuts" at the bottom left (the mic has the right): only where
   there's a keyboard, and only in check mode. */
.shortcuts-hint {
    display: none;
}

@media (hover: hover) and (pointer: fine) {
    .shortcuts-hint:not([hidden]) {
        position: fixed;
        left: calc(16px + env(safe-area-inset-left));
        bottom: calc(16px + env(safe-area-inset-bottom));
        z-index: 150;
        display: inline-flex;
        align-items: center;
        gap: 0.375rem;
        padding: 0.25rem 0.5rem 0.25rem 0.25rem;
        border: 0;
        border-radius: 8px;
        /* Legible over list text scrolling beneath it. */
        background: rgb(var(--color-bg-rgb) / 0.92);
        color: var(--color-text-meta);
        font: inherit;
        font-size: 0.8125rem;
        cursor: pointer;
        transition: color 0.15s ease;
    }

    .shortcuts-hint:hover {
        color: var(--color-text);
    }

    .shortcuts-hint:focus-visible {
        outline: 2px solid var(--color-primary);
        outline-offset: 2px;
    }

    .is-editing .shortcuts-hint:not([hidden]),
    .talk-open .shortcuts-hint:not([hidden]) {
        display: none;
    }
}

.shortcuts-hint .shortcut-key {
    min-width: 1.25rem;
    height: 1.25rem;
    background: var(--color-surface);
    border-bottom-width: 2px;
}

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

.shortcuts-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    text-align: center;
}

.shortcuts-footer .text-muted {
    font-size: 0.75rem;
}

.shortcuts-footer .shortcut-key {
    font-size: 0.625rem;
    min-width: 1.25rem;
    height: 1.25rem;
}

/* Date shortcuts */
.date-shortcut {
    text-decoration: underline dotted;
    text-decoration-color: var(--color-placeholder);
    text-underline-offset: 2px;
    cursor: default;
    user-select: none;
}

.date-shortcut:hover {
    text-decoration-color: var(--color-text-muted);
}

/* Date suggestion popup (autocomplete dropdown) */
.date-suggestion-popup {
    position: fixed;
    background: var(--color-surface-raised);
    border: 1px solid var(--color-border-strong);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    min-width: 240px;
}

.date-suggestion-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    gap: 16px;
}

.date-suggestion-item:first-child {
    border-radius: 7px 7px 0 0;
}

.date-suggestion-item:last-child {
    border-radius: 0 0 7px 7px;
}

.date-suggestion-item:hover,
.date-suggestion-item.selected {
    background: var(--color-suggestion-hover);
}

.date-suggestion-label {
    font-weight: 500;
    color: var(--color-text);
}

.date-suggestion-meta {
    display: flex;
    gap: 8px;
    align-items: center;
}

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

.date-suggestion-relative {
    color: var(--color-text-faint);
    font-size: 0.75rem;
    font-style: italic;
}

/* Responsive - Mobile styles */
@media (max-width: 640px) {
    /* iOS safe area support */
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .container {
        padding: 0 1rem;
    }

    header .container {
        padding: 0 1rem;
    }

    header {
        margin-bottom: 0;
        /* iOS safe area at top with minimum padding fallback, matching bottom padding */
        padding-top: max(1rem, env(safe-area-inset-top));
    }

    /* Smaller header title on mobile */
    header h1 {
        font-size: 1.125rem;
        max-width: 50vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Editable title on mobile - more compact */
    header h1[contenteditable] {
        padding: 0.125rem 0.25rem;
        margin: -0.125rem -0.25rem;
    }

    /* Breadcrumb - hide separator on mobile, just show home icon */
    .breadcrumb-separator {
        display: none;
    }

    .breadcrumb-back {
        width: 36px;
        height: 36px;
        padding: 0;
        margin: 0;
    }

    .breadcrumb-nav h1 {
        font-size: 1.125rem;
        max-width: 50vw;
    }

    /* Smaller nav gap on mobile */
    header nav {
        gap: 0.75rem;
    }

    main {
        border-radius: 0;
        box-shadow: none;
        padding: 0.5rem 1rem;
        margin: 0 -1rem;
    }

    .editor-content {
        border: none;
        padding: 0;
        border-radius: 0;
    }

    /* Task list on mobile - align checkbox with first line of text */
    .tiptap ul[data-type="taskList"] li {
        align-items: flex-start;
        gap: 0;
    }

    /* Larger touch targets for checkboxes (44px minimum tap area) */
    .tiptap ul[data-type="taskList"] li > label {
        display: flex;
        align-items: center;
        justify-content: center;
        /* Padding creates 44px touch target without visual spacing */
        padding: 12px;
        margin: -12px;
        margin-right: -6px;
        flex-shrink: 0;
        transform: none;
    }

    .tiptap ul[data-type="taskList"] li > label input[type="checkbox"] {
        width: 20px;
        height: 20px;
        margin: 0;
    }

    /* Remove paragraph margin inside task items so text aligns with checkbox */
    .tiptap ul[data-type="taskList"] li p {
        margin-bottom: 0;
    }

    /* Hide connection status text on mobile - just show dot */
    .connection-status .status-text {
        display: none;
    }

    .document-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .document-item-actions {
        width: 100%;
        justify-content: flex-end;
    }

    /* Larger buttons on mobile for touch */
    .btn {
        min-height: 44px;
        padding: 0.625rem 1rem;
    }

    .btn-small {
        min-height: 36px;
        padding: 0.5rem 0.75rem;
    }

    .btn-icon {
        width: 44px;
        height: 44px;
    }

    /* User avatar larger on mobile */
    .user-avatar {
        width: 36px;
        height: 36px;
    }

    /* Section toggle larger on mobile */
    .section-toggle {
        width: 44px;
        height: 44px;
        margin: -0.5rem;
        padding: 0.5rem;
    }

    /* Shortcuts modal full screen on mobile */
    .shortcuts-modal {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        height: 100%;
    }

    .shortcuts-overlay {
        padding: 0;
    }

    /* Date suggestion popup full width on mobile */
    .date-suggestion-popup {
        left: 1rem !important;
        right: 1rem !important;
        width: auto !important;
        min-width: auto;
    }

    /* Tiptap editor minimum height reduced on mobile */
    .tiptap {
        min-height: 200px;
    }
}

/*
 * Editor Toolbar (formatting buttons). Edit mode only (#186): fixed to the
 * bottom of the layout viewport and lifted above the on-screen keyboard by
 * --kb-inset (set from visualViewport in editor-toolbar.ts). On wide screens
 * with a mouse it floats as a centered bar instead.
 */
.editor-toolbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 160;
    display: none;
    align-items: center;
    gap: 0.25rem;
    background: var(--color-surface-raised);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
    padding: 0.25rem max(0.375rem, env(safe-area-inset-right))
        calc(0.25rem + env(safe-area-inset-bottom))
        max(0.375rem, env(safe-area-inset-left));
    transform: translateY(calc(-1 * var(--kb-inset, 0px)));
    will-change: transform;
}

.is-editing .editor-toolbar {
    display: flex;
}

/* The keyboard covers the home-indicator area, so drop the safe-area pad. */
.editor-toolbar[data-keyboard="true"] {
    padding-bottom: 0.25rem;
}

.editor-toolbar-tools {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.editor-toolbar-tools::-webkit-scrollbar {
    display: none;
}

/* More tools scroll into view: fade the right edge as a hint. */
.editor-toolbar-tools[data-more] {
    -webkit-mask-image: linear-gradient(to right, #000 85%, transparent);
    mask-image: linear-gradient(to right, #000 85%, transparent);
}

.editor-toolbar-btn {
    flex: none;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 0.5rem;
    font: inherit;
    font-size: 0.875rem;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--color-text);
    cursor: pointer;
    transition:
        background-color 0.15s ease,
        color 0.15s ease;
}

.editor-toolbar-btn:hover {
    background: var(--color-surface-subtle);
}

.editor-toolbar-btn.active {
    background: var(--color-active-bg);
    border-color: var(--color-active-border);
    color: var(--color-active-text);
}

.editor-toolbar-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.editor-toolbar-btn code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8125rem;
}

.editor-toolbar-separator {
    width: 1px;
    height: 1.25rem;
    background: var(--color-border-strong);
    flex-shrink: 0;
}

/* Done: a small check at the right end (#205). The toolbar only shows
   while editing, so it adds no clutter. */
.editor-toolbar-done {
    flex: none;
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--color-on-primary);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.editor-toolbar-done-mark {
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--color-primary);
}

.editor-toolbar-done-mark svg {
    width: 16px;
    height: 16px;
    display: block;
}

.editor-toolbar-done:hover .editor-toolbar-done-mark {
    filter: brightness(0.9);
}

.editor-toolbar-done:focus-visible,
.editor-toolbar-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
}

@media (pointer: coarse) {
    .editor-toolbar-btn {
        min-width: 44px;
        height: 44px;
        font-size: 1rem;
    }

    .editor-toolbar-done {
        width: 44px;
        height: 44px;
    }
}

@media (min-width: 641px) and (pointer: fine) {
    .editor-toolbar {
        left: 50%;
        right: auto;
        bottom: 1rem;
        max-width: calc(100vw - 2rem);
        padding: 0.25rem;
        border: 1px solid var(--color-border);
        border-radius: 12px;
        box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
        transform: translate(-50%, calc(-1 * var(--kb-inset, 0px)));
    }
}

/* Touch device specific - prevent text selection on interactive elements */
@media (hover: none) and (pointer: coarse) {
    .section-toggle,
    .user-avatar,
    .editor-toolbar-btn {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    /* Disable double-tap zoom on buttons */
    button,
    a.btn {
        touch-action: manipulation;
    }
}

/*
 * Talk it out (#207): the mic on day pages, the bottom sheet (talk.ts; a
 * centered dialog on wide screens) and the no-JS talk page, which share the
 * talk-* row and button styles.
 */
.talk-fab {
    position: fixed;
    right: calc(16px + env(safe-area-inset-right));
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 150;
    display: grid;
    place-items: center;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--color-primary);
    color: var(--color-on-primary);
    text-decoration: none;
    box-shadow:
        0 6px 18px rgb(var(--color-primary-rgb) / 0.32),
        0 2px 6px rgba(0, 0, 0, 0.14);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition:
        transform 0.12s ease,
        background-color 0.15s ease;
}

.talk-fab svg {
    width: 28px;
    height: 28px;
    display: block;
}

.talk-fab:hover {
    background: var(--color-primary-hover);
}

.talk-fab:active {
    transform: scale(0.94);
}

.talk-fab:focus-visible {
    outline: 3px solid var(--color-fab-ring);
    box-shadow: 0 0 0 5px var(--color-primary);
}

/* Offline: still opens (the text box saves a draft), but looks asleep. */
.talk-fab[data-offline] {
    background: var(--color-surface-raised);
    color: var(--talk-fab-offline);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
}

/* Unsorted words are saved. */
.talk-fab-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 14px;
    height: 14px;
    border: 2px solid var(--color-fab-ring);
    border-radius: 50%;
    background: var(--color-badge);
}

.talk-fab-badge[hidden] {
    display: none;
}

/* Never on top of the keyboard, or of its own sheet. */
.talk-fab[hidden],
.is-editing .talk-fab,
.talk-open .talk-fab {
    display: none;
}

/* Room under the last task, so the mic never covers it. */
body:has(.talk-fab) .editor-container {
    padding-bottom: 88px;
}

/* With the Undo footer shown, the footer is the page's last line and keeps
   the mic's room itself (.recent-undo), so the list needs only a little tap
   room below it (a tap there still edits at the end). Editing keeps its
   room for the toolbar and keyboard. */
body:not(.is-editing) .editor-container:has(+ .recent-undo:not([hidden])) {
    padding-bottom: 1.5rem;
}

/* The sheet */
.talk-sheet {
    position: fixed;
    inset: auto 0 var(--talk-kb, 0px) 0;
    margin: 0;
    width: 100%;
    max-width: 100%;
    max-height: calc(
        100dvh - var(--talk-kb, 0px) - max(24px, env(safe-area-inset-top))
    );
    padding: 0;
    border: 0;
    border-radius: 20px 20px 0 0;
    background: var(--color-surface-raised);
    color: var(--color-text-strong);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.18);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.talk-sheet::backdrop {
    background: var(--talk-backdrop);
}

.talk-sheet[open] {
    animation: talk-sheet-up 0.22s ease-out;
}

@keyframes talk-sheet-up {
    from {
        transform: translateY(24px);
        opacity: 0.4;
    }
}

.talk-sheet-inner {
    padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
}

.talk-grip {
    width: 40px;
    height: 5px;
    margin: 0 auto 6px;
    border-radius: 3px;
    background: var(--talk-grip);
}

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

.talk-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.125rem;
    font-weight: 650;
}

.talk-title svg {
    width: 22px;
    height: 22px;
    color: var(--color-primary);
    flex: none;
}

.talk-close {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-right: -10px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--color-text-meta);
    cursor: pointer;
}

.talk-close:hover {
    background: var(--talk-close-hover);
}

.talk-step {
    display: none;
}

.talk-sheet[data-step="compose"] .talk-step-compose,
.talk-sheet[data-step="recording"] .talk-step-compose,
.talk-sheet[data-step="thinking"] .talk-step-thinking,
.talk-sheet[data-step="review"] .talk-step-review,
.talk-sheet[data-step="error"] .talk-step-error {
    display: block;
}

/* Talk */
.talk-mic-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 6px 0 14px;
}

.talk-mic-row[hidden] {
    display: none;
}

.talk-mic {
    position: relative;
    display: grid;
    place-items: center;
    width: 80px;
    height: 80px;
    border: 0;
    border-radius: 50%;
    background: var(--color-primary);
    color: var(--color-on-primary);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition:
        background-color 0.15s ease,
        transform 0.12s ease;
}

.talk-mic:active {
    transform: scale(0.95);
}

.talk-mic-icon {
    display: grid;
    place-items: center;
}

.talk-mic-icon svg {
    width: 36px;
    height: 36px;
}

.talk-mic-stop {
    display: none;
}

.talk-mic-rings {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
}

.talk-sheet[data-step="recording"] .talk-mic {
    background: var(--color-record);
}

.talk-sheet[data-step="recording"] .talk-mic-start {
    display: none;
}

.talk-sheet[data-step="recording"] .talk-mic-stop {
    display: grid;
}

.talk-sheet[data-step="recording"] .talk-mic-rings {
    animation: talk-rings 1.6s ease-out infinite;
}

@keyframes talk-rings {
    0% {
        box-shadow: 0 0 0 0 rgb(var(--color-record-rgb) / 0.45);
    }
    100% {
        box-shadow: 0 0 0 22px rgb(var(--color-record-rgb) / 0);
    }
}

.talk-status {
    min-height: 1.4em;
    font-size: 0.9375rem;
    color: var(--color-text-meta-strong);
    text-align: center;
}

.talk-text {
    display: block;
    width: 100%;
    min-height: 8.5rem;
    max-height: 38vh;
    padding: 12px 14px;
    border: 1px solid var(--talk-field-border);
    border-radius: 12px;
    background: var(--talk-field-bg);
    color: inherit;
    /* 16px or more, or iOS zooms in on focus. */
    font: inherit;
    font-size: 1rem;
    line-height: 1.45;
    resize: vertical;
}

.talk-text:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: -1px;
    background: var(--talk-field-focus-bg);
}

.talk-text[readonly] {
    border-color: var(--talk-rec-border);
    background: var(--talk-rec-bg);
}

.talk-hint {
    margin: 6px 2px 0;
    font-size: 0.8125rem;
    color: var(--color-text-meta);
}

.talk-hint.is-notice {
    color: var(--talk-notice);
}

.talk-label {
    display: block;
    margin: 0 2px 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-meta-strong);
}

.talk-actions {
    margin-top: 14px;
}

.talk-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 52px;
    padding: 0 16px;
    border: 0;
    border-radius: 14px;
    background: var(--color-primary);
    color: var(--color-on-primary);
    font: inherit;
    font-size: 1.0625rem;
    font-weight: 650;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.talk-primary:hover {
    background: var(--color-primary-hover);
}

.talk-primary:disabled {
    background: var(--talk-primary-disabled);
    color: var(--talk-primary-disabled-text);
    cursor: default;
}

.talk-primary[hidden] {
    display: none;
}

.talk-secondary {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0 4px;
    margin-top: 6px;
}

.talk-secondary form {
    display: contents;
}

.talk-link-btn {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--color-link);
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 550;
    text-decoration: none;
    cursor: pointer;
}

.talk-link-btn:hover {
    background: var(--talk-link-hover);
}

.talk-link-btn[hidden] {
    display: none;
}

/* Thinking */
.talk-step-thinking {
    padding: 22px 0 6px;
    text-align: center;
}

.talk-spinner {
    display: block;
    width: 38px;
    height: 38px;
    margin: 0 auto 14px;
    border: 3px solid var(--talk-spinner-track);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: talk-spin 0.8s linear infinite;
}

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

.talk-thinking {
    font-size: 1.0625rem;
    font-weight: 600;
}

.talk-step-thinking .talk-hint {
    max-width: 22rem;
    margin: 6px auto 0;
}

/* Review */
.talk-summary {
    margin: 0 2px 12px;
    font-size: 0.9375rem;
    color: var(--color-text-body);
}

.talk-summary[hidden],
.talk-note[hidden] {
    display: none;
}

.talk-note {
    margin: 6px 2px 10px;
    font-size: 0.9375rem;
    color: var(--color-text-meta-strong);
}

.talk-group + .talk-group {
    margin-top: 14px;
}

.talk-group-label {
    margin: 0 4px 6px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--talk-label-faint);
}

.talk-rows {
    list-style: none;
    border: 1px solid var(--talk-rows-border);
    border-radius: 14px;
    background: var(--talk-rows-bg);
    overflow: hidden;
}

.talk-row + .talk-row {
    border-top: 1px solid var(--color-divider-soft);
}

/* The whole row is the toggle. */
.talk-row-hit {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-height: 56px;
    padding: 13px 14px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.talk-row-hit:active {
    background: var(--talk-row-press);
}

.talk-toggle {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.talk-check {
    flex: none;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    margin-top: -1px;
    border: 2px solid var(--talk-check-border);
    border-radius: 8px;
    background: var(--talk-rows-bg);
    color: transparent;
    transition:
        background-color 0.12s ease,
        border-color 0.12s ease;
}

.talk-check svg {
    width: 18px;
    height: 18px;
}

.talk-toggle:checked + .talk-check {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: var(--color-on-primary);
}

.talk-toggle:focus-visible + .talk-check {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.talk-verb {
    flex: none;
    width: 22px;
    height: 22px;
    margin-top: 1px;
    color: var(--talk-verb);
}

.talk-verb svg {
    display: block;
    width: 22px;
    height: 22px;
}

.talk-verb[data-kind="add_task"] {
    color: var(--talk-verb-add);
}

.talk-verb[data-kind="complete_task"] {
    color: var(--talk-verb-complete);
}

.talk-verb[data-kind="pull_task"] {
    color: var(--talk-verb-pull);
}

.talk-verb[data-kind="move_task"] {
    color: var(--talk-verb-move);
}

.talk-verb[data-kind="add_to_note"] {
    color: var(--talk-verb-note);
}

.talk-row-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.talk-row-text {
    font-size: 1rem;
    line-height: 1.35;
    color: var(--color-text-strong);
    overflow-wrap: anywhere;
}

.talk-row-meta {
    font-size: 0.8125rem;
    color: var(--color-text-meta);
}

.talk-new {
    display: inline-block;
    padding: 0 6px;
    border-radius: 6px;
    background: var(--talk-new-bg);
    color: var(--talk-new-text);
    font-size: 0.75rem;
    font-weight: 600;
}

.talk-row-children {
    margin: 4px 0 0 1.1rem;
    font-size: 0.875rem;
    color: var(--color-text-meta-strong);
}

/* Off: still readable, clearly not going in. */
.talk-toggle:not(:checked) ~ .talk-verb,
.talk-toggle:not(:checked) ~ .talk-row-body {
    opacity: 0.45;
}

.talk-dropped {
    margin-top: 12px;
    font-size: 0.875rem;
    color: var(--color-text-meta);
}

.talk-dropped[hidden] {
    display: none;
}

.talk-dropped summary {
    padding: 12px 4px;
    cursor: pointer;
}

.talk-dropped ul {
    margin: 0 0 4px 1.25rem;
}

.talk-dropped-text {
    color: var(--color-text-body);
}

.talk-error,
.talk-inline-error {
    margin: 10px 2px 0;
    font-size: 0.9375rem;
    color: var(--talk-error);
}

/* Not an error wall: plain words, then the way forward. */
.talk-step-error .talk-error {
    margin: 8px 2px 4px;
    font-size: 1rem;
    color: var(--color-text-strong);
}

/* Add stays in reach while the list scrolls. */
.talk-step-review .talk-actions {
    position: sticky;
    bottom: 0;
    z-index: 1;
    margin-top: 6px;
    padding: 14px 0 10px;
    background: linear-gradient(rgb(var(--color-sheet-rgb) / 0), rgb(var(--color-sheet-rgb)) 12px);
}

.talk-inline-error[hidden] {
    display: none;
}

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

/* The no-JS talk page */
.talk-panel {
    max-width: 560px;
    margin: 12px auto 0;
    padding: 16px;
    border-radius: 16px;
    background: var(--color-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.talk-day-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--color-link);
    text-decoration: none;
    font-weight: 550;
}

.talk-edit {
    margin-top: 14px;
}

.talk-edit summary {
    padding: 12px 0;
    color: var(--color-link);
    font-weight: 550;
    cursor: pointer;
}

.talk-page .talk-compose {
    margin-top: 6px;
}

@media (min-width: 641px) {
    .talk-sheet {
        inset: 0;
        margin: auto;
        width: min(520px, calc(100vw - 32px));
        max-height: min(760px, calc(100vh - 64px));
        border-radius: 18px;
        box-shadow: 0 24px 64px rgba(0, 0, 0, 0.24);
    }

    .talk-sheet-inner {
        padding: 14px 20px 20px;
    }

    .talk-grip {
        display: none;
    }

    @keyframes talk-sheet-up {
        from {
            transform: translateY(12px) scale(0.98);
            opacity: 0;
        }
    }
}

@media (prefers-reduced-motion: reduce) {
    .talk-sheet[open],
    .talk-sheet[data-step="recording"] .talk-mic-rings {
        animation: none;
    }

    .talk-spinner {
        animation-duration: 2.4s;
    }
}

/*
 * Undo later (#219): the day page's quiet footer line (only while a recent
 * bulk change is undoable), the Recent changes list (a sheet with JS, a plain
 * page without), and the talk sheet's "Last added" row.
 */
.recent-undo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    /* Room below, so scrolled to the end it sits above the talk mic (60px,
       16px from the bottom): a phone's page has only 8px under main. */
    margin: 20px auto 56px;
    padding: 0 4px;
    color: var(--color-text-meta);
    font-size: 0.875rem;
    text-align: center;
}

/* Wider screens already have 64px under it (main's and the container's
   padding), which clears the mic. */
@media (min-width: 641px) {
    .recent-undo {
        margin-bottom: 16px;
    }
}

.recent-undo[hidden] {
    display: none;
}

.recent-undo-line {
    display: block;
}

.recent-undo-icon {
    display: inline-block;
    margin-right: 4px;
    vertical-align: -3px;
}

.recent-undo-icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

.recent-undo-text {
    margin-right: 2px;
}

.recent-undo-btn {
    min-height: 44px;
    padding: 0 6px;
    margin: -10px 0;
    border: 0;
    background: transparent;
    color: var(--color-link);
    font: inherit;
    font-weight: 650;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.recent-undo-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.recent-undo-more {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    color: var(--color-text-meta);
    font-size: 0.8125rem;
    text-decoration: none;
}

.recent-undo-more:hover,
.recent-undo-btn:hover {
    text-decoration: underline;
}

.changes-panel {
    max-width: 560px;
    margin: 12px auto 0;
    padding: 16px;
    border-radius: 16px;
    background: var(--color-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

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

.changes-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.125rem;
    font-weight: 650;
}

.changes-title svg {
    width: 22px;
    height: 22px;
    color: var(--color-primary);
}

.changes-back {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--color-link);
    font-weight: 550;
    text-decoration: none;
}

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

.changes-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 8px 0;
    border-top: 1px solid var(--color-divider-soft);
}

.changes-row:first-child {
    border-top: 0;
}

.changes-row-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.changes-label {
    color: var(--color-text-strong);
    font-weight: 550;
}

.changes-row[data-status="undone"] .changes-label,
.changes-row[data-status="partial"] .changes-label,
.changes-row[data-status="refused"] .changes-label {
    color: var(--color-text-meta);
}

.changes-meta {
    color: var(--color-text-meta);
    font-size: 0.8125rem;
}

.changes-row form {
    flex: none;
}

.changes-undo {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 40px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: rgb(var(--color-primary-rgb) / 0.1);
    color: var(--color-link-strong);
    font: inherit;
    font-weight: 650;
    cursor: pointer;
    touch-action: manipulation;
}

.changes-undo:disabled {
    opacity: 0.5;
    cursor: default;
}

.changes-undo svg {
    width: 18px;
    height: 18px;
}

.changes-state {
    flex: none;
    color: var(--color-text-state);
    font-size: 0.875rem;
}

.changes-empty,
.changes-hint {
    color: var(--color-text-meta);
    font-size: 0.8125rem;
}

.changes-empty {
    padding: 16px 0;
}

.changes-empty[hidden] {
    display: none;
}

.changes-hint {
    margin-top: 10px;
}

.changes-open .talk-fab {
    visibility: hidden;
}

.talk-last {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 2px 0 10px;
    padding: 2px 4px 2px 12px;
    border-radius: 12px;
    background: var(--talk-last-bg);
    color: var(--color-text-meta-strong);
    font-size: 0.875rem;
}

.talk-last[hidden] {
    display: none;
}

.talk-last-icon {
    display: inline-flex;
    flex: none;
}

.talk-last-icon svg {
    width: 16px;
    height: 16px;
}

.talk-last-text {
    flex: 1;
    min-width: 0;
}

.talk-last-undo {
    flex: none;
    min-height: 40px;
    padding: 0 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--color-link);
    font: inherit;
    font-weight: 650;
    cursor: pointer;
    touch-action: manipulation;
}

.talk-last-undo[hidden] {
    display: none;
}

.talk-last-undo:disabled {
    opacity: 0.5;
}
