:root {
  color-scheme: light;
  --bg: #f6f1e8;
  --surface: rgba(255, 251, 245, 0.92);
  --surface-strong: #fffdf8;
  --text: #1e1b18;
  --muted: #66574d;
  --line: rgba(30, 27, 24, 0.12);
  --accent: #c24f2d;
  --accent-soft: rgba(194, 79, 45, 0.12);
  --accent-deep: #942f14;
  --success: #285b4b;
  --shadow: 0 22px 56px rgba(54, 33, 19, 0.12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(194, 79, 45, 0.16), transparent 26%),
    radial-gradient(circle at top right, rgba(40, 91, 75, 0.14), transparent 24%),
    linear-gradient(180deg, #fffaf2 0%, var(--bg) 100%);
}
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

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

.console-topbar, .console-layout {
  width: min(1420px, 100%);
  margin: 0 auto;
}

.console-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.console-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  color: inherit;
}

.console-brand-mark, .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.74rem;
  color: var(--accent-deep);
}

.console-brand-name { font-size: 1.35rem; font-weight: 700; }

.console-topbar-actions, .status-stack, .capability-row, .composer-actions, .rail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.quick-action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.mode-pill, .status-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--text);
}

.status-chip.secondary { color: var(--muted); }
.text-link, .text-button {
  color: var(--muted);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
}

.console-layout {
  display: grid;
  gap: 24px;
}

.auth-panel, .app-shell {
  display: grid;
  gap: 24px;
}

.auth-panel {
  grid-template-columns: 1.1fr 0.9fr;
  align-items: start;
}

.auth-copy, .auth-card, .rail-card, .chat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-copy h1 {
  font-size: clamp(2rem, 6vw, 4.6rem);
  line-height: 1.02;
  letter-spacing: -0.05em;
  max-width: 10ch;
  margin: 12px 0 16px;
}

.auth-copy p, .auth-copy li, .hint {
  color: var(--muted);
}

.auth-card {
  display: grid;
  gap: 14px;
}

.auth-card label, .composer-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 700;
}

input, select, textarea {
  width: 100%;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 14px 16px;
  color: var(--text);
}

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

.primary-button, .secondary-button {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 13px 18px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  background: var(--accent);
  color: #fff9f3;
}

.secondary-button {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.primary-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.advanced-panel {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.advanced-panel summary {
  cursor: pointer;
  font-weight: 700;
  margin-bottom: 12px;
}

.app-shell {
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  align-items: start;
}

.thread-rail, .side-rail {
  display: grid;
  gap: 18px;
}

.rail-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 14px;
}

.rail-head.compact {
  align-items: center;
  margin-bottom: 12px;
}

.rail-head h2, .rail-head h3, .chat-header h2 {
  margin: 0;
  line-height: 1.08;
}

.thread-list, .stack-list {
  display: grid;
  gap: 12px;
}

.thread-item, .stack-item, .chat-bubble, .capability-button {
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.thread-item, .stack-item, .capability-button {
  padding: 14px 16px;
}

.thread-item {
  cursor: pointer;
}

.thread-item.active {
  border-color: rgba(194, 79, 45, 0.42);
  background: rgba(194, 79, 45, 0.09);
}

.chat-card {
  display: grid;
  gap: 18px;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

.capability-button {
  cursor: pointer;
  background: rgba(194, 79, 45, 0.08);
}

.capability-button.active {
  border-color: rgba(194, 79, 45, 0.42);
  background: rgba(194, 79, 45, 0.16);
}

.chat-log {
  min-height: 500px;
  max-height: 70vh;
  overflow: auto;
  display: grid;
  gap: 14px;
}

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

.chat-bubble {
  padding: 18px 20px;
}

.chat-bubble.user {
  justify-self: end;
  max-width: 80%;
  background: rgba(194, 79, 45, 0.12);
}

.chat-bubble.assistant, .chat-bubble.system {
  max-width: 92%;
}

.chat-bubble pre {
  white-space: pre-wrap;
  margin: 0;
  font-family: inherit;
}

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

.plan-body {
  white-space: pre-wrap;
  color: var(--muted);
  line-height: 1.5;
}

.settings-stack {
  display: grid;
  gap: 10px;
}

.stack-item strong {
  color: var(--text);
}

.stack-item-title {
  color: var(--text);
  margin-bottom: 6px;
  font-weight: 700;
}

.stack-item-meta {
  color: var(--muted);
  font-size: 0.94rem;
}

.approval-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .auth-panel {
    grid-template-columns: 1fr;
  }
}
