:root {
  color-scheme: dark;
  --bg: #121412;
  --panel: #1b1e1b;
  --panel-2: #22261f;
  --line: #343a31;
  --text: #edf1e8;
  --muted: #aab0a0;
  --soft: #76806f;
  --accent: #78d278;
  --accent-strong: #a8e66d;
  --warn: #e7b950;
  --danger: #ec6c5f;
  --shadow: rgba(0, 0, 0, 0.28);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(120, 210, 120, 0.06), transparent 260px),
    var(--bg);
  color: var(--text);
}

button,
textarea,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.shell {
  width: min(1500px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

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

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.08;
  letter-spacing: 0;
}

.health {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: max-content;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 13px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warn);
}

.health.ready .dot {
  background: var(--accent);
}

.health.error .dot {
  background: var(--danger);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr) minmax(230px, 280px);
  gap: 18px;
  padding-top: 18px;
}

.query-panel,
.terminal-panel,
.side-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 42px var(--shadow);
}

.query-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}

.prompt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 226px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11130f;
  color: var(--text);
  padding: 14px;
  line-height: 1.5;
  outline: none;
}

textarea:focus,
input:focus {
  border-color: rgba(120, 210, 120, 0.76);
  box-shadow: 0 0 0 3px rgba(120, 210, 120, 0.12);
}

.action-row,
.token-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.primary {
  border-color: rgba(120, 210, 120, 0.7);
  background: #78d278;
  color: #11170f;
  font-weight: 800;
}

.secondary,
.quick-prompts button {
  background: var(--panel-2);
  color: var(--text);
}

.primary:hover {
  background: #92dd84;
}

.secondary:hover,
.quick-prompts button:hover {
  border-color: var(--accent);
}

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

.quick-prompts button {
  width: 100%;
  padding: 0 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.terminal-panel {
  display: flex;
  min-height: calc(100vh - 126px);
  flex-direction: column;
  overflow: hidden;
}

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #151813;
}

.terminal-header code {
  overflow: hidden;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-width: 70px;
  justify-content: center;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-pill.running {
  border-color: rgba(231, 185, 80, 0.7);
  color: var(--warn);
}

.status-pill.ok {
  border-color: rgba(120, 210, 120, 0.7);
  color: var(--accent);
}

.status-pill.fail {
  border-color: rgba(236, 108, 95, 0.7);
  color: var(--danger);
}

.runtime {
  margin-left: 8px;
  color: var(--soft);
  font-size: 12px;
}

.response {
  flex: 1;
  min-height: 460px;
  overflow: auto;
  padding: 18px;
  background: #080a08;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.answer-hero,
.answer-section {
  border: 1px solid #273025;
  border-radius: 8px;
  background: #11150f;
}

.answer-hero {
  padding: 18px;
}

.answer-hero h2 {
  margin: 0;
  color: var(--accent-strong);
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

.answer-direct {
  margin: 12px 0 0;
  max-width: 900px;
  color: #eef4e8;
  font-size: 16px;
  line-height: 1.55;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.meta-item {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #171c15;
}

.meta-item span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.meta-item strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.25;
}

.answer-section {
  margin-top: 12px;
  padding: 14px;
}

.answer-section h3 {
  margin: 0 0 10px;
  color: #dfe8d5;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.decision {
  margin: 0;
  color: #eef4e8;
  line-height: 1.5;
}

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

.clean-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.clean-list li {
  color: #dbe9d0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.table-wrap {
  overflow-x: auto;
}

.annual-table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
  font-size: 13px;
}

.annual-table th,
.annual-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.annual-table th:first-child,
.annual-table td:first-child {
  text-align: left;
}

.annual-table th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.raw-panel {
  border-top: 1px solid var(--line);
  background: #080a08;
}

.raw-panel summary {
  min-height: 44px;
  padding: 12px 18px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

pre {
  min-height: 220px;
  margin: 0;
  overflow: auto;
  padding: 18px;
  background: #080a08;
  color: #dbe9d0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-self: start;
  padding: 14px;
}

.metric {
  display: grid;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.metric span,
.token-panel label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.metric strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.35;
}

.token-panel {
  display: grid;
  gap: 8px;
}

input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #11130f;
  color: var(--text);
  padding: 0 10px;
  outline: none;
}

.notice {
  margin: auto 0 0;
  color: var(--soft);
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 360px minmax(0, 1fr);
  }

  .side-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: start;
  }

  .notice {
    margin: 0;
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 25px;
  }

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

  .terminal-panel {
    min-height: 520px;
  }

  .terminal-header,
  .side-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .quick-prompts {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 520px) {
  .meta-grid {
    grid-template-columns: 1fr;
  }
}
