/* ============================================
   KNOWLEDGE GARDEN — READER MODE
   Scoped to html[data-mode="reader"] plus the terminal hint, so terminal mode
   is untouched. Loaded after garden-terminal.css.
   ============================================ */

/* ---------- Mode switching ---------- */

html[data-mode="reader"] .floating-terminal,
html[data-mode="reader"] .file-tree {
    display: none;
}

html[data-mode="terminal"] .terminal-hint,
html[data-mode="terminal"] .topic-list {
    display: none;
}

/* The static terminal welcome never shows under reader mode, even before the manifest arrives. */
html[data-mode="reader"] .welcome-content {
    display: none;
}

/* ---------- Texture: the blobs show through and drift toward the active topic ---------- */

html[data-mode="reader"] .blob {
    opacity: 0.3;
}

html[data-mode="reader"] .blob-1 {
    background: radial-gradient(circle, color-mix(in srgb, var(--reader-accent, #BBC3FF) 65%, transparent), transparent 70%);
}

html[data-mode="reader"] .blob-2 {
    background: radial-gradient(circle, color-mix(in srgb, var(--reader-accent, #E8B9D5) 45%, transparent), transparent 70%);
}

/* ---------- Prompt lines: section headings read like a shell ---------- */

.reader-prompt {
    display: block;
    margin: 40px 0 16px;
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 15px;
    font-weight: 500;
    line-height: 24px;
    letter-spacing: 0;
    color: var(--md-sys-color-on-surface);
}

.reader-prompt .prompt-line { color: var(--md-sys-color-on-surface-variant); white-space: nowrap; }
.reader-prompt .prompt-user { color: var(--terminal-green); }
.reader-prompt .prompt-path { color: var(--terminal-blue); }
.reader-prompt .prompt-cmd { color: var(--md-sys-color-on-surface); white-space: normal; }

.reader-group-count {
    margin-left: 10px;
    font-size: 12px;
    font-weight: 400;
    color: var(--md-sys-color-outline);
    white-space: nowrap;
}

.reader-group-count::before {
    content: '· ';
}

p.reader-prompt {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--md-sys-color-on-surface-variant);
}

/* ---------- Terminal hint bar ---------- */

.terminal-hint {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 40;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 13px;
    letter-spacing: 0.1px;
    color: var(--md-sys-color-on-surface);
    background: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-full);
    box-shadow: var(--elevation-2);
    cursor: pointer;
    transition:
        transform var(--duration-short) var(--motion-spring-bouncy),
        background var(--duration-short) var(--motion-spring-bouncy),
        box-shadow var(--duration-short) var(--motion-spring-bouncy);
}

.terminal-hint:hover {
    transform: translateY(-4px) scale(1.02);
    background: var(--md-sys-color-surface-container-highest);
    box-shadow: var(--elevation-3);
}

.terminal-hint:active {
    transform: scale(0.95);
}

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

.terminal-hint-glyph {
    color: var(--md-sys-color-primary);
    font-weight: 600;
}

.terminal-hint kbd {
    font: inherit;
    padding: 0 6px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-extra-small);
    color: var(--md-sys-color-primary);
}

/* Phone width: the hint lives in the sidebar drawer, never pinned over content. */
@media (max-width: 768px) {
    .terminal-hint {
        position: static;
        width: calc(100% - 24px);
        margin: 12px;
        justify-content: center;
        box-shadow: none;
    }
}

/* ---------- Reader sidebar: topics ---------- */

.topic-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    overflow-y: auto;
}

.topic-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: var(--md-sys-shape-corner-full);
    color: var(--md-sys-color-on-surface-variant);
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    text-align: left;
    cursor: pointer;
    transition:
        background var(--duration-short) var(--motion-spring-bouncy),
        color var(--duration-short) var(--motion-spring-bouncy),
        transform var(--duration-short) var(--motion-spring-bouncy);
}

.topic-item:hover {
    background: var(--state-hover);
    color: var(--md-sys-color-on-surface);
}

.topic-item:active {
    transform: scale(0.95);
}

.topic-item[aria-current="page"] {
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.topic-item:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}

.topic-count {
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 12px;
    color: var(--md-sys-color-outline);
}

.topic-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 13px;
}

.topic-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--topic-color, var(--md-sys-color-primary));
    box-shadow: 0 0 8px color-mix(in srgb, var(--topic-color, var(--md-sys-color-primary)) 60%, transparent);
}

html[data-mode="reader"] .sidebar.collapsed .topic-list {
    display: none;
}

/* ---------- Landing and topic pages ---------- */

.reader-home,
.reader-topic {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 0 96px;
}

.reader-intro {
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 17px;
    font-weight: 400;
    line-height: 28px;
    color: var(--md-sys-color-on-surface);
    max-width: 640px;
    margin: 0 0 24px;
}

.reader-topic-header h1 {
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 32px;
    font-weight: 600;
    line-height: 40px;
    color: var(--card-accent, var(--md-sys-color-on-surface));
    margin: 0 0 8px;
}

.reader-topic-header .reader-intro {
    font-size: 16px;
    line-height: 26px;
    color: var(--md-sys-color-on-surface-variant);
}

/* Hero: boot line, intro, search. The dashboard below carries the rest. */

.reader-hero {
    max-width: 760px;
}

.reader-boot {
    margin: 0 0 16px;
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 13px;
    line-height: 20px;
    color: var(--md-sys-color-outline);
    white-space: pre-wrap;
}

.reader-boot::before {
    content: '❯ ';
    color: var(--terminal-green);
}

.reader-cursor {
    display: inline-block;
    width: 9px;
    height: 1.1em;
    margin-left: 2px;
    vertical-align: text-bottom;
    background: var(--terminal-green);
    animation: readerBlink 1s step-end infinite;
}

@keyframes readerBlink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.reader-home-rest {
    transition: opacity var(--duration-long) var(--motion-spring-expressive), transform var(--duration-long) var(--motion-spring-expressive);
}

.reader-home.is-booting .reader-home-rest {
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
}

/* Operator dashboard: the about panel on the left, topic load and the featured queue on the right. */

.reader-ops {
    display: grid;
    grid-template-columns: minmax(0, 480px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    margin-top: 32px;
}

/* The operator and load panels stay in view while the queue scrolls past. */
.reader-ops-main {
    position: sticky;
    top: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.reader-panel {
    position: relative;
    overflow: hidden;
    padding: 18px 20px;
    background: color-mix(in srgb, var(--md-sys-color-surface-container) 90%, transparent);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-medium);
    box-shadow: var(--elevation-1);
}

.reader-panel-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 11px;
    font-weight: 500;
    line-height: 16px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--md-sys-color-outline);
}

.reader-panel-label::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--md-sys-color-primary);
    box-shadow: 0 0 8px color-mix(in srgb, var(--md-sys-color-primary) 60%, transparent);
}

/* neofetch for the vault: patchy, a speech bubble, and the numbers. */

.reader-fetch {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
    margin-bottom: 16px;
}

.reader-patchy {
    display: block;
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: var(--md-sys-shape-corner-small);
    opacity: 0.9;
}

.reader-fetch-side {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
}

.reader-bubble {
    position: relative;
    margin: 4px 0 12px;
    padding: 5px 14px;
    background: var(--md-sys-color-on-surface);
    color: var(--md-sys-color-surface-container-low);
    border-radius: var(--md-sys-shape-corner-medium);
    font-family: 'M PLUS 1 Code', 'Hiragino Sans', 'Noto Sans JP', var(--font-terminal, monospace);
    font-size: 15px;
    font-weight: 500;
    line-height: 22px;
    opacity: 0.9;
}

.reader-bubble::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    border: 8px solid transparent;
    border-right-color: var(--md-sys-color-on-surface);
    border-left: 0;
}

.reader-neofetch {
    margin: 0;
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 12px;
    line-height: 18px;
    color: var(--md-sys-color-on-surface);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.reader-neofetch .about-user { color: var(--terminal-green); font-weight: 600; }
.reader-neofetch .about-rule { color: var(--md-sys-color-outline); }
.reader-neofetch .about-key { color: var(--terminal-cyan); }

/* Vault load: one bar per topic, each opens its topic. */

.reader-load-row {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr) 40px;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 6px 8px;
    margin: 0 -8px;
    box-sizing: content-box;
    background: transparent;
    border: none;
    border-radius: var(--md-sys-shape-corner-small);
    color: var(--md-sys-color-on-surface-variant);
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 12px;
    text-align: left;
    cursor: pointer;
    transition: background var(--duration-short) var(--motion-spring-bouncy), transform var(--duration-short) var(--motion-spring-bouncy);
}

.reader-load-row:hover { background: var(--state-hover); }
.reader-load-row:active { transform: scale(0.98); }
.reader-load-row:focus-visible { outline: 2px solid var(--md-sys-color-primary); outline-offset: 1px; }

.reader-load-bar {
    height: 6px;
    background: var(--md-sys-color-surface-container-highest);
    border-radius: var(--md-sys-shape-corner-full);
    overflow: hidden;
}

.reader-load-bar span {
    display: block;
    width: var(--bar-share, 0%);
    height: 100%;
    background: var(--bar-color);
    border-radius: inherit;
    box-shadow: 0 0 10px color-mix(in srgb, var(--bar-color) 45%, transparent);
}

.reader-load-count {
    text-align: right;
    color: var(--md-sys-color-outline);
}

/* Featured queue under a hazard stripe. */

.reader-queue { padding-top: 26px; }

.reader-hazard {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 8px;
    background: repeating-linear-gradient(135deg, var(--md-sys-color-primary) 0 10px, transparent 10px 20px);
    opacity: 0.8;
}

.reader-job {
    position: relative;
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: baseline;
    width: 100%;
    padding: 10px 8px 10px 14px;
    background: transparent;
    border: none;
    border-top: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 0;
    color: var(--md-sys-color-on-surface);
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    text-align: left;
    cursor: pointer;
    transition: background var(--duration-short) var(--motion-spring-bouncy);
}

.reader-job:first-of-type { border-top: none; }

.reader-job::before {
    content: '';
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 2px;
    background: var(--card-mix, var(--card-accent, var(--md-sys-color-primary)));
}

.reader-job:hover { background: var(--state-hover); }
.reader-job:focus-visible { outline: 2px solid var(--md-sys-color-primary); outline-offset: -2px; }

.reader-job-rank {
    font-size: 13px;
    font-weight: 600;
    color: var(--card-accent, var(--md-sys-color-primary));
}

.reader-job-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.reader-job-title { font-size: 13px; font-weight: 500; line-height: 18px; }
.reader-job-summary { font-family: var(--font-primary); font-size: 13px; line-height: 19px; color: var(--md-sys-color-on-surface-variant); }

.reader-job-topic {
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--md-sys-color-outline);
}

/* Topic tiles with big counts. */

.reader-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.reader-tile-count {
    margin-top: auto;
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 28px;
    font-weight: 600;
    line-height: 34px;
    color: var(--card-accent, var(--md-sys-color-primary));
}

.reader-eggs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.reader-egg {
    padding: 6px 12px;
    background: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-full);
    color: var(--md-sys-color-on-surface);
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 12px;
    cursor: pointer;
    transition:
        transform var(--duration-short) var(--motion-spring-bouncy),
        background var(--duration-short) var(--motion-spring-bouncy),
        border-color var(--duration-short) var(--motion-spring-bouncy);
}

.reader-egg::before {
    content: '$ ';
    color: var(--terminal-green);
}

.reader-egg:hover {
    transform: translateY(-2px) scale(1.04);
    background: var(--md-sys-color-surface-container-highest);
    border-color: var(--terminal-green);
}

.reader-egg:active {
    transform: scale(0.95);
}

.reader-egg:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}

.reader-group {
    margin: 0;
}

.reader-search {
    width: 100%;
    padding: 14px 24px;
    background: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-full);
    color: var(--md-sys-color-on-surface);
    font-family: var(--font-primary);
    font-size: 16px;
    letter-spacing: 0.5px;
    transition:
        border-color var(--duration-short) var(--motion-spring-bouncy),
        box-shadow var(--duration-short) var(--motion-spring-bouncy);
}

.reader-find {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.reader-find .reader-search {
    flex: 1;
    min-width: 0;
}

.reader-graph-btn,
.local-graph-open {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--md-sys-color-surface-container-high);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-full);
    color: var(--md-sys-color-on-surface);
    font-family: var(--font-terminal);
    cursor: pointer;
    transition:
        transform var(--duration-short) var(--motion-spring-bouncy),
        border-color var(--duration-short) var(--motion-spring-bouncy),
        background var(--duration-short) var(--motion-spring-bouncy);
}

.reader-graph-btn {
    flex: none;
    padding: 0 22px;
    font-size: 14px;
}

.reader-graph-btn:hover,
.local-graph-open:hover {
    border-color: var(--md-sys-color-primary);
    background: var(--md-sys-color-surface-container-highest);
    transform: translateY(-2px);
}

.reader-graph-btn:active,
.local-graph-open:active {
    transform: scale(0.95);
}

.reader-graph-btn:focus-visible,
.local-graph-open:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}

/* The local graph under a note: the note, ringed, and what it links to */
.note-local-graph {
    margin-bottom: 8px;
}

.note-local-graph .prompt-line {
    white-space: nowrap;
}

.local-graph {
    position: relative;
    height: 320px;
    background: var(--md-sys-color-surface-container-lowest);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-extra-large);
    overflow: hidden;
}

.local-graph .graph-surface {
    cursor: default;
}

.local-graph-open {
    margin-top: 12px;
    padding: 8px 16px;
    font-size: 12px;
}

@media (max-width: 600px) {
    .local-graph {
        height: 260px;
    }

    .note-local-graph .reader-group-count {
        display: block;
        margin: 4px 0 0;
    }

    .note-local-graph .reader-group-count::before {
        content: none;
    }

    .reader-graph-btn {
        padding: 0 16px;
    }
}

.reader-search::placeholder {
    color: var(--md-sys-color-outline);
}

.reader-search:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 3px var(--state-focus);
}

.reader-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.reader-divider {
    position: relative;
    margin: 40px 0 24px;
    border: none;
    border-top: 1px solid var(--md-sys-color-outline-variant);
    overflow: visible;
}

.reader-divider::after {
    content: attr(data-label);
    position: absolute;
    top: -10px;
    left: 0;
    padding-right: 12px;
    background: var(--md-sys-color-surface);
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.1px;
    color: var(--md-sys-color-on-surface-variant);
}

/* ---------- Cards ---------- */

.reader-card {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 150px;
    padding: 20px 24px 20px 28px;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--card-accent, var(--md-sys-color-primary)) 12%, transparent), transparent 55%),
        color-mix(in srgb, var(--md-sys-color-surface-container) 88%, transparent);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-extra-large);
    color: var(--md-sys-color-on-surface);
    cursor: pointer;
    transition:
        transform var(--duration-short) var(--motion-spring-bouncy),
        border-color var(--duration-short) var(--motion-spring-bouncy),
        box-shadow var(--duration-short) var(--motion-spring-bouncy);
}

/* The accent bar: the note's topic, mixed with the topics it links to. */
.reader-card::before,
.reader-topic-card::before,
.note-topic-chip::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background: var(--card-mix, var(--card-accent, var(--md-sys-color-primary)));
}

.reader-card:hover {
    transform: translateY(-4px) scale(1.02);
    border-color: color-mix(in srgb, var(--card-accent, var(--md-sys-color-primary)) 50%, var(--md-sys-color-outline-variant));
    box-shadow:
        var(--elevation-2),
        0 0 28px color-mix(in srgb, var(--card-accent, var(--md-sys-color-primary)) 22%, transparent);
}

.reader-card:active {
    transform: scale(0.95);
}

.reader-card:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}

.reader-card-topic {
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
    color: var(--card-accent, var(--md-sys-color-primary));
}

.reader-card-title {
    margin: 0;
    font-family: var(--font-primary);
    font-size: 18px;
    font-weight: 500;
    line-height: 24px;
    color: var(--md-sys-color-on-surface);
}

.reader-card-summary {
    flex: 1;
    margin: 0;
    font-family: var(--font-primary);
    font-size: 14px;
    line-height: 20px;
    color: var(--md-sys-color-on-surface-variant);
}

.reader-card-summary:empty {
    display: none;
}

.reader-card-date {
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 12px;
    color: var(--md-sys-color-outline);
}

/* Topic cards on the landing view */

.reader-topic-card {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px 24px 20px 28px;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--card-accent, var(--md-sys-color-primary)) 14%, transparent), transparent 60%),
        color-mix(in srgb, var(--md-sys-color-surface-container-low) 88%, transparent);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-extra-large);
    color: var(--md-sys-color-on-surface);
    font-family: var(--font-primary);
    text-align: left;
    cursor: pointer;
    transition:
        transform var(--duration-short) var(--motion-spring-bouncy),
        background var(--duration-short) var(--motion-spring-bouncy),
        border-radius var(--duration-long) var(--motion-morph);
}

.reader-topic-card:hover {
    transform: translateY(-4px) scale(1.02);
    background: var(--md-sys-color-surface-container-high);
    border-radius: var(--md-sys-shape-corner-medium);
}

.reader-topic-card:active {
    transform: scale(0.95);
}

.reader-topic-card:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}

.reader-topic-label {
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 18px;
    font-weight: 600;
    line-height: 24px;
    color: var(--card-accent, var(--md-sys-color-primary));
}

.reader-topic-desc {
    font-size: 14px;
    line-height: 20px;
    color: var(--md-sys-color-on-surface-variant);
}

.reader-topic-count {
    margin-top: auto;
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 12px;
    color: var(--md-sys-color-outline);
}

/* ---------- Phone width ---------- */

@media (max-width: 768px) {
    .reader-home,
    .reader-topic {
        padding: 16px 0 80px;
    }

    .reader-intro {
        font-size: 15px;
        line-height: 24px;
    }

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

    .reader-topic-header h1 {
        font-size: 26px;
        line-height: 32px;
    }
}

/* Below this the queue column gets too narrow beside the 480px operator panel. */
@media (max-width: 1320px) {
    .reader-ops {
        grid-template-columns: 1fr;
    }

    .reader-ops-main {
        position: static;
    }
}

@media (max-width: 600px) {
    .reader-fetch {
        grid-template-columns: 1fr;
    }

    .reader-bubble {
        margin-top: 2px;
    }

    /* Stacked: the photo is above, so the tail points up at her. */
    .reader-bubble::before {
        left: 22px;
        top: -8px;
        transform: none;
        border: 8px solid transparent;
        border-bottom-color: var(--md-sys-color-on-surface);
        border-top: 0;
    }

    .reader-load-row {
        grid-template-columns: 120px minmax(0, 1fr) 32px;
    }

    .reader-job {
        grid-template-columns: 28px minmax(0, 1fr);
    }

    .reader-job-topic {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .reader-cursor {
        animation: none;
    }

    .reader-home-rest {
        transition: none;
    }
}

/* ---------- Note header (reader mode) ---------- */

.note-header {
    max-width: 820px;
    margin: 32px auto 32px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.note-topic-chip {
    position: relative;
    overflow: hidden;
    align-self: flex-start;
    padding: 6px 14px 6px 18px;
    background: var(--md-sys-color-secondary-container);
    border: none;
    border-radius: var(--md-sys-shape-corner-full);
    color: var(--md-sys-color-on-secondary-container);
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
    cursor: pointer;
    transition:
        transform var(--duration-short) var(--motion-spring-bouncy),
        background var(--duration-short) var(--motion-spring-bouncy);
}

.note-topic-chip:hover {
    transform: translateY(-2px) scale(1.02);
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.note-topic-chip:active {
    transform: scale(0.95);
}

.note-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.note-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: transparent;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-full);
    color: var(--md-sys-color-primary);
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 12px;
    font-weight: 500;
    line-height: 18px;
    letter-spacing: 0;
    cursor: pointer;
    transition:
        transform var(--duration-short) var(--motion-spring-bouncy),
        background var(--duration-short) var(--motion-spring-bouncy),
        border-color var(--duration-short) var(--motion-spring-bouncy);
}

.note-tag:hover {
    transform: translateY(-2px) scale(1.02);
    background: var(--state-hover);
    border-color: var(--md-sys-color-primary);
}

.note-tag:active {
    transform: scale(0.95);
}

.note-tag:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}

.note-tag-count {
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 400;
}

.note-tag-solo {
    cursor: default;
    color: var(--md-sys-color-on-surface-variant);
    border-style: dashed;
}

.note-tag-solo:hover {
    transform: none;
    background: transparent;
    border-color: var(--md-sys-color-outline-variant);
}

.note-header h1 {
    margin: 0;
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 30px;
    font-weight: 600;
    line-height: 40px;
    color: var(--md-sys-color-on-surface);
}

.note-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
    margin: 0;
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0;
    line-height: 20px;
    color: var(--md-sys-color-on-surface-variant);
}

.note-lede {
    margin: 4px 0 0;
    font-family: var(--font-primary);
    font-size: 22px;
    font-weight: 400;
    line-height: 30px;
    color: var(--md-sys-color-on-surface);
}

.note-blurb {
    margin: 12px 0 0;
    padding: 20px 28px;
    background: var(--md-sys-color-primary-container);
    border-radius: var(--md-sys-shape-corner-extra-large);
    color: var(--md-sys-color-on-primary-container);
}

.note-blurb h2 {
    margin: 0 0 8px;
    font-family: var(--font-terminal, 'JetBrains Mono', monospace);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
    color: var(--md-sys-color-on-primary-container);
    opacity: 0.85;
}

.note-blurb p {
    margin: 0;
    font-family: var(--font-primary);
    font-size: 16px;
    line-height: 24px;
    letter-spacing: 0.5px;
}

html[data-mode="reader"] .markdown-content {
    max-width: 820px;
    margin: 0 auto;
}

/* ---------- Related notes ---------- */

.note-related {
    max-width: 1100px;
    margin: 56px auto 96px;
    padding-top: 32px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
}

.note-related h2 {
    margin: 24px 0 16px;
}

@media (max-width: 768px) {
    .note-header {
        margin-top: 16px;
    }

    .note-header h1 {
        font-size: 22px;
        line-height: 30px;
    }

    .note-lede {
        font-size: 18px;
        line-height: 26px;
    }
}

/* The header already shows the title; hide the body's own leading H1 under it. */
html[data-mode="reader"] .note-header + .markdown-content > h1:first-child {
    display: none;
}
