:root {
    color-scheme: light dark;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 18px;
    line-height: 1.65;
    color: #222;
    background: #fff;
    --muted: #6b6b6b;
    --border: #ddd;
    --link: #0055bb;
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 0.14em; }
a:hover { text-decoration-thickness: 2px; }

.site-header,
main,
footer {
    width: min(100% - 2rem, 700px);
    margin-inline: auto;
}

.site-header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    align-items: baseline;
    padding: 1.7rem 0 1rem;
    border-bottom: 1px solid var(--border);
}

.wordmark { color: inherit; font-weight: 700; text-decoration: none; }
.site-header nav { margin-left: auto; }
.site-header nav a { margin-left: 0.7rem; }
.header-search { flex: 0 1 9.5rem; margin-left: 1.25rem; }

input,
button {
    border: 1px solid #aaa;
    border-radius: 0.2rem;
    background: transparent;
    color: inherit;
    font: inherit;
}

input { padding: 0.35rem 0.5rem; }
.header-search input { width: 100%; padding: 0.18rem 0.4rem; font-size: 0.78rem; }
button { padding: 0.35rem 0.7rem; cursor: pointer; }

main { min-height: calc(100vh - 6rem); padding: 2.8rem 0 4rem; }
footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem 0 2rem; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.82rem; }
.footer-actions { display: flex; gap: 0.7rem; }
.footer-actions form { display: inline; margin: 0; }
.footer-actions button { padding: 0; border: 0; color: var(--link); text-decoration: underline; font-size: inherit; }
.login-form { max-width: 22rem; margin-top: 0; }
.login-form > label { font-size: 0.9rem; }

h1,
h2,
h3 { line-height: 1.25; }
h1 { margin: 0.2rem 0 1rem; font-size: clamp(1.75rem, 5vw, 1.85rem); letter-spacing: -0.025em; }
h2 { font-size: 1.25rem; }
p { margin: 0 0 1.15rem; }

.eyebrow,
.metadata {
    color: var(--muted);
    font-size: 0.82rem;
}

.eyebrow { margin-bottom: 0.3rem; }
.page-intro { margin-bottom: 2.5rem; }
.home-intro h1 { margin-bottom: 0.35rem; }
.page-intro.compact { margin-bottom: 1.5rem; }
.page-intro.narrow { max-width: 36rem; }

.question-list { margin: 0; padding: 0; list-style: none; }
.question-list > li { padding: 1.15rem 0; border-top: 1px solid var(--border); }
.question-list > li:last-child { border-bottom: 1px solid var(--border); }
.question-list h2 { margin: 0 0 0.35rem; font-weight: 600; }
.question-list h2 a { color: inherit; }
.question-excerpt { margin: 0.35rem 0 0.55rem; color: #444; font-size: 0.92rem; line-height: 1.55; }

.topics { display: flex; flex-wrap: wrap; gap: 0.15rem 0.65rem; }
.topics a { font-size: 0.84rem; }
.metadata { margin: 0.35rem 0 0; }
.list-topics { margin-left: 1rem; }
.list-topics a { font-size: 0.78rem; }

.question > header { margin-bottom: 2.2rem; }
.question > header h1 { margin-top: 0.65rem; }
.question-context { margin-bottom: 2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); color: #555; }
.answer + .answer { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }

.prose h2,
.prose h3 { margin: 2rem 0 0.7rem; }
.prose img { display: block; max-width: 100%; height: auto; margin: 1.4rem 0; }
.prose pre { overflow: auto; padding: 0.8rem; border: 1px solid var(--border); font-size: 0.88rem; }
.prose code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }
.content-page > h1 { margin-top: 0; }

.page-search { margin-bottom: 2.5rem; }
.page-search label { display: block; margin-bottom: 0.35rem; }
.page-search div { display: flex; gap: 0.4rem; }
.page-search input { flex: 1; min-width: 0; }
.button { color: var(--link); }

.owner-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.4rem 0; font-size: 0.78rem; }
.owner-actions a,
.owner-actions button {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.5rem;
    border: 1px solid #aaa;
    border-radius: 0.2rem;
    background: transparent;
    color: inherit;
    font-size: inherit;
    line-height: 1.3;
    text-decoration: none;
}
.owner-actions a:hover,
.owner-actions button:hover { border-color: var(--link); color: var(--link); }

.owner-actions form { display: inline; margin: 0; }
.question-actions { align-items: center; margin-bottom: 0.7rem; }
.question-actions .question-edit { margin-left: auto; }
.answer-actions { justify-content: flex-end; margin: 0.7rem 0 0; }
.status-note { display: inline-flex; align-items: center; padding: 0.05rem 0.45rem; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 0.78rem; line-height: 1.3; }
.form-error { padding-left: 0.7rem; border-left: 3px solid #a22; color: #a22; }
.editor { margin: 1rem 0 2rem; }
.editor > label { display: block; margin-bottom: 1rem; font-weight: 600; }
.editor input:not([type="checkbox"]):not([type="hidden"]),
.editor textarea { display: block; width: 100%; margin-top: 0.25rem; padding: 0.5rem; }
.editor textarea { resize: vertical; line-height: 1.5; }
.editor fieldset { margin: 0 0 1rem; padding: 0.7rem; border: 1px solid var(--border); }
.editor legend { padding: 0 0.3rem; }
.editor .check-label { display: inline-block; margin: 0 0.8rem 0.3rem 0; font-weight: 400; }
.editor .check-label input { width: auto; }
.editor small { color: var(--muted); font-weight: 400; }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: baseline; }
.form-actions button { padding: 0.25rem 0.65rem; border: 1px solid #888; color: inherit; text-decoration: none; background: transparent; }
.form-actions button:hover { border-color: var(--link); color: var(--link); }
.owner-filters { font-size: 0.9rem; }
.image-tools { margin: -1rem 0 2rem; padding: 0.8rem; border: 1px solid var(--border); font-size: 0.82rem; }
.image-upload { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
.image-upload label { display: block; }
.image-upload input { display: block; width: 100%; margin-top: 0.15rem; font-size: 0.82rem; }
.image-upload button { justify-self: start; padding: 0; border: 0; color: var(--link); text-decoration: underline; }
.image-drop { grid-column: 1 / -1; padding: 0.6rem; border: 1px dashed var(--border); color: var(--muted); text-align: center; }
.image-drop.active { border-color: var(--link); color: var(--link); }
.upload-status { grid-column: 1 / -1; color: var(--muted); }
.image-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.55rem; margin-top: 0.8rem; padding-top: 0.8rem; border-top: 1px solid var(--border); }
.image-tile { position: relative; min-width: 0; margin: 0; }
.image-tile img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border: 1px solid var(--border); }
.image-tile form { position: absolute; top: 0.25rem; right: 0.25rem; }
.image-tile button { display: grid; width: 1.35rem; height: 1.35rem; padding: 0; place-items: center; border: 1px solid #777; border-radius: 50%; background: #fff; color: #222; font-size: 1rem; line-height: 1; }
.image-tile figcaption { margin-top: 0.2rem; overflow: hidden; color: var(--muted); font-size: 0.72rem; text-overflow: ellipsis; white-space: nowrap; }
.pending-image-tools { margin-top: 0; }
.pending-image-tools .image-tiles:empty { display: none; }
.pending-image-tools .image-tile > button { position: absolute; top: 0.25rem; right: 0.25rem; display: grid; width: 1.35rem; height: 1.35rem; padding: 0; place-items: center; border: 1px solid #777; border-radius: 50%; background: #fff; color: #222; line-height: 1; }

.pagination { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.5rem; font-size: 0.9rem; }
.empty-state { padding: 1rem 0; border-block: 1px solid var(--border); color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (prefers-color-scheme: dark) {
    :root { color: #ddd; background: #181a1b; --muted: #aaa; --border: #444; --link: #8ab4f8; }
    .question-context { color: #bbb; }
    .question-excerpt { color: #c4c4c4; }
}

@media (max-width: 36rem) {
    :root { font-size: 17px; }
    main { padding-top: 2rem; }
    .site-header nav { order: 3; flex-basis: 100%; margin-left: 0; }
    .site-header nav a { margin: 0 0.7rem 0 0; }
    .header-search { margin-left: auto; }
    .image-upload { grid-template-columns: 1fr; }
    .image-drop, .upload-status { grid-column: 1; }
    .image-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    footer { flex-wrap: wrap; }
}
