:root {
    color-scheme: light;
    --paper: #f7f3eb;
    --ink: #1c1915;
    --muted: #5c564c;
    --line: #e4d9c8;
    --accent: #9c3b2e;
    --serif: "Iowan Old Style", Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
    --sans: "Avenir Next", Avenir, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 1.0625rem;
    line-height: 1.5;
}

.page {
    max-width: 38rem;
    margin: 0 auto;
    padding:
        calc(1.5rem + env(safe-area-inset-top))
        calc(1.25rem + env(safe-area-inset-right))
        calc(2.5rem + env(safe-area-inset-bottom))
        calc(1.25rem + env(safe-area-inset-left));
}

.wordmark {
    margin: 0 0 2.6rem;
    font-size: 0.95rem;
}

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

.wordmark.lead {
    font-family: var(--serif);
    font-size: clamp(1.85rem, 7vw, 2.35rem);
    font-weight: 500;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.wordmark.lead a {
    display: inline-flex;
    align-items: baseline;
    gap: 0.16em;
}

.wordmark.lead .mark {
    width: 1.4em;
    height: auto;
    flex: none;
    fill: var(--accent);
}

h1, h2, h3, p { margin: 0; }

h1, .prompt {
    font-family: var(--serif);
    font-size: clamp(2.05rem, 8vw, 2.8rem);
    font-weight: 500;
    line-height: 1.12;
    letter-spacing: -0.02em;
}

h1 label { cursor: text; }

h2 {
    margin: 1.75rem 0 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
}

#answer h2 {
    font-family: var(--serif);
    font-size: clamp(1.85rem, 7vw, 2.35rem);
    font-weight: 500;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

#ask input {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.7rem 0;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
    color: inherit;
    font-family: var(--serif);
    font-size: 1.35rem;
    line-height: 1.3;
    appearance: none;
}

#ask input:focus {
    outline: none;
    border-bottom-color: var(--ink);
}

#ask > button {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    gap: 0.55rem;
    min-height: 44px;
    margin-top: 1.15rem;
    padding: 0.65rem 1.05rem 0.65rem 1.15rem;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: var(--paper);
    font: inherit;
    font-size: 1rem;
    cursor: pointer;
}

#ask > button::after {
    content: "→";
    display: inline-block;
    font-size: 1.15rem;
    line-height: 1;
    transition: transform 0.15s ease;
}

#ask > button:hover,
#ask > button:focus-visible { background: #7d2e24; }

#ask > button:hover::after,
#ask > button:focus-visible::after { transform: translateX(0.2rem); }

@media (prefers-reduced-motion: reduce) {
    #ask > button::after { transition: none; }
}

.status {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-height: 1.5rem;
    margin-top: 0.85rem;
    color: var(--muted);
}

.loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.75rem;
    color: var(--muted);
}

.spinner {
    width: 1.5rem;
    height: 1.5rem;
    flex: none;
    color: var(--accent);
    animation: spin 0.8s linear infinite;
}

.status .spinner { display: none; }

.status.waiting .spinner { display: block; }

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

#matches,
#list {
    margin: 0;
    padding: 0;
    list-style: none;
}

#matches button,
#suggest-matches button,
.item {
    display: block;
    width: 100%;
    border: 0;
    border-top: 1px solid var(--line);
    background: none;
    color: inherit;
    text-align: left;
}

#matches button,
#suggest-matches button {
    min-height: 44px;
    padding: 0.85rem 0;
    font: inherit;
    cursor: pointer;
}

#matches button:hover .match-title,
#matches button:focus-visible .match-title,
#suggest-matches button:hover .match-title,
#suggest-matches button:focus-visible .match-title { color: var(--accent); }

.match-title {
    display: block;
    font-family: var(--serif);
    font-size: 1.3rem;
    line-height: 1.25;
}

.match-meta,
.meta {
    display: block;
    margin-top: 0.15rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.item { padding: 1.05rem 0 0.9rem; }

.item h3 {
    font-family: var(--serif);
    font-size: 1.45rem;
    font-weight: 500;
    line-height: 1.2;
}

.kicker {
    margin-bottom: 0.25rem;
    color: var(--accent);
    font-size: 0.85rem;
}

.reason { margin-top: 0.35rem; }

.find,
#again {
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

.find {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-top: 0.15rem;
}

#more {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-height: 44px;
    margin-top: 1.15rem;
    padding: 0.65rem 1.15rem;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: var(--paper);
    font: inherit;
    font-size: 1rem;
    cursor: pointer;
}

#more:hover,
#more:focus-visible { background: #7d2e24; }

#more:disabled {
    opacity: 0.72;
    cursor: default;
}

.more-note {
    margin-top: 1rem;
    color: var(--muted);
}

#recommend {
    margin-top: 2rem;
    padding-top: 0.25rem;
}

#answer #recommend h2 {
    margin: 1.75rem 0 0.35rem;
    font-size: 1.55rem;
}

#recommend label {
    display: block;
    margin-top: 0.95rem;
    color: var(--muted);
    font-size: 0.92rem;
}

#recommend input[type="text"] {
    display: block;
    width: 100%;
    padding: 0.55rem 0;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 1.15rem;
    line-height: 1.3;
    appearance: none;
}

#recommend input[type="text"]:focus {
    outline: none;
    border-bottom-color: var(--ink);
}

#recommend > button,
.review-key button,
.review-list button:not(.text-button) {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-top: 1.1rem;
    padding: 0.65rem 1.15rem;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: var(--paper);
    font: inherit;
    font-size: 1rem;
    cursor: pointer;
}

#recommend > button:hover,
#recommend > button:focus-visible,
.review-key button:hover,
.review-key button:focus-visible,
.review-list button:not(.text-button):hover,
.review-list button:not(.text-button):focus-visible { background: #7d2e24; }

.suggest-which { margin-top: 1.25rem; }

#suggest-matches {
    margin: 0.4rem 0 0;
    padding: 0;
    list-style: none;
}

#suggest-status { min-height: 0; }

.hp {
    position: absolute;
    left: -9999px;
    height: 0;
    width: 0;
    opacity: 0;
}

.review-key label {
    display: block;
    margin-top: 1rem;
    color: var(--muted);
}

.review-key input {
    display: block;
    width: 100%;
    max-width: 20rem;
    margin-top: 0.35rem;
    padding: 0.7rem 0;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 1.15rem;
}

.review-list {
    margin: 1.25rem 0 0;
    padding: 0;
    list-style: none;
}

.review-list > li {
    padding: 1rem 0;
    border-top: 1px solid var(--line);
}

.review-list h2 {
    margin-top: 0.15rem;
    font-family: var(--serif);
    font-size: 1.45rem;
    font-weight: 500;
}

.review-list h3 {
    margin-top: 0.15rem;
    font-family: var(--serif);
    font-size: 1.25rem;
    font-weight: 500;
}

.review-list form { display: flex; flex-wrap: wrap; gap: 0.75rem 1.15rem; align-items: center; }

.text-button {
    min-height: 44px;
    margin-top: 1.1rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

.review-list .text-button { margin-top: 1.1rem; }

#again {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-top: 0.35rem;
    padding: 0;
}

footer {
    margin-top: 2.75rem;
    color: var(--muted);
    font-size: 0.95rem;
}

footer a { color: inherit; }

.cover {
    display: block;
    width: 9.5rem;
    height: auto;
    margin: 0 0 1.15rem;
    border: 1px solid var(--line);
}

.blurb { margin-top: 1rem; }

.buy {
    margin: 0.2rem 0 0;
    padding: 0;
    list-style: none;
}

.buy a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-right: 1.15rem;
    color: var(--accent);
    text-underline-offset: 0.18em;
}

.disclosure {
    margin-top: 0.35rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.prose h1 { margin-bottom: 1rem; }

.prose p { margin: 0 0 1rem; }

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

[hidden] { display: none !important; }
