:root {
  --bg: #f5efe4;
  --paper: #fffaf0;
  --ink: #1d1a16;
  --muted: #6c6256;
  --line: #d6c8b5;
  --accent: #6a8d73;
  --accent-strong: #335c44;
  --shadow: 0 12px 30px rgba(38, 29, 17, 0.08);
  --shadow-soft: 0 8px 22px rgba(38, 29, 17, 0.05);
  --radius: 22px;
  --display-font: "Playfair Display", Georgia, "Times New Roman", serif;
  --ui-font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: var(--ui-font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(circle at top left, rgba(201, 184, 168, 0.2), transparent 34%),
    radial-gradient(circle at top right, rgba(106, 141, 115, 0.08), transparent 28%),
    linear-gradient(180deg, #f7f1e7 0%, var(--bg) 100%);
  color: var(--ink);
}

.shell { width: min(92vw, 1450px); margin: 0 auto; padding: 18px 18px 44px; }
.brand-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 8px;
}
.brand-wire {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(14, 24, 36, 0.14);
  background: linear-gradient(180deg, #0d1723 0%, #162233 100%);
  box-shadow: 0 10px 22px rgba(8, 15, 24, 0.15);
  color: #f5efe4;
  text-decoration: none;
  letter-spacing: 0.08em;
  line-height: 1;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}
.brand-wire:hover {
  transform: translateY(-1px);
  border-color: rgba(217, 106, 75, 0.45);
  box-shadow: 0 16px 28px rgba(8, 15, 24, 0.2);
}
.brand-wire-main,
.brand-wire-sub {
  font-size: 0.78rem;
  font-weight: 700;
}
.brand-wire-sub {
  opacity: 0.92;
}
.brand-wire-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #d96a4b;
  box-shadow: 0 0 0 3px rgba(217, 106, 75, 0.14);
}
.brand-guide-links {
  display: grid;
  gap: 5px;
  justify-items: end;
  position: relative;
  top: 0;
}
.brand-guide-title {
  color: var(--muted);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 0.66rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.brand-guide-title-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  position: relative;
  transition: color 160ms ease, transform 160ms ease;
}
.brand-guide-title-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 1px;
  background: currentColor;
  opacity: 0.18;
  transition: opacity 160ms ease;
}
.brand-guide-title-link-primary {
  color: var(--accent-strong);
}
.brand-guide-separator {
  color: inherit;
  opacity: 0.55;
}
.brand-guide-title-link:hover,
.brand-guide-title-link:focus-visible {
  color: var(--accent-strong);
}
.brand-guide-title-link:hover::after,
.brand-guide-title-link:focus-visible::after {
  opacity: 0.42;
}
.brand-guide-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
  margin-top: 6px;
}
.brand-guide-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 11px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.94);
  box-shadow: 0 6px 16px rgba(38, 29, 17, 0.05);
  color: var(--accent-strong);
  text-decoration: none;
  font-size: 0.76rem;
  font-weight: 600;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease,
    color 160ms ease;
}
.brand-guide-link:hover,
.brand-guide-link:focus-visible,
.brand-guide-title-link:hover,
.brand-guide-title-link:focus-visible {
  transform: translateY(-1px);
}
.brand-guide-link:hover,
.brand-guide-link:focus-visible {
  border-color: rgba(51, 92, 68, 0.5);
  background: rgba(255, 251, 244, 1);
  box-shadow: 0 10px 18px rgba(51, 92, 68, 0.08);
}
.hero { max-width: 620px; margin-bottom: 18px; margin-top: 0; }
.eyebrow {
  letter-spacing: 0.26em;
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 12px;
  font-weight: 600;
}
h1, h2, h3 {
  margin: 0;
  font-family: var(--display-font);
  font-weight: 700;
}
h1 {
  font-size: clamp(2.5rem, 3.9vw, 3.8rem);
  line-height: 0.97;
  max-width: 700px;
  letter-spacing: -0.03em;
}
.lede {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--muted);
  max-width: 560px;
}

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

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

.domain-card {
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  min-height: 70px;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease,
    color 180ms ease;
}
.domain-card::after {
  content: "";
  position: absolute;
  inset: auto 12px 10px;
  height: 2px;
  border-radius: 999px;
  background: transparent;
  transition: background 180ms ease, opacity 180ms ease;
  opacity: 0;
}
.domain-card:hover,
.domain-card.active {
  border-color: rgba(106, 141, 115, 0.42);
}
.domain-card:hover {
  transform: translateY(-1px);
  background: rgba(255, 251, 244, 0.98);
  box-shadow: 0 12px 24px rgba(38, 29, 17, 0.06);
}
.domain-card:hover::after {
  background: rgba(51, 92, 68, 0.28);
  opacity: 1;
}
.domain-card.active {
  background: rgba(255, 250, 240, 0.98);
  border-color: rgba(51, 92, 68, 0.58);
  box-shadow:
    0 10px 24px rgba(38, 29, 17, 0.06),
    0 0 0 1px rgba(51, 92, 68, 0.18) inset;
}
.domain-card.active:hover {
  box-shadow:
    0 14px 26px rgba(38, 29, 17, 0.07),
    0 0 0 1px rgba(51, 92, 68, 0.18) inset;
}
.domain-card.active::after {
  background: var(--accent-strong);
  opacity: 1;
}
.domain-card strong {
  display: block;
  margin-bottom: 7px;
  font-family: var(--display-font);
  font-size: 0.98rem;
  line-height: 1.05;
}
.domain-card span { color: var(--muted); line-height: 1.35; font-size: 0.83rem; }
.domain-card.active strong { color: var(--accent-strong); }
.domain-card.active span { color: #5b625c; }

.panel { padding: 15px 14px; }
.panel-head { margin-bottom: 12px; }
.panel-head p { margin: 6px 0 0; color: var(--muted); font-size: 0.84rem; line-height: 1.4; }

.field { display: grid; gap: 10px; margin-bottom: 18px; }
.field span, legend { font-size: 0.84rem; font-weight: 600; }
textarea, input[type="file"], input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 254, 249, 0.98);
  padding: 12px 13px;
  color: var(--ink);
  font-family: var(--ui-font);
  font-size: 0.9rem;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}
textarea:hover,
input[type="file"]:hover,
input[type="text"]:hover {
  border-color: rgba(106, 141, 115, 0.32);
  background: rgba(255, 255, 250, 1);
}

.toggle-field { margin-top: -2px; }
.toggle {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 254, 249, 0.98);
  padding: 12px 14px;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}
.toggle:hover {
  border-color: rgba(106, 141, 115, 0.3);
  background: rgba(255, 251, 244, 1);
}
.toggle input { margin-top: 3px; }
.inline-toggle { margin-top: 14px; }
.toggle-compact { margin-top: 0; padding: 8px 12px; border-radius: 999px; align-items: center; white-space: nowrap; }
.toggle-compact span { font-size: 0.82rem; font-weight: 600; }

.submit, .secondary {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  font-family: var(--ui-font);
  font-size: 0.9rem;
  font-weight: 600;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.submit {
  background: linear-gradient(180deg, #41694e 0%, #335c44 100%);
  color: #f6efe3;
  box-shadow: 0 10px 22px rgba(51, 92, 68, 0.18);
}
.submit:hover,
.submit:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(51, 92, 68, 0.22);
}
.secondary {
  background: rgba(106, 141, 115, 0.08);
  color: var(--accent-strong);
  border: 1px solid var(--line);
}
.secondary:hover,
.secondary:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(51, 92, 68, 0.34);
  background: rgba(106, 141, 115, 0.12);
}

.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.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.meta dd { margin: 6px 0 0; font-weight: 600; font-size: 0.94rem; }
.llm-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 254, 249, 0.98);
  transition: box-shadow 180ms ease, border-color 180ms ease, background 180ms ease;
}
.llm-panel:hover {
  border-color: rgba(106, 141, 115, 0.24);
  box-shadow: 0 10px 20px rgba(38, 29, 17, 0.04);
}
.result-panel { min-width: 0; }
.llm-panel h3 { margin: 0 0 10px; font-size: 0.98rem; }
.llm-meta { margin-bottom: 10px; }
.result-panel.is-running { border-color: rgba(51, 92, 68, 0.42); box-shadow: 0 14px 34px rgba(51, 92, 68, 0.12); }
.result-provenance { margin: 0.35rem 0 0.8rem; color: var(--muted); font-size: 0.84rem; line-height: 1.45; }
.run-support {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}
.reading-guide {
  margin: 0.8rem 0 0;
  padding: 0.8rem 0.95rem;
  border-radius: 16px;
  border: 1px solid rgba(51, 92, 68, 0.18);
  background: rgba(106, 141, 115, 0.08);
  color: #30463a;
  font-size: 0.93rem;
  line-height: 1.45;
}
.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; }
.llm-summary.warning {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid rgba(212, 156, 47, 0.34);
  border-radius: 999px;
  background: rgba(212, 156, 47, 0.14);
  color: #7a5310;
  font-weight: 700;
}
.source-list li + li { margin-top: 8px; } .source-list a { color: var(--accent-strong); }
.debug-panel {
  margin-top: 16px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: rgba(255, 254, 249, 0.84);
}
.debug-panel summary {
  cursor: pointer;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
  list-style: none;
}
.debug-panel summary::-webkit-details-marker {
  display: none;
}
.debug-panel summary::after {
  content: "Show";
  float: right;
  color: var(--accent-strong);
  font-size: 0.85rem;
}
.debug-panel[open] summary::after {
  content: "Hide";
}
.debug-panel-body {
  padding: 0 14px 14px;
  border-top: 1px dashed var(--line);
}
.compact-head p { margin-bottom: 0.35rem; }
.debug-meta { margin-bottom: 0.75rem; }
.debug-toggle { margin-top: 0.15rem; }
.debug-raw-result {
  margin-top: 0.75rem;
  padding: 0.9rem 1rem;
  max-height: 260px;
  overflow: auto;
  border-radius: 14px;
  background: #f6f6f4;
  border: 1px solid var(--line);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.88rem;
  line-height: 1.45;
}
small { color: var(--muted); }
.compact { margin-bottom: 14px; }
.inline-field { display: grid; gap: 10px; grid-template-columns: 1fr auto; }
.followup-panel { margin-top: 16px; padding: 16px; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; }
.followup-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.followup-hint { margin-top: 6px; display: block; }

@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; }
  .brand-bar {
    margin-bottom: 16px;
    flex-direction: column;
    align-items: stretch;
  }
  .brand-wire { gap: 7px; padding: 7px 12px; }
  .brand-wire-main, .brand-wire-sub { font-size: 0.84rem; }
  .brand-wire-dot { width: 8px; height: 8px; }
  .brand-guide-links {
    justify-items: stretch;
    width: 100%;
    position: static;
  }
  .brand-guide-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
