:root {
  --bg: #08090a;
  --panel: #101113;
  --panel-2: #15171a;
  --panel-3: #f7f7f2;
  --ink: #f5f5f0;
  --dark: #111317;
  --muted: rgba(245, 245, 240, 0.62);
  --muted-dark: rgba(17, 19, 23, 0.62);
  --line: rgba(245, 245, 240, 0.12);
  --line-dark: rgba(17, 19, 23, 0.12);
  --teal: #20c7b5;
  --teal-2: #0e8178;
  --warn: #ffb84d;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
}
button, textarea, select, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #090a0c;
  padding: 22px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
  font-family: var(--mono);
  font-size: 1.05rem;
}
.brand img { width: 42px; height: 42px; object-fit: contain; filter: invert(1); }
.sidebar nav { display: grid; gap: 8px; }
.sidebar button {
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  padding: 12px;
  text-align: left;
  font-weight: 750;
}
.sidebar button.is-active {
  border-color: rgba(32, 199, 181, 0.32);
  background: rgba(32, 199, 181, 0.12);
  color: var(--ink);
}
.usage-card {
  margin-top: 28px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  padding: 16px;
}
.usage-card span, .usage-card small { color: var(--muted); font-size: 0.78rem; font-weight: 750; }
.usage-card strong { display: block; margin: 8px 0; font-family: var(--mono); font-size: 2rem; }
.usage-card i { display: block; height: 8px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.1); }
.usage-card em { display: block; height: 100%; background: var(--teal); }

.console { padding: 24px; min-width: 0; }
.console-top {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}
.console-top span, .panel-head span, .request-card span, .score-card span {
  color: var(--teal);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: .05em;
  text-transform: uppercase;
}
h1 {
  margin: 4px 0 0;
  font-family: var(--mono);
  font-size: clamp(2.4rem, 5vw, 5.4rem);
  line-height: .88;
}
.run-button {
  border: 0;
  border-radius: 12px;
  background: var(--teal);
  color: #06100f;
  padding: 13px 18px;
  font-weight: 850;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(320px, .9fr) minmax(380px, 1.15fr) 320px;
  gap: 16px;
}
.composer, .answer, .trust-panel, .sources-panel, .json-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  padding: 16px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.panel-head b { font-family: var(--mono); }
textarea {
  width: 100%;
  min-height: 170px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #090a0c;
  color: var(--ink);
  padding: 14px;
  line-height: 1.45;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 12px 0;
}
label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
}
select, input[type="range"] {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #090a0c;
  color: var(--ink);
  padding: 0 10px;
  accent-color: var(--teal);
}
.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  grid-column: 1 / -1;
}
.request-card, .answer-box, .source-detail, .json-panel pre {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #090a0c;
  padding: 14px;
}
pre { white-space: pre-wrap; color: #d7fff9; font-family: var(--mono); font-size: .82rem; line-height: 1.45; }
.answer-box {
  min-height: 270px;
  color: rgba(245,245,240,.86);
  line-height: 1.5;
}
.answer-box p { margin-top: 0; }
.answer-box mark {
  border-radius: 6px;
  background: rgba(32,199,181,.18);
  color: #d9fffb;
  padding: 1px 5px;
}
.citation-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.citation-row button {
  border: 1px solid rgba(32,199,181,.28);
  border-radius: 999px;
  background: rgba(32,199,181,.1);
  color: #d9fffb;
  padding: 8px 10px;
  font-size: .78rem;
  font-weight: 800;
}
.score-card {
  border: 1px solid rgba(32,199,181,.36);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(32,199,181,.16), transparent);
  padding: 16px;
}
.score-card strong {
  display: block;
  margin: 6px 0;
  color: var(--teal);
  font-family: var(--mono);
  font-size: 4rem;
  line-height: .9;
}
.score-card small { color: var(--muted); font-weight: 800; }
.checks { display: grid; gap: 9px; margin-top: 12px; }
.checks div {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #090a0c;
  padding: 12px;
}
.checks b, .checks span { display: block; }
.checks span { margin-top: 4px; color: var(--muted); font-size: .78rem; font-weight: 760; }
.checks div::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--teal);
}
.checks .warn::before { background: var(--warn); }

.lower-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
.source-detail strong, .source-detail p, .source-detail span { display: block; }
.source-detail p { color: rgba(245,245,240,.82); font-weight: 720; }
.source-detail span { color: var(--muted); font-size: .82rem; font-weight: 800; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .workbench { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .console { padding: 14px; }
  .console-top, .lower-grid { grid-template-columns: 1fr; display: grid; }
  .settings-grid { grid-template-columns: 1fr; }
}
