:root {
  --bg: #f7f3ea;
  --sidebar: #19231f;
  --surface: #fffdf8;
  --surface-soft: #f8f2e8;
  --text: #1f241f;
  --muted: #8a8172;
  --line: #e2d7c4;
  --accent: #b04735;
  --accent-strong: #8f2f24;
  --accent-soft: #f5e1d8;
  --gold: #b78946;
  --jade: #2d6a5f;
  --shadow: 0 22px 60px rgba(60, 45, 24, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 78% 18%, rgba(176, 71, 53, 0.10), transparent 28%),
    linear-gradient(90deg, rgba(183, 137, 70, 0.07) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, rgba(45, 106, 95, 0.06) 0 1px, transparent 1px 100%),
    var(--bg);
  background-size: auto, 32px 32px, 32px 32px, auto;
  color: var(--text);
  font-family: ui-sans-serif, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 246px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  background: var(--sidebar);
  border-right: 1px solid rgba(255,255,255,0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 20px;
  font-size: 22px;
  letter-spacing: -0.04em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  color: white;
  font-weight: 900;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 4px;
  color: rgba(255,255,255,0.72);
  text-decoration: none;
  font-size: 15px;
}

.nav-item.active {
  background: rgba(255, 253, 248, 0.12);
  color: #fff8e9;
  font-weight: 700;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 18px;
  color: rgba(255,255,255,0.72);
}

.sidebar-note {
  margin: 0;
  padding: 0 12px;
  color: rgba(255,255,255,0.48);
  font-size: 13px;
  line-height: 1.7;
}

.chat-stage {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 100vh;
  padding: 20px clamp(18px, 5vw, 72px) 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
}

.icon-button,
.clear-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: #494556;
  border-radius: 999px;
}

.icon-button {
  width: 34px;
  height: 34px;
}

.hero-panel {
  align-self: center;
  width: min(860px, 100%);
  margin: 0 auto;
  padding-bottom: 80px;
  text-align: center;
}

.kicker {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
}

h1 {
  margin: 0 0 34px;
  font-size: clamp(30px, 4.2vw, 46px);
  line-height: 1.15;
  letter-spacing: -0.04em;
}

h1 em {
  font-style: italic;
  font-weight: 900;
}

.composer {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  text-align: left;
}

.mode-pills {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 18px 18px 6px;
}

.mode-pills label { cursor: pointer; }
.mode-pills input { position: absolute; opacity: 0; pointer-events: none; }
.mode-pills span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: #5c5145;
  font-size: 14px;
}
.mode-pills input:checked + span {
  color: var(--accent-strong);
  border-color: #e8c1b4;
  background: #fff4ec;
  box-shadow: 0 0 0 3px rgba(176, 71, 53, 0.08);
}

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

textarea, input, select {
  width: 100%;
  border: 1px solid var(--line);
  outline: 0;
  background: var(--surface);
  color: var(--text);
}

#question-input {
  display: block;
  min-height: 120px;
  padding: 18px 20px 12px;
  border: 0;
  resize: vertical;
  font-size: 16px;
  line-height: 1.7;
}

#question-input::placeholder { color: #b2aeba; }

.advanced-fields {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 18px 12px;
}
body[data-mode="drafting"] .advanced-fields { display: grid; }
.advanced-fields textarea,
.advanced-fields input,
.advanced-fields select {
  min-height: 40px;
  border-radius: 10px;
  padding: 9px 11px;
  background: var(--surface-soft);
}
.advanced-fields textarea { grid-column: 1 / -1; resize: vertical; }

.composer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 14px;
}

.clear-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 14px;
  margin-left: auto;
}

.send-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(176, 71, 53, 0.28);
}

.send-button[disabled] { opacity: 0.7; cursor: wait; }

.prompt-chips {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 78px;
}

.prompt-chips button {
  border: 0;
  border-radius: 4px;
  background: var(--surface);
  color: #51483d;
  padding: 11px 18px;
  box-shadow: 0 1px 8px rgba(23, 21, 40, 0.04);
}

.result-shell {
  width: min(920px, 100%);
  margin: 0 auto;
}

.empty-state {
  text-align: center;
  color: #a29686;
  font-size: 13px;
  padding: 20px;
}

.result-card {
  margin: 0 auto 24px;
  padding: 26px clamp(20px, 4vw, 42px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  text-align: left;
}

.result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

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

.copy-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: #5a4d3f;
  padding: 0 12px;
}

.result-card h2 {
  margin: 0 0 16px;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.markdown-output {
  color: #2d2922;
  font-size: 16px;
  line-height: 1.85;
  word-break: break-word;
}
.markdown-output > *:first-child { margin-top: 0; }
.markdown-output > *:last-child { margin-bottom: 0; }
.markdown-output h2,
.markdown-output h3,
.markdown-output h4,
.markdown-output h5 {
  margin: 1.1em 0 0.45em;
  line-height: 1.35;
}
.markdown-output h2 { font-size: 22px; }
.markdown-output h3 { font-size: 19px; }
.markdown-output h4,
.markdown-output h5 { font-size: 17px; }
.markdown-output p { margin: 0.65em 0; }
.markdown-output ul,
.markdown-output ol { margin: 0.7em 0 0.7em 1.35em; padding: 0; }
.markdown-output li { margin: 0.28em 0; }
.markdown-output code { background: #f2f0f7; padding: 0.08em 0.32em; border-radius: 4px; }

.result-card--needs-info,
.result-card--config { border-color: #f2d7a7; }
.result-card--error { border-color: #f2b6b6; }

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .chat-stage { padding: 14px 14px 22px; }
  .hero-panel { padding-bottom: 30px; }
  .prompt-chips { margin-top: 28px; gap: 10px; }
  .composer-actions { align-items: stretch; flex-wrap: wrap; }
  .clear-button { margin-left: 0; }
  .advanced-fields { grid-template-columns: 1fr; }
}
