:root {
  --bg: #f3ede4;
  --bg-2: #efe5d7;
  --surface: rgba(255, 250, 242, 0.9);
  --surface-strong: #fffaf3;
  --surface-muted: rgba(250, 243, 231, 0.82);
  --ink: #1f221f;
  --muted: #657064;
  --line: rgba(80, 72, 57, 0.16);
  --accent: #165847;
  --accent-soft: rgba(22, 88, 71, 0.12);
  --accent-2: #9e5933;
  --accent-2-soft: rgba(158, 89, 51, 0.12);
  --bad: #9b3c30;
  --good: #0d7859;
  --warn: #8c5a19;
  --shadow: 0 22px 60px rgba(33, 30, 25, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(22, 88, 71, 0.13), transparent 28%),
    radial-gradient(circle at bottom right, rgba(158, 89, 51, 0.13), transparent 30%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

button,
input,
textarea,
select {
  font: inherit;
}

.shell {
  width: min(1460px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
  display: grid;
  gap: 20px;
}

.masthead,
.setup-card,
.workspace-card,
.result-card,
.feed-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.masthead {
  padding: 28px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.eyebrow,
.section-title,
.card-kicker {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.masthead h1,
.workspace-card h2,
.results-stage h2,
.feed-card h2 {
  font-family: "Iowan Old Style", Georgia, serif;
  margin: 0;
  letter-spacing: -0.02em;
}

.masthead h1 {
  font-size: clamp(38px, 7vw, 74px);
  line-height: 0.94;
  margin-top: 6px;
}

.lead,
.section-copy,
.mode-summary,
.status,
.tiny {
  color: var(--muted);
  line-height: 1.6;
}

.lead {
  max-width: 52rem;
  font-size: 17px;
  margin: 14px 0 0;
}

.section-copy {
  margin: 0;
  font-size: 14px;
}

.masthead-copy {
  display: grid;
  gap: 16px;
}

.step-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.step-pill,
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
}

.step-pill span,
.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.step-badge {
  min-width: auto;
  min-height: auto;
  padding: 6px 10px;
}

.masthead-stats {
  display: grid;
  gap: 14px;
}

.stat-tile {
  border-radius: 22px;
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid var(--line);
  display: grid;
  gap: 6px;
}

.stat-tile strong {
  font-size: 34px;
  line-height: 1;
  font-family: "Iowan Old Style", Georgia, serif;
}

.setup-band {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.85fr);
  gap: 18px;
}

.setup-card,
.workspace-card,
.feed-card {
  padding: 22px;
  display: grid;
  gap: 16px;
}

.setup-card-primary {
  background:
    linear-gradient(135deg, rgba(22, 88, 71, 0.08), transparent 36%),
    var(--surface);
}

.card-topline,
.feed-head,
.results-stage-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.setup-grid,
.mini-grid {
  display: grid;
  gap: 14px;
}

.setup-grid {
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.2fr);
}

.mini-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
}

input,
textarea,
select {
  width: 100%;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  padding: 13px 15px;
  color: var(--ink);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(22, 88, 71, 0.42);
  box-shadow: 0 0 0 4px rgba(22, 88, 71, 0.08);
  background: #fff;
}

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

.setup-card textarea,
.advanced textarea {
  min-height: 96px;
}

.token-field input {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.action-row,
.mode-row,
.chip-row,
.composer-actions,
.grade-row,
.card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition:
    transform 140ms ease,
    background 140ms ease,
    color 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    opacity 140ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

button.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 14px 28px rgba(22, 88, 71, 0.18);
}

button.secondary {
  background: rgba(233, 225, 210, 0.95);
  color: var(--ink);
}

button.ghost {
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  border: 1px solid var(--line);
}

.mode-row button.is-active,
.chip-row button.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.status {
  font-size: 14px;
}

.status.good {
  color: var(--good);
}

.status.bad {
  color: var(--bad);
}

.status-chip.good {
  background: rgba(13, 120, 89, 0.12);
  color: var(--good);
  border-color: rgba(13, 120, 89, 0.18);
}

.status-chip.bad {
  background: rgba(155, 60, 48, 0.12);
  color: var(--bad);
  border-color: rgba(155, 60, 48, 0.18);
}

.status-chip.warn {
  background: rgba(140, 90, 25, 0.12);
  color: var(--warn);
  border-color: rgba(140, 90, 25, 0.18);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.7fr);
  gap: 18px;
  align-items: start;
}

.composer-column,
.inspector-column {
  display: grid;
  gap: 16px;
}

.inspector-column {
  position: sticky;
  top: 18px;
}

.section-block {
  display: grid;
  gap: 10px;
}

.mode-summary {
  font-size: 14px;
}

.review-notes,
.guide-card ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.review-notes li,
.guide-card li {
  color: var(--ink);
  line-height: 1.55;
}

.guide-list-block {
  display: grid;
  gap: 8px;
}

.results-stage {
  display: grid;
  gap: 14px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 28px;
  padding: 34px 28px;
  background: rgba(255, 255, 255, 0.52);
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  display: block;
  color: var(--ink);
  font-family: "Iowan Old Style", Georgia, serif;
  font-size: 28px;
  margin-bottom: 10px;
}

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

.result-card {
  overflow: hidden;
}

.result-card header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
  display: grid;
  gap: 6px;
}

.result-card header strong {
  font-size: 26px;
  font-family: "Iowan Old Style", Georgia, serif;
}

.latency {
  font-size: 13px;
  color: var(--muted);
}

.result-card .body {
  padding: 18px 20px 20px;
  display: grid;
  gap: 16px;
}

.thread {
  display: grid;
  gap: 12px;
}

.turn {
  padding: 15px 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  line-height: 1.62;
  white-space: pre-wrap;
}

.turn.user {
  background: rgba(249, 243, 233, 0.88);
}

.turn.assistant {
  background: rgba(255, 255, 255, 0.94);
}

.turn-label {
  display: block;
  margin-bottom: 8px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.follow-up {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

.follow-up textarea {
  min-height: 96px;
}

.grade-row button.is-good {
  background: var(--good);
  color: white;
}

.grade-row button.is-bad {
  background: var(--bad);
  color: white;
}

.grade-row button.is-best {
  background: var(--accent-2);
  color: white;
}

.feed-card {
  gap: 14px;
}

.feed-list {
  display: grid;
  gap: 10px;
}

.feed-item {
  padding: 14px 15px;
  background: rgba(255, 255, 255, 0.84);
  border-radius: 20px;
  border: 1px solid var(--line);
  display: grid;
  gap: 6px;
}

.feed-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
}

.pill.best {
  background: var(--accent-2-soft);
  color: var(--accent-2);
}

.pill.bad {
  background: rgba(155, 60, 48, 0.12);
  color: var(--bad);
}

details.advanced {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.56);
  overflow: hidden;
}

details.advanced summary {
  padding: 15px 18px;
  cursor: pointer;
  font-weight: 600;
}

.advanced-inner {
  border-top: 1px solid var(--line);
  padding: 18px;
  display: grid;
  gap: 16px;
}

@media (max-width: 1180px) {
  .masthead,
  .setup-band,
  .workspace {
    grid-template-columns: 1fr;
  }

  .inspector-column {
    position: static;
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 1460px);
    padding: 14px 0 24px;
    gap: 14px;
  }

  .masthead,
  .setup-card,
  .workspace-card,
  .feed-card {
    padding: 18px;
    border-radius: 22px;
  }

  .setup-grid,
  .mini-grid {
    grid-template-columns: 1fr;
  }

  .masthead h1 {
    font-size: 42px;
  }

  .result-card header strong {
    font-size: 22px;
  }
}
