/* Claude Memory Web UI — Custom Theme */

:root {
    color-scheme: dark light;

    /* Core palette */
    --color-bg: light-dark(#f5f5f7, #1e2028);
    --color-surface: light-dark(#ffffff, #262830);
    --color-surface-hover: light-dark(#f0f0f2, #2d3038);
    --color-border: light-dark(#e0e0e4, #363a44);
    --color-border-strong: light-dark(#d0d0d5, #444952);

    /* Text */
    --color-text: light-dark(#1a1a1e, #eceef4);
    --color-text-muted: light-dark(#6b6e7a, #8e94ad);
    --color-text-faint: light-dark(#9a9daa, #626a82);

    /* Accent */
    --color-accent: light-dark(#4a6ee0, #7b98ff);
    --color-accent-dim: light-dark(#e8eef8, #242c48);

    /* Sidebar */
    --color-sidebar: light-dark(#fafafa, #1a1c24);
    --color-sidebar-border: light-dark(#e8e8ec, #30343e);

    /* Entry type colors */
    --color-type-note-bg: light-dark(#e8eef8, #222c48);
    --color-type-note: light-dark(#4a6ee0, #7b98ff);

    --color-type-decision-bg: light-dark(#f0e8f8, #302342);
    --color-type-decision: light-dark(#7c3aed, #b88ef0);

    --color-type-issue-bg: light-dark(#f8e8e8, #362020);
    --color-type-issue: light-dark(#dc2626, #f07878);

    --color-type-context-bg: light-dark(#e8f4f8, #203036);
    --color-type-context: light-dark(#0891b2, #68c4d4);

    --color-type-progress-bg: light-dark(#e8f8ee, #1e3424);
    --color-type-progress: light-dark(#16a34a, #78d496);

    --color-type-plan-bg: light-dark(#f8f4e8, #34301c);
    --color-type-plan: light-dark(#ca8a04, #dcc050);

    /* Stale */
    --color-stale-bg: light-dark(#fef3e0, #2a200a);
    --color-stale: light-dark(#b8860b, #6b4d1a);
    --color-stale-text: light-dark(#92670a, #d4b84a);

    /* Pinned */
    --color-pinned: light-dark(#d97706, #f59e0b);
    --color-pinned-bg: light-dark(rgba(217, 119, 6, 0.05), rgba(245, 158, 11, 0.08));

    /* Semantic search score */
    --color-score: light-dark(#0891b2, #06b6d4);

    /* Reference colors */
    --color-ref-in: light-dark(#16a34a, #22c55e);

    /* Read-only banner */
    --color-banner-bg: light-dark(#f0f4e8, #1e2518);
    --color-banner-border: light-dark(#c8d8a0, #40522e);
    --color-banner-text: light-dark(#5a8020, #98cc60);
    --color-banner-muted: light-dark(#7a9050, #748460);

    /* Layout dimensions */
    --sidebar-width: 240px;
    --topbar-height: 48px;

    /* Typography */
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace;
}

/* ── Reset & Base ──────────────────────────────────────────────────────────── */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    max-width: 100%;
    overflow-x: hidden;
    font-family: var(--font-sans);
    font-size: 16px;
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--color-accent);
    text-decoration: none;

    &:hover {
        text-decoration: underline;
    }
}

code, pre {
    font-family: var(--font-mono);
    font-size: 0.875em;
}

pre {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    overflow-x: auto;
}

hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 1.5rem 0;
}

h1, h2, h3, h4 {
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 1.5rem; margin-bottom: 0.75rem; }
h2 { font-size: 1.15rem; margin-bottom: 0.5rem; }
h3 { font-size: 1rem; margin-bottom: 0.5rem; }

/* ── App Shell ─────────────────────────────────────────────────────────────── */

.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ── Topbar ────────────────────────────────────────────────────────────────── */

.topbar {
    display: flex;
    align-items: center;
    height: var(--topbar-height);
    padding: 0 20px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-sidebar-border);
    flex-shrink: 0;
    gap: 4px;
    z-index: 20;

    & .brand {
        font-size: 1.05rem;
        font-weight: 600;
        color: var(--color-text);
        margin-right: 1.5rem;
        text-decoration: none;
    }
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 0;
    height: 100%;

    & a {
        display: flex;
        align-items: center;
        height: 100%;
        padding: 0 12px;
        font-size: 0.875rem;
        color: var(--color-text-muted);
        text-decoration: none;
        border-bottom: 2px solid transparent;
        transition: color 0.12s;

        &:hover {
            color: var(--color-text);
            text-decoration: none;
        }

        &.active {
            color: var(--color-text);
            font-weight: 500;
            border-bottom-color: var(--color-accent);
        }
    }
}

.topbar-spacer {
    flex: 1;
}

.topbar-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ── Read-only banner ──────────────────────────────────────────────────────── */

.readonly-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 20px;
    background: var(--color-banner-bg);
    border-bottom: 1px solid var(--color-banner-border);
    flex-shrink: 0;

    & .label {
        color: var(--color-banner-text);
        font-size: 0.7rem;
        font-family: var(--font-mono);
        letter-spacing: 0.06em;
    }

    & .message {
        color: var(--color-banner-muted);
        font-size: 0.8rem;
    }
}

/* ── Layout body ───────────────────────────────────────────────────────────── */

.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar);
    border-right: 1px solid var(--color-sidebar-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-sidebar-border);

    & .sidebar-label {
        font-family: var(--font-mono);
        font-size: 0.65rem;
        color: var(--color-text-faint);
        letter-spacing: 0.1em;
        text-transform: uppercase;
    }
}

.sidebar-filter {
    padding: 8px 10px;
    border-bottom: 1px solid var(--color-sidebar-border);

    & input {
        width: 100%;
        background: var(--color-border);
        border: none;
        border-radius: 5px;
        padding: 5px 8px;
        color: var(--color-text);
        font-family: var(--font-sans);
        font-size: 0.8rem;
        outline: none;

        &::placeholder {
            color: var(--color-text-faint);
        }
    }
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 12px;
}

.sidebar-all-link {
    display: block;
    padding: 7px 12px 7px 14px;
    cursor: pointer;
    font-size: 0.825rem;
    color: var(--color-text-muted);
    text-decoration: none;
    border-left: 2px solid transparent;

    &:hover {
        background: rgba(255, 255, 255, 0.03);
        text-decoration: none;
    }

    &.active {
        color: var(--color-accent);
        background: var(--color-accent-dim);
        border-left-color: var(--color-accent);
    }
}

/* ── Sidebar project tree ──────────────────────────────────────────────────── */

.sidebar-project {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px 5px var(--indent);
    cursor: pointer;
    text-decoration: none;
    color: var(--color-text-muted);
    border-left: 2px solid transparent;
    transition: background 0.1s;
    font-size: 0.825rem;

    &:hover {
        background: rgba(255, 255, 255, 0.03);
        text-decoration: none;
    }

    &.active {
        color: var(--color-accent);
        background: var(--color-accent-dim);
        border-left-color: var(--color-accent);
        font-weight: 500;
    }

    & .project-name {
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    & .project-count {
        font-size: 0.7rem;
        color: var(--color-text-faint);
        font-family: var(--font-mono);
        flex-shrink: 0;
    }

    & .tree-toggle {
        width: 12px;
        flex-shrink: 0;
        color: var(--color-text-faint);
        font-size: 0.65rem;
    }
}

/* ── Main content area ─────────────────────────────────────────────────────── */

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
    min-width: 0;
}

/* ── Stat cards ────────────────────────────────────────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 7px;
    padding: 14px 16px;

    & .stat-value {
        font-size: 2rem;
        font-weight: 700;
        line-height: 1;
        color: var(--stat-color, var(--color-accent));
    }

    & .stat-label {
        color: var(--color-text-muted);
        font-size: 0.65rem;
        font-family: var(--font-mono);
        text-transform: uppercase;
        letter-spacing: 0.09em;
        margin-top: 5px;
    }
}

/* ── Section headers ───────────────────────────────────────────────────────── */

.section-header {
    font-size: 0.7rem;
    font-family: var(--font-mono);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    margin: 0 0 10px;
}

/* ── Dashboard grid ────────────────────────────────────────────────────────── */

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    min-width: 0;
}

@media (max-width: 960px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.dashboard-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

/* ── Entry rows (compact) ──────────────────────────────────────────────────── */

.entry-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 5px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.12s;

    &:hover {
        border-color: var(--color-border-strong);
        text-decoration: none;
    }

    &.pinned {
        border-color: var(--color-pinned);
        background: var(--color-pinned-bg);
    }

    & .entry-body {
        flex: 1;
        min-width: 0;
        overflow-wrap: anywhere;
    }

    & .entry-title {
        color: var(--color-text);
        font-size: 0.875rem;
        font-weight: 500;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    & .entry-summary {
        color: var(--color-text-muted);
        font-size: 0.8rem;
        line-height: 1.4;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        overflow-wrap: anywhere;
    }

    & .entry-meta {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 3px;
        flex-shrink: 0;
    }

    & .entry-project {
        color: var(--color-accent);
        font-size: 0.8rem;
        font-family: var(--font-mono);
    }

    & .entry-date {
        color: var(--color-text-faint);
        font-size: 0.75rem;
        font-family: var(--font-mono);
    }

    & .entry-refs {
        display: flex;
        gap: 4px;
    }
}

.entry-list {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 5px;
}

/* ── Type chips (badges) ───────────────────────────────────────────────────── */

.type-chip {
    display: inline-block;
    border-radius: 3px;
    padding: 2px 7px;
    font-size: 0.65rem;
    font-family: var(--font-mono);
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    line-height: 1.5;
}

.type-chip-note { background: var(--color-type-note-bg); color: var(--color-type-note); border: 1px solid color-mix(in srgb, var(--color-type-note) 20%, transparent); }
.type-chip-decision { background: var(--color-type-decision-bg); color: var(--color-type-decision); border: 1px solid color-mix(in srgb, var(--color-type-decision) 20%, transparent); }
.type-chip-issue { background: var(--color-type-issue-bg); color: var(--color-type-issue); border: 1px solid color-mix(in srgb, var(--color-type-issue) 20%, transparent); }
.type-chip-context { background: var(--color-type-context-bg); color: var(--color-type-context); border: 1px solid color-mix(in srgb, var(--color-type-context) 20%, transparent); }
.type-chip-progress { background: var(--color-type-progress-bg); color: var(--color-type-progress); border: 1px solid color-mix(in srgb, var(--color-type-progress) 20%, transparent); }
.type-chip-plan { background: var(--color-type-plan-bg); color: var(--color-type-plan); border: 1px solid color-mix(in srgb, var(--color-type-plan) 20%, transparent); }

/* ── Stale badge ───────────────────────────────────────────────────────────── */

.badge-stale {
    display: inline-block;
    background: var(--color-stale-bg);
    color: var(--color-stale-text);
    border: 1px solid color-mix(in srgb, var(--color-stale) 30%, transparent);
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 0.55rem;
    font-family: var(--font-mono);
    text-transform: uppercase;
}

/* ── Pin indicator ─────────────────────────────────────────────────────────── */

.pin-indicator {
    display: inline-flex;
    align-items: center;
    color: var(--color-pinned);

    & svg { display: block; }
}

/* ── Score indicator (semantic search) ─────────────────────────────────────── */

.score-indicator {
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--color-surface);
    color: var(--color-score);
    font-weight: 600;
    font-family: var(--font-mono);
    border: 1px solid var(--color-border);
}

/* ── Reference indicators ──────────────────────────────────────────────────── */

.ref-indicator {
    font-size: 0.7rem;
    padding: 1px 5px;
    border-radius: 3px;
    color: var(--color-text-faint);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    font-family: var(--font-mono);
    cursor: help;

    &.ref-out { color: var(--color-accent); }
    &.ref-in { color: var(--color-ref-in); }
}

/* ── Activity bar (entry breakdown) ────────────────────────────────────────── */

.activity-bar {
    display: flex;
    align-items: center;
    gap: 10px;

    & .bar-label {
        color: var(--color-text-muted);
        font-size: 0.7rem;
        font-family: var(--font-mono);
        width: 68px;
        flex-shrink: 0;
        text-transform: uppercase;
    }

    & .bar-track {
        flex: 1;
        background: var(--color-border);
        border-radius: 2px;
        height: 5px;
    }

    & .bar-fill {
        border-radius: 2px;
        height: 5px;
    }

    & .bar-value {
        color: var(--color-text-faint);
        font-size: 0.7rem;
        font-family: var(--font-mono);
        width: 32px;
        text-align: right;
    }
}

/* ── Panel (surface container) ─────────────────────────────────────────────── */

.panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 7px;
    padding: 14px 16px;
    min-width: 0;
    overflow: hidden;
}

/* ── Top projects list ─────────────────────────────────────────────────────── */

.top-project-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 5px;
    text-decoration: none;
    color: var(--color-text);
    font-size: 0.875rem;
    transition: border-color 0.12s;

    &:hover {
        border-color: var(--color-border-strong);
        text-decoration: none;
    }

    & .count {
        color: var(--color-accent);
        font-size: 0.725rem;
        font-family: var(--font-mono);
    }
}

/* ── Issues & Plans list ───────────────────────────────────────────────────── */

.compact-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--color-border);
    text-decoration: none;
    color: inherit;
    transition: background 0.1s;
    min-width: 0;

    &:last-child {
        border-bottom: none;
    }

    &:hover {
        background: var(--color-surface-hover);
        text-decoration: none;
    }

    & .compact-title {
        flex: 1;
        color: var(--color-text);
        font-size: 0.8rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    & .compact-project {
        color: var(--color-text-faint);
        font-size: 0.65rem;
        font-family: var(--font-mono);
        flex-shrink: 0;
    }
}

/* ── Tags ──────────────────────────────────────────────────────────────────── */

.tag {
    display: inline-block;
    background: var(--color-surface-hover);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    padding: 1px 6px;
    font-size: 0.65rem;
    font-family: var(--font-mono);
    letter-spacing: 0.04em;
}

/* ── Breadcrumbs ───────────────────────────────────────────────────────────── */

.breadcrumbs {
    color: var(--color-text-faint);
    font-size: 0.725rem;
    font-family: var(--font-mono);
    margin-bottom: 10px;

    & a {
        color: var(--color-accent);
    }

    & .sep {
        margin: 0 6px;
    }
}

/* ── Project detail ────────────────────────────────────────────────────────── */

.project-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;

    & .project-tags {
        display: flex;
        gap: 5px;
        margin-top: 6px;
    }
}

.project-identifiers {
    color: var(--color-text-faint);
    font-size: 0.75rem;
    font-family: var(--font-mono);
    margin-top: 0.5rem;

    & .separator {
        margin: 0 0.5rem;
    }
}

/* ── Summary section ───────────────────────────────────────────────────────── */

.summary-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 7px;
    padding: 14px;
    margin-bottom: 18px;

    & .summary-header {
        display: flex;
        justify-content: space-between;
        margin-bottom: 8px;

        & .summary-title {
            font-size: 0.825rem;
            font-weight: 600;
            color: var(--color-text);
        }

        & .summary-date {
            font-size: 0.65rem;
            color: var(--color-text-faint);
            font-family: var(--font-mono);
        }
    }

    & .summary-body {
        color: var(--color-text-muted);
        font-size: 0.825rem;
        line-height: 1.6;

        & p:last-child { margin-bottom: 0; }
    }

    & .summary-tabs {
        margin-top: 4px;
    }

    & .summary-footer {
        border-top: 1px solid var(--color-border);
        padding-top: 8px;
        margin-top: 10px;
    }
}

/* ── Summary tabs ─────────────────────────────────────────────────────────── */

.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--color-border);
    overflow-x: auto;
    scrollbar-width: none;

    &::-webkit-scrollbar { display: none; }

    & button {
        background: none;
        border: none;
        border-bottom: 2px solid transparent;
        padding: 6px 14px;
        font-size: 0.8rem;
        font-family: var(--font-sans);
        color: var(--color-text-muted);
        cursor: pointer;
        white-space: nowrap;
        transition: color 0.12s, border-color 0.12s;

        &:hover {
            color: var(--color-text);
        }

        &.active {
            color: var(--color-text);
            font-weight: 500;
            border-bottom-color: var(--color-accent);
        }
    }
}

.tab-panel {
    display: none;
    color: var(--color-text-muted);
    font-size: 0.825rem;
    line-height: 1.6;
    padding: 10px 0 0;

    &.active {
        display: block;
    }

    & p:last-child { margin-bottom: 0; }
}

.open-question {
    display: flex;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-bottom: 3px;

    & .question-bullet {
        color: var(--color-type-issue);
    }
}

/* ── Child project summaries ───────────────────────────────────────────────── */

.child-summaries {
    margin: 1.5rem 0;
}

.child-summary-card {
    border: 1px solid var(--color-border);
    border-radius: 7px;
    padding: 1rem;
    margin-bottom: 1rem;

    & header {
        margin-bottom: 0.75rem;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid var(--color-border);

        & a { text-decoration: none; &:hover { text-decoration: underline; } }
    }
}

/* ── Filter bar ────────────────────────────────────────────────────────────── */

.filter-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.filter-chip {
    background: transparent;
    color: var(--color-text-faint);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 3px 9px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.12s;

    &:hover {
        border-color: var(--color-border-strong);
        text-decoration: none;
    }

    &.active {
        background: var(--color-accent-dim);
        color: var(--color-accent);
        border-color: color-mix(in srgb, var(--color-accent) 30%, transparent);
    }
}

/* Type-specific filter chips */
.filter-chip-note.active { background: var(--color-type-note-bg); color: var(--color-type-note); border-color: color-mix(in srgb, var(--color-type-note) 30%, transparent); }
.filter-chip-decision.active { background: var(--color-type-decision-bg); color: var(--color-type-decision); border-color: color-mix(in srgb, var(--color-type-decision) 30%, transparent); }
.filter-chip-issue.active { background: var(--color-type-issue-bg); color: var(--color-type-issue); border-color: color-mix(in srgb, var(--color-type-issue) 30%, transparent); }
.filter-chip-context.active { background: var(--color-type-context-bg); color: var(--color-type-context); border-color: color-mix(in srgb, var(--color-type-context) 30%, transparent); }
.filter-chip-progress.active { background: var(--color-type-progress-bg); color: var(--color-type-progress); border-color: color-mix(in srgb, var(--color-type-progress) 30%, transparent); }
.filter-chip-plan.active { background: var(--color-type-plan-bg); color: var(--color-type-plan); border-color: color-mix(in srgb, var(--color-type-plan) 30%, transparent); }

/* ── Search ────────────────────────────────────────────────────────────────── */

.search-form {
    margin-bottom: 1.5rem;
}

.search-input {
    width: 100%;
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: 7px;
    padding: 11px 16px;
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: 0.925rem;
    outline: none;
    margin-bottom: 12px;

    &:focus {
        border-color: var(--color-accent);
    }

    &::placeholder {
        color: var(--color-text-faint);
    }
}

.search-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 7px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;

    & label:first-child {
        font-size: 0.65rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--color-text-muted);
    }

    & select {
        margin-bottom: 0;
        min-width: 150px;
        background: var(--color-bg);
        border: 1px solid var(--color-border);
        border-radius: 5px;
        padding: 5px 8px;
        color: var(--color-text);
        font-size: 0.825rem;
    }
}

.filter-types {
    flex: 1;
    min-width: 200px;
}

.type-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.type-checkbox {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    margin-bottom: 0;

    & input[type="checkbox"] {
        margin: 0;
        width: auto;
        accent-color: var(--color-accent);
    }

    & .type-chip {
        cursor: pointer;
        opacity: 0.5;
        transition: opacity 0.15s;
    }

    & input[type="checkbox"]:checked + .type-chip {
        opacity: 1;
    }
}

/* ── Entry detail page ─────────────────────────────────────────────────────── */

.entry-detail {
    & .entry-detail-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0.5rem;
    }

    & .entry-badges {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    & .entry-detail-meta {
        color: var(--color-text-muted);
        font-size: 0.825rem;
    }

    & .entry-detail-content {
        margin: 1rem 0;
    }

    & .entry-footer {
        color: var(--color-text-muted);
        font-size: 0.825rem;

        & p { margin-bottom: 0.5rem; }
    }
}

/* ── Markdown content ──────────────────────────────────────────────────────── */

.markdown-content {
    & pre {
        background: var(--color-bg);
        padding: 1rem;
        border-radius: 6px;
        border: 1px solid var(--color-border);
        overflow-x: auto;
    }

    & code { font-size: 0.875em; }

    & blockquote {
        border-left: 3px solid var(--color-accent);
        padding-left: 1rem;
        margin-left: 0;
        color: var(--color-text-muted);
    }

    & p { margin-bottom: 0.75rem; }

    & ul, & ol {
        padding-left: 1.5rem;
        margin-bottom: 0.75rem;
    }
}

/* ── References ────────────────────────────────────────────────────────────── */

.references {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.reference-list {
    list-style: none;
    padding-left: 0;

    & li { padding: 0.25rem 0; }
}

.ref-type {
    color: var(--color-text-muted);
    font-size: 0.825rem;
    font-style: italic;
}

/* ── Empty states ──────────────────────────────────────────────────────────── */

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

    & h3 { margin-bottom: 0.5rem; }
}

/* ── Login page ────────────────────────────────────────────────────────────── */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-bg);
}

.login-card {
    max-width: 400px;
    width: 100%;
    text-align: center;
    padding: 2rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;

    & h1 { margin-bottom: 0.5rem; }
    & p { color: var(--color-text-muted); }
}

.login-button {
    display: block;
    width: 100%;
    padding: 10px 20px;
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: 7px;
    font-size: 0.925rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    margin-top: 1.5rem;

    &:hover {
        opacity: 0.9;
        text-decoration: none;
        color: white;
    }
}

/* ── User menu ─────────────────────────────────────────────────────────────── */

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;

    & .user-name {
        color: var(--color-text-muted);
        font-size: 0.825rem;
    }
}

.btn-outline {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    border-radius: 5px;
    padding: 4px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: none;

    &:hover {
        border-color: var(--color-border-strong);
        color: var(--color-text);
        text-decoration: none;
    }
}

/* ── Content preview (truncation) ──────────────────────────────────────────── */

.content-preview {
    max-height: 6em;
    overflow: hidden;
    position: relative;

    &::after {
        content: "";
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 2em;
        background: linear-gradient(transparent, var(--color-surface));
    }
}

/* ── htmx loading indicator ────────────────────────────────────────────────── */

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .topbar {
        padding: 0 12px;
        gap: 2px;

        & .brand {
            font-size: 0.95rem;
            margin-right: 0.75rem;
            white-space: nowrap;
        }
    }

    .topbar-nav a {
        padding: 0 8px;
        font-size: 0.8rem;
    }

    .readonly-banner {
        padding: 4px 12px;

        & .message {
            display: none;
        }
    }

    .main-content {
        padding: 14px 12px;
        overflow-x: hidden;
    }

    h1 {
        font-size: 1.4rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .stat-card {
        padding: 12px;

        & .stat-value {
            font-size: 1.5rem;
        }
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    /* Entry rows with meta (actual entries, not project list items) */
    .entry-row:has(.entry-meta) {
        display: flex;
        flex-direction: column;
        gap: 4px;
        padding: 10px;
        overflow: hidden;

        & .pin-indicator {
            position: absolute;
        }

        & .type-chip {
            align-self: flex-start;
        }

        & .entry-body {
            min-width: 0;
            width: 100%;
        }

        & .entry-title {
            white-space: normal;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        & .entry-summary {
            -webkit-line-clamp: 2;
            word-break: break-word;
        }

        & .entry-meta {
            flex-direction: row;
            flex-wrap: wrap;
            align-items: center;
            gap: 6px;
        }

        & .entry-date {
            font-size: 0.7rem;
            white-space: nowrap;
        }

        & .entry-project {
            display: none;
        }
    }

    .entry-row.pinned:has(.entry-meta) {
        padding-left: 28px;
        position: relative;

        & .pin-indicator {
            left: 10px;
            top: 12px;
        }
    }

    /* Project list items stay horizontal, just tighter */
    .entry-row:not(:has(.entry-meta)) {
        padding: 10px;
    }

    .entry-list {
        max-width: 100%;
        overflow: hidden;
    }

    .section-header {
        font-size: 0.75rem;
    }

    /* Search page */
    .search-filters {
        flex-direction: column;
        gap: 8px;
    }

    .search-input {
        font-size: 15px; /* prevents iOS zoom on focus */
    }

    /* Project detail */
    .project-identifiers {
        flex-wrap: wrap;
        font-size: 0.75rem;
    }

    .child-summary-card {
        padding: 10px;
    }
}
