:root {
  --bg: #f5efe4;
  --paper: #fffaf0;
  --ink: #1d1a16;
  --muted: #6c6256;
  --line: #d6c8b5;
  --accent: #6a8d73;
  --accent-strong: #335c44;
  --shadow: 0 18px 48px rgba(38, 29, 17, 0.08);
  --radius: 24px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at top left, rgba(106, 141, 115, 0.18), transparent 32%),
    linear-gradient(180deg, #f8f2e8 0%, var(--bg) 100%);
  color: var(--ink);
}

.shell { width: min(98vw, 1720px); margin: 0 auto; padding: 48px 28px 72px; }
.hero { max-width: 760px; margin-bottom: 32px; }
.eyebrow { letter-spacing: 0.24em; font-size: 12px; color: var(--muted); margin: 0 0 12px; }
h1, h2 { margin: 0; font-weight: 600; }
h1 { font-size: clamp(2.4rem, 4vw, 4.2rem); line-height: 0.95; max-width: 720px; }
.lede { font-size: 1.05rem; line-height: 1.6; color: var(--muted); max-width: 620px; }

.domains, .workspace { display: grid; gap: 18px; }
.domains { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 24px; }
.control-strip {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr);
  margin-bottom: 24px;
}
.workspace { grid-template-columns: minmax(0, 0.98fr) minmax(0, 1.02fr); }
.control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}
.control-group h2 { margin: 0; font-size: 1.2rem; }
.control-group h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}
.control-group p { margin: 0 0 14px; color: var(--muted); }
.inline-control-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.domain-card, .panel {
  background: rgba(255, 250, 240, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.domain-card {
  padding: 18px;
  text-align: left;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}
.domain-card::after {
  content: "";
  position: absolute;
  inset: auto 16px 12px;
  height: 3px;
  border-radius: 999px;
  background: transparent;
  transition: background 180ms ease, opacity 180ms ease;
  opacity: 0;
}
.domain-card:hover,
.domain-card.active {
  transform: translateY(-2px);
  border-color: var(--accent);
}
.domain-card.active {
  background: linear-gradient(180deg, #e8f1ff 0%, #d8e8ff 100%);
  border-color: #72a4f2;
  box-shadow:
    0 22px 48px rgba(60, 95, 160, 0.18),
    0 0 0 1px rgba(114, 164, 242, 0.28) inset;
}
.domain-card.active::after {
  background: #4e84dc;
  opacity: 1;
}
.domain-card strong { display: block; margin-bottom: 8px; font-size: 1.05rem; }
.domain-card span { color: var(--muted); line-height: 1.4; }
.domain-card.active strong {
  color: #214f99;
}
.domain-card.active span {
  color: #415a82;
}

.panel { padding: 24px; }
.panel-head { margin-bottom: 18px; }
.panel-head p { margin: 8px 0 0; color: var(--muted); }

.field { display: grid; gap: 10px; margin-bottom: 18px; }
.field span, legend { font-size: 0.95rem; font-weight: 600; }
textarea, input[type="file"], input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffef9;
  padding: 16px;
  color: var(--ink);
}

.chip-list { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  border: 1px solid var(--line);
  background: #fffef9;
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
}
.chip input { display: none; }
.chip-small {
  padding: 7px 12px;
  font-size: 0.88rem;
}
.compact-chip-list {
  gap: 8px;
}
.sub-control {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(214, 200, 181, 0.75);
}
.inline-chip-list {
  flex: 1 1 320px;
}

.toggle-field { margin-top: -2px; }
.toggle {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffef9;
  padding: 14px 16px;
}
.toggle input { margin-top: 3px; }
.inline-toggle { margin-top: 14px; }
.toggle-compact {
  margin-top: 0;
  padding: 10px 14px;
  border-radius: 999px;
  align-items: center;
  white-space: nowrap;
}
.toggle-compact span {
  font-size: 0.9rem;
  font-weight: 600;
}

.submit, .secondary {
  border: none;
  border-radius: 999px;
  padding: 14px 20px;
  cursor: pointer;
}

.submit {
  background: var(--accent-strong);
  color: #f6efe3;
}

.secondary {
  background: rgba(106, 141, 115, 0.12);
  color: var(--accent-strong);
  border: 1px solid var(--line);
}

.meta { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.meta div { border-top: 1px solid var(--line); padding-top: 10px; }
.meta dt { color: var(--muted); font-size: 0.9rem; }
.meta dd { margin: 6px 0 0; font-weight: 600; }
.llm-panel {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffef9;
}
.result-panel {
  min-width: 0;
}
.llm-panel h3 { margin: 0 0 12px; font-size: 1rem; }
.llm-meta { margin-bottom: 10px; }
.result-panel.is-running {
  border-color: var(--accent);
  box-shadow: 0 18px 48px rgba(51, 92, 68, 0.18);
}
.result-provenance {
  margin: 0.4rem 0 0.9rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}
.source-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
}
.llm-notes {
  margin: -0.2rem 0 0.9rem;
  padding-left: 1rem;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}
.llm-notes li + li {
  margin-top: 0.2rem;
}
.source-list li + li { margin-top: 8px; } .source-list a { color: var(--accent-strong); }
small { color: var(--muted); }
.compact { margin-bottom: 14px; }
.inline-field { display: grid; gap: 10px; grid-template-columns: 1fr auto; }

@media (min-width: 1280px) {
  .workspace {
    gap: 22px;
  }
  .result-panel {
    padding: 26px;
  }
}

@media (max-width: 960px) {
  .control-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .inline-control-row {
    align-items: flex-start;
    flex-direction: column;
  }
  .control-strip, .workspace { grid-template-columns: 1fr; }
}
