/* CredCite. One stylesheet for the app and the login / sign-up pages.
   Light and dark follow the system setting. Everything is built from the tokens below. */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede7;
  --text: #1b1b19;
  --muted: #62615b;
  --faint: #8e8c84;
  --border: #e4e2da;
  --border-strong: #d0cdc3;
  --accent: #2b5a88;
  --accent-hover: #224a71;
  --accent-soft: #e3ebf3;
  --on-accent: #f6f5f1;
  --good: #2c7a4d;
  --warn: #9a5d00;
  --edu: #6a3fa0;
  --gov: #2b5a88;
  --doi: #2c7a4d;
  --org: #a8551e;
  --mark: #fff0b3;
  --shadow: 0 1px 2px rgb(27 27 25 / 0.04), 0 6px 20px rgb(27 27 25 / 0.05);
  --ring: 0 0 0 3px rgb(43 90 136 / 0.22);
  --radius: 14px;
  --radius-sm: 10px;
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --topbar: 56px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131312;
    --surface: #1b1b19;
    --surface-2: #232321;
    --text: #edece7;
    --muted: #a6a59d;
    --faint: #75746d;
    --border: #2c2b28;
    --border-strong: #403f3a;
    --accent: #8db6e0;
    --accent-hover: #a6c7e9;
    --accent-soft: #1d2936;
    --on-accent: #0f1620;
    --good: #6cc391;
    --warn: #e0a64a;
    --edu: #b896e6;
    --gov: #8db6e0;
    --doi: #6cc391;
    --org: #e39a64;
    --mark: #57490f;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
    --ring: 0 0 0 3px rgb(141 182 224 / 0.28);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2 { text-wrap: balance; }
p { text-wrap: pretty; }
[hidden] { display: none !important; }
.error { color: var(--warn); }
.meta { font-size: 0.87rem; color: var(--muted); overflow-wrap: anywhere; }
.empty { color: var(--muted); padding: 28px 0; text-align: center; }

/* ---------- controls ---------- */
button, a.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 18px; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--on-accent);
  font: 600 0.93rem/1 var(--sans); text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
button:hover, a.button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.55; cursor: default; }
button.ghost { background: transparent; color: var(--text); border-color: var(--border-strong); font-weight: 500; }
button.ghost:hover { background: var(--surface-2); }
button.small { min-height: 32px; padding: 0 12px; font-size: 0.84rem; border-radius: 8px; }
:is(button, a, input, select, summary):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select { font: inherit; color: var(--text); }
select {
  min-height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); font-size: 0.9rem;
}
input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: var(--accent); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5; height: var(--topbar);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 650; font-size: 1.05rem; letter-spacing: -0.015em; }
.mark { width: 28px; height: 28px; flex: none; }
.wordmark b { font-weight: inherit; color: var(--accent); }
.mark rect { fill: var(--accent); }
.mark g { fill: none; stroke: var(--on-accent); stroke-width: 5.5; stroke-linecap: round; stroke-linejoin: round; }
.user { display: flex; align-items: center; gap: 14px; min-width: 0; font-size: 0.9rem; color: var(--muted); }
.user a:not(.button) { color: var(--text); text-decoration: none; font-weight: 500; }
.user a:not(.button):hover { text-decoration: underline; }
.user :is(button, a.button) { min-height: 34px; padding: 0 14px; font-size: 0.88rem; }
#user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 272px minmax(0, 1fr); align-items: start; max-width: 1200px; margin: 0 auto; }
main { min-width: 0; max-width: 860px; padding: 36px 28px 72px; }

#sidebar { position: sticky; top: var(--topbar); max-height: calc(100vh - var(--topbar)); overflow-y: auto; padding: 36px 8px 24px 24px; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.side-head h2 { margin: 0; font-size: 0.74rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); }
.side-empty { margin: 0; font-size: 0.87rem; color: var(--muted); }
.guest-note { margin: 18px 0 0; padding: 12px 14px; font-size: 0.84rem; color: var(--muted); background: var(--surface-2); border-radius: var(--radius-sm); }
#topic-list { list-style: none; margin: 0 0 0 -10px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
#topic-list li { display: flex; align-items: stretch; border-radius: var(--radius-sm); transition: background-color 0.15s; }
#topic-list li:hover { background: var(--surface-2); }
#topic-list li.active { background: var(--accent-soft); }
.topic-open {
  flex: 1; min-width: 0; min-height: 0; padding: 8px 10px; background: none; color: var(--text);
  flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; font-weight: 400; text-align: left;
}
.topic-open:hover { background: none; }
.topic-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 0.92rem; line-height: 1.3; }
#topic-list li.active .topic-name { font-weight: 600; color: var(--accent); }
.topic-sub { font-size: 0.76rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.topic-delete { min-height: 0; padding: 0 10px; background: none; color: var(--faint); font-size: 1.1rem; font-weight: 400; opacity: 0; }
.topic-delete:hover { background: none; color: var(--warn); }
#topic-list li:hover .topic-delete, .topic-delete:focus-visible { opacity: 1; }

/* ---------- hero and search ---------- */
#hero { margin: 28px 0 26px; }
#hero h1 { margin: 0 0 12px; font: 400 clamp(2rem, 4.6vw, 3rem)/1.08 var(--serif); letter-spacing: -0.025em; }
#hero p { margin: 0; max-width: 58ch; font-size: 1.02rem; color: var(--muted); }

.search-row {
  display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 16px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-row:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.search-row svg { flex: none; width: 18px; height: 18px; color: var(--faint); }
.search-row input { flex: 1; min-width: 0; height: 44px; padding: 0 8px; border: 0; background: none; font-size: 1.05rem; outline: none; }
.search-row input::placeholder { color: var(--faint); }
.search-row input::-webkit-search-cancel-button { display: none; }
.search-row button { min-height: 44px; padding: 0 22px; }

.strictness { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 14px; }
.opt-label { font-size: 0.84rem; font-weight: 500; color: var(--muted); }
.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: var(--radius-sm); }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 5px 14px; border-radius: 7px; font-size: 0.87rem; color: var(--muted); transition: background-color 0.15s, color 0.15s; }
.segmented input:checked + span { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.preset-help { flex: 1; min-width: 240px; margin: 0; font-size: 0.84rem; color: var(--muted); }

#advanced { margin-top: 10px; }
#advanced > summary { display: inline-block; cursor: pointer; font-size: 0.84rem; font-weight: 500; color: var(--muted); border-radius: 6px; list-style: none; }
#advanced > summary::-webkit-details-marker { display: none; }
#advanced > summary::after { content: " +"; }
#advanced[open] > summary::after { content: " −"; }
#advanced > summary:hover { color: var(--text); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px 28px; margin-top: 12px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; }
.field small { color: var(--muted); font-size: 0.8rem; }
.label, .field > label { font-weight: 500; }
.field input[type="text"], .field input[type="number"], .field select { min-height: 36px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--bg); }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks.column { flex-direction: column; }
.checks label { display: flex; align-items: baseline; gap: 7px; }

/* ---------- welcome ---------- */
#welcome { margin-top: 44px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0; margin-bottom: 30px; border-top: 1px solid var(--border); }
.steps div { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px 4px 0; font-size: 0.92rem; color: var(--muted); }
.steps b { font: italic 400 1.5rem/1 var(--serif); color: var(--accent); }
.try { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; font-size: 0.87rem; color: var(--muted); }
#examples { display: contents; }

.chip {
  min-height: 32px; padding: 0 13px; border-radius: 999px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); font-size: 0.85rem; font-weight: 500;
}
.chip:hover { background: var(--surface-2); }
.chip span { color: var(--faint); font-variant-numeric: tabular-nums; }
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip.on span { color: inherit; opacity: 0.7; }

/* ---------- status and loading ---------- */
#status { margin-top: 20px; font-size: 0.9rem; color: var(--muted); }
#status:empty { margin: 0; }
.notice { padding: 12px 16px; background: color-mix(in srgb, var(--warn) 10%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); border-radius: var(--radius-sm); color: var(--text); }
.spinner { display: inline-block; width: 14px; height: 14px; margin-right: 6px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; vertical-align: -2px; animation: spin 0.8s linear infinite; }
.skeleton { height: 148px; margin-top: 12px; border-radius: var(--radius); background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%) 0 0 / 300% 100%; border: 1px solid var(--border); animation: shimmer 1.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -150% 0; } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
  .skeleton { animation: none; }
  * { transition: none !important; }
}

/* ---------- topic view ---------- */
#topic-view { margin-top: 40px; }
.topic-head h1 { margin: 0 0 6px; font: 400 clamp(1.6rem, 3.2vw, 2.15rem)/1.15 var(--serif); letter-spacing: -0.02em; overflow-wrap: anywhere; }
.topic-head .meta { margin: 0; }
.mix { display: flex; gap: 3px; height: 4px; margin-top: 16px; }
.mix-part { border-radius: 2px; min-width: 6px; }
.mix-part.edu { background: var(--edu); } .mix-part.gov { background: var(--gov); } .mix-part.doi { background: var(--doi); } .mix-part.org { background: var(--org); }

.tabs { display: flex; gap: 24px; margin-top: 24px; border-bottom: 1px solid var(--border); }
.tabs button { min-height: 42px; padding: 0; margin-bottom: -1px; background: none; color: var(--muted); border: 0; border-bottom: 2px solid transparent; border-radius: 0; font-weight: 500; }
.tabs button:hover { color: var(--text); background: none; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }
.count { padding: 2px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 0.74rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 14px 0; }
#sources-view > .toolbar { position: sticky; top: var(--topbar); z-index: 3; background: var(--bg); }
.toolbar .spacer { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.sort, .select-all { display: inline-flex; align-items: center; gap: 7px; font-size: 0.86rem; color: var(--muted); white-space: nowrap; }

/* ---------- source cards ---------- */
.card { padding: 18px 20px; margin-bottom: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); transition: border-color 0.15s, box-shadow 0.15s; }
.card:hover { border-color: var(--border-strong); }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); }
.card-top input[type="checkbox"] { width: 16px; height: 16px; margin: 0; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.07em; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.edu { color: var(--edu); } .badge.gov { color: var(--gov); } .badge.doi { color: var(--doi); } .badge.org { color: var(--org); }
.cited { color: var(--good); font-weight: 600; }
.cited::before { content: "✓ "; }
.score { margin-left: auto; display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.bar { width: 56px; height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--good); border-radius: 2px; }
.card h2 { margin: 10px 0 4px; font-size: 1.08rem; font-weight: 600; line-height: 1.35; letter-spacing: -0.005em; }
.card h2 { text-wrap: pretty; }
.card h2 a { color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.card h2 a:hover { color: var(--accent); text-decoration: underline; }
.snippet { margin: 10px 0; color: var(--text); }
mark { background: var(--mark); color: inherit; padding: 0 2px; border-radius: 3px; }
.terms { font-size: 0.8rem; color: var(--faint); }
.card .terms + .meta { font-size: 0.8rem; color: var(--faint); }
.phd { margin-top: 12px; padding: 4px 12px; border-left: 2px solid var(--org); font-size: 0.85rem; color: var(--muted); }
.card-actions { margin-top: 14px; }

/* ---------- ads: two labelled spots, fixed height so the page never jumps ---------- */
.ad { margin: 4px 0 14px; padding: 10px 14px 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius); }
#ad-bottom { margin-top: 28px; }
.ad-label { display: block; margin-bottom: 6px; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.ad ins { display: block; width: 100%; height: 100px; overflow: hidden; }
.ad:has(ins[data-ad-status="unfilled"]) { display: none; }
.ad.ad-is-preview { border: 2px dashed var(--accent); background: var(--accent-soft); }
.ad-is-preview .ad-label { color: var(--accent); }
#ad-top { margin: 16px 0 0; }
.ad-preview { display: grid; place-items: center; height: 100px; border-radius: 8px; background: var(--surface-2); color: var(--faint); font-size: 0.85rem; }

#rejected-wrap { margin-top: 28px; }
#rejected-wrap summary { cursor: pointer; font-size: 0.9rem; color: var(--muted); }
#rejected { padding-left: 18px; font-size: 0.88rem; }
#rejected li { margin: 7px 0; overflow-wrap: anywhere; }
#rejected .why { color: var(--muted); }

.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 0.74rem; font-weight: 600; white-space: nowrap; }
.pill.good { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }
.pill.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }

/* ---------- bibliography ---------- */
#bib-list { list-style: none; margin: 0; padding: 0; counter-reset: ref; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
#bib-list:empty { display: none; }
#bib-list li { padding: 18px 22px; counter-increment: ref; }
#bib-list li + li { border-top: 1px solid var(--border); }
.bib-text { padding-left: 2em; text-indent: -2em; font: 1.02rem/1.6 var(--serif); overflow-wrap: anywhere; }
#bib-list.ieee .bib-text::before { content: "[" counter(ref) "] "; }
.bib-text.code, .cite-preview.code { padding-left: 0; text-indent: 0; font: 0.84rem/1.55 var(--mono); white-space: pre-wrap; }
.bib-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 10px; opacity: 0.55; transition: opacity 0.15s; }
#bib-list li:hover .bib-actions, .bib-actions:focus-within { opacity: 1; }

/* ---------- citations dialog ---------- */
dialog {
  width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 26px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border-strong); border-radius: 18px;
  box-shadow: 0 24px 80px rgb(0 0 0 / 0.3);
}
dialog::backdrop { background: rgb(15 15 14 / 0.55); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2 { margin: 0; font: 400 1.6rem/1.2 var(--serif); letter-spacing: -0.015em; }
dialog > .meta { margin: 8px 0 0; }
.dialog-foot { position: sticky; bottom: -26px; display: flex; justify-content: flex-end; gap: 10px; margin-bottom: -26px; padding: 16px 0 26px; background: var(--bg); border-top: 1px solid var(--border); }

.style-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-top: 20px; }
.style-option {
  flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 3px; min-height: 96px; padding: 16px 18px;
  background: var(--surface); color: var(--text); border-color: var(--border); border-radius: var(--radius);
  font-weight: 400; text-align: left; white-space: normal; line-height: 1.35;
}
.style-option:hover { background: var(--surface); border-color: var(--accent); box-shadow: var(--ring); }
.style-option.last-used { border-color: var(--accent); }
.style-option b { font: 400 1.3rem/1.2 var(--serif); }
.style-option span { font-size: 0.84rem; }
.style-option small { font-size: 0.8rem; color: var(--muted); }

.cite-list { margin: 16px 0; }
.cite-item { margin-bottom: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.cite-item[open] { border-color: var(--border-strong); }
.cite-item summary { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px 18px; cursor: pointer; list-style: none; border-radius: var(--radius); }
.cite-item summary::-webkit-details-marker { display: none; }
.cite-preview { font: 1rem/1.55 var(--serif); overflow-wrap: anywhere; }
.cite-from { margin: 0; padding: 0 18px; font-size: 0.8rem; color: var(--faint); }
.cite-edit { padding: 12px 18px 18px; }
.kind-row { margin-bottom: 14px; font-size: 0.88rem; color: var(--muted); }
.cite-fields { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px 12px; }
.cf { grid-column: span 3; display: flex; flex-direction: column; gap: 5px; font-size: 0.82rem; font-weight: 500; color: var(--muted); }
.cf.wide { grid-column: 1 / -1; }
.cf.short { grid-column: span 2; }
.cf :is(input, select) { width: 100%; min-width: 0; min-height: 38px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--bg); color: var(--text); font-weight: 400; }
.cf :is(input, select):focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.cf small { font-weight: 400; color: var(--faint); }
.cf em { display: none; margin-left: 8px; font-style: normal; font-weight: 400; color: var(--warn); }
.cf.missing em { display: inline; }
.cf.missing :is(input, select) { border-color: var(--warn); border-style: dashed; }
.cf button { align-self: flex-start; }

#toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 20; max-width: calc(100vw - 32px); padding: 11px 18px;
  background: var(--text); color: var(--bg); border-radius: var(--radius-sm); font-size: 0.9rem; box-shadow: 0 8px 30px rgb(0 0 0 / 0.25);
  opacity: 0; transform: translate(-50%, 16px); pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; margin-top: 64px; padding-top: 18px; border-top: 1px solid var(--border); font-size: 0.8rem; color: var(--faint); }
.foot-links { display: flex; gap: 18px; }
.foot-links a { color: var(--muted); }

/* ---------- text pages (privacy, not found) ---------- */
.prose { max-width: 680px; margin: 0 auto; padding: 56px 20px 80px; }
.prose h1 { margin: 0 0 12px; font: 400 clamp(2rem, 4.6vw, 2.8rem)/1.1 var(--serif); letter-spacing: -0.025em; }
.prose h2 { margin: 40px 0 10px; font-size: 1.05rem; font-weight: 650; }
.prose .lede { font-size: 1.05rem; color: var(--muted); }
.prose ul { padding-left: 20px; }
.prose li { margin: 8px 0; }

/* ---------- login and sign-up ---------- */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; }
.auth { width: min(400px, 100%); max-width: none; padding: 0; }
.auth .mark { width: 40px; height: 40px; }
.auth .brand { font-size: 1.2rem; }
.auth h1 { margin: 28px 0 6px; font: 400 2.1rem/1.15 var(--serif); letter-spacing: -0.02em; }
.tagline { margin: 0 0 24px; color: var(--muted); }
.auth-card { display: flex; flex-direction: column; gap: 12px; padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); }
.auth form { display: flex; flex-direction: column; gap: 14px; }
.auth label { display: flex; flex-direction: column; gap: 6px; font-size: 0.86rem; font-weight: 500; }
.auth input { min-height: 44px; padding: 0 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg); }
.auth input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.auth small { margin-top: -8px; font-size: 0.8rem; color: var(--faint); }
.auth form button { min-height: 44px; margin-top: 4px; }
.auth .error { margin: 0; font-size: 0.88rem; }
.provider {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-weight: 600; font-size: 0.93rem; text-decoration: none; transition: background-color 0.15s;
}
.provider:hover { background: var(--surface-2); }
.provider svg { width: 18px; height: 18px; flex: none; }
.provider[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.provider[aria-disabled="true"]:hover { background: var(--surface); }
.agree { margin: 0; font-size: 0.8rem; color: var(--muted); text-align: center; }
.provider-note { margin: 0; font-size: 0.8rem; color: var(--faint); text-align: center; }
.or { display: flex; align-items: center; gap: 12px; margin: 4px 0; font-size: 0.8rem; color: var(--faint); }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.switch { margin: 18px 0 0; font-size: 0.9rem; color: var(--muted); text-align: center; }
.switch + .switch { margin-top: 8px; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .topbar { padding: 0 16px; }
  #sidebar { position: static; max-height: 230px; padding: 20px 16px 0; }
  #topic-list { margin-left: 0; }
  main { padding: 20px 16px 56px; }
  #hero { margin-top: 12px; }
  .topic-delete { opacity: 1; }
}
@media (max-width: 520px) {
  .search-row { padding-left: 12px; }
  .search-row button { padding: 0 16px; }
  .score { margin-left: 0; width: 100%; }
  .cf, .cf.short { grid-column: span 3; }
  #get-citations { flex: 1; }
  #sources-view > .toolbar { position: static; }
  #user-name { display: none; }
}
