:root {
  color-scheme: light;
  --paper: #f4f0e6;
  --ink: #17211d;
  --muted: #69716b;
  --line: #c8c4b8;
  --card: #fffdf7;
  --acid: #d9ff5b;
  --orange: #e66f2f;
  --green: #176b4a;
  --red: #a43d2f;
  font-family: "Songti SC", "STSong", Georgia, serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 300px;
  background:
    linear-gradient(rgba(23, 33, 29, .035) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 28px;
  color: var(--ink);
}

button, textarea { font: inherit; }
button { color: inherit; }

.shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(48px, env(safe-area-inset-bottom));
}

.masthead,
.section-heading,
.submit-row,
.card-topline,
.answer-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.masthead {
  padding: 4px 2px 22px;
  border-bottom: 2px solid var(--ink);
}

.eyebrow,
.field-label,
.index,
.card-number,
.meta-row,
.status-pill,
.live-mark {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.eyebrow { margin: 0 0 3px; font-size: 10px; color: var(--muted); }
h1 { margin: 0; font-size: clamp(29px, 10vw, 46px); line-height: 1; letter-spacing: -.06em; }

.live-mark { display: flex; gap: 7px; align-items: center; font-size: 11px; }
.live-mark span { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(23, 107, 74, .12); }

.composer,
.queue { padding-top: 26px; }

.section-heading { justify-content: flex-start; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.section-heading.compact { margin-bottom: 12px; }
.section-heading .index { flex: 0 0 auto; padding-top: 3px; color: var(--orange); font-size: 11px; font-weight: 700; }
.section-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.025em; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.composer form {
  padding: 15px;
  border: 1.5px solid var(--ink);
  background: var(--card);
  box-shadow: 5px 5px 0 var(--ink);
}

.field-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 10px; font-weight: 700; }

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0;
  outline: none;
  background: #fff;
  color: var(--ink);
}

textarea { min-height: 205px; resize: vertical; padding: 13px; font-size: 16px; line-height: 1.65; }
textarea:focus { border-color: var(--ink); box-shadow: inset 3px 0 0 var(--acid); }

.submit-row { align-items: flex-end; gap: 12px; padding-top: 14px; }
.submit-row p { max-width: 150px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.submit-row button {
  display: flex;
  align-items: center;
  gap: 22px;
  border: 1.5px solid var(--ink);
  padding: 11px 13px 11px 17px;
  background: var(--acid);
  font-weight: 800;
  cursor: pointer;
}
.submit-row button:active { transform: translate(2px, 2px); }
.submit-row button b { font-size: 18px; }

.question-list { display: grid; gap: 14px; }
.question-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 14px;
  box-shadow: 0 3px 12px rgba(23, 33, 29, .06);
  animation: card-in .3s ease-out both;
}
.question-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--orange); }
.question-card[data-status="complete"]::before { background: var(--green); }
.question-card[data-status="failed"]::before { background: var(--red); }

@keyframes card-in { from { opacity: 0; transform: translateY(10px); } }

.card-number { color: var(--muted); font-size: 10px; }
.status-pill { display: flex; align-items: center; gap: 7px; font-size: 10px; font-weight: 700; }
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); animation: pulse 1.1s ease-in-out infinite; }
[data-status="complete"] .status-pill i { background: var(--green); animation: none; }
[data-status="failed"] .status-pill i { background: var(--red); animation: none; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.75); } }

.raw-preview {
  display: -webkit-box;
  margin: 13px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.normalized-block,
.result-block,
.error-block { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.meta-row { color: var(--orange); font-size: 10px; font-weight: 700; }
.normalized-title { margin: 7px 0 0; font-size: 19px; line-height: 1.48; }
.options { margin: 10px 0 0; padding: 0; list-style-position: inside; color: var(--muted); }
.options li { margin-top: 5px; font-size: 14px; line-height: 1.45; }
.answer-line { align-items: baseline; }
.answer-line span { color: var(--muted); font-size: 12px; }
.answer-line strong { color: var(--green); font-size: 34px; letter-spacing: -.04em; }
.analysis { margin: 10px 0 0; font-size: 15px; line-height: 1.7; white-space: pre-wrap; }
.confidence { margin: 10px 0 0; color: var(--muted); font: 11px ui-monospace, monospace; }

.error-block strong { color: var(--red); }
.error-message { margin: 6px 0 11px; color: var(--muted); font-size: 13px; }
.retry-button { border: 1px solid var(--red); background: transparent; color: var(--red); padding: 7px 13px; font-weight: 700; cursor: pointer; }

.empty-state { padding: 38px 20px; border: 1px dashed var(--line); text-align: center; color: var(--muted); }
.empty-state span { font-size: 26px; }
.empty-state p { margin: 7px 0 0; font-size: 13px; }
[hidden] { display: none !important; }

@media (min-width: 640px) {
  .shell { padding-left: 24px; padding-right: 24px; }
  .composer form, .question-card { padding: 20px; }
  .normalized-title { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
