/* CoS inbox.
   Layout borrows the two things GTD task managers (OmniFocus, Todoist) get right: a left
   PERSPECTIVE sidebar with a badge per list, and a row whose left edge is a status circle you
   click to finish. The middle stays CoS's own: a dense, alignment-first table, keyboard-driven,
   monospace only where columns must line up. */

:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-sunken: #eef1f4;
    --sidebar: #f0f2f5;
    --border: #e4e7ec;
    --border-strong: #cfd4db;
    --text: #1a1e24;
    --muted: #5b616b;
    --faint: #949aa3;

    --accent: #2c8059;
    --accent-strong: #1f6044;
    --accent-weak: #e7f2ec;

    --danger: #c23b34;
    --danger-weak: #fbeceb;
    --warn: #a9750f;
    --warn-weak: #f6efdc;

    --row-hover: #f4f5f7;

    --shadow-sm: 0 1px 2px rgba(20, 24, 30, 0.05);
    --shadow-panel: 0 1px 2px rgba(20, 24, 30, 0.04), 0 8px 24px -12px rgba(20, 24, 30, 0.14);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-pill: 999px;

    --font-ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Aptos", sans-serif;
    --font-mono: "Cascadia Mono", Consolas, ui-monospace, "SF Mono", monospace;

    --size-base: 16px;
    --sidebar-w: 15.5rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1216;
        --surface: #171b21;
        --surface-sunken: #12161c;
        --sidebar: #12151a;
        --border: #262c35;
        --border-strong: #363e49;
        --text: #e6e9ec;
        --muted: #99a1ac;
        --faint: #667080;

        --accent: #58c491;
        --accent-strong: #7ad3a8;
        --accent-weak: #182720;

        --danger: #e88580;
        --danger-weak: #2a1b1b;
        --warn: #d9a441;
        --warn-weak: #292315;

        --row-hover: #1d222a;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-panel: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px -12px rgba(0, 0, 0, 0.6);
    }
}

:root[data-font="console"] {
    --font-ui: "Cascadia Code", "Cascadia Mono", Consolas, ui-monospace, monospace;
    --font-mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
}

:root[data-font="system"] {
    --font-ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-mono: "Cascadia Mono", Consolas, ui-monospace, "SF Mono", monospace;
}

:root[data-font="aptos"] {
    --font-ui: "Aptos", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
    --font-mono: "Aptos Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;
    --size-base: 17px;
}

:root[data-font="sitka"] {
    --font-ui: "Sitka Text", Georgia, "Times New Roman", serif;
    --font-mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
    --size-base: 17px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: var(--size-base);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* App shell: sidebar + content ---------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    color: var(--text);
    padding: 1.1rem 1.15rem 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.brand::before {
    content: "";
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 4px;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-weak);
}

/* Perspectives */
.perspectives { display: flex; flex-direction: column; gap: 0.1rem; padding: 0.35rem 0.5rem; }

.perspectives hr { border: none; border-top: 1px solid var(--border); margin: 0.5rem 0.4rem; }

.persp {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.45rem 0.65rem;
    border-radius: var(--radius-sm);
    color: var(--muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background 0.12s ease, color 0.12s ease;
}

.persp:hover { background: var(--row-hover); color: var(--text); }
.persp.active { background: var(--accent-weak); color: var(--accent-strong); font-weight: 600; }

.persp-icon { width: 1.25rem; text-align: center; font-size: 0.95rem; flex-shrink: 0; }
.persp-label { flex: 1 1 auto; }

.persp .badge {
    font-size: 0.72rem;
    font-family: var(--font-mono);
    background: var(--surface-sunken);
    color: var(--muted);
    border-radius: var(--radius-pill);
    padding: 0.02rem 0.45rem;
    min-width: 1.4rem;
    text-align: center;
}

.persp.active .badge { background: var(--accent); color: #fff; }
.persp .badge:empty, .persp .badge.zero { display: none; }

@media (prefers-color-scheme: dark) {
    .persp.active .badge { color: #0f1216; }
}

.sidebar-foot { margin-top: auto; padding: 0.6rem 0.75rem 1rem; }

.content {
    flex: 1 1 auto;
    min-width: 0;
    padding: 1.15rem 1.5rem 3rem;
    max-width: 70rem;
}

/* Table views (Inbox/Next/Waiting/Someday/Agenda/Review) use the full width - a dense queue
   wants the room, and long titles get more before they clip. Briefs stay narrow for reading. */
.content.wide { max-width: 120rem; }

/* Content head: view title + logout */
.view-head {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 1rem;
}

.view-title { font-size: 1.5rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.view-head .logout-form { margin-left: auto; }

.linkish {
    font: inherit;
    font-size: 0.8rem;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 0.3rem 0.4rem;
    border-radius: var(--radius-sm);
    transition: color 0.12s ease, background 0.12s ease;
}

.linkish:hover { color: var(--text); background: var(--row-hover); }

/* Connector health + view controls ------------------------------------------------------ */
.statusbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.8rem;
}

.statusbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.statusbar-right form { margin: 0; }

.status {
    display: inline-flex;
    gap: 0.45rem;
    align-items: center;
    padding: 0.28rem 0.7rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    box-shadow: var(--shadow-sm);
}

.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status strong { text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.72rem; color: var(--text); }
.status-ok { color: var(--accent); }
.status-warn { color: var(--warn); background: var(--warn-weak); border-color: transparent; }
.status-error { color: var(--danger); background: var(--danger-weak); border-color: transparent; }

.fontpicker {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    font-size: 0.75rem;
    background: var(--surface-sunken);
    border-radius: var(--radius-pill);
    padding: 0.15rem;
}

.fontpicker-label { color: var(--faint); margin: 0 0.35rem 0 0.5rem; }

.fontpicker button {
    font: inherit;
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border: none;
    border-radius: var(--radius-pill);
    background: none;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.fontpicker button:hover { color: var(--text); }
.fontpicker button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.alert {
    border: 1px solid transparent;
    border-left: 3px solid var(--danger);
    border-radius: var(--radius-sm);
    background: var(--danger-weak);
    padding: 0.7rem 0.9rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--danger);
}

.alert-detail { margin-top: 0.3rem; font-size: 0.8rem; opacity: 0.85; word-break: break-word; }

/* The queue ----------------------------------------------------------------------------- */
.queue-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-panel);
    overflow: hidden;
}

/* table-layout: fixed so the declared column widths hold and the title column takes the rest
   with a clean ellipsis - without it, a long unbroken title stretches the table past the panel,
   pushing Stav/Stáří off the clipped edge and cutting the title with no "...". */
.queue { width: 100%; border-collapse: collapse; table-layout: fixed; font-variant-numeric: tabular-nums; }

.queue thead th {
    text-align: left;
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--faint);
    padding: 0.7rem 0.65rem;
    background: var(--surface-sunken);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.queue tbody td { padding: 0.5rem 0.65rem; border: none; vertical-align: middle; transition: background 0.1s ease; }

.item { cursor: default; }
.item td { border-bottom: 1px solid var(--border); }
.item:hover td { background: var(--row-hover); }
/* The selected row merges visually with its action row below, so drop the divider there. */
.item.selected td { background: var(--accent-weak); border-bottom-color: transparent; }

/* Status circle: click to finish, coloured by urgency. Borrowed from Todoist/OmniFocus. */
.col-check { width: 2.2rem; text-align: center; padding-left: 0.7rem !important; }
.col-check form { margin: 0; display: inline-flex; }

.check {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border-strong);
    background: transparent;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    font-size: 12px;
    line-height: 1;
    transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.check::after { content: "✓"; }
.check:hover { border-color: var(--accent); background: var(--accent-weak); color: var(--accent-strong); }
.item.urgency-overdue .check { border-color: var(--danger); }
.item.urgency-today .check { border-color: var(--warn); }
.item.urgency-overdue .check:hover, .item.urgency-today .check:hover { border-color: var(--accent); }

/* Due date as a coloured pill. */
.due-pill {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.82em;
    padding: 0.05rem 0.45rem;
    border-radius: var(--radius-pill);
    background: var(--surface-sunken);
    color: var(--muted);
    white-space: nowrap;
}

.urgency-overdue .due-pill { background: var(--danger-weak); color: var(--danger); font-weight: 600; }
.urgency-today .due-pill { background: var(--warn-weak); color: var(--warn); font-weight: 600; }
.col-due { width: 5.5rem; }
.nil { color: var(--faint); }

/* Odkaz is shown in full - never truncated - so a sender name or ticket ref stays readable;
   long ones wrap within the fixed column rather than clipping. */
.col-ref {
    width: 18rem;
    font-family: var(--font-mono);
    font-size: 0.9em;
    white-space: normal;
    overflow-wrap: anywhere;
    color: var(--muted);
}

/* Source icon: a small brand glyph per connector, so a glance down the column tells mail from
   Jira. SVG symbols are defined once per page (the sprite in _Queue) and referenced here. */
.src-ico { display: inline-flex; vertical-align: middle; margin-right: 0.5rem; }
.src-ico svg { width: 15px; height: 15px; display: block; }

/* The old colour dot is still used by the agenda's slots. */
.src { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 0.5rem; vertical-align: middle; background: var(--faint); }
.src-jira { background: #4d84d6; }
.src-fellow { background: #b46fd0; }
.src-mail { background: #d09a4a; }
.src-manual { background: var(--faint); }

.col-title { width: auto; }

.col-title a, .col-title > span {
    color: var(--text);
    text-decoration: none;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    font-variant-ligatures: none;
}

.col-title a:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }

.col-meta { width: 13rem; color: var(--muted); font-size: 0.9em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-age { width: 4rem; text-align: right; font-family: var(--font-mono); font-size: 0.88em; color: var(--faint); white-space: nowrap; }

/* Actions appear only under the selected row. */
.actions-row { display: none; }
.actions-row.visible { display: table-row; }
.actions-row td { padding: 0.1rem 0.65rem 0.65rem 2.9rem !important; background: var(--accent-weak); box-shadow: inset 3px 0 0 var(--accent); }

.item-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.item-actions form { margin: 0; }

.act {
    font: inherit;
    font-size: 0.82rem;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    min-height: 2rem;
    box-shadow: var(--shadow-sm);
    transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease, transform 0.06s ease;
}

.act:hover { color: var(--text); border-color: var(--muted); }
.act:active { transform: translateY(1px); }

.act-done { color: #fff; background: var(--accent); border-color: var(--accent); font-weight: 600; }
.act-done:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.act-drop:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-weak); }
.act-doing { color: var(--accent-strong); border-color: var(--accent); font-weight: 600; }
.act-doing:hover { background: var(--accent-weak); color: var(--accent-strong); border-color: var(--accent); }

/* Snooze to a picked date, alongside the presets. */
.snooze-date { display: inline-flex; gap: 0.25rem; align-items: center; }

.act-date-input {
    font: inherit;
    font-size: 0.82rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    color-scheme: light dark;
    min-height: 2rem;
}

/* Edit a manual task inline: a disclosure that opens a title (+ note) form. */
.edit-manual > summary { list-style: none; cursor: pointer; }
.edit-manual > summary::-webkit-details-marker { display: none; }
.item-actions .edit-manual[open] { flex-basis: 100%; }

.edit-manual-form { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }

.edit-manual-form input {
    font: inherit;
    font-size: 0.85rem;
    padding: 0.4rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
}

.edit-manual-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.edit-manual-form input[name="title"] { flex: 1 1 18rem; }
.edit-manual-form input[name="note"] { flex: 1 1 12rem; }

.ag-edit { font-size: 0.72rem; color: var(--faint); cursor: pointer; margin-left: 0.5rem; }
.ag-edit:hover { color: var(--accent-strong); }
.edit-manual-inline .edit-manual-form { max-width: 34rem; }

/* Reschedule a manual task: an inline "→ zítra" one-click sits alongside the edit/move links,
   so a button has to shed its native chrome to read as the same faint affordance. */
.ag-quick { display: inline; }
button.ag-edit { background: none; border: none; padding: 0; font: inherit; }

@media (prefers-color-scheme: dark) {
    .act-done { color: #0f1216; }
    .act-done:hover { color: #0f1216; }
}

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

/* Empty + hints */
.empty {
    text-align: center;
    padding: 4.5rem 1rem;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.empty-headline { font-size: 1.15rem; color: var(--text); margin: 0 0 0.35rem; font-weight: 600; }
.empty-note { margin: 0; font-size: 0.92rem; }
.empty a, .empty-note a { color: var(--accent-strong); }

.hints { display: flex; flex-wrap: wrap; gap: 1.1rem; margin-top: 1rem; padding: 0.65rem 0.9rem; font-size: 0.78rem; color: var(--faint); }

kbd {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 5px;
    padding: 0.08rem 0.35rem;
    background: var(--surface);
    color: var(--muted);
}

/* New-task capture */
.newtask {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 0.7rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.newtask input[name="title"] {
    flex: 1 1 22rem;
    font: inherit;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.newtask input[name="title"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }

.newtask input[type="datetime-local"] {
    font: inherit;
    padding: 0.45rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    color-scheme: light dark;
}

.newtask-hint { font-size: 0.75rem; color: var(--faint); flex: 1 1 100%; }

/* Review dashboard */
.review-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.75rem; margin-bottom: 1.75rem; }

.review-card {
    display: block;
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 0.9rem 1rem;
    color: var(--text);
    transition: border-color 0.12s ease, transform 0.06s ease;
}

.review-card:hover { border-color: var(--accent); }
.review-card:active { transform: translateY(1px); }
.review-card .num { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.review-card .lbl { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.4rem; font-size: 0.85rem; color: var(--muted); }
.review-section-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); margin: 1.5rem 0 0.5rem; }

/* Agenda */
.agenda { max-width: 52rem; }

/* Day tabs: each day is a horizontal tab; clicking one shows that day's panel. */
.ag-tabbar {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    padding-bottom: 0.6rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    scrollbar-width: thin;
}

.ag-tab {
    /* Stretch to share the full width equally when there are few days; the min-width keeps them
       from getting too narrow with many days, at which point the tab bar scrolls instead. */
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    min-width: 4.25rem;
    padding: 0.4rem 0.65rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--surface-sunken);
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    line-height: 1.2;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.ag-tab:hover { color: var(--text); }

.ag-tab.is-active {
    background: var(--accent-weak);
    color: var(--accent-strong);
    border-color: var(--accent);
    font-weight: 600;
}

.ag-tab-dow { text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.66rem; color: var(--faint); }
.ag-tab.is-active .ag-tab-dow { color: var(--accent-strong); }
.ag-tab-date { font-family: var(--font-mono); font-size: 0.9rem; }
.ag-tab-badge { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent-strong); }
.ag-tab-count { font-family: var(--font-mono); font-size: 0.66rem; color: var(--faint); }
.ag-tab.is-active .ag-tab-count { color: var(--accent-strong); }

.ag-panel { display: none; }
.ag-panel.is-active { display: block; }
.ag-manual { color: var(--accent); }
.ag-event { color: #4d84d6; }
.ag-act { width: 1.5rem; text-align: right; }

/* Tick a calendar meeting off: a status circle like the inbox row's, filling to a check when
   handled. The handled row dims and strikes through, but stays in place so the tick is reversible. */
.ag-check { background: none; border: none; padding: 0; cursor: pointer; font-size: 0.95rem; line-height: 1; color: var(--faint); }
.ag-check:hover { color: var(--accent-strong); }
.ag-check.is-done { color: var(--accent); }
.ag-handled .ag-title a, .ag-handled .ag-title span { text-decoration: line-through; }
.ag-handled { opacity: 0.5; }

/* Inbox source filter: a row of pills above the queue, one per source present plus "Vše". */
.source-filter { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 0.75rem; }
.sf-chip {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.2rem 0.6rem; border: 1px solid var(--border); border-radius: 999px;
    font-size: 0.8rem; color: var(--faint); text-decoration: none; background: none;
}
.sf-chip:hover { border-color: var(--accent); color: var(--accent-strong); }
.sf-chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.sf-count { font-variant-numeric: tabular-nums; opacity: 0.75; font-size: 0.72rem; }

@media (prefers-color-scheme: dark) { .ag-event { color: #74a8ec; } }

.ag-day { margin-bottom: 1.75rem; }

.ag-day h2 {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin: 0 0 0.5rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    font-weight: 600;
}

.ag-dow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.72rem; color: var(--faint); }
.ag-date { font-family: var(--font-mono); color: var(--text); }
.ag-tag { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-strong); background: var(--accent-weak); border-radius: var(--radius-pill); padding: 0.05rem 0.5rem; }
.ag-day-today h2 { border-bottom-color: var(--accent); }
.ag-later .ag-dow { color: var(--muted); }
.ag-later .count { font-family: var(--font-mono); font-size: 0.72rem; border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 0 0.45rem; color: var(--muted); }

.ag-list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); overflow: hidden; }
.ag-list td { padding: 0.4rem 0.65rem; vertical-align: baseline; }
.ag-entry { transition: background 0.1s ease; }
.ag-entry:hover td { background: var(--row-hover); }
.ag-kind { width: 7rem; font-family: var(--font-mono); font-size: 0.88em; white-space: nowrap; }
.ag-snooze { color: var(--warn); }
.ag-due { color: var(--muted); }
.ag-when { color: var(--muted); }
.ag-ref { width: 11rem; font-family: var(--font-mono); font-size: 0.88em; color: var(--muted); white-space: nowrap; }
.ag-title a, .ag-title > span { color: var(--text); text-decoration: none; font-variant-ligatures: none; }
.ag-title a:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }
.ag-legend { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-top: 1rem; padding: 0.65rem 0.9rem; font-size: 0.78rem; color: var(--faint); }

@media (max-width: 52rem) {
    .ag-kind { width: 6rem; }
    .ag-ref { width: auto; }
    .ag-title { display: block; padding-top: 0 !important; }
    .ag-title a { white-space: normal; }
}

/* Login */
.login { max-width: 21rem; margin: 6rem auto 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-panel); padding: 1.75rem 1.5rem; }
.login label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.4rem; }
.login input { width: 100%; font: inherit; padding: 0.6rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); margin-bottom: 0.85rem; transition: border-color 0.12s ease, box-shadow 0.12s ease; }
.login input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.login button { width: 100%; font: inherit; font-weight: 600; padding: 0.6rem; border: 1px solid var(--accent); border-radius: var(--radius-sm); background: var(--accent); color: #fff; cursor: pointer; transition: background 0.12s ease; }
.login button:hover { background: var(--accent-strong); }
.login-error { color: var(--danger); font-size: 0.85rem; margin: 0 0 0.7rem; }

@media (prefers-color-scheme: dark) { .login button { color: #0f1216; } }

/* Today brief */
.brief-section { margin-bottom: 1.75rem; }
.brief-section h2 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); margin: 0 0 0.5rem; display: flex; align-items: baseline; gap: 0.5rem; }
.brief-section .count { font-family: var(--font-mono); font-size: 0.72rem; border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 0 0.45rem; }
.brief-section ul { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; }
.brief-section li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--border); transition: background 0.1s ease; }
.brief-section li:hover { background: var(--row-hover); }
.brief-section li:last-child { border-bottom: none; }
.brief-section a { color: var(--text); text-decoration: none; font-weight: 500; }
.brief-section a:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }
.brief-section .when { color: var(--muted); font-family: var(--font-mono); font-size: 0.82em; flex-shrink: 0; }
.brief-overdue h2, .brief-overdue .when { color: var(--danger); }
.brief-overdue .count { border-color: var(--danger); color: var(--danger); }
.brief-overdue ul { border-left: 3px solid var(--danger); }
.brief-today h2 { color: var(--warn); }
.brief-today ul { border-left: 3px solid var(--warn); }
.brief-footer { font-size: 0.9rem; color: var(--muted); }
.brief-footer a { color: var(--accent-strong); font-weight: 600; }
.brief-note { margin-top: 2rem; font-size: 0.76rem; color: var(--faint); }

/* Phone: sidebar becomes a bottom tab bar; the table collapses into cards ---------------- */
@media (max-width: 52rem) {
    .app { flex-direction: column; }

    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: auto;
        height: auto;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border);
        z-index: 20;
        overflow: visible;
    }

    .brand, .sidebar-foot { display: none; }
    .perspectives { flex-direction: row; overflow-x: auto; width: 100%; padding: 0.2rem; gap: 0; }
    .perspectives hr { display: none; }

    .persp { flex-direction: column; gap: 0.15rem; font-size: 0.62rem; padding: 0.35rem 0.55rem; white-space: nowrap; border-radius: var(--radius-sm); }
    .persp-icon { font-size: 1.15rem; }
    .persp-label { flex: none; }
    .persp .badge { position: absolute; margin-top: -0.3rem; margin-left: 1.1rem; font-size: 0.6rem; min-width: 0; padding: 0 0.3rem; }

    .content { padding: 0.85rem 0.85rem 4.5rem; max-width: none; }
    .view-title { font-size: 1.25rem; }

    .queue-panel { border-radius: var(--radius); background: transparent; border: none; box-shadow: none; overflow: visible; }
    .queue thead { display: none; }
    .queue, .queue tbody, .queue tr, .queue td { display: block; width: auto; }

    .item {
        position: relative;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        background: var(--surface);
        box-shadow: var(--shadow-sm);
        margin-bottom: 0.5rem;
        padding: 0.6rem 0.7rem 0.6rem 2.8rem;
        overflow: hidden;
    }

    .item td { padding: 0 !important; background: none !important; }
    .item.selected { background: var(--accent-weak); border-color: var(--accent); }
    .item.urgency-overdue { box-shadow: inset 4px 0 0 var(--danger), var(--shadow-sm); }
    .item.urgency-today { box-shadow: inset 4px 0 0 var(--warn), var(--shadow-sm); }

    .col-check { position: absolute; left: 0.6rem; top: 0.6rem; width: auto; padding: 0 !important; }
    .col-title { order: -1; }
    .col-title a, .col-title > span { white-space: normal; font-size: 1.02em; margin-bottom: 0.25rem; }
    .col-due, .col-ref, .col-meta, .col-age { display: inline-block !important; width: auto; margin-right: 0.7rem; font-size: 0.8rem; }

    .actions-row td { padding: 0.1rem 0 0.5rem !important; background: none; box-shadow: none; }
    .item-actions .act { flex: 1 1 auto; }

    .hints { display: none; }
    .statusbar-right { width: 100%; margin-left: 0; }
    .view-head .logout-form { margin-left: auto; }
}

/* Respect a reduced-motion preference. */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
