:root {
    --rich-black: #1b1a19;
    --light-grey: #d9d9d9;
    --dos-gold: #b9ad7c;
    --dark-grey: #999;
    --white: white;
    --dos-dark-gold: #947701;
    --dim-grey: #6d6d6d;
    --black: black;

    /* What the pages use, built from the palette above. */
    --bg: var(--rich-black);
    --surface: #24221f;
    --text: var(--light-grey);
    --muted: var(--dark-grey);
    --accent: var(--dos-gold);
    --rule: #3a3733;
    --focus: var(--dos-gold);

    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, "Cascadia Code", Consolas, monospace;

    color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.6 var(--sans);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main, header.site, footer.site {
    width: 100%;
    max-width: 46rem;
    margin: 0 auto;
    padding: 0 1rem;
}

main { flex: 1; padding-bottom: 3rem; }

a { color: var(--accent); }
a:hover { color: var(--white); }

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

/* --- Header and footer ---------------------------------------------------- */

header.site {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: .5rem 1.5rem;
    padding-top: 1.5rem;
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--rule);
}

header.site h1 {
    margin: 0;
    font: 400 1.35rem/1.2 var(--serif);
    letter-spacing: .01em;
}

header.site h1 a { color: var(--text); text-decoration: none; }

header.site nav { display: flex; gap: 1.25rem; font-size: .95rem; }
header.site nav a { color: var(--muted); text-decoration: none; }
header.site nav a:hover, header.site nav a[aria-current] { color: var(--accent); }

footer.site {
    padding-top: 1rem;
    padding-bottom: 2rem;
    border-top: 1px solid var(--rule);
    color: var(--muted);
    font-size: .85rem;
}

/* --- Type ----------------------------------------------------------------- */

h2 { font: 400 1.5rem/1.3 var(--serif); margin: 2rem 0 1rem; }
h3 { font: 600 .8rem/1.4 var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 2rem 0 .75rem; }

.meta { color: var(--muted); font-size: .9rem; font-style: italic; }
.empty { color: var(--muted); }
.lede { color: var(--muted); margin-top: -.5rem; }

code, pre { font-family: var(--mono); font-size: .875rem; }

/* --- Forms ---------------------------------------------------------------- */

input, select, textarea, button {
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 4px;
    padding: .5rem .75rem;
    min-width: 0;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }

button {
    cursor: pointer;
    background: var(--accent);
    color: var(--rich-black);
    border-color: var(--accent);
    font-weight: 600;
}
button:hover { background: var(--white); border-color: var(--white); }

label, .label { display: block; color: var(--muted); font-size: .85rem; }

form.search label { margin-bottom: .4rem; }
form.search .row { display: flex; gap: .5rem; }
form.search input { flex: 1; font-size: 1.1rem; }

/* --- Lists of words ------------------------------------------------------- */

ul.results { list-style: none; margin: 0; padding: 0; }

.result {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    border-bottom: 1px solid var(--rule);
}

.result > a {
    flex: 1;
    min-width: 0;
    display: block;
    padding: .9rem 0;
    color: var(--text);
    text-decoration: none;
}

.result .title { font: 1.2rem/1.3 var(--serif); color: var(--accent); margin-right: .5rem; }
.result a:hover .title { color: var(--white); }
.result .definition {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text);
    opacity: .85;
    font-size: .95rem;
    margin-top: .2rem;
}

button.copy {
    background: none;
    border: none;
    color: var(--muted);
    padding: .9rem .25rem;
    font-size: 1.1rem;
    line-height: 1;
}
button.copy:hover { color: var(--accent); background: none; }
h2 button.copy, p button.copy { padding: 0 .25rem; vertical-align: middle; }

nav.letters { display: flex; flex-wrap: wrap; gap: .35rem; }
nav.letters a {
    display: inline-grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid var(--rule);
    border-radius: 4px;
    text-decoration: none;
    text-transform: uppercase;
    font-family: var(--serif);
}
nav.letters a:hover, nav.letters a[aria-current] { border-color: var(--accent); background: var(--surface); color: var(--white); }

.featured article {
    background: var(--surface);
    border-left: 3px solid var(--accent);
    padding: 1rem 1.25rem;
    border-radius: 0 4px 4px 0;
}
.featured h3 { margin: 0; font: 1.4rem/1.3 var(--serif); text-transform: none; letter-spacing: 0; }
.featured h3 a { text-decoration: none; }
.featured .meta, .featured .definition { margin: .25rem 0 0; }
.featured .definition { font-family: var(--serif); font-size: 1.05rem; }

/* --- A word --------------------------------------------------------------- */

article.word header h2 { font-size: 2.6rem; margin: 0; line-height: 1.1; overflow-wrap: anywhere; }
article.word .entry { margin: 0 0 .25rem; color: var(--muted); font-size: .85rem; }
article.word .meta { margin: .4rem 0 0; display: flex; gap: 1rem; }
article.word .definition { font: 1.3rem/1.6 var(--serif); margin: 1.5rem 0; white-space: pre-line; }

.video { position: relative; aspect-ratio: 16 / 9; margin: 1.5rem 0; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 1px solid var(--rule); border-radius: 4px; }

.quotes blockquote {
    margin: 0 0 1rem;
    padding: .25rem 0 .25rem 1rem;
    border-left: 2px solid var(--accent);
    font: italic 1.05rem/1.6 var(--serif);
    white-space: pre-line;
}

p.api { margin-top: 2rem; color: var(--muted); }

nav.pager {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--rule);
    font-family: var(--serif);
}
nav.pager a { text-decoration: none; }

/* --- Custom query --------------------------------------------------------- */

form.query fieldset { border: 1px solid var(--rule); border-radius: 4px; margin: 0 0 1rem; padding: 1rem; }
form.query legend { padding: 0 .4rem; color: var(--accent); font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; }

.modes label { display: flex; align-items: center; gap: .5rem; color: var(--text); font-size: 1rem; padding: .2rem 0; cursor: pointer; }
.modes input { accent-color: var(--accent); }

.filters, .word-pick {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: .6rem 1rem;
    align-items: center;
}
.filters legend, .word-pick legend { grid-column: 1 / -1; }
.filters label, .filters .label, .word-pick label { margin: 0; }
.range { display: flex; gap: .5rem; align-items: center; }
.range input { flex: 1; width: 0; }
.range span { color: var(--muted); }

/* dos.js hides the fieldsets the chosen mode does not use. */
.js form.query [data-for][hidden] { display: none; }
.js form.query .build { display: none; }

.built .url { display: flex; align-items: center; gap: .25rem; overflow-wrap: anywhere; }
.built .url a { text-decoration: none; }
.built .url code { color: var(--accent); }

pre.preview {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 4px;
    padding: 1rem;
    max-height: 32rem;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin: 0;
    color: var(--text);
}
pre.preview:empty::before { content: "—"; color: var(--muted); }
pre.preview.error { border-color: #a35a4a; }

@media (max-width: 30rem) {
    .filters, .word-pick { grid-template-columns: 1fr; gap: .3rem; }
    article.word header h2 { font-size: 2rem; }
}

/* --- Adding, editing and deleting (D-28) ----------------------------------- */

:root { --danger: #c9735f; }

.notice {
    background: var(--surface);
    border-left: 3px solid var(--accent);
    border-radius: 0 4px 4px 0;
    padding: .6rem 1rem;
    margin: 0 0 1.5rem;
}

form.edit { display: grid; gap: 1.25rem; }
form.edit .field { display: grid; gap: .35rem; }
form.edit input, form.edit select, form.edit textarea { width: 100%; }
form.edit textarea { resize: vertical; line-height: 1.5; }
#f-title { font: 1.4rem/1.3 var(--serif); }
#f-definition, #f-quote { font: 1.1rem/1.5 var(--serif); }

.field .hint, p.hint { margin: 0; color: var(--muted); font-size: .85rem; }
.field .error { margin: 0; color: var(--danger); font-size: .9rem; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); }
output.placement { color: var(--muted); font: .85rem var(--mono); min-height: 1.3em; }
output.placement.error { color: var(--danger); font-family: var(--sans); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; }
.actions .danger { margin-left: auto; }
a.danger { color: var(--danger); }
a.danger:hover { color: var(--white); }
button.danger { background: var(--danger); border-color: var(--danger); }
button.danger:hover { background: var(--white); border-color: var(--white); }

p.edit-links { display: flex; gap: 1.25rem; font-size: .95rem; }

.edit-quotes .quote-row { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between; margin-bottom: 1.25rem; }
.edit-quotes blockquote { flex: 1; min-width: 0; margin-bottom: 0; }
.row-actions { display: flex; gap: .75rem; margin: .25rem 0 0; font-size: .9rem; }

.doomed { opacity: .85; }
p.doomed.definition { font: 1.2rem/1.6 var(--serif); white-space: pre-line; border-left: 2px solid var(--danger); padding-left: 1rem; }
blockquote.doomed { margin: 0 0 1rem; padding-left: 1rem; border-left: 2px solid var(--danger); font: italic 1.05rem/1.6 var(--serif); white-space: pre-line; }

@media (max-width: 30rem) {
    .edit-quotes .quote-row { flex-direction: column; gap: 0; }
    .actions .danger { margin-left: 0; }
}

/* --- The copied-link notice ------------------------------------------------ */

.toast {
    position: fixed;
    left: 50%;
    bottom: 1.5rem;
    transform: translateX(-50%);
    background: var(--accent);
    color: var(--rich-black);
    font-weight: 600;
    padding: .6rem 1.2rem;
    border-radius: 4px;
    box-shadow: 0 4px 16px rgb(0 0 0 / .4);
    z-index: 10;
}

@media (prefers-reduced-motion: no-preference) {
    .toast:not([hidden]) { animation: toast-in .2s ease-out; }
    @keyframes toast-in { from { opacity: 0; transform: translate(-50%, .5rem); } }
}
