:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1c2330;
  --muted: #5d6778;
  --border: #dde2ea;
  --accent: #2457c5;
  --accent-text: #ffffff;
  --code-bg: #0f1722;
  --code-text: #e6edf3;
  --warn-bg: #fff6e0;
  --warn-border: #e6b84f;
  --ok: #1e7f4f;
  --bad: #b3261e;
  --neutral: #6b5bb5;
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c;
    --card: #1a2029;
    --text: #e3e8ef;
    --muted: #98a3b3;
    --border: #2c3542;
    --accent: #6d9cff;
    --accent-text: #0b1220;
    --code-bg: #0a0f16;
    --code-text: #e6edf3;
    --warn-bg: #2d2614;
    --warn-border: #8a6d22;
    --ok: #5cc28f;
    --bad: #ff8a80;
    --neutral: #b5a8ff;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { width: 100%; max-width: 920px; margin: 0 auto; padding: 16px; flex: 1; }
h1 { font-size: 1.3rem; margin: 0 0 8px; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; margin: 18px 0 6px; }
code { font-family: var(--mono); font-size: 0.92em; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--card);
}
.brand { font-weight: 700; font-size: 1.1rem; }
.brand .sub { font-weight: 400; color: var(--muted); font-size: 0.85rem; margin-left: 8px; }
.top-right { display: flex; align-items: center; gap: 8px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.narrow { max-width: 420px; margin: 48px auto; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type=password], textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit;
}
textarea { resize: vertical; min-height: 72px; }
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-text); padding: 8px 16px; font-weight: 600;
}
button:disabled { opacity: 0.6; cursor: progress; }
button.ghost { background: transparent; color: var(--text); border-color: var(--border); font-weight: 500; padding: 6px 12px; }
#loginForm button { margin-top: 12px; width: 100%; }

.ask-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.examples { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  font-weight: 500; padding: 4px 10px; border-radius: 999px; font-size: 0.85rem;
}

.pill { font-size: 0.8rem; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; }
.result-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px 8px; border-radius: 6px; border: 1px solid currentColor; }
.badge.answered { color: var(--ok); }
.badge.not_found, .badge.no_term { color: var(--neutral); }
.badge.unverified, .badge.error { color: var(--bad); }
.badge.route { color: var(--muted); }
.question-echo { margin: 10px 0 12px; font-weight: 600; }

.answer p { margin: 4px 0; overflow-wrap: anywhere; }
.answer .indent { padding-left: 20px; }
.answer .label { font-weight: 700; margin-top: 12px; }
.cite { font-size: 0.75em; vertical-align: super; margin-left: 2px; color: var(--accent); text-decoration: none; }
.cite:hover { text-decoration: underline; }

.code {
  position: relative; background: var(--code-bg); color: var(--code-text); border-radius: 8px;
  margin: 6px 0 10px 20px; padding: 10px 12px; font-family: var(--mono); font-size: 0.88rem;
  white-space: pre; overflow-x: auto;
}
.code .copy {
  position: absolute; top: 6px; right: 6px; background: transparent; color: var(--code-text);
  border: 1px solid #3a4656; font-size: 0.75rem; padding: 2px 8px; font-weight: 500;
  user-select: none;
}

.notes { background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: 8px; padding: 10px 12px; margin-top: 12px; }
.notes p { margin: 4px 0; overflow-wrap: anywhere; }
.sources { padding-left: 24px; margin: 0; font-size: 0.88rem; }
.sources li { margin: 2px 0; overflow-wrap: anywhere; }
.sources li:target { background: var(--warn-bg); }

.upload h2 { margin: 0 0 10px; }
.drop {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 18px; text-align: center; cursor: pointer;
}
.drop p { margin: 4px 0; }
.drop.over, .drop:focus-visible { border-color: var(--accent); outline: none; background: var(--bg); }
.linklike { color: var(--accent); text-decoration: underline; }
.folder-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
label.inline { display: inline; margin: 0; }
.folder-row input {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
  color: var(--text); font: inherit; width: 220px; max-width: 100%;
}
.uploads { list-style: none; padding: 0; margin: 12px 0 0; }
.uploads li { border-top: 1px solid var(--border); padding: 8px 0; display: grid; gap: 4px; }
.uploads .name { font-weight: 600; overflow-wrap: anywhere; }
.uploads .state { font-size: 0.85rem; }
.uploads .state.bad { color: var(--bad); }
.uploads .state.good { color: var(--ok); }
progress { width: 100%; height: 8px; accent-color: var(--accent); }

.status summary { cursor: pointer; font-weight: 600; }
.status table { border-collapse: collapse; margin-top: 8px; }
.status td { padding: 2px 12px 2px 0; }
.foot { text-align: center; padding: 12px 16px 20px; }

@media (max-width: 600px) {
  .brand .sub { display: none; }
  .code { margin-left: 0; }
  .answer .indent { padding-left: 10px; }
}
