:root {
  --bg: #101114;
  --raised: #191c22;
  --raised-2: #21262e;
  --line: rgba(236, 232, 223, 0.12);
  --text: #ece8df;
  --muted: #a39e93;
  --faint: #736e66;
  --accent: #f3f0e7;
  --danger: #e36a5d;
  --danger-dim: rgba(227, 106, 93, 0.14);
  --ok: #8fbf9a;
  --ok-dim: rgba(143, 191, 154, 0.14);
  --warn: #e2b15a;
  --warn-dim: rgba(226, 177, 90, 0.16);
  --info: #8eb4d6;
  --info-dim: rgba(142, 180, 214, 0.14);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", "Times New Roman", serif;
  --sans: "Avenir Next", "Segoe UI", sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(900px 420px at -10% -20%, rgba(243, 240, 231, 0.07), transparent 55%),
    var(--bg);
}

button, input, textarea, select { font: inherit; color: inherit; }

button { cursor: pointer; }

.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.login-card, .panel, .log, .topic, .example, .chat-row {
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.login-card {
  width: min(440px, 100%);
  padding: 32px;
  box-shadow: var(--shadow);
}

.eyebrow, .brand-sub, .section-kicker {
  margin: 0;
  color: var(--faint);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
}

h1, h2, .brand-name {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.03em;
}

h1 { font-size: 40px; margin: 8px 0 8px; }

h2 { font-size: 32px; margin: 0; }

.lede, .hint, .muted { color: var(--muted); }

.lede { margin: 0 0 22px; line-height: 1.45; }

label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

input, textarea, select {
  width: 100%;
  background: #12141a;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}

textarea { min-height: 120px; resize: vertical; line-height: 1.45; }

input:focus, textarea:focus, select:focus {
  border-color: rgba(243, 240, 231, 0.45);
}

.primary, .danger, .ghost, .textish {
  border-radius: 999px;
  padding: 10px 16px;
}

.primary {
  background: var(--accent);
  color: #161616;
  border: 0;
  font-weight: 650;
}

.danger {
  background: var(--danger);
  color: white;
  border: 0;
}

.ghost, .textish {
  background: transparent;
  border: 1px solid var(--line);
}

.textish { border: 0; color: var(--muted); padding-inline: 8px; }

.primary:disabled, .danger:disabled, .ghost:disabled { opacity: 0.55; cursor: wait; }

.form-error { min-height: 1.2em; color: var(--danger); margin: 10px 0; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
}

aside {
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px; }

.mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(236, 232, 223, 0.45);
  border-radius: 12px;
  font-family: var(--serif);
}

.brand-name { font-size: 22px; line-height: 1; }
.brand-sub { margin-top: 4px; }

nav { display: grid; gap: 4px; }

nav button {
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--muted);
}

nav button.active {
  background: var(--raised);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--accent);
}

.aside-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.status-pill {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--raised);
  color: var(--muted);
}

.status-pill.on { color: var(--ok); background: var(--ok-dim); }
.status-pill.off { color: var(--danger); background: var(--danger-dim); }

main { min-width: 0; }

#view { padding: 32px 36px 64px; max-width: 1080px; }

.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; margin-bottom: 22px; }

.page-head p { margin: 8px 0 0; max-width: 62ch; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.stat b { display: block; font-size: 28px; font-family: var(--serif); font-weight: 600; margin-top: 6px; }
.stat span { color: var(--muted); font-size: 13px; }

.banner {
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 12px;
  line-height: 1.45;
}

.banner strong { display: block; margin-bottom: 4px; }
.banner.warn { background: var(--warn-dim); }
.banner.bad { background: var(--danger-dim); }
.banner.ok { background: var(--ok-dim); }
.banner.info { background: var(--info-dim); }

.grid-2 { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 14px; }
.stack { display: grid; gap: 12px; }

.panel { padding: 18px; }
.panel h3 { margin: 0 0 8px; font-size: 18px; font-family: var(--serif); }
.hint { margin: 0 0 14px; font-size: 14px; line-height: 1.45; }

.row-actions, .filters, .inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.filters { margin-bottom: 14px; }

.chip {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--muted);
}

.chip.active { color: #161616; background: var(--accent); border-color: transparent; }

.check-result, .log, .topic, .example, .chat-row { padding: 14px 16px; }

.log { border-left-width: 3px; border-left-style: solid; }
.log.decision-violation { border-left-color: var(--danger); }
.log.decision-allow { border-left-color: var(--ok); }
.log.decision-review { border-left-color: var(--warn); }
.log.decision-error { border-left-color: var(--danger); }
.log.decision-skipped, .log.decision-pending { border-left-color: var(--info); }

.log header, .topic header, .example header, .who-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pill {
  font-size: 12px;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--raised-2);
}

.pill.violation { background: var(--danger-dim); color: #ffc7c1; }
.pill.allow { background: var(--ok-dim); color: #d5efe0; }
.pill.review { background: var(--warn-dim); color: #ffe3b0; }
.pill.error { background: var(--danger-dim); color: #ffc7c1; }
.pill.human { background: var(--info-dim); color: #d6e8f6; }

.mono, .model { font-family: var(--mono); font-size: 12px; color: var(--muted); }

.message-text {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 10px 0;
  line-height: 1.45;
  max-height: 220px;
  overflow: auto;
}

.reason { margin: 0; color: var(--muted); line-height: 1.45; }
.primary-reason { margin: 6px 0 0; color: var(--faint); font-size: 13px; }

.topic p, .example p { margin: 8px 0; white-space: pre-wrap; }

.switch {
  border-radius: 999px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}

.switch.on { color: #d5efe0; background: var(--ok-dim); border-color: transparent; }

dialog {
  width: min(520px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #1b1e25;
  color: var(--text);
  padding: 20px;
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(0, 0, 0, 0.62); }

dialog h3 { font-family: var(--serif); margin: 0 0 8px; }

#toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  z-index: 20;
}

.toast {
  background: #2a241c;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  max-width: 360px;
  box-shadow: var(--shadow);
}

.toast.bad { background: #3a221f; }
.toast.ok { background: #1d2a22; }

.check-box textarea { min-height: 90px; }

.range-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.range-row input[type="range"] { padding: 0; }

.empty {
  padding: 28px 8px;
  color: var(--muted);
}

.chat-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.chat-row b { display: block; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  aside { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  nav { grid-auto-flow: column; overflow: auto; }
  .aside-foot { margin-top: 0; }
  #view { padding: 22px 16px 48px; }
  .stats, .grid-2 { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; }
}
