:root {
    --bg: #f7f5f0;
    --surface: #ffffff;
    --surface-2: #f1eee7;
    --text: #1d1b18;
    --muted: #6b665d;
    --border: #e4dfd4;
    --accent: #c2410c;
    --accent-hover: #9a3412;
    --accent-soft: #fdeee4;
    --accent-text: #ffffff;
    --verified: #15803d;
    --verified-soft: #e6f4ea;
    --danger: #b91c1c;
    --danger-soft: #fdecec;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(29, 27, 24, 0.06), 0 2px 8px rgba(29, 27, 24, 0.04);
    --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-serif: "Fraunces", Georgia, "Times New Roman", serif;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #141311;
        --surface: #1d1b18;
        --surface-2: #26231f;
        --text: #f0ece4;
        --muted: #a39d92;
        --border: #34302a;
        --accent: #fb923c;
        --accent-hover: #fdba74;
        --accent-soft: #3a2416;
        --accent-text: #1d1b18;
        --verified: #4ade80;
        --verified-soft: #16301f;
        --danger: #f87171;
        --danger-soft: #3a1a1a;
        --shadow: none;
        color-scheme: dark;
    }
}

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

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

h1, h2 { font-family: var(--font-serif); font-weight: 600; line-height: 1.2; margin: 0 0 0.25em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.25rem; margin-top: 1.5rem; }
h1:focus { outline: none; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.hint { display: block; color: var(--muted); font-size: 0.8125rem; margin-top: 0.25rem; font-weight: 400; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

/* Top bar */
.topbar {
    position: sticky; top: 0; z-index: 10;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.topbar-inner {
    max-width: 960px; margin: 0 auto; padding: 0.75rem 16px;
    display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
}
.brand { font-family: var(--font-serif); font-size: 1.4rem; font-weight: 600; color: var(--text); }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; color: var(--text); }
.nav-links { display: flex; gap: 1rem; flex: 1; }
.nav-links a { color: var(--muted); font-weight: 500; display: inline-flex; align-items: center; gap: 0.35rem; }
.nav-links a.active, .nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-account { display: flex; align-items: center; gap: 0.5rem; }
.nav-account form { margin: 0; }
.nav-handle { color: var(--muted); font-weight: 500; }
.badge {
    background: var(--accent); color: var(--accent-text);
    border-radius: 999px; font-size: 0.75rem; font-weight: 600;
    min-width: 1.25rem; padding: 0 0.4rem; text-align: center; line-height: 1.25rem;
}

.page { max-width: 960px; margin: 0 auto; padding: 2rem 16px 4rem; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-header p { margin: 0; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
    border: 1px solid transparent; border-radius: 999px;
    padding: 0.55rem 1.1rem; font: inherit; font-weight: 500; cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-sm { padding: 0.3rem 0.8rem; font-size: 0.875rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); color: var(--accent-text); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.link-button { background: none; border: none; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.link-button:hover { text-decoration: underline; }

.tabs { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.tabs button {
    border: none; background: transparent; color: var(--muted);
    padding: 0.35rem 0.9rem; border-radius: 999px; font: inherit; font-size: 0.875rem; font-weight: 500; cursor: pointer;
}
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Quotes */
.quote-list { display: flex; flex-direction: column; gap: 1rem; }
.quote-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.5rem 1.5rem 1rem; box-shadow: var(--shadow);
}
.quote-card blockquote { margin: 0 0 1rem; position: relative; padding-left: 1.75rem; }
.quote-card blockquote::before {
    content: "“"; position: absolute; left: -0.25rem; top: -0.6rem;
    font-family: var(--font-serif); font-size: 3.5rem; color: var(--accent); line-height: 1;
}
.quote-text {
    font-family: var(--font-serif); font-size: 1.35rem; line-height: 1.45; color: var(--text);
    white-space: pre-line; overflow-wrap: anywhere;
}
.quote-text:hover { color: var(--text); text-decoration: none; }
.quote-meta { padding-left: 1.75rem; }
.attribution { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; }
.attribution .dash { color: var(--muted); }
.speaker { font-weight: 600; color: var(--text); }
.context { color: var(--muted); font-style: italic; margin: 0.25rem 0 0; font-size: 0.9375rem; }
.chip {
    font-size: 0.75rem; font-weight: 500; padding: 0.1rem 0.55rem; border-radius: 999px;
    background: var(--surface-2); color: var(--muted);
}
.chip-verified { background: var(--verified-soft); color: var(--verified); }
.quote-footer { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 0.75rem; }
.quote-footer a { color: var(--muted); }
.like {
    display: inline-flex; align-items: center; gap: 0.35rem;
    background: none; border: 1px solid var(--border); border-radius: 999px;
    padding: 0.2rem 0.75rem; color: var(--muted); font: inherit; font-size: 0.875rem; cursor: pointer;
}
span.like { cursor: default; }
.like span { font-size: 1rem; }
button.like:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.like.liked { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.credit-actions {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
    margin-top: 1rem; padding: 0.75rem 1rem; border-radius: 8px; background: var(--accent-soft);
}
.credit-actions .small { flex: 1; min-width: 12rem; }
.load-more { display: flex; margin: 1.5rem auto 0; }
.detail { display: flex; flex-direction: column; gap: 1rem; }
.owner-actions { justify-content: flex-end; }

.empty {
    text-align: center; padding: 3rem 1rem; color: var(--muted);
    border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty h1 { color: var(--text); }

/* Forms */
label { display: block; font-weight: 500; margin-bottom: 1rem; }
input:not([type=radio]):not([type=checkbox]), textarea, select {
    display: block; width: 100%; margin-top: 0.35rem;
    padding: 0.6rem 0.8rem; font: inherit; font-weight: 400; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
textarea { resize: vertical; font-family: var(--font-serif); font-size: 1.1rem; }
fieldset { border: none; padding: 0; margin: 0 0 1rem; }
legend { font-weight: 500; margin-bottom: 0.5rem; }
.input-prefix { display: flex; align-items: center; margin-top: 0.35rem; }
.input-prefix span {
    padding: 0.6rem 0.7rem; background: var(--surface-2); border: 1px solid var(--border);
    border-right: none; border-radius: 8px 0 0 8px; color: var(--muted);
}
.input-prefix input { margin-top: 0 !important; border-radius: 0 8px 8px 0 !important; }
.validation-message { color: var(--danger); font-size: 0.8125rem; font-weight: 400; margin-top: 0.25rem; }
.alert { background: var(--danger-soft); color: var(--danger); padding: 0.75rem 1rem; border-radius: 8px; margin: 0 0 1rem; }

.auth-card, .form-page {
    max-width: 440px; margin: 2rem auto; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow);
}
.form-page { max-width: 640px; }
.auth-card h1, .form-page h1 { margin-bottom: 1rem; }

.choice-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.5rem; }
.choice {
    display: flex; gap: 0.6rem; align-items: flex-start; margin: 0;
    border: 1px solid var(--border); border-radius: 10px; padding: 0.75rem; cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: 0.3rem; accent-color: var(--accent); }
.choice span { display: flex; flex-direction: column; }
.choice small { color: var(--muted); font-weight: 400; }
.speaker-picker { margin-top: 0.75rem; }
.search-results {
    list-style: none; margin: 0.25rem 0 0; padding: 0.25rem;
    border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}
.search-results button {
    width: 100%; text-align: left; background: none; border: none; padding: 0.5rem 0.6rem;
    font: inherit; color: var(--text); border-radius: 6px; cursor: pointer;
}
.search-results button:hover { background: var(--surface-2); }
.picked {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.6rem 0.8rem; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent-soft);
}
.edit-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }

/* Profile & groups */
.profile-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.profile-header p { margin: 0; }
.avatar {
    width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0;
    display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
    font-family: var(--font-serif); font-size: 1.75rem; font-weight: 600;
}
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.panel h2 { margin-top: 0; }
.panel h2 + * { margin-top: 0; }
.panel h2:not(:first-child) { margin-top: 1.25rem; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.inline-form { display: flex; gap: 0.5rem; }
.inline-form input { margin-top: 0 !important; }
.group-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.group-list a {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    padding: 1rem 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text);
}
.group-list a:hover { border-color: var(--accent); text-decoration: none; }
.group-layout { display: grid; grid-template-columns: 1fr 280px; gap: 1.5rem; align-items: start; }
.member-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: 0.35rem; }
.invite {
    display: block; padding: 0.5rem 0.75rem; background: var(--surface-2); border-radius: 8px;
    font-size: 0.8125rem; overflow-wrap: anywhere; user-select: all;
}

@media (max-width: 720px) {
    .group-layout { grid-template-columns: 1fr; }
    .nav-links { order: 3; flex-basis: 100%; }
    .topbar-inner { gap: 0.75rem; }
    .quote-card { padding: 1.25rem 1rem 0.75rem; }
    .quote-meta { padding-left: 0; }
    .quote-text { font-size: 1.2rem; }
    h1 { font-size: 1.6rem; }
    .auth-card, .form-page { padding: 1.25rem; margin: 1rem auto; }
}

/* Blazor error UI */
#blazor-error-ui {
    background: lightyellow; color: #000; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.success { background: var(--verified-soft); color: var(--verified); padding: 0.75rem 1rem; border-radius: 8px; margin: 1rem 0 0; }
.steps { padding-left: 1.25rem; color: var(--muted); }
.steps code, .form-page code { background: var(--surface-2); padding: 0.1rem 0.35rem; border-radius: 4px; }
.row.center { justify-content: center; }
