:root {
  color-scheme: dark;
  --bg: #101113;
  --panel: #171a1f;
  --panel-soft: #20242b;
  --text: #f3f0e8;
  --muted: #aaa397;
  --line: #30343c;
  --accent: #8fcf9f;
  --accent-strong: #b6f2c5;
  --danger: #f19b8f;
  --warning-bg: #2b2118;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 16px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(16, 17, 19, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  font-weight: 800;
  text-decoration: none;
}

nav {
  display: flex;
  gap: 16px;
}

nav a,
.button,
button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  text-decoration: none;
  font: inherit;
  font-weight: 650;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary,
button.primary,
.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #08110b;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.7fr);
  gap: 28px;
  align-items: stretch;
  padding: 28px 0 24px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  max-width: 820px;
}

h2 {
  font-size: 1.2rem;
}

p {
  margin: 0;
}

.lead {
  color: var(--muted);
  font-size: 1.1rem;
  max-width: 680px;
  margin-top: 18px;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.actions.split {
  justify-content: space-between;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.status-panel,
.panel,
.info-grid > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.status-panel,
.panel {
  padding: 22px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.info-grid > div {
  padding: 18px;
}

.info-grid p,
.muted {
  color: var(--muted);
}

.panel {
  margin-top: 18px;
}

.narrow {
  max-width: 720px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

dl {
  display: grid;
  gap: 12px;
  margin: 16px 0 0;
}

dl div,
.recovery-box,
.notice,
.error,
.message {
  border-radius: var(--radius);
  padding: 14px;
}

dl div {
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.details {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.details.single {
  grid-template-columns: 1fr;
}

dt {
  color: var(--muted);
  font-size: 0.86rem;
}

dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

code {
  color: var(--accent-strong);
  overflow-wrap: anywhere;
}

.recovery-box {
  margin-bottom: 18px;
  background: var(--warning-bg);
  border: 1px solid #5b472c;
}

.recovery-box span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.recovery-box code {
  display: block;
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.notice {
  background: #17251d;
  border: 1px solid #315a3f;
  margin-bottom: 16px;
}

.error {
  background: #2a1919;
  border: 1px solid #6b3730;
  color: var(--danger);
  margin-bottom: 16px;
}

.slim {
  margin: 10px 0;
}

.pill,
.balance-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-strong);
  padding: 8px 12px;
  white-space: nowrap;
}

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

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0c0d0f;
  color: var(--text);
  font: inherit;
  padding: 12px;
}

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

.chat-log {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.chat-log.compact {
  margin: 12px 0;
}

.message {
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.message.user {
  border-color: #506478;
}

.message.assistant {
  border-color: #3a6449;
}

.message strong {
  display: block;
  margin-bottom: 6px;
}

.message p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.composer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
}

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

@media (max-width: 760px) {
  .topbar,
  .section-heading,
  .composer-row {
    align-items: stretch;
    flex-direction: column;
  }

  nav {
    width: 100%;
  }

  nav a,
  .actions > *,
  .actions a,
  .actions button,
  .inline-actions,
  .inline-actions form,
  .inline-actions button,
  .composer-row button {
    width: 100%;
  }

  .hero,
  .info-grid,
  .details {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 2.35rem;
  }
}
