:root {
  color-scheme: dark;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #eaf3ff;
  background: #090f1e;
  --panel: #111c2f;
  --field: #0b1426;
  --accent: #8cddff;
  --muted: #aabed8;
  --border: #293c57;
}

* { box-sizing: border-box; }
body {
  display: flow-root;
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(ellipse 780px 420px at 40% 0, #172d48, transparent);
}
[hidden] { display: none !important; }
a { color: var(--accent); text-underline-offset: 3px; overflow-wrap: anywhere; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .6; cursor: wait; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.layout {
  width: min(1220px, 100% - 64px);
  margin: 52px auto 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(288px, 350px);
  grid-template-areas:
    "header header"
    "query references"
    "results references";
  align-items: start;
  gap: 20px;
}

header { grid-area: header; padding: 8px 0 18px; text-align: center; }
h1 { margin: 0; font-size: clamp(30px, 4.5vw, 46px); letter-spacing: .025em; }
h2 { margin: 0 0 16px; font-size: 18px; font-weight: 650; }
.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 14px 34px #05091245;
}
.query { grid-area: query; }
.sidebar { grid-area: references; position: sticky; top: 20px; }
.results { grid-area: results; min-width: 0; display: grid; gap: 16px; }

textarea, input {
  width: 100%;
  border: 1px solid #385271;
  border-radius: 8px;
  background: var(--field);
  color: inherit;
  padding: 11px 13px;
}
textarea { display: block; resize: vertical; line-height: 1.65; min-height: 106px; }
textarea::placeholder, input::placeholder { color: #91a7c4; }
#online-access { margin-top: 12px; }
#reader-key-field { display: block; max-width: 420px; }
#reader-key { display: block; margin-top: 4px; }
.actions, .examples { display: flex; gap: 8px; flex-wrap: wrap; }
.actions { margin-top: 14px; }
button { border: 1px solid var(--border); border-radius: 8px; padding: 9px 14px; }
.primary {
  padding-inline: 21px;
  background: var(--accent);
  border-color: var(--accent);
  color: #0a1a2d;
  font-weight: 650;
}
.primary:hover:not(:disabled) { background: #b8edff; }
.secondary { color: #d8ecff; background: #1a2b43; }
.secondary:hover:not(:disabled), .examples button:hover {
  background: #223954;
  border-color: #597b9b;
}
.examples { padding-top: 15px; margin-top: 20px; border-top: 1px solid var(--border); }
#examples-label { flex-basis: 100%; margin: 0 0 3px; color: var(--muted); font-size: 13px; }
.examples button {
  padding: 7px 10px;
  background: var(--field);
  color: #c6d8ef;
  text-align: left;
  font-size: 13px;
  line-height: 1.5;
}

#status { margin: 0; padding: 2px 2px 0; line-height: 1.6; color: var(--muted); }
#status.error { color: #ffb2a8; }
#answer { display: grid; gap: 10px; margin: 0; padding-left: 22px; line-height: 1.75; }
#answer li { overflow-wrap: anywhere; }
#answer a { margin-left: 8px; font-size: 13px; }
.answer-excerpts { margin-top: 5px; padding: 4px 0; border-top: 0; }
.answer-excerpts summary { color: var(--accent); font-size: 13px; }
.answer-excerpts blockquote {
  margin: 0 0 8px;
  padding: 4px 0 4px 10px;
  border-left: 2px solid var(--border);
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
details { border-top: 1px solid var(--border); padding: 12px 0; scroll-margin-top: 18px; }
details:last-child { padding-bottom: 0; }
summary { cursor: pointer; line-height: 1.6; font-weight: 600; overflow-wrap: anywhere; }
.source-text { white-space: pre-wrap; line-height: 1.7; overflow-wrap: anywhere; font-size: 14px; }
.locator { margin: 6px 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
a.locator { color: var(--accent); }
.source-links { display: flex; flex-wrap: wrap; gap: 5px 12px; }

#catalog-filter { font-size: 13px; }
#catalog {
  list-style: none;
  max-height: min(62vh, 600px);
  margin: 12px 0 0;
  padding: 0 8px 0 0;
  overflow: auto;
  scrollbar-color: #45617f transparent;
  scrollbar-width: thin;
}
#catalog li {
  padding: 11px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.55;
}
.reference { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 6px; }
.reference-number { color: #a5c4e6; font-variant-numeric: tabular-nums; }
.reference-body { overflow-wrap: anywhere; }
.reference-body p { margin: 0; }
.reference-doi {
  display: inline-block;
  margin: 4px 0 0;
  font-family: Consolas, monospace;
  font-size: 12px;
}
.catalog-status { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

@media (max-width: 830px) {
  .layout {
    width: min(100% - 32px, 660px);
    margin: 26px auto 40px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "header" "query" "results" "references";
    gap: 14px;
  }
  header { padding-bottom: 9px; }
  .panel { padding: 17px; }
  .sidebar { position: static; }
  #catalog { max-height: 400px; }
}
