:root {
    --paper: oklch(97% 0.018 82);
    --paper-raised: oklch(99% 0.009 82);
    --paper-deep: oklch(92% 0.026 78);
    --ink: oklch(25% 0.026 48);
    --ink-soft: oklch(48% 0.026 48);
    --ink-faint: oklch(64% 0.023 52);
    --line: oklch(84% 0.025 70);
    --accent: oklch(60% 0.16 30);
    --accent-deep: oklch(47% 0.14 28);
    --accent-soft: oklch(91% 0.065 37);
    --success: oklch(52% 0.105 150);
    --danger: oklch(52% 0.14 25);
    --shadow: 0 18px 46px oklch(30% 0.035 45 / 0.08);
    --radius-small: 0.65rem;
    --radius: 1.05rem;
    --radius-large: 1.5rem;
    --max-width: 72rem;
    --bottom-nav-height: 4.15rem;
    --study-nav-offset: 0rem;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 320px; background: var(--paper); }

body {
    min-width: 320px;
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: "Avenir Next", "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
    text-rendering: optimizeLegibility;
}

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

button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }

button, .primary-button, .secondary-button, .danger-button, .filter-chip, .bottom-nav-item, .round-arrow, .reveal-button, .review-button, .search-button, .text-button, .file-button {
    min-height: 44px;
}

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

h1, h2, p { margin-top: 0; }
h1, h2 { letter-spacing: -0.035em; }
h1 { font-size: clamp(2.45rem, 7vw, 4.5rem); line-height: 0.98; margin-bottom: 1rem; }
h2 { font-size: clamp(1.35rem, 2.5vw, 2rem); line-height: 1.12; }
p { color: var(--ink-soft); }

.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;
}

.app-body { padding-bottom: var(--bottom-nav-height); }
.app-shell { width: min(100% - 2rem, var(--max-width)); margin: 0 auto; }
.page-wrap { padding: 2rem 0 2rem; }
.page-wrap-narrow { width: min(100%, 46rem); margin: 0 auto; }

.topbar, .guest-topbar {
    width: min(100% - 2rem, var(--max-width));
    min-height: 78px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.topbar { border-bottom: 1px solid var(--line); }
.wordmark { display: inline-flex; align-items: center; gap: 0.22rem; color: var(--ink); font-size: 1.18rem; font-weight: 800; letter-spacing: 0.12em; }
.wordmark-mark { color: var(--accent); font-size: 1.1em; letter-spacing: 0; }
.topbar-tools { display: flex; align-items: center; gap: 1rem; }
.topbar-path { display: inline-flex; align-items: center; gap: 0.5rem; max-width: 18rem; color: var(--ink-soft); font-size: 0.84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-dot { display: inline-block; flex: 0 0 auto; width: 0.48rem; height: 0.48rem; border-radius: 50%; background: var(--accent); }
.account-menu { position: relative; }
.account-menu summary { display: grid; place-items: center; width: 2.35rem; height: 2.35rem; border: 1px solid var(--line); border-radius: 50%; background: var(--paper-raised); cursor: pointer; color: var(--ink-soft); font-size: 0.8rem; font-weight: 700; list-style: none; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-popover { position: absolute; z-index: 10; top: calc(100% + 0.75rem); right: 0; width: 15rem; padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius-small); background: var(--paper-raised); box-shadow: var(--shadow); }
.account-popover strong, .account-popover span { display: block; }
.account-popover span { margin: 0.25rem 0 0.8rem; color: var(--ink-faint); font-size: 0.8rem; overflow-wrap: anywhere; }

.app-body > .topbar { display: none; }
.bottom-nav { position: fixed; z-index: 20; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(3, 1fr); width: min(100%, 28rem); margin: 0 auto; padding: 0.4rem 0.55rem 0.45rem; border-top: 1px solid var(--line); background: var(--paper); }
.bottom-nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.2rem; min-height: 3.1rem; border-radius: 0.45rem; color: var(--ink-faint); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.025em; transition: color 180ms ease-out, transform 180ms ease-out; }
.bottom-nav-item:hover { color: var(--ink); }
.bottom-nav-item.is-active { color: var(--ink); font-weight: 800; }
.bottom-nav-item:active { transform: translateY(1px); }
.nav-icon { display: grid; place-items: center; width: 1.15rem; height: 1.15rem; }
.nav-icon svg { width: 100%; height: 100%; }

.study-body { height: 100dvh; min-height: 100svh; overflow: hidden; padding-bottom: 0; }
.study-body .app-shell { height: calc(100dvh - var(--bottom-nav-height) - var(--study-nav-offset)); min-height: 0; }
.study-body .study-wrap { display: flex; height: 100%; min-height: 0; flex-direction: column; align-items: center; justify-content: center; padding: 0.75rem 0; }
.study-body .study-card { display: flex; flex: 0 1 auto; width: 100%; max-height: 100%; min-height: 0; flex-direction: column; overflow: hidden; padding: clamp(0.9rem, 3vw, 2rem); }
.study-body .study-card-meta { flex: 0 0 auto; }
.study-body .prompt-block { display: flex; flex: 0 0 auto; min-height: 0; align-items: center; flex-direction: column; justify-content: center; padding: clamp(1.25rem, 4vh, 2rem) 0 1rem; text-align: center; }
.study-body .study-prompt { text-align: center; }
.study-body .reveal-button { align-self: center; }
.study-body .answer-block { flex: 0 0 auto; margin-top: 0.5rem; padding-top: 0.5rem; text-align: center; }
.study-body .answer-main { padding-bottom: 0.75rem; }
.study-body .answer-support { gap: 0.75rem; padding: 0.75rem 0; text-align: center; }
.study-body .audio-row { gap: 0.5rem; padding: 0.5rem 0; }
.study-body .recording-control { gap: 0.2rem; }
.study-body .recording-status { min-height: 0; }
.study-body .review-actions { gap: 0.5rem; margin-top: 0.5rem; }
.study-body .review-button { gap: 0.05rem; padding: 0.45rem 0.65rem; }
.study-body .review-button span { font-size: 0.9rem; line-height: 1.1; white-space: nowrap; }
.study-body .review-button small { font-size: 0.64rem; line-height: 1.1; white-space: nowrap; }

.flash-message { width: min(100% - 2rem, 56rem); margin: 1rem auto 0; padding: 0.8rem 1rem; border: 1px solid oklch(66% 0.09 35 / 0.28); border-radius: var(--radius-small); background: var(--accent-soft); color: var(--accent-deep); font-size: 0.9rem; }
.flash-message ul { margin: 0.35rem 0 0; padding-left: 1.2rem; }
.flash-error { border-color: oklch(60% 0.12 25 / 0.3); background: oklch(94% 0.04 25); color: var(--danger); }
.flash-error li { color: var(--danger); }

.eyebrow, .path-kicker, .prompt-label, .support-label, .card-row-kicker, .card-index { display: block; color: var(--accent-deep); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.12em; line-height: 1.2; text-transform: uppercase; }
.page-heading { margin-bottom: 2.5rem; }
.page-heading .lede, .study-heading + .study-summary + .filter-row { max-width: 42rem; }
.lede { max-width: 38rem; font-size: 1.05rem; }
.study-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.6rem; }
.study-heading h1 { margin-bottom: 0; }
.study-heading .eyebrow { margin-bottom: 0.55rem; }
.quiet-link, .back-link { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 44px; color: var(--accent-deep); font-size: 0.9rem; font-weight: 750; }
.back-link { margin-bottom: 1.25rem; color: var(--ink-soft); }
.quiet-link span { font-size: 1.15em; }

.primary-button, .secondary-button, .danger-button, .search-button, .text-button { display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; border: 1px solid transparent; border-radius: 999px; cursor: pointer; font-weight: 750; transition: background-color 180ms ease-out, color 180ms ease-out, border-color 180ms ease-out, transform 180ms ease-out; }
.primary-button { padding: 0.62rem 1.05rem; background: var(--ink); color: var(--paper-raised); }
.primary-button:hover { background: var(--accent-deep); color: var(--paper-raised); }
.secondary-button { padding: 0.62rem 1rem; border-color: var(--line); background: var(--paper-raised); color: var(--ink); }
.secondary-button:hover { border-color: var(--accent); color: var(--accent-deep); }
.danger-button { padding: 0.62rem 1rem; border-color: oklch(68% 0.09 25 / 0.5); background: transparent; color: var(--danger); }
.danger-button:hover { background: oklch(94% 0.04 25); }
.compact-button { min-height: 42px; padding: 0.45rem 0.85rem; font-size: 0.86rem; }
.inline-button { margin-top: 0.7rem; }
.text-button { min-height: 44px; padding: 0.15rem 0; border: 0; border-radius: 0; background: transparent; color: var(--accent-deep); font-size: 0.84rem; }
button:active, .primary-button:active, .secondary-button:active, .danger-button:active { transform: translateY(1px); }

.study-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.65rem; max-width: 38rem; margin-bottom: 1.75rem; }
.study-summary div { padding: 0.85rem 0; border-top: 1px solid var(--line); }
.study-summary strong, .study-summary span { display: block; }
.study-summary strong { font-size: 1.4rem; letter-spacing: -0.03em; }
.study-summary span { color: var(--ink-faint); font-size: 0.74rem; }
.filter-row { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem; }
.filter-label { margin-right: 0.15rem; color: var(--ink-faint); font-size: 0.77rem; font-weight: 700; }
.filter-chip { display: inline-flex; align-items: center; padding: 0.42rem 0.76rem; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink-soft); font-size: 0.78rem; font-weight: 700; }
.filter-chip:hover, .filter-chip.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-deep); }
.filter-context { margin-left: 0.35rem; color: var(--ink-faint); font-size: 0.77rem; }

.study-card, .detail-card { padding: clamp(1.25rem, 5vw, 3rem); border: 1px solid var(--line); border-radius: var(--radius-large); background: var(--paper-raised); box-shadow: var(--shadow); }
.study-card { max-width: 56rem; margin: 0 auto; }
.study-card-meta, .detail-topline { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.study-card-meta { justify-content: space-between; }
.tag-list { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.study-card-tags { min-width: 0; flex: 1 1 auto; }
.study-card-meta .tag-list { justify-content: flex-start; }
.tag-pill { display: inline-flex; align-items: center; min-height: 1.55rem; padding: 0.2rem 0.48rem; border-radius: 0.35rem; background: var(--paper-deep); color: var(--ink-soft); font-size: 0.68rem; font-weight: 700; }
.study-card-tags-empty { color: var(--ink-faint); font-size: 0.74rem; }
.study-edit-button { flex: 0 0 auto; }
.prompt-block { padding: clamp(3.5rem, 10vw, 7rem) 0 2.5rem; }
.prompt-label { margin-bottom: 0.85rem; color: var(--ink-faint); }
.study-prompt, .detail-prompt { max-width: 14ch; margin-bottom: 0; font-size: clamp(2.5rem, 8vw, 6.5rem); line-height: 0.98; overflow-wrap: anywhere; }
.reveal-button { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.6rem 0; border: 0; background: transparent; color: var(--ink); cursor: pointer; font-size: 0.95rem; font-weight: 800; }
.reveal-button:hover { border-color: var(--accent); color: var(--accent-deep); }
.answer-block { margin-top: 1.5rem; padding-top: 1.5rem; }
.answer-main { padding-bottom: 1.75rem; }
.study-card .answer-main { text-align: center; }
.translation { margin-bottom: 0.45rem; color: var(--ink); font-size: clamp(1.7rem, 4vw, 3rem); font-weight: 700; letter-spacing: -0.035em; line-height: 1.1; }
.study-card .translation { margin-bottom: 0.35rem; font-size: clamp(2.25rem, 8vw, 4.5rem); font-weight: 750; letter-spacing: -0.045em; line-height: 1.02; }
.answer-subtitle { display: block; margin-bottom: 0.55rem; color: var(--ink-faint); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; }
.jyutping { margin-bottom: 0; color: var(--accent-deep); font-size: 1.1rem; font-weight: 650; letter-spacing: 0.02em; }
.answer-support { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; padding: 1.25rem 0; border-top: 1px solid var(--line); }
.answer-support p { margin: 0; color: var(--ink-soft); font-size: 0.92rem; }
.support-label { margin-bottom: 0.45rem; color: var(--ink-faint); font-size: 0.64rem; }
.audio-row { display: flex; flex-wrap: wrap; gap: 1rem; padding: 1.25rem 0; border-top: 1px solid var(--line); }
.audio-item { display: flex; flex: 1 1 14rem; flex-direction: column; gap: 0.4rem; }
.study-card .answer-support, .study-card .audio-row { border-top: 0; }
.study-card .audio-row { justify-content: center; text-align: center; }
.study-card .audio-item, .study-card .recording-control { align-items: center; }
.study-card .recording-control { display: flex; flex: 1 1 14rem; flex-direction: column; gap: 0.4rem; }
audio { width: min(100%, 22rem); height: 2.25rem; }
.stored-recording-audio { display: none; }
.audio-toggle-button { min-width: 5.8rem; padding: 0.5rem 0.8rem; }
.audio-toggle-button.is-playing { border-color: var(--accent); color: var(--accent-deep); }
.audio-toggle-icon { display: inline-grid; place-items: center; width: 0.9rem; height: 0.9rem; }
.audio-toggle-icon svg { width: 100%; height: 100%; }
.audio-empty { align-self: center; color: var(--ink-faint); font-size: 0.82rem; }
.record-button { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.62rem 1rem; }
.record-button svg { width: 1.1rem; height: 1.1rem; }
.record-button.is-recording { border-color: var(--danger); background: oklch(95% 0.035 35); color: var(--danger); }
.recording-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.recording-status { min-height: 1.1rem; color: var(--ink-faint); font-size: 0.72rem; }
.review-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; margin-top: 1rem; }
.review-actions form { display: flex; }
.review-button { display: flex; flex: 1; flex-direction: column; align-items: flex-start; justify-content: center; gap: 0.15rem; padding: 0.8rem 1rem; border: 1px solid var(--line); border-radius: var(--radius-small); cursor: pointer; text-align: left; }
.review-button span { font-weight: 800; }
.review-button small { color: var(--ink-faint); font-size: 0.72rem; }
.review-again { background: oklch(95% 0.035 35); color: var(--danger); }
.review-again:hover { border-color: var(--danger); }
.review-known { background: oklch(94% 0.035 150); color: var(--success); }
.review-known:hover { border-color: var(--success); }
.study-edit-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; background: var(--paper); color: var(--ink); }
.study-edit-dialog::backdrop { background: oklch(25% 0.026 48 / 0.55); }
.study-edit-dialog__shell { min-height: 100%; overflow-y: auto; padding: max(1.25rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) calc(1.5rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
.study-edit-dialog__header, .study-edit-dialog__body { width: min(100%, 46rem); margin: 0 auto; }
.study-edit-dialog__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; }
.study-edit-dialog__header .eyebrow { margin-bottom: 0.5rem; }
.study-edit-dialog__header h2 { margin-bottom: 0; font-size: clamp(1.8rem, 5vw, 2.8rem); }
.study-edit-close { display: grid; flex: 0 0 auto; place-items: center; width: 2.75rem; height: 2.75rem; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--paper-raised); color: var(--ink-soft); cursor: pointer; font-size: 1.5rem; line-height: 1; }
.study-edit-close:hover { border-color: var(--accent); color: var(--accent-deep); }
.study-edit-form { gap: 1rem; }
.study-edit-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.35rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.study-empty { max-width: 40rem; margin: 3rem auto; text-align: center; }
.empty-state { padding: 3rem 1.5rem; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; }
.empty-state h2 { margin-bottom: 0.6rem; }
.empty-state p { margin-bottom: 1.2rem; }
.empty-mark { display: grid; place-items: center; width: 3rem; height: 3rem; margin: 0 auto 1.2rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent-deep); font-size: 1.5rem; font-weight: 700; }
.study-footnote { margin: 1rem auto 0; color: var(--ink-faint); font-size: 0.78rem; text-align: center; }

.path-list { display: grid; gap: 0.75rem; }
.path-option { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-raised); text-align: left; transition: border-color 180ms ease-out, transform 180ms ease-out, box-shadow 180ms ease-out; }
.path-option:hover, .path-option.is-selected { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.path-option-copy { min-width: 0; }
.path-option h2 { margin: 0.35rem 0 0.25rem; font-size: 1.45rem; }
.path-option p { margin: 0; font-size: 0.88rem; }
.round-arrow { display: grid; flex: 0 0 auto; place-items: center; width: 2.75rem; height: 2.75rem; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--paper); color: var(--accent-deep); cursor: pointer; font-size: 1.2rem; }
.round-arrow:hover { border-color: var(--accent); background: var(--accent-soft); }
.quiet-note { display: flex; align-items: center; gap: 0.55rem; margin-top: 1.2rem; color: var(--ink-faint); font-size: 0.78rem; }
.account-panel { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.account-panel > div { min-width: 0; }
.account-panel strong, .account-panel > div > span:last-child { display: block; overflow-wrap: anywhere; }
.account-panel strong { margin-top: 0.2rem; font-size: 0.95rem; }
.account-panel > div > span:last-child { color: var(--ink-faint); font-size: 0.8rem; }
.account-kicker { display: block; color: var(--ink-faint); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }

.card-toolbar { display: grid; gap: 1rem; margin-bottom: 1.25rem; }
.search-form { display: flex; gap: 0.55rem; }
.search-form input { flex: 1; min-width: 0; }
.search-button { padding: 0.55rem 1rem; background: var(--ink); color: var(--paper-raised); }
.search-button:hover { background: var(--accent-deep); }
.card-filters { margin: 0; }
.card-list { display: grid; gap: 0.55rem; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.2rem; border: 1px solid var(--line); border-radius: var(--radius-small); background: var(--paper-raised); transition: border-color 180ms ease-out, background-color 180ms ease-out; }
.card-row:hover { border-color: var(--accent); background: oklch(98% 0.026 80); }
.card-row-copy { min-width: 0; }
.card-row-kicker { margin-bottom: 0.45rem; color: var(--ink-faint); font-size: 0.62rem; }
.card-row h2 { margin-bottom: 0.25rem; font-size: 1.35rem; overflow-wrap: anywhere; }
.card-row p { margin: 0 0 0.55rem; overflow-wrap: anywhere; }
.card-row-side { display: flex; flex: 0 0 auto; align-items: center; gap: 0.75rem; color: var(--ink-faint); font-size: 0.72rem; }
.card-row-side strong { color: var(--accent-deep); font-size: 1.2rem; }
.pagination-wrap { margin-top: 1.5rem; }
.pagination-wrap nav { display: flex; justify-content: center; }
.pagination-wrap svg { width: 1rem; }
.pagination-wrap a, .pagination-wrap span { display: inline-flex; align-items: center; justify-content: center; min-width: 2.4rem; min-height: 2.4rem; padding: 0.3rem; color: var(--ink-soft); }

.form-heading { margin-bottom: 1.5rem; }
.form-heading .back-link { margin-bottom: 2rem; }
.form-stack { display: grid; gap: 1.1rem; }
.field-group { display: grid; gap: 0.45rem; }
.field-group label, .field-label-row { color: var(--ink); font-size: 0.82rem; font-weight: 750; }
.field-label-row { display: flex; justify-content: space-between; gap: 1rem; }
.field-hint { color: var(--ink-faint); font-size: 0.72rem; font-weight: 500; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-small); background: var(--paper-raised); color: var(--ink); }
input, select { min-height: 3rem; padding: 0.7rem 0.8rem; }
textarea { min-height: 5rem; padding: 0.7rem 0.8rem; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
input:hover, select:hover, textarea:hover { border-color: oklch(70% 0.04 60); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 3px solid oklch(60% 0.16 30 / 0.16); }
.checkbox-row { display: flex; align-items: center; gap: 0.55rem; color: var(--ink-soft); font-size: 0.82rem; }
.checkbox-row input { width: 1.1rem; min-height: 1.1rem; accent-color: var(--accent); }
.form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 1rem; margin-top: 0.4rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.recording-panel { display: grid; gap: 0.9rem; margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.recording-panel h2 { margin-bottom: 0.35rem; font-size: 1.45rem; }
.recording-panel p { margin-bottom: 0; font-size: 0.88rem; }
.recording-form { display: flex; align-items: center; flex-wrap: wrap; gap: 0.65rem; }
.file-button { display: inline-flex; align-items: center; justify-content: center; padding: 0.55rem 0.9rem; border: 1px solid var(--line); border-radius: 999px; background: var(--paper-raised); color: var(--ink-soft); cursor: pointer; font-size: 0.82rem; font-weight: 700; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.detail-topline { margin-bottom: 1.25rem; }
.detail-topline .back-link { margin: 0; }
.detail-card { padding-bottom: 2rem; }
.detail-prompt { max-width: none; margin: 2.2rem 0 2.5rem; }
.detail-answer { padding-bottom: 1.4rem; border-top: 1px solid var(--line); padding-top: 1.6rem; }
.detail-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 1rem 0 1.5rem; }
.detail-stats div { padding: 0.8rem 0; border-top: 1px solid var(--line); }
.detail-stats strong, .detail-stats span { display: block; }
.detail-stats strong { font-size: 1.35rem; }
.detail-stats span { color: var(--ink-faint); font-size: 0.76rem; }
.detail-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 0.8rem; }
.detail-actions form { display: flex; }

.guest-body { min-height: 100vh; background: var(--paper); }
.guest-topbar { border-bottom: 1px solid var(--line); }
.guest-caption { color: var(--ink-faint); font-size: 0.78rem; }
.guest-shell { width: min(100% - 2rem, 30rem); margin: 0 auto; padding: 4.5rem 0 3rem; }
.auth-panel { padding: clamp(1.4rem, 5vw, 2.5rem); border: 1px solid var(--line); border-radius: var(--radius-large); background: var(--paper-raised); box-shadow: var(--shadow); }
.auth-intro { margin-bottom: 2rem; }
.auth-intro h1 { font-size: clamp(2.15rem, 8vw, 3.7rem); }
.auth-intro p:last-child { max-width: 29rem; margin-bottom: 0; }
.auth-footnote { margin: 1.4rem 0 0; color: var(--ink-faint); font-size: 0.84rem; text-align: center; }
.auth-footnote a { color: var(--accent-deep); font-weight: 750; }

@media (min-width: 720px) {
    :root { --study-nav-offset: 1rem; }
    .app-body { padding-bottom: calc(var(--bottom-nav-height) + 1rem); }
    .app-shell { width: min(100% - 4rem, var(--max-width)); }
    .topbar, .guest-topbar { width: min(100% - 4rem, var(--max-width)); }
    .bottom-nav { margin-bottom: 1rem; }
    .page-wrap { padding-top: 3rem; }
    .study-card { margin-top: 1.2rem; }
    .card-toolbar { grid-template-columns: minmax(18rem, 1fr) auto; align-items: center; }
    .card-filters { justify-content: end; }
}

@media (max-width: 560px) {
    .page-wrap { padding-top: 1.5rem; }
    .study-heading { align-items: flex-start; flex-direction: column; }
    .study-heading .quiet-link { align-self: flex-start; }
    .study-summary { gap: 0.45rem; }
    .study-summary strong { font-size: 1.2rem; }
    .study-summary span { font-size: 0.66rem; }
    .study-card, .detail-card { border-radius: 1.15rem; }
    .detail-topline { align-items: flex-start; flex-direction: column; }
    .prompt-block { padding-top: 3.5rem; }
    .answer-support { grid-template-columns: 1fr; }
    .card-row { align-items: flex-start; }
    .card-row-side { flex-direction: column; align-items: end; gap: 0.35rem; }
    .guest-caption { display: none; }
    .guest-shell { padding-top: 3rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
