:root {
  --ink: #0e1512;
  --muted: #5a6b62;
  --bg: #e8eee9;
  --surface: rgba(248, 251, 249, 0.92);
  --surface-solid: #f7faf8;
  --line: #c5d1ca;
  --line-strong: #9aada2;
  --brand: #163528;
  --brand-mid: #1f4a36;
  --accent: #0d9488;
  --accent-deep: #0f766e;
  --warn: #b45309;
  --danger: #9f1239;
  --ok: #047857;
  --shadow: 0 24px 60px rgba(14, 21, 18, 0.1);
  --radius: 10px;
  --font-display: "Syne", sans-serif;
  --font-body: "Manrope", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-body);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.5;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(120deg, rgba(22, 53, 40, 0.08) 0%, transparent 42%),
    radial-gradient(900px 520px at 88% -8%, rgba(13, 148, 136, 0.14), transparent 55%),
    radial-gradient(700px 480px at 0% 100%, rgba(22, 53, 40, 0.1), transparent 50%),
    linear-gradient(180deg, #dfe8e2 0%, #eef3ef 48%, #e6ece8 100%);
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cpath d='M0 60h120M60 0v120' stroke='%23163528' stroke-opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
}

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: shell-in 480ms ease-out;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(154, 173, 162, 0.45);
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 4vw, 2.75rem);
  letter-spacing: -0.04em;
  color: var(--brand);
  line-height: 1.05;
}

.brand-sub {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: flex-end;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
}

.status.ok { color: var(--ok); border-color: #a7d7c4; }
.status.ok::before { background: var(--ok); box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.15); }
.status.bad { color: var(--danger); border-color: #f5c2cc; }
.status.bad::before { background: var(--danger); }

.toggle {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  gap: 0.45rem;
  align-items: center;
  font-weight: 500;
}

.toggle input {
  accent-color: var(--brand-mid);
  width: 1rem;
  height: 1rem;
}

.nav-link {
  font-size: 0.85rem;
  color: var(--brand-mid);
  text-decoration: none;
  font-weight: 650;
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
  transition: border-color 160ms ease, color 160ms ease;
}
.nav-link:hover {
  color: var(--accent-deep);
  border-bottom-color: var(--accent);
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(240px, 0.9fr);
  gap: 1.35rem;
  align-items: stretch;
  min-height: 0;
}

.chat-stage {
  display: flex;
  flex-direction: column;
  min-height: min(78vh, 760px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.chat-intro {
  padding: 1.35rem 1.4rem 1rem;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(105deg, rgba(22, 53, 40, 0.06), transparent 55%),
    var(--surface-solid);
}

.chat-intro h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.2vw, 1.7rem);
  letter-spacing: -0.03em;
  font-weight: 700;
  color: var(--brand);
  max-width: 18ch;
}

.chat-intro .lede {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 42ch;
}

.thread {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.15rem 1.25rem;
  scroll-behavior: smooth;
}

.bubble {
  max-width: min(92%, 560px);
  padding: 0.85rem 1rem;
  border-radius: 8px;
  line-height: 1.5;
  white-space: pre-wrap;
  animation: rise 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bubble.user {
  align-self: flex-end;
  background: var(--brand);
  color: #f3f8f5;
  border-bottom-right-radius: 3px;
}

.bubble.agent {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-left-radius: 3px;
  color: var(--ink);
}

.bubble .meta-line {
  margin-top: 0.55rem;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(197, 209, 202, 0.7);
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.bubble.user .meta-line {
  border-top-color: rgba(243, 248, 245, 0.2);
  color: rgba(243, 248, 245, 0.72);
}

.bubble.typing {
  color: var(--muted);
  font-style: italic;
}

.composer {
  display: grid;
  gap: 0.55rem;
  padding: 1rem 1.15rem 1.15rem;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.65);
}

.composer-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0.55rem;
}

.composer input,
.composer textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.composer input:focus,
.composer textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.composer textarea {
  resize: vertical;
  min-height: 76px;
  grid-column: 1 / -1;
}

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

button {
  border: 0;
  border-radius: 8px;
  padding: 0.65rem 1.2rem;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  background: var(--brand);
  color: #f4faf7;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

button:hover {
  background: var(--brand-mid);
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

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

button.ghost:hover {
  background: rgba(22, 53, 40, 0.04);
  color: var(--brand);
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
  padding: 0.15rem 0.1rem;
}

.rail section {
  animation: rise 420ms ease-out both;
}

.rail section:nth-child(2) { animation-delay: 60ms; }
.rail section:nth-child(3) { animation-delay: 120ms; }

.rail h2 {
  margin: 0 0 0.65rem;
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-mid);
  font-weight: 700;
}

.cases {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.case-btn {
  text-align: left;
  width: 100%;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  font-weight: 500;
  font-size: 0.86rem;
  line-height: 1.35;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.case-btn:hover {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.7);
  transform: translateX(2px);
}

.stats {
  margin: 0;
  display: grid;
  gap: 0.5rem;
}

.stats div {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 0.35rem;
  font-size: 0.86rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid rgba(197, 209, 202, 0.55);
}

.stats dt { color: var(--muted); font-weight: 500; }
.stats dd { margin: 0; word-break: break-all; font-weight: 650; color: var(--brand); }

.metrics {
  margin: 0;
  padding: 0.85rem;
  background: #101814;
  color: #c9ddd2;
  border-radius: 8px;
  font-size: 0.72rem;
  overflow: auto;
  max-height: 200px;
  font-family: ui-monospace, "Cascadia Code", monospace;
  border: 1px solid #1c2a23;
}

.footnote {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes shell-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 920px) {
  .workspace { grid-template-columns: 1fr; }
  .chat-stage { min-height: 62vh; }
  .composer-row { grid-template-columns: 1fr; }
  .brand { font-size: 1.85rem; }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .meta { justify-content: flex-start; }
}

/* Shadow page compatibility */
.review-wrap { max-width: 1100px; margin: 1.5rem auto; padding: 0 1rem 2rem; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.ghost-link { color: var(--brand-mid); text-decoration: none; font-weight: 650; }
.ghost-link:hover { text-decoration: underline; }
.pill { /* legacy */
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 6px;
}
.pill.ok { color: var(--ok); }
.pill.bad { color: var(--danger); }
.lede { color: var(--muted); }
.topnav a { color: var(--brand-mid); margin-right: 1rem; }
