:root {
  --ink: #111a24;
  --ink-soft: #263647;
  --paper: #f4efe4;
  --paper-bright: #fffdf6;
  --line: rgba(17, 26, 36, 0.18);
  --muted: #68727a;
  --acid: #c8ff47;
  --cyan: #58ded1;
  --warning: #ffb74d;
  --danger: #ff6b61;
  --radius: 6px;
  --shadow: 0 28px 70px rgba(4, 11, 18, 0.22);
  --display: "Iowan Old Style", "Songti SC", "STSong", serif;
  --body: "Aptos", "Microsoft YaHei", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 0; background: var(--ink); }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: var(--body);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: max-content;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50% 50% 48% 52% / 45% 48% 52% 55%;
  font: 700 22px/1 var(--display);
  transform: rotate(-7deg);
}

.brand > span:last-child { display: grid; gap: 1px; }
.brand strong { font: 700 17px/1.2 var(--display); letter-spacing: .08em; }
.brand small { font-size: 8px; letter-spacing: .18em; opacity: .68; }
.brand--light { color: var(--paper-bright); }

.eyebrow, .section-code {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .17em;
  text-transform: uppercase;
}

.muted { color: var(--muted); }

.primary-button, .secondary-button, .text-button {
  border: 0;
  transition: transform .18s ease, background .18s ease, color .18s ease, box-shadow .18s ease;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  min-height: 52px;
  padding: 0 19px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--acid);
  font-weight: 800;
  box-shadow: 5px 5px 0 var(--ink);
}

.primary-button:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--ink); }
.primary-button:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.primary-button:disabled { cursor: wait; filter: grayscale(.7); opacity: .65; transform: none; }

.secondary-button {
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-soft);
  background: transparent;
  font-weight: 700;
}
.secondary-button:hover { border-color: var(--ink); background: rgba(17, 26, 36, .05); }
.text-button { padding: 6px 0; color: inherit; background: transparent; border-bottom: 1px solid currentColor; }

/* Login — dark archival desk */
.login-page {
  color: var(--paper-bright);
  background:
    radial-gradient(circle at 12% 18%, rgba(88, 222, 209, .13), transparent 25rem),
    radial-gradient(circle at 86% 78%, rgba(200, 255, 71, .09), transparent 28rem),
    var(--ink);
}

.ambient-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .13;
  background-image:
    linear-gradient(rgba(255,255,255,.24) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.24) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(110deg, #000, transparent 70%);
}

.login-layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(360px, .82fr);
  min-height: 100vh;
}

.login-intro {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
  padding: clamp(30px, 5vw, 76px);
}

.login-copy { max-width: 760px; margin: 10vh 0; }
.login-copy .eyebrow { color: var(--acid); }
.login-copy h1 {
  margin: 18px 0 26px;
  font: 500 clamp(52px, 7.5vw, 108px)/.98 var(--display);
  letter-spacing: -.055em;
}
.login-copy > p:last-child { max-width: 580px; color: rgba(255,255,255,.66); font-size: clamp(15px, 1.5vw, 19px); line-height: 1.8; }

.trust-list {
  display: flex;
  flex-wrap: wrap;
  gap: 24px 42px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: rgba(255,255,255,.72);
  font-size: 13px;
}
.trust-list li { display: flex; align-items: center; gap: 10px; }
.trust-list span { color: var(--acid); font: 700 11px/1 var(--body); }

.login-card {
  align-self: center;
  display: grid;
  gap: 32px;
  width: min(520px, calc(100% - 40px));
  margin: 40px auto;
  padding: clamp(30px, 5vw, 64px);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 10px 3px 10px 3px;
  box-shadow: var(--shadow);
  animation: card-enter .65s cubic-bezier(.2,.8,.2,1) both;
}
.login-card .section-code { color: #4b756e; }
.login-card h2 { margin: 10px 0 12px; font: 600 clamp(32px, 4vw, 48px)/1 var(--display); }
.login-card .muted { margin: 0; line-height: 1.7; font-size: 14px; }
.login-form { display: grid; gap: 11px; }
.login-form label { margin-top: 7px; font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.login-form input {
  width: 100%;
  height: 54px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: 0;
  color: var(--ink);
  background: var(--paper-bright);
}
.login-form input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(88,222,209,.28); }
.login-form .primary-button { margin-top: 13px; }
.form-status { min-height: 22px; margin: -18px 0 0; color: #a33b34; font-size: 13px; }
.security-note { margin: 0; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.security-note span { color: #41a77e; }

/* Search workspace */
.search-page {
  background:
    linear-gradient(90deg, transparent 49.9%, rgba(17,26,36,.035) 50%, transparent 50.1%),
    var(--paper);
  background-size: 48px 48px;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px clamp(18px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  background: rgba(244,239,228,.88);
  backdrop-filter: blur(14px);
}

.account-cluster { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: #2ebd85; box-shadow: 0 0 0 4px rgba(46,189,133,.13); }

.search-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 340px);
  gap: clamp(36px, 6vw, 92px);
  width: min(1420px, calc(100% - clamp(32px, 8vw, 128px)));
  margin: 0 auto;
  padding: clamp(52px, 7vw, 102px) 0 90px;
}

.query-column { min-width: 0; }
.query-heading { max-width: 900px; animation: rise-in .55s ease both; }
.query-heading .eyebrow { color: #3f756e; }
.query-heading h1 {
  margin: 16px 0 18px;
  font: 600 clamp(44px, 6vw, 82px)/1.02 var(--display);
  letter-spacing: -.045em;
}
.query-heading h1 em { color: #315f59; font-style: normal; }
.query-heading > p:last-child { max-width: 760px; margin: 0; color: var(--muted); line-height: 1.8; }

.query-card {
  position: relative;
  margin-top: 38px;
  padding: clamp(18px, 3vw, 30px);
  border: 1px solid var(--ink);
  border-radius: 3px 10px 3px 10px;
  background: var(--paper-bright);
  box-shadow: 8px 8px 0 var(--ink);
  animation: rise-in .55s .09s ease both;
}
.query-card::before { content: "INPUT  /  RAW QUESTION"; position: absolute; top: -10px; right: 18px; padding: 2px 7px; color: var(--paper); background: var(--ink); font-size: 8px; letter-spacing: .16em; }
.query-card__label { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 12px; font-size: 12px; }
.query-card__label label { font-weight: 900; letter-spacing: .08em; }
.query-card__label span { color: var(--muted); }

#question-input {
  display: block;
  width: 100%;
  min-height: 230px;
  resize: vertical;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: 0;
  color: var(--ink);
  background:
    linear-gradient(var(--paper-bright), var(--paper-bright)) padding-box,
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(17,26,36,.045) 31px 32px);
  font-size: 16px;
  line-height: 2;
}
#question-input:focus { border-color: #356b64; box-shadow: 0 0 0 4px rgba(88,222,209,.23); }
#question-input::placeholder { color: #9c9c93; }
.query-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 18px; }

.status-line { display: flex; align-items: center; gap: 10px; min-height: 52px; margin-top: 22px; color: var(--muted); font-size: 13px; }
.status-pulse { width: 8px; height: 8px; border: 1px solid currentColor; border-radius: 50%; }
.status-line.is-busy .status-pulse { border-color: var(--ink); border-top-color: transparent; animation: spin .8s linear infinite; }

.result-panel {
  margin-top: 12px;
  padding: clamp(22px, 4vw, 38px);
  border: 1px solid var(--ink);
  border-radius: 10px 3px 10px 3px;
  background: var(--paper-bright);
  box-shadow: var(--shadow);
  animation: result-enter .4s ease both;
}
.result-panel[data-state="verified"] { border-top: 8px solid #2b9f78; }
.result-panel[data-state="candidate"], .result-panel[data-state="queued"] { border-top: 8px solid var(--warning); }
.result-panel[data-state="unverified"], .result-panel[data-state="error"] { border-top: 8px solid var(--danger); }
.result-header { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; }
.result-header h2 { margin: 4px 0 0; font: 600 31px/1.1 var(--display); }
.result-badge { padding: 8px 10px; border: 1px solid var(--ink); border-radius: 999px; font-size: 11px; font-weight: 900; }
.match-score { color: var(--muted); font: 700 12px/1 var(--body); }
.answer-block { margin-top: 28px; padding: 22px; background: var(--ink); color: var(--paper-bright); border-radius: var(--radius); }
.result-label { margin: 0 0 12px; color: var(--acid); font-size: 10px; font-weight: 900; letter-spacing: .14em; }
.answer-texts { display: flex; flex-wrap: wrap; gap: 9px; }
.answer-chip { padding: 8px 11px; border: 1px solid rgba(255,255,255,.24); border-radius: 2px; font: 600 20px/1.3 var(--display); }
.answer-letters { margin: 14px 0 0; color: rgba(255,255,255,.62); font-size: 12px; }
.result-message { margin: 24px 0 0; line-height: 1.8; }
.evidence-details { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.evidence-details summary { cursor: pointer; font-weight: 800; }
.evidence-details p, .evidence-details dl { color: var(--ink-soft); line-height: 1.85; white-space: pre-wrap; }
.evidence-details dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; }
.evidence-details dt { color: var(--muted); }
.evidence-details dd { margin: 0; overflow-wrap: anywhere; }

.method-rail { position: sticky; top: 110px; align-self: start; padding: 26px 0 0 28px; border-left: 1px solid var(--line); animation: rise-in .55s .16s ease both; }
.method-rail h2 { margin: 10px 0 28px; font: 600 31px/1.1 var(--display); }
.method-rail ol { display: grid; gap: 26px; margin: 0; padding: 0; list-style: none; }
.method-rail li { display: grid; grid-template-columns: 30px 1fr; gap: 12px; }
.method-rail li > span { color: #3f756e; font-size: 10px; font-weight: 900; }
.method-rail strong { font-size: 14px; }
.method-rail li p, .rail-note p { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.75; }
.rail-note { margin-top: 34px; padding: 17px; border: 1px dashed var(--line); background: rgba(255,255,255,.32); }

@keyframes card-enter { from { opacity: 0; transform: translateY(18px) rotate(.6deg); } to { opacity: 1; transform: none; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes result-enter { from { opacity: 0; transform: translateY(10px) scale(.992); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .login-layout { grid-template-columns: 1fr; }
  .login-intro { min-height: auto; padding-bottom: 20px; }
  .login-copy { margin: 12vh 0 8vh; }
  .login-copy h1 { font-size: clamp(48px, 12vw, 76px); }
  .login-card { margin-top: 12px; }
  .search-layout { grid-template-columns: 1fr; }
  .method-rail { position: static; padding: 26px 0 0; border-top: 1px solid var(--line); border-left: 0; }
}

@media (max-width: 600px) {
  .topbar { min-height: 64px; padding: 10px 16px; }
  .brand small { display: none; }
  .brand-mark { width: 34px; height: 34px; font-size: 18px; }
  .account-cluster { gap: 7px; }
  #account-name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .search-layout { width: calc(100% - 28px); padding-top: 42px; }
  .query-heading h1 { font-size: 43px; }
  .query-card { padding: 15px; box-shadow: 5px 5px 0 var(--ink); }
  .query-card__label span { display: none; }
  #question-input { min-height: 250px; padding: 14px; font-size: 15px; }
  .query-actions { display: grid; grid-template-columns: .7fr 1.3fr; }
  .primary-button { gap: 10px; padding: 0 13px; }
  .result-header { grid-template-columns: auto 1fr; }
  .match-score { grid-column: 2; }
  .evidence-details dl { grid-template-columns: 1fr; gap: 4px; }
  .evidence-details dd { margin-bottom: 8px; }
  .login-intro { padding: 24px 20px; }
  .login-copy { margin: 11vh 0 6vh; }
  .trust-list { display: grid; gap: 12px; }
  .login-card { width: calc(100% - 28px); padding: 28px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Administration console */
.admin-page { background: #ece8de; }
.topbar--admin { border-bottom-color: var(--ink); }
.admin-shell { width: min(1500px, calc(100% - clamp(30px, 7vw, 110px))); margin: 0 auto; padding: 58px 0 90px; }
.admin-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, 360px); align-items: end; gap: 44px; }
.admin-hero .eyebrow { color: #3f756e; }
.admin-hero h1 { margin: 13px 0 0; font: 600 clamp(42px, 5.4vw, 76px)/1.02 var(--display); letter-spacing: -.045em; }
.admin-hero h1 em { color: #315f59; font-style: normal; }
.maintenance-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px 18px; padding: 22px; border: 1px solid var(--ink); border-radius: var(--radius); background: var(--paper-bright); box-shadow: 6px 6px 0 var(--ink); cursor: pointer; }
.maintenance-card > span:first-child { display: grid; gap: 5px; }
.maintenance-card small { color: var(--muted); }
.maintenance-card input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { grid-column: 2; grid-row: 1; display: block; width: 54px; height: 30px; padding: 3px; border: 1px solid var(--ink); border-radius: 999px; background: #d8d7ce; transition: background .18s ease; }
.switch-track span { display: block; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); transition: transform .18s ease; }
.maintenance-card input:checked + .switch-track { background: var(--danger); }
.maintenance-card input:checked + .switch-track span { transform: translateX(24px); }
.maintenance-card input:focus-visible + .switch-track { outline: 3px solid rgba(88,222,209,.4); }
.admin-status { min-height: 24px; margin: 28px 0 12px; color: #315f59; font-size: 13px; }
.admin-status.is-error { color: #a33b34; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 10px 0 28px; }
.stat-grid article { display: grid; min-height: 138px; padding: 18px; border: 1px solid var(--line); background: var(--paper); }
.stat-grid article > span { font-size: 9px; font-weight: 900; letter-spacing: .16em; }
.stat-grid strong { align-self: end; font: 600 48px/1 var(--display); }
.stat-grid small { margin-top: 7px; color: var(--muted); }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(340px, .8fr); gap: 20px; }
.admin-panel { min-width: 0; padding: 26px; border: 1px solid var(--ink); border-radius: var(--radius); background: var(--paper-bright); }
.admin-panel--wide { grid-column: 1 / -1; }
.admin-panel > header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.admin-panel h2 { margin: 6px 0 0; font: 600 31px/1 var(--display); }
.panel-count { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 50%; color: var(--paper); background: var(--ink); font-weight: 800; }
.inline-form { display: grid; grid-template-columns: 1fr 1fr .7fr auto; gap: 10px; align-items: end; margin-bottom: 20px; }
.inline-form label { display: grid; gap: 6px; font-size: 11px; font-weight: 800; }
.inline-form input, .inline-form select { height: 44px; min-width: 0; padding: 0 10px; border: 1px solid var(--line); border-radius: 3px; background: #fff; }
.inline-form .primary-button { min-height: 44px; box-shadow: 3px 3px 0 var(--ink); }
.table-wrap { max-width: 100%; overflow-x: auto; }
.admin-panel table { width: 100%; border-collapse: collapse; font-size: 12px; }
.admin-panel th { padding: 10px 8px; border-bottom: 2px solid var(--ink); text-align: left; white-space: nowrap; }
.admin-panel td { max-width: 460px; padding: 12px 8px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.table-actions { display: flex; flex-wrap: wrap; gap: 5px; min-width: 180px; }
.mini-button { padding: 5px 7px; border: 1px solid var(--line); border-radius: 2px; background: transparent; font-size: 10px; }
.mini-button:hover { border-color: var(--ink); background: var(--acid); }
.review-list { display: grid; gap: 10px; max-height: 590px; overflow-y: auto; padding-right: 3px; }
.review-card { padding: 16px; border: 1px solid var(--line); background: var(--paper); }
.review-card h3 { margin: 7px 0 10px; font-size: 14px; line-height: 1.6; }
.review-card > p:not(.review-meta) { margin: 0; color: var(--muted); font-size: 12px; }
.review-meta { margin: 0; color: #3f756e; font-size: 9px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.review-actions { display: flex; gap: 7px; margin-top: 14px; }
.empty-state { color: var(--muted); }

@media (max-width: 1050px) {
  .admin-hero, .admin-grid { grid-template-columns: 1fr; }
  .admin-panel--wide { grid-column: auto; }
  .inline-form { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 650px) {
  .admin-shell { width: calc(100% - 28px); padding-top: 38px; }
  .admin-hero h1 { font-size: 42px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-grid article { min-height: 110px; }
  .inline-form { grid-template-columns: 1fr; }
  .admin-panel { padding: 18px 14px; }
  .topbar--admin .account-cluster a { display: none; }
}
