:root {
  --bg: #f6f1e8;
  --panel: #fff9ef;
  --ink: #1f1e1a;
  --muted: #6a655a;
  --line: #d7ccb7;
  --accent: #b45c2e;
  --accent-strong: #8f4219;
  --danger: #8f2727;
  --shadow: 0 14px 40px rgba(85, 54, 22, 0.12);
  --radius: 18px;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --sans: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(180, 92, 46, 0.18), transparent 26%),
    linear-gradient(135deg, #f3ede0 0%, #f7f4ec 40%, #ebe1cf 100%);
}

.shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 24px auto 60px;
}

.hero,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  padding: 28px;
  margin-bottom: 18px;
}

.panel {
  padding: 24px;
  margin-bottom: 18px;
}

.panel.narrow {
  max-width: 480px;
  margin: 80px auto;
}

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

h1,
h2,
h3 {
  margin: 0 0 10px;
}

p {
  margin: 0 0 14px;
}

.muted {
  color: var(--muted);
}

.error {
  color: var(--danger);
  font-weight: 600;
}

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

label span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.92rem;
  color: var(--muted);
}

input,
textarea,
select,
button {
  width: 100%;
  font: inherit;
  border-radius: 12px;
}

input,
textarea,
select {
  border: 1px solid var(--line);
  background: #fffdf7;
  padding: 10px 12px;
  color: var(--ink);
}

button {
  border: 0;
  background: var(--accent);
  color: #fff;
  padding: 11px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: var(--accent-strong);
}

button.secondary {
  background: #2f4f4f;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 150px;
  padding: 11px 14px;
  border-radius: 12px;
  background: #2f4f4f;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.button-link:hover {
  background: #264040;
}

button.danger {
  background: var(--danger);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.checkbox input {
  width: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 18px;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 0.95rem;
}

th {
  color: var(--muted);
  font-weight: 700;
}

.mono {
  font-family: var(--mono);
  word-break: break-all;
}

.route-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.route-groups {
  display: grid;
  gap: 18px;
  margin-bottom: 22px;
}

.route-group {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 247, 0.65);
}

.route-group-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.route-group-tools {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: min(320px, 100%);
}

.route-group-example {
  width: 100%;
}

.route-group-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.route-chain-table {
  margin-bottom: 0;
}

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

.chip {
  background: rgba(180, 92, 46, 0.1);
  color: var(--accent-strong);
  border: 1px solid rgba(180, 92, 46, 0.18);
  padding: 8px 12px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.9rem;
}

.example-details summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 700;
}

.example-actions {
  margin: 10px 0 8px;
}

.example-block {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf7;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.45;
}

.composer-actions {
  display: flex;
  justify-content: flex-end;
}

.composer-actions button {
  width: auto;
}

.chat-history {
  display: grid;
  gap: 14px;
  max-height: 520px;
  overflow-y: auto;
  margin: 14px 0;
  padding: 8px 4px;
}

.chat-empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 247, 0.8);
  color: var(--muted);
}

.chat-bubble {
  max-width: 82%;
  padding: 14px 16px;
  border-radius: 18px;
  white-space: pre-wrap;
  line-height: 1.6;
  box-shadow: 0 8px 20px rgba(85, 54, 22, 0.08);
}

.chat-bubble-user {
  justify-self: end;
  background: linear-gradient(180deg, #b45c2e, #9e4e25);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.chat-bubble-assistant {
  justify-self: start;
  background: linear-gradient(180deg, rgba(180, 92, 46, 0.08), rgba(180, 92, 46, 0.03));
  border: 1px solid rgba(180, 92, 46, 0.16);
  color: var(--ink);
  border-bottom-left-radius: 6px;
}

.chat-role {
  margin-bottom: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0.85;
}

.chat-content {
  word-break: break-word;
}

@media (max-width: 720px) {
  .shell {
    width: min(100vw - 18px, 1240px);
    margin-top: 10px;
  }

  .hero,
  .panel {
    padding: 18px;
  }

  .hero {
    flex-direction: column;
  }

  .route-group-head {
    flex-direction: column;
  }
}
