/* Libram: deep-water design (see docs/architecture.md, "UI theme").
   Two themes share every rule; only the colors differ. The person's theme is set on
   <html data-theme> from their account. All text pairings pass WCAG AA:
   --text on --bg 12.7:1, --muted on --raised-2 4.9:1 (teal) or better. */

@font-face {
    font-family: "Inter";
    src: url("../fonts/inter.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Space Grotesk";
    src: url("../fonts/space-grotesk.woff2") format("woff2");
    font-weight: 300 700;
    font-style: normal;
    font-display: swap;
}

:root,
[data-theme="teal"] {
    --rail: #031019;
    --bg: #041421;
    --panel: #042630;
    --raised: #0a3340;
    --raised-2: #0d3a47;
    --line: #4c7273;
    --accent: #86b9b0;
    --on-accent: #041421;
    --muted: #93a8aa;
    --text: #d0d6d6;
    --hairline: rgba(134, 185, 176, 0.12);
    --hairline-strong: rgba(134, 185, 176, 0.24);
    --accent-wash: rgba(134, 185, 176, 0.08);
    --partner: #e7a3c4;
    --partner-wash: rgba(231, 163, 196, 0.14);
    --on-partner: #2b0a1b;
    --accent-hover: #a2cbc4;
    color-scheme: dark;
}

[data-theme="rose"] {
    --rail: #19030e;
    --bg: #210413;
    --panel: #30041a;
    --raised: #400a25;
    --raised-2: #470d2a;
    --line: #734c60;
    --accent: #fcacd4;
    --on-accent: #210413;
    --muted: #aa939e;
    --text: #d6d0d3;
    --hairline: rgba(252, 172, 212, 0.12);
    --hairline-strong: rgba(252, 172, 212, 0.24);
    --accent-wash: rgba(252, 172, 212, 0.08);
    --partner: #86b9b0;
    --partner-wash: rgba(134, 185, 176, 0.14);
    --on-partner: #041421;
    --accent-hover: #fdc4e0;
}

[data-theme="pink-panels"] {
    --rail: #2c0a1d;
    --bg: #3a0e27;
    --panel: #5e1d46;
    --raised: #702556;
    --raised-2: #7a2a5e;
    --line: #a8538a;
    --accent: #ffc4e1;
    --on-accent: #3a0e27;
    --muted: #fad3e6;
    --text: #fff2f8;
    --hairline: rgba(255, 196, 225, 0.14);
    --hairline-strong: rgba(255, 196, 225, 0.28);
    --accent-wash: rgba(255, 196, 225, 0.10);
    --partner: #9fd8cc;
    --partner-wash: rgba(159, 216, 204, 0.16);
    --on-partner: #072522;
    --accent-hover: #ffd9ec;
}

/* The one light theme: lighter shadows, and native controls drawn light. */
:root[data-theme="strawberry-milk"] {
    --rail: #f7d3de;
    --bg: #fbe6ec;
    --panel: #fff7f9;
    --raised: #f8dbe4;
    --raised-2: #f4cbd8;
    --line: #e39bb3;
    --accent: #b8235f;
    --on-accent: #fff7f9;
    --muted: #86475e;
    --text: #45172a;
    --hairline: rgba(184, 35, 95, 0.14);
    --hairline-strong: rgba(184, 35, 95, 0.28);
    --accent-wash: rgba(184, 35, 95, 0.10);
    --partner: #1f6f66;
    --partner-wash: rgba(31, 111, 102, 0.12);
    --on-partner: #f3fbf9;
    --accent-hover: #9c1a50;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 6px 18px rgba(120, 30, 70, 0.10);
    --shadow-lift: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 12px 28px rgba(120, 30, 70, 0.16);
    --shadow-pop: 0 16px 40px rgba(120, 30, 70, 0.20);
    --dim: rgba(120, 30, 70, 0.05);
    color-scheme: light;
}

:root {
    --radius: 12px;
    --radius-lg: 18px;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lift: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 14px 34px rgba(0, 0, 0, 0.45);
    --shadow-pop: 0 18px 48px rgba(0, 0, 0, 0.55);
    --dim: rgba(0, 0, 0, 0.18);
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-title: "Space Grotesk", "Inter", system-ui, sans-serif;
    --font-mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
    --nav-width: 248px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: var(--font-title);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

h1 {
    font-size: 2.1rem;
    letter-spacing: -0.03em;
    margin: 0 0 0.5rem;
}

h2 {
    font-size: 1.2rem;
    margin: 0 0 0.25rem;
}

a {
    color: var(--accent);
    text-decoration: none;
}

    a:hover {
        color: var(--accent-hover);
    }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.muted, .hint {
    color: var(--muted);
}

.eyebrow {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
}

.hint {
    font-size: 0.9rem;
    padding: 0 0.5rem;
}

.notice, .error {
    background: var(--panel);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow);
}

.error {
    font-weight: 600;
    border-color: var(--text);
}

.section-heading {
    margin-top: 2.5rem;
}

/* Buttons and fields */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 2.75rem;
    background: var(--accent);
    color: var(--on-accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 0.5rem 1.1rem;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, transform 0.15s var(--ease), box-shadow 0.15s ease;
}

    .button:hover {
        background: var(--accent-hover);
        border-color: var(--accent-hover);
        color: var(--on-accent);
    }

    .button:active {
        transform: translateY(1px);
    }

    .button.secondary {
        background: transparent;
        color: var(--text);
        border-color: var(--hairline-strong);
    }

        .button.secondary:hover {
            background: var(--raised);
            color: var(--text);
        }

    .button:disabled {
        opacity: 0.55;
        cursor: not-allowed;
    }

.link-button, .icon-button {
    background: none;
    border: none;
    color: var(--accent);
    font: inherit;
    cursor: pointer;
    padding: 0;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 10px;
    color: var(--muted);
    font-size: 1.2rem;
    line-height: 1;
}

    .icon-button:hover {
        background: var(--raised);
        color: var(--text);
    }

.input {
    width: 100%;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--radius);
    padding: 0.6rem 0.8rem;
    font: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

    .input:focus {
        outline: none;
        border-color: var(--accent);
        box-shadow: 0 0 0 3px var(--accent-wash);
    }

    .input::placeholder {
        color: var(--muted);
        opacity: 1;
    }

label {
    display: block;
    font-size: 0.9rem;
    margin: 0.75rem 0 0.3rem;
}

.actions, .header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.actions {
    margin-top: 1rem;
}

/* Tags */

.tag {
    display: inline-block;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.05rem 0.6rem;
    font-size: 0.82rem;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
}

a.tag:hover {
    border-color: var(--accent);
    color: var(--text);
}

.tag.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
}

.tag .count {
    opacity: 0.8;
}

.entry-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

/* Centered screens: loading, sign-in, errors */

.centered {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.sign-in h1 {
    font-size: 3rem;
}

.sign-in .notice {
    max-width: 26rem;
    text-align: left;
}

.boot-message {
    text-align: center;
    margin-top: 30vh;
    color: var(--muted);
}

/* Signed-in shell: sidebar, top bar and content. On phones the sidebar becomes
   bottom tabs and the New button floats above them. */

.app {
    min-height: 100vh;
    display: flex;
}

.app-nav {
    position: sticky;
    top: 0;
    height: 100vh;
    flex: 0 0 var(--nav-width);
    width: var(--nav-width);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.4rem 0.9rem;
    background: var(--rail);
    border-right: 1px solid var(--hairline);
    transition: width 0.2s var(--ease), flex-basis 0.2s var(--ease);
    z-index: 5;
}

    .app-nav .nav-item, .app-nav .app-brand {
        overflow: hidden;
    }

[data-nav="collapsed"] .app-nav {
    --nav-width: 76px;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0 0.45rem;
    color: var(--text);
    min-height: 2.5rem;
}

    .app-brand:hover {
        color: var(--text);
    }

.brand-mark {
    flex: none;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 10px;
    background: var(--accent);
    color: var(--on-accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-name {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: -0.02em;
}

.nav-items {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    min-height: 2.75rem;
    padding: 0.55rem 0.8rem;
    border-radius: 10px;
    color: var(--muted);
    background: none;
    border: none;
    font: inherit;
    text-align: left;
    width: 100%;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

    .nav-item .icon {
        flex: none;
    }

    .nav-item:hover {
        background: var(--raised);
        color: var(--text);
    }

    .nav-item.active {
        background: var(--raised);
        color: var(--text);
        font-weight: 600;
        box-shadow: inset 3px 0 0 var(--accent);
    }

        .nav-item.active .icon {
            color: var(--accent);
        }

.nav-label {
    transition: opacity 0.15s ease;
}

[data-nav="collapsed"] .nav-label {
    opacity: 0;
    pointer-events: none;
    width: 0;
    overflow: hidden;
}

[data-nav="collapsed"] .nav-item,
[data-nav="collapsed"] .app-brand {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    gap: 0;
}

.nav-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--hairline);
}

.avatar {
    flex: none;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 999px;
    background: var(--line);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.account-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-menu, .new-menu {
    position: relative;
}

.menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
}

.popover {
    position: absolute;
    z-index: 31;
    min-width: 15rem;
    padding: 0.5rem;
    background: var(--raised);
    border: 1px solid var(--hairline-strong);
    border-radius: 14px;
    box-shadow: var(--shadow-pop);
    animation: pop-in 0.16s var(--ease);
}

.account-popover {
    left: 0.25rem;
    bottom: calc(100% + 0.5rem);
}

.app-top .account-popover {
    left: auto;
    right: 0;
    bottom: auto;
    top: calc(100% + 0.5rem);
}

.new-popover {
    right: 0;
    top: calc(100% + 0.5rem);
}

.fab-menu .new-popover {
    top: auto;
    bottom: calc(100% + 0.75rem);
}

.popover-title {
    margin: 0.35rem 0.6rem 0.6rem;
    font-weight: 600;
}

.popover-label {
    margin: 0.5rem 0.6rem 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.menu-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    min-height: 2.75rem;
    padding: 0.5rem 0.6rem;
    border-radius: 10px;
    background: none;
    border: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

    .menu-row:hover {
        background: var(--raised-2);
        color: var(--text);
    }

.theme-choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
    padding: 0 0.25rem 0.5rem;
    margin-bottom: 0.35rem;
    border-bottom: 1px solid var(--hairline);
}

.theme-choice {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.75rem;
    padding: 0.4rem 0.6rem;
    border-radius: 10px;
    border: 1px solid var(--hairline-strong);
    background: none;
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

    .theme-choice.selected {
        border-color: var(--accent);
        box-shadow: inset 0 0 0 1px var(--accent);
        font-weight: 600;
    }

.swatch {
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 999px;
    flex: none;
}

.swatch-teal {
    background: linear-gradient(135deg, #86b9b0 50%, #042630 50%);
}

.swatch-rose {
    background: linear-gradient(135deg, #fcacd4 50%, #30041a 50%);
}

.swatch-pink-panels {
    background: linear-gradient(135deg, #ffc4e1 50%, #5e1d46 50%);
}

.swatch-strawberry-milk {
    background: linear-gradient(135deg, #b8235f 50%, #fff7f9 50%);
    box-shadow: inset 0 0 0 1px rgba(184, 35, 95, 0.3);
}

.small-error {
    margin: 0.25rem;
    font-size: 0.85rem;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-top {
    position: sticky;
    top: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 2.5rem;
    padding-top: max(1rem, env(safe-area-inset-top));
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.top-search {
    flex: 1;
    max-width: 40rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    height: 2.75rem;
    padding: 0 0.9rem;
    border-radius: var(--radius);
    background: var(--panel);
    border: 1px solid var(--hairline);
    color: var(--muted);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

    .top-search:focus-within {
        border-color: var(--accent);
        box-shadow: 0 0 0 3px var(--accent-wash);
    }

    .top-search input {
        flex: 1;
        min-width: 0;
        background: none;
        border: none;
        outline: none;
        color: var(--text);
        font: inherit;
    }

        .top-search input::placeholder {
            color: var(--muted);
        }

.app-top .new-menu {
    margin-left: auto;
}

.phone-only, .tabbar {
    display: none;
}

.content {
    width: 100%;
    max-width: 1240px;
    padding: 1rem 2.5rem 4rem;
    animation: content-in 0.25s var(--ease);
}

.fab {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 18px;
    border: none;
    background: var(--accent);
    color: var(--on-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-pop);
    cursor: pointer;
    transition: transform 0.15s var(--ease);
}

    .fab:active {
        transform: scale(0.94);
    }

/* Cards and pillar tiles, used across pages */

.pillar-card, .entry-card, .panel, .card {
    background: var(--panel);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.entry-card, .pillar-card {
    transition: transform 0.15s var(--ease), box-shadow 0.15s ease, border-color 0.15s ease;
}

    .entry-card:hover, .pillar-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-lift);
        border-color: var(--hairline-strong);
    }

.pillar-tile {
    flex: none;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 12px;
    background: var(--raised-2);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

    .pillar-tile.small-tile {
        width: 2rem;
        height: 2rem;
        border-radius: 9px;
    }

/* Home */

.home-header {
    margin: 0.5rem 0 1.75rem;
}

    .home-header h1 {
        font-size: 2.5rem;
        margin: 0.15rem 0 0.4rem;
    }

    .home-header p {
        margin: 0;
    }

.home-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 1.25rem;
}

.card {
    padding: 1.35rem 1.5rem;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

    .card-head h2 {
        margin: 0;
        font-size: 1.15rem;
    }

    .card-head a {
        font-size: 0.9rem;
        white-space: nowrap;
    }

.span-7 { grid-column: span 7; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.span-8 { grid-column: span 8; }

.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.timeline-item {
    display: flex;
    gap: 1rem;
    align-items: stretch;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    color: var(--text);
}

    .timeline-item:hover {
        background: var(--raised);
        color: var(--text);
    }

    .timeline-item.all-day {
        background: var(--raised);
        align-items: center;
    }

    .timeline-item.past {
        opacity: 0.6;
    }

.timeline-time {
    flex: 0 0 4.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    padding-top: 0.1rem;
    font-variant-numeric: tabular-nums;
}

.all-day .timeline-time {
    color: var(--accent);
}

.timeline-bar {
    flex: none;
    width: 3px;
    border-radius: 3px;
    background: var(--accent);
}

.past .timeline-bar {
    background: var(--line);
}

.timeline-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.timeline-title {
    font-weight: 500;
}

.timeline-meta {
    font-size: 0.85rem;
    color: var(--muted);
}

.now-line {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.1rem 0.75rem;
    font-size: 0.75rem;
    color: var(--accent);
}

    .now-line::after {
        content: "";
        flex: 1;
        height: 1px;
        background: var(--accent);
        opacity: 0.6;
    }

    .now-line span {
        flex: 0 0 4.75rem;
    }

.ring-head {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.9rem;
}

    .ring-head h2 {
        margin: 0;
        font-size: 1.15rem;
    }

    .ring-head p {
        margin: 0;
        font-size: 0.85rem;
        color: var(--muted);
    }

    .ring-head > div {
        flex: 1;
    }

.ring circle {
    transition: stroke-dasharray 0.5s var(--ease);
}

.ring-track {
    stroke: var(--raised-2);
}

.ring-fill {
    stroke: var(--accent);
}

.ring-text {
    fill: var(--text);
    font-family: var(--font-title);
    font-weight: 600;
}

.inline-add {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 2.75rem;
    margin-top: 0.75rem;
    padding: 0 0.8rem;
    border-radius: var(--radius);
    border: 1px dashed var(--line);
    color: var(--muted);
}

    .inline-add:focus-within {
        border-style: solid;
        border-color: var(--accent);
    }

    .inline-add input {
        flex: 1;
        min-width: 0;
        background: none;
        border: none;
        outline: none;
        color: var(--text);
        font: inherit;
        font-size: 0.95rem;
    }

.mini-month {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.2rem;
    text-align: center;
    font-size: 0.85rem;
}

.mini-weekday {
    font-size: 0.7rem;
    color: var(--muted);
    padding-bottom: 0.25rem;
}

.mini-day {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 2.1rem;
    border-radius: 999px;
    color: var(--text);
    position: relative;
}

    .mini-day:hover {
        background: var(--raised);
        color: var(--text);
    }

    .mini-day.other-month {
        color: var(--muted);
        opacity: 0.5;
    }

    .mini-day.has-events::after {
        content: "";
        position: absolute;
        bottom: 0.2rem;
        width: 0.3rem;
        height: 0.3rem;
        border-radius: 999px;
        background: var(--accent);
    }

    .mini-day.is-today {
        background: var(--accent);
        color: var(--on-accent);
        font-weight: 700;
    }

        .mini-day.is-today::after {
            background: var(--on-accent);
        }

.recent-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.recent-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1.1rem;
    color: var(--text);
}

    .recent-card:hover {
        color: var(--text);
    }

.recent-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.recent-title {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-meta {
    font-size: 0.85rem;
    color: var(--muted);
}

.summary-strip {
    display: none;
}

/* Library: sidebar + list */

.library {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
}

.sidebar {
    position: sticky;
    top: 5rem;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
}

.sidebar-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 0.4rem;
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

    .sidebar-heading + .tag-cloud {
        margin-bottom: 1rem;
    }

.tree {
    list-style: none;
    margin: 0 0 1.5rem;
    padding: 0;
}

    .tree li {
        padding-left: calc(var(--depth, 0) * 0.9rem);
    }

.tree-link {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius);
    text-decoration: none;
}

    .tree-link:hover {
        background: var(--raised);
    }

    .tree-link.selected {
        background: var(--raised);
        font-weight: 600;
        box-shadow: inset 3px 0 0 var(--accent);
    }

.tree-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-link .count {
    font-size: 0.8rem;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.library-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

    .library-header h1 {
        margin: 0;
    }

.category-form {
    padding: 1rem 1.25rem 1.25rem;
    margin-bottom: 1.5rem;
    max-width: 32rem;
}

.empty {
    padding: 2rem 0;
}

.entry-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.6rem;
}

.entry-card {
    display: grid;
    gap: 0.3rem;
    padding: 0.85rem 1.1rem;
    text-decoration: none;
}

.entry-title {
    font-weight: 600;
    font-size: 1.05rem;
}

.entry-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 1rem;
    font-size: 0.9rem;
}

/* Reading an entry */

.entry {
    max-width: 52rem;
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 0.75rem;
}

    .breadcrumbs a {
        color: var(--muted);
    }

.entry-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.entry > .entry-meta {
    margin: 0 0 1.5rem;
    color: var(--muted);
}

/* Rendered Markdown */

.markdown {
    overflow-wrap: anywhere;
}

    .markdown > :first-child {
        margin-top: 0;
    }

    .markdown h1, .markdown h2, .markdown h3 {
        margin: 1.6em 0 0.5em;
    }

    .markdown h2 {
        font-size: 1.4rem;
    }

    .markdown h3 {
        font-size: 1.15rem;
    }

    .markdown code {
        font-family: var(--font-mono);
        font-size: 0.9em;
        background: var(--panel);
        border-radius: 4px;
        padding: 0.1em 0.35em;
    }

    .markdown pre {
        background: var(--panel);
        border: 1px solid var(--hairline);
        border-radius: var(--radius);
        padding: 0.9rem 1rem;
        overflow-x: auto;
    }

        .markdown pre code {
            background: none;
            padding: 0;
        }

    .markdown blockquote {
        margin: 1rem 0;
        padding: 0.1rem 1rem;
        border-left: 4px solid var(--line);
    }

    .markdown table {
        border-collapse: collapse;
        display: block;
        overflow-x: auto;
    }

    .markdown th, .markdown td {
        border: 1px solid var(--hairline);
        padding: 0.4rem 0.7rem;
    }

    .markdown th {
        background: var(--panel);
    }

    .markdown hr {
        border: none;
        border-top: 1px solid var(--hairline);
        margin: 2rem 0;
    }

    .markdown img {
        max-width: 100%;
    }

    .markdown .task-list-item {
        list-style: none;
    }

        .markdown .task-list-item input {
            margin: 0 0.5rem 0 -1.4rem;
        }

/* Markdown extras: code colors, callouts, footnotes, definition lists, diagrams.
   Code colors come from each theme's own accent and text, so every theme matches
   and every token keeps AA contrast on the code background. */

.markdown pre code.hljs {
    display: block;
    background: none;
    color: var(--text);
    padding: 0;
}

.hljs-keyword, .hljs-selector-tag, .hljs-section, .hljs-doctag, .hljs-meta .hljs-keyword {
    color: var(--accent);
    font-weight: 600;
}

.hljs-string, .hljs-regexp, .hljs-addition, .hljs-template-tag, .hljs-meta .hljs-string {
    color: color-mix(in srgb, var(--accent) 85%, var(--text));
}

.hljs-comment, .hljs-quote {
    color: var(--muted);
    font-style: italic;
}

.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet, .hljs-variable.language_ {
    color: var(--accent-hover);
    font-weight: 600;
}

.hljs-title, .hljs-title.function_, .hljs-title.class_, .hljs-name {
    color: var(--text);
    font-weight: 600;
}

.hljs-built_in, .hljs-type, .hljs-attr, .hljs-attribute, .hljs-selector-class,
.hljs-selector-id, .hljs-params, .hljs-variable, .hljs-template-variable, .hljs-meta {
    color: color-mix(in srgb, var(--accent) 45%, var(--muted));
}

.hljs-deletion {
    color: var(--muted);
    text-decoration: line-through;
}

.hljs-emphasis {
    font-style: italic;
}

.hljs-strong {
    font-weight: 700;
}

.markdown-alert {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    border-left: 4px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--accent-wash);
}

    .markdown-alert > :last-child {
        margin-bottom: 0;
    }

.markdown-alert-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.35rem;
    font-weight: 600;
    color: var(--accent);
}

    .markdown-alert-title svg {
        fill: currentColor;
        flex: none;
    }

.markdown-alert-important {
    background: var(--raised);
}

/* The palettes have no red: warnings use the text color and a heavier bar. */
.markdown-alert-warning, .markdown-alert-caution {
    border-left-width: 6px;
    border-left-color: var(--text);
    background: var(--raised);
}

    .markdown-alert-warning .markdown-alert-title,
    .markdown-alert-caution .markdown-alert-title {
        color: var(--text);
    }

.markdown .footnotes {
    margin-top: 2rem;
    font-size: 0.9rem;
    color: var(--muted);
}

    .markdown .footnotes hr {
        margin: 0 0 1rem;
    }

    .markdown .footnotes p {
        display: inline;
    }

.markdown a.footnote-ref, .markdown a.footnote-back-ref {
    text-decoration: none;
    font-weight: 600;
}

.markdown dl dt {
    font-weight: 600;
    margin-top: 0.75rem;
}

.markdown dl dd {
    margin: 0.15rem 0 0 1.25rem;
}

.markdown pre.mermaid {
    text-align: center;
    font-family: var(--font);
    white-space: pre-wrap;
}

    .markdown pre.mermaid svg {
        max-width: 100%;
        height: auto;
    }

.format-help {
    font-size: 0.9rem;
    color: var(--muted);
}

    .format-help summary {
        cursor: pointer;
        width: fit-content;
    }

    .format-help dl {
        display: grid;
        grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
        gap: 0.35rem 1.25rem;
        margin: 0.6rem 0 0;
        padding: 0.9rem 1rem;
        background: var(--panel);
        border: 1px solid var(--hairline);
        border-radius: var(--radius);
    }

    .format-help dt {
        color: var(--text);
    }

    .format-help dd {
        margin: 0;
    }

    .format-help code {
        font-family: var(--font-mono);
        font-size: 0.85rem;
        background: var(--raised);
        border-radius: 4px;
        padding: 0.05em 0.3em;
    }

@media (max-width: 600px) {
    .format-help dl {
        grid-template-columns: minmax(0, 1fr);
    }

        .format-help dd {
            margin-bottom: 0.4rem;
        }
}

/* Editing an entry */

.editor {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.title-input {
    font-family: var(--font-title);
    font-size: 1.6rem;
    font-weight: 600;
    background: transparent;
    border-color: transparent;
    border-bottom-color: var(--muted);
    border-radius: 0;
    padding-left: 0;
}

.field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0 1rem;
}

.editor-panes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.body-input {
    min-height: 60vh;
    resize: vertical;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.6;
}

.preview {
    min-height: 60vh;
    padding: 0.6rem 1rem;
    border: 1px dashed var(--hairline-strong);
    border-radius: var(--radius);
}

.mode-switch {
    display: none;
    gap: 0.25rem;
}

    .mode-switch button {
        background: none;
        border: 1px solid var(--hairline);
        color: var(--text);
        font: inherit;
        padding: 0.35rem 1rem;
        border-radius: var(--radius);
        cursor: pointer;
    }

        .mode-switch button.active {
            background: var(--raised);
            font-weight: 600;
        }

.sticky-actions {
    position: sticky;
    bottom: 0;
    background: var(--bg);
    padding: 0.75rem 0 max(0.75rem, env(safe-area-inset-bottom));
    border-top: 1px solid var(--hairline);
}

/* Linking and search */

.button.small {
    padding: 0.3rem 0.8rem;
    font-size: 0.9rem;
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.link-picker {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.5rem;
    display: grid;
    gap: 0.15rem;
    max-width: 36rem;
}

.picker-heading {
    margin: 0.1rem 0.4rem 0.3rem;
    font-weight: 600;
}

.picker-option {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    text-align: left;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--text);
    font: inherit;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
}

    .picker-option:hover {
        border-color: var(--raised);
    }

    .picker-option.active {
        background: var(--bg);
        border-color: var(--line);
        font-weight: 600;
    }

.picker-meta {
    font-size: 0.85rem;
    white-space: nowrap;
}

.link-picker .hint {
    margin: 0.3rem 0.4rem 0.1rem;
    padding: 0;
    font-size: 0.8rem;
    color: var(--text);
}

.backlinks {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--hairline);
}

.topbar-search {
    flex: 0 1 16rem;
}

    .topbar-search .input {
        padding: 0.35rem 0.7rem;
        background: var(--bg);
    }

.search-page-form {
    display: flex;
    gap: 0.5rem;
    max-width: 40rem;
    margin-bottom: 1rem;
}

.snippet {
    font-size: 0.92rem;
    line-height: 1.5;
}

mark {
    background: var(--raised);
    color: var(--text);
    font-weight: 600;
    border-radius: 3px;
    padding: 0 0.15em;
}

/* Runbooks and runs */

.steps-field label .optional {
    font-weight: normal;
}

.steps-input {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.6;
    resize: vertical;
}

.runbook {
    margin-top: 2rem;
}

.section-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

    .section-title h2 {
        margin: 0 auto 0 0;
    }

.steps-list li {
    margin: 0.3rem 0;
}

.runbook h3 {
    margin: 1.75rem 0 0.75rem;
}

.run {
    max-width: 48rem;
}

.run-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 0.5rem 0 1.25rem;
    font-weight: 600;
}

    .run-progress progress {
        flex: 1;
        max-width: 20rem;
        height: 0.6rem;
        accent-color: var(--accent);
    }

.checklist {
    list-style: none;
    margin: 0 0 1.5rem;
    padding: 0;
    display: grid;
    gap: 0.5rem;
}

    .checklist li {
        display: flex;
        align-items: flex-start;
        gap: 0.9rem;
        background: var(--panel);
        border: 1px solid var(--hairline);
        border-radius: var(--radius);
        padding: 0.8rem 1rem;
    }

        .checklist li.done {
            border-color: var(--line);
        }

            .checklist li.done .markdown {
                text-decoration: line-through;
                text-decoration-color: var(--line);
            }

    .checklist input[type="checkbox"] {
        width: 1.5rem;
        height: 1.5rem;
        margin: 0.1rem 0 0;
        flex: none;
        accent-color: var(--accent);
        cursor: pointer;
    }

.checklist-text {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.6rem;
}

.step-number {
    font-weight: 600;
}

.done-time {
    font-size: 0.85rem;
}

.run-notes {
    resize: vertical;
}

.delete-run {
    margin-left: auto;
}

/* To-dos and calendar: shared bits. The palette has no red, so "overdue" is
   shown with weight and a bar in the text color rather than a warning color. */

.details-panel {
    display: grid;
    gap: 0.75rem;
    background: var(--panel);
    border: 1px solid var(--hairline);
    box-shadow: var(--shadow);
    border-radius: var(--radius-lg);
    padding: 1rem 1.1rem;
    margin: 1rem 0 1.5rem;
}

    .details-panel h3 {
        margin: 0.5rem 0 0;
        font-size: 1.05rem;
    }

    .details-panel .entry-meta, .details-panel .muted, .details-panel .hint {
        color: var(--text);
    }

.panel-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.panel-facts p {
    margin: 0.15rem 0;
}

.status {
    font-size: 1.1rem;
    font-weight: 600;
}

.overdue-label {
    margin-left: 0.5rem;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    background: var(--text);
    color: var(--bg);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.repeat {
    white-space: nowrap;
}

.priority {
    font-size: 0.8rem;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--line);
}

.priority-high {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
}

.priority-medium {
    border-color: var(--accent);
    color: var(--accent);
}

.history summary {
    cursor: pointer;
}

.history-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0;
    display: grid;
    gap: 0.3rem;
}

    .history-list li {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem 1rem;
        align-items: center;
    }

        .history-list li.is-selected {
            font-weight: 600;
        }

.inline-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
}

.number-input {
    width: 4.5rem;
}

.date-input {
    width: auto;
}

/* Repeat picker */

.repeat-editor {
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    padding: 0.6rem 0.9rem 0.8rem;
    margin: 0;
    display: grid;
    gap: 0.6rem;
}

    .repeat-editor legend {
        padding: 0 0.3rem;
        font-size: 0.9rem;
    }

    .repeat-editor .input {
        margin: 0;
    }

    .repeat-editor select.input {
        width: auto;
    }

.repeat-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
}

.weekday-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.weekday {
    min-width: 2.6rem;
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

    .weekday.selected {
        background: var(--accent);
        border-color: var(--accent);
        color: var(--on-accent);
        font-weight: 600;
    }

/* To-do list */

.quick-add {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

    .quick-add .input {
        margin: 0;
    }

.todo-group {
    margin-bottom: 1.1rem;
    padding: 0.9rem 0.6rem 0.5rem;
    background: var(--panel);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

    .todo-group .group-title, .todo-group .group-toggle {
        margin-left: 0.6rem;
        font-family: var(--font);
        font-size: 0.8rem;
        font-weight: 600;
        letter-spacing: 0.1em;
        text-transform: uppercase;
    }

    .todo-group.today .group-title {
        color: var(--accent);
    }

    .todo-group.done {
        background: none;
        border-color: transparent;
        box-shadow: none;
    }

.group-title {
    font-size: 1.05rem;
    margin: 0 0 0.5rem;
}

    .group-title .count {
        font-family: var(--font);
        font-weight: 400;
        color: var(--muted);
        margin-left: 0.35rem;
    }

.group-toggle {
    background: none;
    border: none;
    color: var(--text);
    font: inherit;
    font-family: var(--font-title);
    font-weight: 600;
    font-size: 1.05rem;
    cursor: pointer;
    padding: 0;
    margin-bottom: 0.5rem;
}

.todo-list, .agenda-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.4rem;
}

.todo-row {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    border-radius: var(--radius);
    padding: 0.7rem 0.8rem;
    transition: background 0.15s ease, opacity 0.3s ease, transform 0.3s var(--ease);
}

    .todo-row:hover {
        background: var(--raised);
    }

    .todo-row.is-open {
        background: var(--raised);
        box-shadow: inset 0 0 0 1px var(--hairline-strong);
    }

    .todo-row.is-overdue .due {
        background: var(--text);
        color: var(--bg);
        border-radius: 999px;
        padding: 0 0.5rem;
    }

        .todo-row.is-overdue .due {
            font-weight: 700;
        }

    .todo-row.is-done .todo-title {
        text-decoration: line-through;
        text-decoration-color: var(--line);
    }

.todo-check {
    width: 1.35rem;
    height: 1.35rem;
    margin-top: 0.15rem;
    flex: none;
    accent-color: var(--accent);
    cursor: pointer;
}

.todo-body {
    display: grid;
    gap: 0.2rem;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: var(--text);
}

.todo-title {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.notice {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-bottom: 1rem;
}

/* Calendar */

.segmented {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

    .segmented a {
        padding: 0.5rem 0.9rem;
        text-decoration: none;
        color: var(--text);
    }

        .segmented a.selected {
            background: var(--raised-2);
            color: var(--text);
            font-weight: 600;
        }

.month-nav {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.month-grid {
    background: var(--panel);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.weekday-row, .week-row {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday-name {
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
    color: var(--muted);
    border-bottom: 1px solid var(--hairline);
}

.day-cell {
    min-height: 6.5rem;
    padding: 0.3rem;
    border-right: 1px solid var(--hairline);
    border-bottom: 1px solid var(--hairline);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

    .week-row .day-cell:last-child {
        border-right: none;
    }

    .week-row:last-child .day-cell {
        border-bottom: none;
    }

    .day-cell.other-month {
        background: var(--dim);
    }

        .day-cell.other-month .day-number {
            color: var(--muted);
        }

    .day-cell.is-selected {
        background: var(--raised);
    }

.day-number {
    align-self: flex-start;
    background: none;
    border: none;
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    min-width: 1.8rem;
    height: 1.8rem;
    border-radius: 999px;
    cursor: pointer;
}

    .day-number:hover {
        background: var(--panel);
    }

.day-cell.is-today .day-number {
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 700;
}

.day-chips {
    display: grid;
    gap: 0.15rem;
    min-width: 0;
}

.chip {
    display: block;
    font-size: 0.8rem;
    line-height: 1.35;
    padding: 0.05rem 0.35rem;
    border-radius: 6px;
    background: var(--raised);
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: none;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

    .chip.all-day {
        background: var(--line);
        color: var(--text);
        font-weight: 600;
    }

    .chip.more {
        background: transparent;
        color: var(--muted);
    }

.chip-time {
    font-weight: 600;
    margin-right: 0.25rem;
}

.day-dots {
    display: none;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    text-align: center;
}

.agenda-day {
    margin-bottom: 1.5rem;
}

    .agenda-day.is-today .group-title {
        text-decoration: underline;
        text-decoration-color: var(--line);
        text-underline-offset: 0.25em;
    }

.selected-day-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

    .selected-day-header .group-title {
        margin: 0;
    }

.agenda-item {
    display: flex;
    gap: 1rem;
    background: var(--raised);
    border-radius: var(--radius);
    box-shadow: inset 3px 0 0 var(--accent);
    padding: 0.7rem 1rem;
    text-decoration: none;
    color: var(--text);
}

.agenda-time {
    flex: 0 0 8.5rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.agenda-body {
    display: grid;
    gap: 0.2rem;
    min-width: 0;
}

.occurrence-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.move-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem 0.75rem;
}

    .move-form label {
        display: grid;
        gap: 0.2rem;
        margin: 0;
    }

    .move-form .input {
        margin: 0;
    }

    .move-form .hint {
        flex-basis: 100%;
        padding: 0;
        margin: 0;
    }

/* Side panels: an item opens beside its list instead of on a new page. On narrower
   screens the panel becomes a sheet that slides up from the bottom. */

.with-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

    .with-panel.panel-open {
        grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
    }

.side-panel {
    position: sticky;
    top: 5rem;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.3rem 1.4rem;
    background: var(--panel);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lift);
    animation: panel-in 0.22s var(--ease);
}

.side-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

    .side-panel-head h2 {
        margin: 0.1rem 0 0;
        font-size: 1.4rem;
        overflow-wrap: anywhere;
    }

.side-panel .details-panel {
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
}

.side-panel .markdown {
    font-size: 0.95rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--hairline);
}

.side-panel-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.panel-scrim {
    display: none;
}

/* Calendar: the grid and a column for the chosen day or event */

.calendar-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    gap: 1.5rem;
    align-items: start;
}

.calendar-side {
    position: sticky;
    top: 5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

    .calendar-side .agenda-day {
        background: var(--panel);
        border: 1px solid var(--hairline);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow);
        padding: 1.2rem 1.3rem;
        margin: 0;
    }

.calendar-side .side-panel {
    position: static;
    max-height: none;
}

.chip.is-open {
    box-shadow: inset 0 0 0 1px var(--accent);
}

.with-icon .icon {
    flex: none;
}

#blazor-error-ui .dismiss {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
}

/* Settings */

.settings {
    display: grid;
    gap: 1.25rem;
    max-width: 46rem;
}

    .settings .card p:first-of-type {
        margin-top: 0;
    }

.status-line {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 600;
}

.status-dot {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-wash);
}

.toggle-row {
    margin: 0 0 0.5rem;
}

    .toggle-row input {
        width: 1.2rem;
        height: 1.2rem;
        accent-color: var(--accent);
    }

.steps-help {
    margin: 0.5rem 0;
    padding-left: 1.3rem;
    display: grid;
    gap: 0.3rem;
}

.device-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.5rem;
}

    .device-list li {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.7rem 0.9rem;
        border-radius: var(--radius);
        background: var(--raised);
    }

        .device-list li > span {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 0.25rem 0.6rem;
        }

.device-meta {
    flex-basis: 100%;
    font-size: 0.85rem;
}

.feed-link {
    display: flex;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

    .feed-link .input {
        font-family: var(--font-mono);
        font-size: 0.85rem;
    }

.setup-help {
    margin-top: 0.75rem;
}

    .setup-help summary {
        cursor: pointer;
        font-weight: 600;
    }

/* Quick capture and access (phase 7) */

.top-search {
    cursor: pointer;
    font: inherit;
    text-align: left;
}

    .top-search:hover {
        border-color: var(--hairline-strong);
    }

.top-search-text {
    flex: 1;
    color: var(--muted);
}

kbd {
    font-family: var(--font);
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 6px;
    border: 1px solid var(--line);
    color: var(--muted);
    white-space: nowrap;
}

.nav-count {
    margin-left: auto;
    min-width: 1.4rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
}

[data-nav="collapsed"] .nav-count {
    position: absolute;
    top: 0.3rem;
    right: 0.6rem;
    min-width: 0;
    width: 0.55rem;
    height: 0.55rem;
    padding: 0;
    font-size: 0;
}

.nav-item {
    position: relative;
}

.nav-pinned {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-height: 0;
    overflow-y: auto;
}

.nav-heading {
    margin: 0 0.8rem 0.3rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.nav-pin {
    min-height: 2.4rem;
    font-size: 0.92rem;
}

    .nav-pin .nav-label {
        overflow: hidden;
        text-overflow: ellipsis;
    }

.command-scrim {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.5);
    animation: content-in 0.15s ease;
}

.command-bar {
    position: fixed;
    z-index: 51;
    top: 12vh;
    left: 50%;
    width: min(40rem, calc(100vw - 2rem));
    max-height: 70vh;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--hairline-strong);
    border-radius: 18px;
    box-shadow: var(--shadow-pop);
    overflow: hidden;
    animation: pop-in 0.16s var(--ease);
}

.command-input {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid var(--hairline);
    color: var(--muted);
}

    .command-input input {
        flex: 1;
        min-width: 0;
        background: none;
        border: none;
        outline: none;
        color: var(--text);
        font: inherit;
        font-size: 1.05rem;
    }

.command-chips, .quick-capture-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.command-chips {
    padding: 0.6rem 1.1rem 0;
}

    .command-chips .tag, .quick-capture-chips .tag {
        border-color: var(--accent);
        color: var(--accent);
    }

.command-saved {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin: 0.6rem 1.1rem 0;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius);
    background: var(--accent-wash);
    font-size: 0.92rem;
}

.command-results {
    list-style: none;
    margin: 0;
    padding: 0.4rem;
    overflow-y: auto;
}

.command-group {
    padding: 0.6rem 0.7rem 0.25rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.command-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 2.75rem;
    padding: 0.45rem 0.7rem;
    border-radius: 10px;
    cursor: pointer;
}

    .command-item.selected {
        background: var(--raised);
    }

.command-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.command-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.command-detail {
    font-size: 0.8rem;
    color: var(--muted);
}

.command-help {
    padding: 0.5rem 1.2rem 1.2rem;
    overflow-y: auto;
    font-size: 0.92rem;
}

    .command-help h2 {
        font-size: 1rem;
        margin: 1rem 0 0.5rem;
    }

    .command-help dl {
        display: grid;
        grid-template-columns: auto 1fr;
        gap: 0.4rem 1rem;
        margin: 0;
    }

    .command-help dd {
        margin: 0;
        color: var(--muted);
    }

.quick-capture {
    margin-bottom: 1.1rem;
}

.quick-capture-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 3.25rem;
    padding: 0.35rem 0.4rem 0.35rem 1rem;
    border-radius: 14px;
    background: var(--panel);
    border: 1px solid var(--hairline-strong);
    box-shadow: var(--shadow);
    color: var(--accent);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

    .quick-capture-row:focus-within {
        border-color: var(--accent);
        box-shadow: 0 0 0 3px var(--accent-wash), var(--shadow);
    }

    .quick-capture-row input {
        flex: 1;
        min-width: 0;
        background: none;
        border: none;
        outline: none;
        color: var(--text);
        font: inherit;
    }

.quick-capture-chips {
    padding: 0.5rem 0.4rem 0;
    font-size: 0.85rem;
}

.quick-capture.inline .quick-capture-row {
    min-height: 2.75rem;
    margin-top: 0.75rem;
    box-shadow: none;
    border-style: dashed;
    border-color: var(--line);
}

    .quick-capture.inline .quick-capture-row .button {
        min-height: 2.2rem;
        padding: 0.3rem 0.8rem;
        font-size: 0.85rem;
    }

.inbox-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.6rem;
}

.inbox-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    background: var(--panel);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: opacity 0.3s ease, transform 0.3s var(--ease);
}

    .inbox-row.is-completing {
        opacity: 0;
        transform: translateX(14px);
    }

.inbox-body {
    flex: 1;
    min-width: 0;
    display: grid;
    gap: 0.2rem;
    color: var(--text);
}

    .inbox-body:hover {
        color: var(--text);
    }

.inbox-file {
    flex: 0 0 13rem;
}

.inbox-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
    color: var(--muted);
}

    .inbox-empty strong {
        color: var(--text);
    }

.share-form, .share-done {
    max-width: 36rem;
}

.share-kind {
    margin-bottom: 0.5rem;
}

.segmented button {
    padding: 0.5rem 0.9rem;
    border: none;
    background: none;
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

    .segmented button.selected {
        background: var(--raised-2);
        font-weight: 600;
    }

.side-panel-tools {
    display: flex;
    gap: 0.25rem;
}

.pin-button.pinned {
    color: var(--accent);
}

.button.pin-button.pinned {
    border-color: var(--accent);
}

.markdown.tickable .task-list-item input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--accent);
    cursor: pointer;
    vertical-align: -0.15em;
}

.picker-create {
    color: var(--accent);
}

@media (max-width: 760px) {
    .inbox-row {
        flex-wrap: wrap;
    }

    .inbox-file {
        flex: 1 1 100%;
    }

    .top-search kbd {
        display: none;
    }
}

/* UI fixes: collapse arrow, ⋯ menus, category pages, settings */

.nav-toggle {
    position: absolute;
    top: 1.7rem;
    right: -0.8rem;
    z-index: 6;
    width: 1.6rem;
    height: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--hairline-strong);
    background: var(--panel);
    color: var(--muted);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, transform 0.15s var(--ease);
}

    .nav-toggle:hover {
        color: var(--text);
        border-color: var(--accent);
        transform: scale(1.08);
    }

.popover-person {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.4rem 0.6rem 0.7rem;
    margin-bottom: 0.3rem;
    border-bottom: 1px solid var(--hairline);
}

    .popover-person > span:last-child {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

        .popover-person > span:last-child > span {
            font-size: 0.8rem;
            overflow: hidden;
            text-overflow: ellipsis;
        }

.popover .menu-row {
    white-space: nowrap;
}

.account-popover {
    min-width: 15rem;
}

.menu-row kbd {
    margin-left: auto;
}

.menu-row.danger:hover {
    background: var(--raised-2);
    color: var(--text);
    box-shadow: inset 3px 0 0 var(--text);
}

.more-menu {
    position: relative;
}

.more-button {
    border: 1px solid var(--hairline-strong);
    width: 2.75rem;
    height: 2.75rem;
    border-radius: var(--radius);
}

.more-popover {
    right: 0;
    top: calc(100% + 0.4rem);
    min-width: 14rem;
}

.theme-grid {
    grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    border-bottom: none;
    padding: 0;
    margin: 0.5rem 0 0;
}

h1.with-icon {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.subcategory-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.1rem;
}

.subcategory-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.5rem;
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--hairline-strong);
    background: var(--panel);
    color: var(--text);
}

    .subcategory-chip:hover {
        border-color: var(--accent);
        color: var(--text);
    }

    .subcategory-chip .count {
        font-size: 0.8rem;
        color: var(--muted);
    }

.category-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
    gap: 1.1rem;
    align-items: start;
}

    .category-sections .card-head h2 .count {
        font-family: var(--font);
        font-size: 0.85rem;
        font-weight: 400;
        color: var(--muted);
        margin-left: 0.3rem;
    }

.section-links {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.dated-item {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
}

    .dated-item > .agenda-list {
        flex: 1;
        min-width: 0;
    }

.date-badge {
    flex: 0 0 2.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
}

    .date-badge strong {
        font-family: var(--font-title);
        font-size: 1.3rem;
        color: var(--text);
        line-height: 1.1;
    }

.category-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.4rem;
    max-width: 48rem;
}

    .category-list li {
        padding-left: calc(var(--depth, 0) * 1.5rem);
    }

.category-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 3rem;
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    background: var(--panel);
    border: 1px solid var(--hairline);
    color: var(--text);
    transition: border-color 0.15s ease, transform 0.15s var(--ease);
}

    .category-row:hover {
        color: var(--text);
        border-color: var(--hairline-strong);
        transform: translateX(2px);
    }

    .category-row > .icon {
        color: var(--accent);
    }

    .category-row.unfiled > .icon {
        color: var(--muted);
    }

.category-name {
    flex: 1;
    font-weight: 600;
}

.category-counts {
    display: flex;
    gap: 0.9rem;
    font-size: 0.85rem;
    color: var(--muted);
}

    .category-counts span {
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;
    }

/* Runbooks and templates (phase 8) */

.markdown pre.has-copy {
    position: relative;
    padding-right: 4.5rem;
}

.copy-code {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.2rem 0.6rem;
    font: 600 0.75rem/1.4 var(--font);
    color: var(--muted);
    background: var(--raised);
    border: 1px solid var(--hairline-strong);
    border-radius: 999px;
    cursor: pointer;
    opacity: 0.75;
    transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

    .markdown pre:hover .copy-code, .copy-code:focus-visible {
        opacity: 1;
    }

    .copy-code:hover {
        color: var(--text);
        border-color: var(--accent);
    }

    .copy-code.copied {
        color: var(--on-accent);
        background: var(--accent);
        border-color: var(--accent);
        opacity: 1;
    }

code.copyable {
    cursor: copy;
    border: 1px dashed transparent;
    transition: border-color 0.15s ease, background 0.15s ease;
}

    code.copyable:hover, code.copyable:focus-visible {
        border-color: var(--line);
        outline: none;
    }

    code.copyable.copied {
        background: var(--accent);
        color: var(--on-accent);
    }

.run-clock {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--hairline-strong);
    background: var(--panel);
    font: 600 1.05rem var(--font-mono);
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    white-space: nowrap;
}

    .run-clock.running {
        color: var(--text);
        border-color: var(--accent);
    }

        .run-clock.running .icon {
            color: var(--accent);
        }

.run-values {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0 0 1rem;
}

    .run-values > div {
        display: flex;
        align-items: center;
        gap: 0.45rem;
        padding: 0.3rem 0.4rem 0.3rem 0.75rem;
        border-radius: 999px;
        background: var(--panel);
        border: 1px solid var(--hairline);
    }

    .run-values dt {
        font-size: 0.8rem;
        color: var(--muted);
    }

    .run-values dd {
        margin: 0;
    }

.value-copy {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: var(--raised);
    cursor: copy;
}

.chip-button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 2rem;
    padding: 0.2rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--hairline-strong);
    background: var(--raised);
    color: var(--text);
    font: 500 0.85rem var(--font);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

    .chip-button:hover {
        border-color: var(--accent);
        color: var(--text);
    }

    .chip-button .icon {
        color: var(--accent);
    }

.step-timer {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.15rem 0.35rem 0.15rem 0.7rem;
    border-radius: 999px;
    background: var(--accent-wash);
    border: 1px solid var(--accent);
    font: 600 0.85rem var(--font-mono);
    font-variant-numeric: tabular-nums;
}

    .step-timer .link-button {
        font: 500 0.8rem var(--font);
    }

    .step-timer.ended {
        background: var(--accent);
        color: var(--on-accent);
    }

        .step-timer.ended .link-button {
            color: var(--on-accent);
        }

.checklist li.timer-ended {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-wash);
    animation: timer-pulse 1.6s ease-in-out 3;
}

@keyframes timer-pulse {
    50% {
        box-shadow: 0 0 0 7px var(--accent-wash);
    }
}

.took {
    color: var(--muted);
}

.run-reference {
    margin: 0 0 1.5rem;
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    background: var(--panel);
    padding: 0.4rem 1rem;
}

    .run-reference > summary {
        cursor: pointer;
        font-weight: 600;
        padding: 0.5rem 0;
    }

    .run-reference[open] > summary {
        border-bottom: 1px solid var(--hairline);
        margin-bottom: 0.75rem;
    }

    .run-reference .markdown pre {
        background: var(--bg);
    }

.values-form {
    margin: 0.5rem 0 1.25rem;
    display: grid;
    gap: 0.75rem;
}

    .values-form h3, .values-form h1, .values-form p {
        margin: 0;
    }

.values-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
    gap: 0.75rem;
}

    .values-grid label {
        display: grid;
        gap: 0.3rem;
        font-weight: 600;
        font-size: 0.9rem;
    }

.template-fill {
    max-width: 44rem;
}

.template-note {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0 0 0.75rem;
}

.template-new {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.template-group {
    margin-bottom: 1.75rem;
}

    .template-group h2 {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        font-size: 1.15rem;
    }

.template-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.6rem;
}

.template-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    background: var(--panel);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
}

.template-body {
    flex: 1;
    min-width: 0;
    display: grid;
    gap: 0.3rem;
}

.template-name {
    font-weight: 600;
    color: var(--text);
}

.template-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.9rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.template-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.blank-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.blank-chip {
    display: inline-block;
    padding: 0.05rem 0.55rem;
    margin: 0 0.15rem;
    border-radius: 999px;
    border: 1px dashed var(--line);
    font: 0.8rem var(--font-mono);
    color: var(--text);
}

    .blank-chip::before {
        content: "{{";
        color: var(--muted);
    }

    .blank-chip::after {
        content: "}}";
        color: var(--muted);
    }

.template-help ul {
    text-align: left;
    display: inline-grid;
    gap: 0.4rem;
}

.menu-divider {
    border-top: 1px solid var(--hairline);
    margin-top: 0.3rem;
    padding-top: 0.6rem;
}

/* Sharing (phase 10): the other person's colour, avatars, share panel, badges */

.avatar.small {
    width: 1.35rem;
    height: 1.35rem;
    font-size: 0.6rem;
    flex: 0 0 auto;
}

.avatar.theirs, .nav-avatar.theirs {
    background: var(--partner);
    color: var(--on-partner);
}

.avatar.mine {
    background: var(--accent);
    color: var(--on-accent);
}

.nav-avatar {
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: 700 0.6rem var(--font);
    flex: 0 0 auto;
}

.assignee {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.3rem;
    height: 1.3rem;
    margin-left: 0.4rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    font: 700 0.6rem var(--font);
    vertical-align: middle;
}

    .assignee.mine {
        background: var(--accent);
        color: var(--on-accent);
    }

    .assignee.theirs {
        background: var(--partner);
        color: var(--on-partner);
    }

.chip.theirs {
    background: var(--partner-wash);
    border-left: 3px solid var(--partner);
    color: var(--text);
}

.agenda-item.theirs {
    box-shadow: inset 3px 0 0 var(--partner);
}

    .agenda-item.theirs .entry-title {
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
    }

.calendar-people {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: -0.25rem 0 1rem;
}

.person-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.25rem;
    padding: 0.2rem 0.8rem 0.2rem 0.3rem;
    border-radius: 999px;
    border: 1px solid var(--hairline-strong);
    background: var(--panel);
    color: var(--muted);
    font: 500 0.85rem var(--font);
    cursor: pointer;
    opacity: 0.65;
    transition: opacity 0.15s ease, border-color 0.15s ease;
}

    .person-toggle.on {
        opacity: 1;
        color: var(--text);
    }

    .person-toggle.on.mine {
        border-color: var(--accent);
    }

    .person-toggle.on.theirs {
        border-color: var(--partner);
    }

    .person-toggle:not(.on) .avatar {
        filter: grayscale(1);
    }

.share-card {
    margin-bottom: 1.25rem;
    max-width: 40rem;
}

.share-people {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
    display: grid;
    gap: 0.6rem;
}

    .share-people li {
        display: flex;
        align-items: center;
        gap: 0.75rem;
    }

    .share-people select {
        width: auto;
        min-width: 9rem;
    }

.share-name {
    flex: 1;
    display: grid;
    font-weight: 600;
}

    .share-name .hint {
        font-weight: 400;
        margin: 0;
    }

.sharing-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0.35rem 0 0;
    padding: 0.2rem 0.7rem 0.2rem 0.3rem;
    border-radius: 999px;
    background: var(--panel);
    border: 1px solid var(--hairline);
    font-size: 0.85rem;
    color: var(--muted);
}

    .sharing-badge > .icon {
        margin-left: 0.3rem;
        color: var(--accent);
    }

.sharing-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--muted);
    margin-left: 0.5rem;
}

.view-only-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    border: 1px dashed var(--line);
    color: var(--muted);
    font-size: 0.85rem;
}

.tree-shared {
    display: inline-flex;
    color: var(--accent);
    margin-left: 0.15rem;
}

    .tree-shared.theirs {
        color: var(--partner);
    }

.todo-filters {
    display: flex;
    gap: 0.4rem;
    margin: 0 0 1rem;
}

    .todo-filters .chip-button.active {
        border-color: var(--accent);
        background: var(--accent-wash);
    }

.switch-list {
    display: grid;
    gap: 0.25rem;
    margin: 0.5rem 0 1rem;
}

/* Motion. Everything here is switched off when the device asks for less motion. */

@keyframes pop-in {
    from { opacity: 0; transform: translateY(4px) scale(0.97); }
    to { opacity: 1; transform: none; }
}

@keyframes content-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

@keyframes panel-in {
    from { opacity: 0; transform: translateX(16px); }
    to { opacity: 1; transform: none; }
}

@keyframes sheet-in {
    from { transform: translateY(100%); }
    to { transform: none; }
}

@keyframes check-pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.notice {
    animation: pop-in 0.2s var(--ease);
}

.todo-row.is-completing {
    opacity: 0;
    transform: translateX(14px);
    transition-delay: 0.18s;
}

    .todo-row.is-completing .todo-check {
        animation: check-pop 0.3s var(--ease);
    }

    .todo-row.is-completing .todo-title {
        text-decoration: line-through;
        text-decoration-color: var(--accent);
    }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0s !important;
    }
}

/* Medium screens: cards stack, side panels become sheets */

@media (max-width: 1100px) {
    .span-7, .span-5 {
        grid-column: span 12;
    }

    .span-4 {
        grid-column: span 5;
    }

    .span-8 {
        grid-column: span 7;
    }

    .with-panel.panel-open {
        grid-template-columns: minmax(0, 1fr);
    }

    .side-panel {
        position: fixed;
        z-index: 41;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        max-height: 82vh;
        border-radius: 22px 22px 0 0;
        padding-bottom: max(1.4rem, env(safe-area-inset-bottom));
        animation: sheet-in 0.26s var(--ease);
    }

    .panel-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 40;
        background: rgba(0, 0, 0, 0.5);
        animation: content-in 0.2s ease;
    }

    .calendar-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .calendar-side {
        position: static;
    }
}

/* Narrow screens: one editor pane at a time */

@media (max-width: 900px) {
    .mode-switch {
        display: flex;
    }

    .editor-panes {
        grid-template-columns: 1fr;
    }

        .editor-panes.show-write .preview,
        .editor-panes.show-preview .body-input {
            display: none;
        }
}

/* Phones: bottom tabs, a floating New button, stacked library */

@media (max-width: 760px) {
    .app-nav, .desktop-only {
        display: none;
    }

    .phone-only {
        display: block;
    }

    .app-top .app-brand.phone-only {
        display: flex;
        padding: 0;
    }

    .app-top {
        padding: 0.75rem 1rem;
        padding-top: max(0.75rem, env(safe-area-inset-top));
        gap: 0.6rem;
    }

    .content {
        padding: 0.5rem 1rem calc(7.5rem + env(safe-area-inset-bottom));
    }

    .tabbar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 20;
        padding: 0.3rem 0.4rem max(0.5rem, env(safe-area-inset-bottom));
        background: color-mix(in srgb, var(--rail) 92%, transparent);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        border-top: 1px solid var(--hairline);
    }

    .tab {
        flex: 1;
        min-width: 0;
        min-height: 3.25rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.15rem;
        font-size: 0.68rem;
        color: var(--muted);
        border-radius: 12px;
    }

        .tab.active {
            color: var(--accent);
            font-weight: 600;
        }

    .fab-menu {
        position: fixed;
        right: 1rem;
        bottom: calc(5rem + env(safe-area-inset-bottom));
        z-index: 21;
    }

    .home-grid {
        gap: 1rem;
    }

    .span-4, .span-8 {
        grid-column: span 12;
    }

    .home-header h1 {
        font-size: 1.9rem;
    }

    .summary-strip {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .summary-tile {
        padding: 0.8rem 1rem;
        border-radius: 14px;
        background: var(--panel);
        border: 1px solid var(--hairline);
    }

        .summary-tile strong {
            display: block;
            font-family: var(--font-title);
            font-size: 1.5rem;
            line-height: 1.2;
        }

        .summary-tile span {
            font-size: 0.82rem;
            color: var(--muted);
        }

    .card {
        padding: 1.1rem 1.1rem;
    }

    .library {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .sidebar {
        position: static;
        max-height: 40vh;
        border-bottom: 1px solid var(--hairline);
        padding-bottom: 0.75rem;
    }

    h1 {
        font-size: 1.6rem;
    }

    .quick-add {
        flex-wrap: wrap;
    }

        .quick-add .input:first-child {
            flex-basis: 100%;
        }

    .day-cell {
        min-height: 3.2rem;
        align-items: center;
        padding: 0.15rem;
    }

    .day-chips {
        display: none;
    }

    .day-dots {
        display: block;
    }

    .agenda-item {
        flex-direction: column;
        gap: 0.2rem;
    }

    .agenda-time {
        flex-basis: auto;
    }

    .sticky-actions {
        bottom: calc(4.4rem + env(safe-area-inset-bottom));
    }
}

/* Blazor error bar */

#blazor-error-ui {
    background: var(--text);
    color: var(--bg);
    bottom: 0;
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui a {
        color: var(--bg);
    }

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: var(--panel);
    border-left: 4px solid var(--text);
    padding: 1rem;
}

    .blazor-error-boundary::after {
        content: "Something went wrong showing this part of the page.";
    }
