:root {
    --bg: #efe6d6;
    --paper: #fffaf3;
    --ink: #221c16;
    --muted: #655c52;
    --line: #e2d5c3;
    --accent: #1f4b3a;
    --accent-ink: #f6f1e7;
    --signal: #9a3b1b;
    --ok: #1d6b45;
    --bad: #8d2e2e;
    --warn: #8a5a12;
    --shadow: 0 16px 40px rgba(60, 40, 20, 0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.7), transparent 28rem),
        var(--bg);
    font: 16px/1.5 "Segoe UI", sans-serif;
}

h1, h2, legend, .brand strong {
    font-family: Georgia, "Palatino Linotype", serif;
    font-weight: 600;
    letter-spacing: -0.02em;
}

h1 { font-size: 2rem; line-height: 1.15; margin: 0; }
h2 { font-size: 1.25rem; margin: 0 0 0.75rem; }
p { margin: 0 0 0.75rem; }

a { color: var(--accent); }
code { font-family: Consolas, "Courier New", monospace; font-size: 0.92em; }

.shell { width: min(1080px, calc(100% - 2rem)); margin: 0 auto; padding: 1.5rem 0 3rem; }
.bare .shell { padding-top: 4rem; }

.top {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: 0.85rem 1.25rem;
    background: var(--accent);
    color: var(--accent-ink);
}
.brand, .top-user, .top-nav { display: flex; align-items: center; gap: 0.75rem; }
.brand, .top-nav a { color: inherit; text-decoration: none; }
.top-nav a { font-size: 0.92rem; }
.top-nav a:hover { text-decoration: underline; }
.brand small, .top-user span, .top-user small { display: block; color: rgba(246, 241, 231, 0.75); font-size: 0.85rem; }
.brand-mark {
    width: 2.6rem;
    height: 2.6rem;
    display: grid;
    place-items: center;
    border: 1px solid rgba(246, 241, 231, 0.4);
    border-radius: 4px;
    font-family: Georgia, serif;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.crumbs { display: flex; flex-wrap: wrap; gap: 0.4rem; color: var(--muted); margin-bottom: 1rem; }
.crumbs a { color: var(--muted); }

.card, .stats article {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 1.25rem;
}
.card + .card, .card + .split, .split + .card, .split + .split, .page-head + .card, .page-head + .split, .note + .card, .switcher + .split, .switcher + .card { margin-top: 1rem; }
.switcher { display: flex; gap: 0.75rem; align-items: end; }
.switcher .field { margin: 0; min-width: 16rem; }
.narrow { width: min(680px, 100%); margin: 0 auto; }
.stack > * + * { margin-top: 0.9rem; }
.split { display: grid; grid-template-columns: 1fr 1.3fr; gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }

.page-head, .section-head, .button-row, .top-user form { display: flex; gap: 0.6rem; align-items: center; }
.page-head, .section-head { justify-content: space-between; align-items: flex-end; margin-bottom: 1rem; }
.page-head .button-row { flex-wrap: wrap; justify-content: flex-end; }
.eyebrow { margin: 0; color: var(--signal); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.75rem; }
.lede, .hint, .meta, .empty { color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center; }

.field { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.92rem; }
.field input, .field select, .field textarea, .check input {
    font: inherit;
    color: inherit;
}
.field input, .field select, .field textarea {
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: 1px solid #cbbbA8;
    border-radius: 4px;
    background: white;
}
.check { display: flex; gap: 0.5rem; align-items: flex-start; margin: 0.35rem 0; }
.checks { display: grid; gap: 0.15rem; }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 0; padding: 0.8rem 1rem 0.4rem; }
legend { padding: 0 0.3rem; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    border-radius: 4px;
    padding: 0.45rem 0.8rem;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-danger { border-color: var(--bad); color: var(--bad); }
.btn-quiet { border-color: transparent; color: inherit; background: transparent; }
.top .btn-quiet { color: var(--accent-ink); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.inline-form { display: flex; gap: 0.5rem; align-items: end; flex-wrap: wrap; }
.inline-form .field { min-width: 9rem; }
.inline-form input { width: 9rem; }
.danger-zone { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }

.flash { border-radius: 6px; padding: 0.75rem 0.9rem; margin: 0 0 1rem; }
.flash ul { margin: 0; padding-left: 1.1rem; }
.flash-ok { background: #e5f4ec; color: var(--ok); }
.flash-error { background: #fdeceb; color: var(--bad); }
.note { background: #fff4df; border: 1px solid #efd7aa; color: var(--warn); border-radius: 6px; padding: 0.75rem 0.9rem; }
.pill { margin: 0; background: #fff4df; color: var(--warn); border-radius: 999px; padding: 0.35rem 0.75rem; }

.badge { display: inline-block; border-radius: 999px; padding: 0.1rem 0.55rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-draft { background: #ece7df; color: var(--muted); }
.badge-published { background: #e5f4ec; color: var(--ok); }
.badge-closed { background: #fdeceb; color: var(--bad); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

.config { display: grid; gap: 0.6rem; margin: 0; }
.config div { display: grid; grid-template-columns: 8rem 1fr; gap: 0.5rem; }
.config dt { color: var(--muted); }
.config dd { margin: 0; overflow-wrap: anywhere; }

.question-list, .assets, .choices { list-style: none; margin: 0; padding: 0; }
.question-list li, .assets li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--line);
}
.option-row {
    display: grid;
    grid-template-columns: 1fr auto 9rem;
    gap: 0.7rem;
    align-items: end;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--line);
}
.answer-row {
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--line);
}
.assets li img { width: 96px; height: 72px; object-fit: cover; border-radius: 4px; background: white; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.7rem; margin-bottom: 1rem; }
.stats span { display: block; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.prompt, .essay-answer {
    white-space: pre-wrap;
    background: #fff;
    border-radius: 6px;
    padding: 0.8rem;
    margin-bottom: 0.8rem;
}
.choices li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 4px;
    margin-top: 0.4rem;
}
.choices .is-selected { border-color: var(--accent); }
.choices .is-correct { background: #e5f4ec; }
.answer header { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.answer header p { color: var(--muted); }

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

@media (max-width: 800px) {
    .split, .grid-2, .stats, .option-row, .config div { grid-template-columns: 1fr; }
    .page-head, .question-list li, .assets li, .top, .switcher { flex-direction: column; align-items: stretch; }
    .bare .shell { padding-top: 1.5rem; }
}
