:root {
  --ink: #1f2a44;
  --paper: #faf6f0;
  --paper-strong: #fffaf4;
  --terracotta: #b94729;
  --sage: #6e8f68;
  --gold: #c28a2e;
  --muted: #60708a;
  --line: rgba(31, 42, 68, 0.16);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.58; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  background:
    linear-gradient(90deg, rgba(185, 71, 41, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(31, 42, 68, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -80px;
  padding: 10px;
  background: var(--gold);
  color: var(--ink);
  border-radius: 6px;
}

.skip-link:focus { top: 12px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.setup {
  color: #fffaf4;
  background: var(--ink);
  border-right: 4px solid var(--terracotta);
  padding: 24px;
  display: grid;
  align-content: start;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 2px solid var(--gold);
  border-radius: 50%;
  font-weight: 900;
}

.brand p {
  margin: 0;
  font-family: Georgia, serif;
  font-size: 1.5rem;
}

.brand span,
.setup label,
.setup legend,
.setup small { color: #dce3ee; }

.problem-line {
  margin: 0;
  color: #f0f4fb;
  font-size: 0.95rem;
  line-height: 1.45;
  max-width: 32ch;
}

form, label, fieldset {
  display: grid;
  gap: 9px;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

input, select, textarea {
  width: 100%;
  border: 1px solid #c8c0b5;
  border-radius: 6px;
  color: var(--ink);
  background: var(--paper-strong);
  padding: 10px 12px;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

.chips, .tabs, .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chips button,
.tabs button,
.actions button,
.ghost {
  min-height: 42px;
  border: 1px solid #d9d0c5;
  background: var(--paper-strong);
  color: var(--ink);
  border-radius: 6px;
  padding: 9px 12px;
}

.chips button[aria-pressed="true"],
.tabs .active,
.primary {
  border: 0;
  background: var(--sage);
  color: #0f220f;
  font-weight: 800;
}

.primary {
  min-height: 46px;
  border-radius: 6px;
  padding: 12px 14px;
}

.results {
  padding: 24px;
  overflow: auto;
}

.tabs {
  position: sticky;
  z-index: 2;
  top: 0;
  padding-bottom: 16px;
  background: rgba(250, 246, 240, 0.96);
}

.tabs button[role="tab"][aria-selected="true"] {
  box-shadow: 0 0 0 1px rgba(122, 155, 118, 0.35) inset;
}

.tabs button:focus-visible {
  transform: translateY(-1px);
}

.view { display: grid; gap: 16px; }

.challenge {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 244, 0.88);
}

.challenge-head {
  display: grid;
  gap: 8px;
}

.challenge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.challenge-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid rgba(31, 42, 68, 0.08);
  border-radius: 6px;
  background: rgba(250, 246, 240, 0.92);
}

.challenge-item strong,
.fact-row dt {
  color: var(--ink);
  font-weight: 800;
}

.challenge-item p,
.fact-row dd {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

h1, h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1.03;
}

h2 { font-size: 1.35rem; }
p { margin: 0; }

.muted, .eyebrow, small { color: var(--muted); }
.eyebrow {
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.card, .context-panel, .empty, .status {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 244, 0.94);
  box-shadow: 0 18px 45px rgba(31, 42, 68, 0.08);
}

.card {
  overflow: hidden;
}

.card-body, .empty, .context-panel, .status {
  padding: 16px;
}

.visual {
  min-height: 112px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  padding: 16px;
  color: #fffaf4;
  background:
    linear-gradient(135deg, rgba(185, 71, 41, 0.94), rgba(31, 42, 68, 0.92)),
    repeating-linear-gradient(45deg, transparent 0 12px, rgba(255, 255, 255, 0.16) 12px 13px);
}

.card-body {
  display: grid;
  gap: 10px;
}

.context-panel {
  color: var(--ink);
  display: grid;
  gap: 8px;
}

.map-frame {
  width: 100%;
  height: 170px;
  border: 0;
  border-radius: 6px;
}

.status.bad {
  border-color: #d85648;
  background: #fdeceb;
  color: #7d1c12;
}

.status.good {
  border-color: var(--sage);
  background: #edf5e9;
}

.status[role="status"],
.status[role="alert"] {
  min-height: 48px;
}

.detail {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(300px, 1.1fr);
  gap: 16px;
}

.fact-list {
  display: grid;
  gap: 12px;
}

.fact-row {
  display: grid;
  gap: 4px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(31, 42, 68, 0.12);
  background: rgba(238, 244, 233, 0.92);
  color: var(--ink);
}

pre {
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  background: #182137;
  color: #fffaf4;
  border-radius: 6px;
  padding: 12px;
}

.passport {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 14px;
}

.stamp {
  min-height: 138px;
  display: grid;
  place-items: center;
  align-content: center;
  border: 2px dashed #aab2c2;
  border-radius: 8px;
  background: rgba(255, 250, 244, 0.74);
  color: var(--muted);
}

.stamp.earned {
  border-style: solid;
  border-color: var(--sage);
  background: #edf5e9;
  color: var(--ink);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

@media (max-width: 860px) {
  .shell, .detail { grid-template-columns: 1fr; }
  .setup { border-right: 0; border-bottom: 4px solid var(--terracotta); }
  .section-head { display: grid; }
  h1 { font-size: 2.25rem; }
  .challenge-grid { grid-template-columns: 1fr; }
}
