/* CSS Variables */
:root {
    --color-primary: #007bff;
    --color-primary-hover: #0056b3;
}

/* 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: #333;
    background-color: #f5f5f5;
    min-height: 100vh;
}

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

/* Header */
header {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    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 #007bff;
    outline-offset: 0;
}

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

header nav a {
    color: #666;
    text-decoration: none;
}

header nav a:hover {
    color: #333;
}

header nav span {
    color: #666;
}

/* 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: #666;
    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: #007bff;
    background: rgba(0, 123, 255, 0.08);
}

.breadcrumb-back:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.3);
    color: #007bff;
}

.breadcrumb-back:focus-visible {
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.5);
}

.breadcrumb-back:active {
    background: rgba(0, 123, 255, 0.15);
}

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

.breadcrumb-separator {
    color: #ccc;
    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: #007bff;
    color: #fff;
    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: #0056b3;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    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 #e0e0e0;
    font-size: 0.875rem;
    color: #666;
    word-break: break-all;
}

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

.user-dropdown-item:hover {
    background: #f5f5f5;
}

/* Main content */
main {
    background: #fff;
    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: #007bff;
    color: #fff;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #fff;
    color: #333;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background: #f5f5f5;
}

.btn-danger {
    background: #dc3545;
    color: #fff;
}

.btn-danger:hover {
    background: #c82333;
}

.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: #666;
    cursor: pointer;
    border-radius: 4px;
    transition:
        color 0.15s ease,
        background-color 0.15s ease;
}

.btn-icon:hover {
    color: #dc3545;
    background: rgba(220, 53, 69, 0.1);
}

.btn-icon:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.3);
}

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

.btn-google {
    background: #fff;
    color: #333;
    border: 1px solid #ddd;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-google:hover {
    background: #f5f5f5;
}

.btn-github {
    background: #1f2328;
    color: #fff;
    border: 1px solid #1f2328;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-github:hover {
    background: #32383f;
    border-color: #32383f;
}

.btn-github:focus-visible {
    outline: 2px solid #1f2328;
    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 #ddd;
    border-radius: 6px;
    font-size: 1rem;
    background: #fff;
}

.form-group select {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    background: #fff;
    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: #007bff;
}

.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: #d4edda;
    color: #155724;
}

.messages .error {
    background: #f8d7da;
    color: #721c24;
}

.messages .warning {
    background: #fff3cd;
    color: #856404;
}

.messages .info {
    background: #cce5ff;
    color: #004085;
}

.errorlist {
    color: #721c24;
    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 #ddd;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
}

.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: #fff;
    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: #dc3545;
}

.auth-page main button.danger:hover {
    background: #c82333;
}

/* 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 #ddd;
    border-radius: 6px;
    background: #fff;
    color: #333;
    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: #f5f5f5;
    text-decoration: none;
}

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

.auth-page main ul.provider-list a.provider-github {
    background: #1f2328;
    border-color: #1f2328;
    color: #fff;
}

.auth-page main ul.provider-list a.provider-github:hover {
    background: #32383f;
    border-color: #32383f;
}

/* 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 #e0e0e0;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    background: #fff;
    transition: border-color 0.15s ease;
}

.document-item:hover {
    border-color: #007bff;
}

.document-item a {
    color: #333;
    text-decoration: none;
    font-weight: 500;
    flex: 1;
}

.document-item a:hover {
    color: #007bff;
}

.document-item .document-meta {
    color: #666;
    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: #666;
}

.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: #666;
    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 rgba(0, 123, 255, 0.5);
}

.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: #666;
    text-decoration: none;
    transition:
        color 0.15s ease,
        background-color 0.15s ease;
}

a.day-nav-btn:hover {
    color: var(--color-primary);
    background: rgba(0, 123, 255, 0.08);
}

a.day-nav-btn:active {
    background: rgba(0, 123, 255, 0.15);
}

a.day-nav-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.5);
}

.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: #666;
}

.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: #666;
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.week-day:hover {
    background: rgba(0, 123, 255, 0.06);
}

.week-day:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.5);
}

.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: #333;
    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: #9a9a9a;
}

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

.week-day.has-leftover .week-day-dot {
    background: #c27014;
}

.week-day.is-selected {
    background: #f5f5f5;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.06),
        0 0 0 1px #e0e0e0;
}

/* 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: #999;
}

.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: rgba(0, 0, 0, 0.06);
}

.routine-check:focus-visible .routine-gutter {
    box-shadow: inset 0 0 0 2px var(--color-primary);
}

@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: #fff;
}

.routine-item[data-checked="true"] .routine-text {
    text-decoration: line-through;
    color: #666;
}

/* "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: #a3a3a3;
}

.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: #fff;
        border: 1px solid #e0e0e0;
        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: #fff;
    border: 1px solid #e0e0e0;
    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: #fdf0de;
    color: #9a5a0f;
    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: #888;
}

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

.from-earlier .fe-all:active,
.from-earlier .fe-min:active {
    background: #f0f0f0;
}

.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: #777;
    text-decoration: none;
}

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

.fe-row + .fe-row {
    border-top: 1px solid #f0f0f0;
}

.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: #f0f0f0;
}

.fe-box {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border: 2px solid #8a9099;
    border-radius: 6px;
    background: #fff;
    color: transparent;
}

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

@media (hover: hover) {
    .fe-check:hover .fe-box {
        border-color: var(--color-primary);
        color: rgba(0, 123, 255, 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: #f0f0f0;
}

.fe-ctx,
.fe-sub {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.78rem;
    color: #777;
}

.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: rgba(0, 123, 255, 0.1);
    color: #0062cc;
}

.from-earlier .fe-letgo {
    margin-right: 2px;
    background: #f2f2f2;
    color: #666;
}

.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 rgba(0, 123, 255, 0.5);
}

.fe-more {
    padding: 0.5rem 0.625rem 0;
    font-size: 0.8125rem;
    color: #777;
}

/* 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: #888;
}

/* 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: #fdf0de;
    color: #9a5a0f;
    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: #5a6b80;
}

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

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

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

.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: #5a6b80;
    -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: #e8f2ff;
    color: #0b3d75;
}

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

.new-day-link {
    font-weight: 700;
    color: #0062cc;
    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: #e8f2ff;
    color: #0b3d75;
}

.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: rgba(0, 123, 255, 0.12);
    color: #0062cc;
    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: #222;
    color: #fff;
    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: rgba(255, 255, 255, 0.16);
    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: #8a8a8a;
}

.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: #8a8a8a;
}

.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: #777;
    white-space: nowrap;
    text-decoration: underline;
    text-decoration-color: #ccc;
    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: rgba(0, 123, 255, 0.14);
        box-shadow: 0 0 0 6px rgba(0, 123, 255, 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: rgba(0, 123, 255, 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 #e0e0e0;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    background: #fff;
}

.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 #e0e0e0;
    border-radius: 6px;
    padding: 1rem;
    background: #fff;
}

.editor-content:focus {
    outline: none;
    border-color: #007bff;
}

/* 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: #666;
}

/*
 * 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);
}

.task-gutter:focus-visible {
    box-shadow: inset 0 0 0 2px var(--color-primary);
}

/* Forced colors drop box shadows: keep the focus ring as an outline. */
@media (forced-colors: active) {
    .task-gutter:focus-visible,
    .routine-check:focus-visible .routine-gutter {
        outline: 2px solid CanvasText;
        outline-offset: -2px;
    }
}

.task-gutter:active {
    background: rgba(0, 0, 0, 0.06);
}

.task-box,
.routine-box {
    width: var(--task-box);
    height: var(--task-box);
    flex: none;
    display: grid;
    place-items: center;
    border: 2px solid #8a9099;
    border-radius: 5px;
    background: #fff;
    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: #fff;
}

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

/*
 * 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: #fff;
    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: #fff;
    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: #666;
    transition:
        color 0.15s ease,
        background-color 0.15s ease;
}

.section-toggle:hover {
    background: #e0e0e0;
    color: #333;
}

.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: #28a745;
}

.connection-status .status-dot.connecting {
    background: #ffc107;
}

.connection-status .status-dot.syncing {
    background: #17a2b8;
}

.connection-status .status-dot.disconnected {
    background: #dc3545;
}

.connection-status .status-dot.offline {
    background: #6c757d;
}

.connection-status .status-dot.unauthenticated {
    background: #dc3545;
}

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

.reauth-modal-dialog {
    background: #fff;
    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: #555;
}

.reauth-modal-button {
    display: inline-block;
    background: #0070f3;
    color: #fff;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
}

.reauth-modal-button:hover,
.reauth-modal-button:focus {
    background: #0060d3;
}

.connection-status .status-text {
    color: #666;
}

/* Offline banner */
.offline-banner {
    background: #6c757d;
    color: #fff;
    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: #666;
}

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

/* Loading spinner */
.loading {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid #e0e0e0;
    border-top-color: #007bff;
    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: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.shortcuts-modal {
    background: #fff;
    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 #e0e0e0;
}

.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: #666;
    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: #f0f0f0;
    color: #333;
}

.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: #666;
    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: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    color: #333;
}

.shortcut-description {
    color: #666;
    font-size: 0.875rem;
}

.shortcuts-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e0e0e0;
    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: #999;
    text-underline-offset: 2px;
    cursor: default;
    user-select: none;
}

.date-shortcut:hover {
    text-decoration-color: #666;
}

/* Date suggestion popup (autocomplete dropdown) */
.date-suggestion-popup {
    position: fixed;
    background: white;
    border: 1px solid #ddd;
    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: #f0f7ff;
}

.date-suggestion-label {
    font-weight: 500;
    color: #333;
}

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

.date-suggestion-date {
    color: #666;
    font-size: 0.875rem;
}

.date-suggestion-relative {
    color: #888;
    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: #fff;
    border-top: 1px solid #e0e0e0;
    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: #333;
    cursor: pointer;
    transition:
        background-color 0.15s ease,
        color 0.15s ease;
}

.editor-toolbar-btn:hover {
    background: #f2f2f2;
}

.editor-toolbar-btn.active {
    background: #e3f2fd;
    border-color: #90caf9;
    color: #1976d2;
}

.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: #ddd;
    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: #fff;
    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 #e0e0e0;
        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: #fff;
    text-decoration: none;
    box-shadow:
        0 6px 18px rgba(0, 123, 255, 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 #fff;
    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: #fff;
    color: #8a929b;
    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 #fff;
    border-radius: 50%;
    background: #f59f00;
}

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

/* 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: #fff;
    color: #1f2328;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.18);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.talk-sheet::backdrop {
    background: rgba(17, 24, 39, 0.38);
}

.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: #d9dce1;
}

.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: #6b7280;
    cursor: pointer;
}

.talk-close:hover {
    background: #f2f4f7;
}

.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: #fff;
    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: #e03131;
}

.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 rgba(224, 49, 49, 0.45);
    }
    100% {
        box-shadow: 0 0 0 22px rgba(224, 49, 49, 0);
    }
}

.talk-status {
    min-height: 1.4em;
    font-size: 0.9375rem;
    color: #4b5563;
    text-align: center;
}

.talk-text {
    display: block;
    width: 100%;
    min-height: 8.5rem;
    max-height: 38vh;
    padding: 12px 14px;
    border: 1px solid #d0d5dd;
    border-radius: 12px;
    background: #fafbfc;
    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: #fff;
}

.talk-text[readonly] {
    border-color: #f3c4c4;
    background: #fffafa;
}

.talk-hint {
    margin: 6px 2px 0;
    font-size: 0.8125rem;
    color: #6b7280;
}

.talk-hint.is-notice {
    color: #9a4f00;
}

.talk-label {
    display: block;
    margin: 0 2px 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #4b5563;
}

.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: #fff;
    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: #c4d3e6;
    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: #0b5ed7;
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 550;
    text-decoration: none;
    cursor: pointer;
}

.talk-link-btn:hover {
    background: #f0f5ff;
}

.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 #dbe6f5;
    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: #374151;
}

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

.talk-note {
    margin: 6px 2px 10px;
    font-size: 0.9375rem;
    color: #4b5563;
}

.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: #7b8490;
}

.talk-rows {
    list-style: none;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    background: #fff;
    overflow: hidden;
}

.talk-row + .talk-row {
    border-top: 1px solid #eef0f3;
}

/* 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: #f7f9fc;
}

.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 #c3c8cf;
    border-radius: 8px;
    background: #fff;
    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: #fff;
}

.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: #5c6670;
}

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

.talk-verb[data-kind="add_task"] {
    color: #1c6fd1;
}

.talk-verb[data-kind="complete_task"] {
    color: #2b8a3e;
}

.talk-verb[data-kind="pull_task"] {
    color: #7048e8;
}

.talk-verb[data-kind="move_task"] {
    color: #c26a00;
}

.talk-verb[data-kind="add_to_note"] {
    color: #0c8599;
}

.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: #1f2328;
    overflow-wrap: anywhere;
}

.talk-row-meta {
    font-size: 0.8125rem;
    color: #6b7280;
}

.talk-new {
    display: inline-block;
    padding: 0 6px;
    border-radius: 6px;
    background: #eef4ff;
    color: #1d4ed8;
    font-size: 0.75rem;
    font-weight: 600;
}

.talk-row-children {
    margin: 4px 0 0 1.1rem;
    font-size: 0.875rem;
    color: #4b5563;
}

/* 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: #6b7280;
}

.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: #374151;
}

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

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

/* 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(rgba(255, 255, 255, 0), #fff 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: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

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

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

.talk-edit summary {
    padding: 12px 0;
    color: #0b5ed7;
    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. */
    margin: 20px auto 56px;
    padding: 0 4px;
    color: #6b7280;
    font-size: 0.875rem;
    text-align: center;
}

.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: #0b5ed7;
    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: #6b7280;
    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: #fff;
    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: #0b5ed7;
    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 #eef0f3;
}

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

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

.changes-label {
    color: #1f2328;
    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: #6b7280;
}

.changes-meta {
    color: #6b7280;
    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: rgba(0, 123, 255, 0.1);
    color: #0062cc;
    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: #8a8f98;
    font-size: 0.875rem;
}

.changes-empty,
.changes-hint {
    color: #6b7280;
    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: #f3f5f8;
    color: #4b5563;
    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: #0b5ed7;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
    touch-action: manipulation;
}

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

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