:root {
    --bg: #1f1f22;
    --panel: #2a2b2f;
    --panel-2: #34363b;
    --text: #ece8e1;
    --muted: #aaa7a0;
    --accent: #c8a04a;
    --border: #45484f;
    --danger: #d06b6b;
    --success: #6fa77b;
    --blue: #7aa2f7;
    --warning: #e09f5a;
    --ai: #9d7cd8;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(200, 160, 74, 0.12), transparent 35%),
        linear-gradient(180deg, #19191c 0%, #1f1f22 100%);
    color: var(--text);
    font-family: Inter, "Atkinson Hyperlegible", sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea,
select {
    font: inherit;
}

.shell {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px;
}

.topbar,
.page-head,
.panel-heading-spread,
.inline-actions,
.topbar-actions,
.cluster,
.inline-form,
.split {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar,
.page-head,
.panel-heading-spread {
    justify-content: space-between;
}

.brand {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.subtitle,
.muted {
    color: var(--muted);
}

.flash {
    margin: 18px 0;
    padding: 14px 18px;
    background: rgba(111, 167, 123, 0.14);
    border: 1px solid rgba(111, 167, 123, 0.4);
    border-radius: 16px;
}

.flash-error {
    background: rgba(208, 107, 107, 0.12);
    border-color: rgba(208, 107, 107, 0.4);
}

.page-head {
    margin: 28px 0 24px;
}

.eyebrow,
.mono {
    color: var(--muted);
    font-family: "JetBrains Mono", "Fira Code", monospace;
}

.panel,
.book-card,
.auth-card,
.reading-frame {
    background: rgba(42, 43, 47, 0.94);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.18);
}

.auth-card,
.narrow {
    max-width: 720px;
    margin: 0 auto;
}

.card-grid,
.board-summary,
.subpanel-grid,
.editor-layout {
    display: grid;
    gap: 20px;
}

.card-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.board-summary {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: 20px;
}

.workspace {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr) 360px;
    gap: 20px;
}

.sidebar {
    align-self: start;
    position: sticky;
    top: 24px;
}

.book-card h2,
.panel h2,
.auth-card h1,
.page-head h1,
.main-panel h2 {
    margin: 0 0 10px;
}

.book-cover {
    width: 84px;
    height: 108px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(200, 160, 74, 0.72), rgba(58, 43, 16, 0.9));
    display: grid;
    place-items: center;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.stats dt {
    color: var(--muted);
    font-size: 0.85rem;
}

.stats dd {
    margin: 6px 0 0;
    font-size: 1.3rem;
    font-weight: 700;
}

.badge {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.85rem;
}

.badge-gold {
    background: rgba(200, 160, 74, 0.18);
    color: #f2dab2;
}

.badge-muted,
.badge-status {
    background: rgba(122, 162, 247, 0.14);
}

.button {
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    background: var(--accent);
    color: #1f1f22;
    font-weight: 700;
    cursor: pointer;
}

.button-ghost {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.button-success {
    background: rgba(111, 167, 123, 0.92);
    color: #f6f2ea;
}

.button-danger {
    background: rgba(208, 107, 107, 0.92);
    color: #f6f2ea;
}

.stack {
    display: grid;
    gap: 14px;
}

.compact-form {
    margin-bottom: 18px;
}

.field {
    display: grid;
    gap: 8px;
}

.field input,
.field textarea,
.field select,
.compact-form input,
.compact-form textarea,
.compact-form select,
.inline-form select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(19, 20, 24, 0.9);
    color: var(--text);
}

.editor {
    min-height: 480px;
    font-family: "JetBrains Mono", "Fira Code", monospace;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-list,
.warning-list ul,
.warning-bullets,
.actor-list,
.choice-list,
.comment-feed {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-list li {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-list li a,
.choice-list li,
.actor-list li,
.tree-node {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0;
}

.nav-list li.active a {
    color: var(--accent);
}

.text-frame,
.reading-frame {
    line-height: 1.8;
    font-size: 1.05rem;
}

.text-frame h2,
.reading-frame h2 {
    margin-top: 0;
    font-size: 1.6rem;
}

.subpanel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 24px;
}

.subpanel {
    padding: 18px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.03);
}

.comment-card {
    margin: 14px 0;
    padding: 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.comment-card-open {
    border-color: rgba(200, 160, 74, 0.28);
    background: rgba(200, 160, 74, 0.08);
}

.comment-card-success {
    border-color: rgba(111, 167, 123, 0.3);
}

.comment-card-danger {
    border-color: rgba(208, 107, 107, 0.28);
}

.comment-card-warning {
    border-color: rgba(224, 159, 90, 0.28);
}

.comment-card-ai {
    border-color: rgba(157, 124, 216, 0.28);
}

.actor-list li {
    justify-content: flex-start;
}

.avatar,
.user-chip {
    display: inline-grid;
    place-items: center;
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(200, 160, 74, 0.2);
    color: var(--text);
    font-weight: 700;
}

.tree {
    display: grid;
    gap: 14px;
}

.tree-node {
    display: block;
    padding: 18px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.03);
}

.tree-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.read-choices {
    display: grid;
    gap: 12px;
}

.choice-link {
    display: block;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(200, 160, 74, 0.14);
}

.choice-link-muted {
    opacity: 0.6;
}

.badge-status-success {
    background: rgba(111, 167, 123, 0.16);
}

.badge-status-danger {
    background: rgba(208, 107, 107, 0.16);
}

.badge-status-warning {
    background: rgba(224, 159, 90, 0.16);
}

.badge-status-ai {
    background: rgba(157, 124, 216, 0.16);
}

.comment-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

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

    .sidebar {
        position: static;
    }
}

@media (max-width: 800px) {
    .shell {
        padding: 16px;
    }

    .topbar,
    .page-head,
    .subpanel-grid,
    .editor-layout,
    .split,
    .comment-actions {
        display: grid;
    }
}
