:root {
  --bg: #f5f1ea;
  --bg-deep: #ece4d7;
  --panel: rgba(255, 251, 246, 0.92);
  --panel-soft: rgba(255, 255, 255, 0.62);
  --ink: #211c17;
  --muted: #6d655d;
  --line: #d7c9b7;
  --accent: #b34b2d;
  --accent-strong: #8a341c;
  --accent-soft: #ead1c3;
  --shadow: 0 18px 40px rgba(58, 35, 18, 0.08);
  --success: #276444;
  --danger: #a33428;
  --sans: "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(179, 75, 45, 0.18), transparent 24%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
}

textarea,
input,
button {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease, opacity 120ms ease;
}

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

button.secondary {
  background: var(--accent-soft);
  color: var(--ink);
}

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

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

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: #fff;
  color: var(--ink);
}

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

.page-shell {
  min-height: 100vh;
  padding: 24px;
}

.page-header,
.workspace-panel,
.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.page-header {
  max-width: 1400px;
  margin: 0 auto 18px;
  padding: 24px 28px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: start;
}

.page-header h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 50px);
  line-height: 1;
}

.subtitle,
.meta {
  color: var(--muted);
}

.subtitle {
  margin: 14px 0 0;
  max-width: 70ch;
  line-height: 1.6;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.session-box {
  text-align: right;
}

.auth-shell {
  max-width: 480px;
  margin: 40px auto 0;
}

.auth-card {
  padding: 28px;
}

.auth-card h2 {
  margin: 0 0 8px;
}

.auth-form,
.composer,
.detail-body,
.chat-log {
  display: grid;
  gap: 12px;
}

.workspace {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(420px, 1.05fr);
  gap: 18px;
  align-items: start;
}

.workspace-panel {
  overflow: hidden;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-head {
  padding: 20px 22px 16px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  border-bottom: 1px solid var(--line);
}

.panel-head h2,
.info-card h3 {
  margin: 0;
}

.chat-log,
.composer,
.detail-body {
  padding: 18px 22px 22px;
}

.chat-log {
  flex: 1 1 auto;
  min-height: 340px;
  max-height: min(52vh, 720px);
  align-content: start;
  overflow-y: auto;
}

.composer {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  background: var(--panel-soft);
}

.field {
  display: grid;
  gap: 8px;
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

.turn {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.bubble {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 14px;
  background: #fff;
}

.bubble.user {
  background: #f9e9df;
}

.bubble.assistant {
  background: #fffdf9;
}

.bubble-copy.assistant-copy {
  white-space: pre-line;
}

.bubble-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
}

.status.succeeded {
  color: var(--success);
  font-weight: 700;
}

.status.failed {
  color: var(--danger);
  font-weight: 700;
}

.detail-body {
  gap: 14px;
}

.info-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  padding: 16px;
}

.kv {
  display: grid;
  gap: 8px;
}

.kv div {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 10px;
  font-size: 14px;
}

.kv dt {
  color: var(--muted);
  font-weight: 700;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 6px 11px;
  font-size: 12px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 18px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.48);
  color: var(--muted);
}

details summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 700;
  margin-bottom: 8px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  background: #261f19;
  color: #f6efe3;
  border-radius: 16px;
  padding: 14px;
  font-family: var(--mono);
  font-size: 12px;
  overflow: auto;
}

@media (max-width: 980px) {
  .workspace,
  .reference-grid,
  .page-header {
    grid-template-columns: 1fr;
  }

  .page-header {
    display: grid;
  }

  .session-box {
    text-align: left;
  }

  .chat-log {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 14px;
  }

  .page-header,
  .panel-head,
  .chat-log,
  .composer,
  .detail-body,
  .auth-card {
    padding-left: 16px;
    padding-right: 16px;
  }

  .kv div {
    grid-template-columns: 1fr;
  }
}
