:root {
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-head: #f1f5f9;
  --color-text: #0f172a;
  --color-muted: #475569;
  --color-border: #e2e8f0;
  --color-primary: #0f6e66;
  --color-primary-hover: #0b564f;
  --color-on-primary: #f4fffc;
  --color-primary-soft: #e6f4f1;
  --color-sidebar: #0f172a;
  --color-sidebar-text: #e2e8f0;
  --color-sidebar-muted: #94a3b8;
  --color-sidebar-line: #334155;
  --color-sidebar-active: rgb(45 212 191 / 16%);
  --color-sidebar-active-text: #ccfbf1;
  --color-sidebar-mark: #2dd4bf;
  --scrollbar-thumb: #cbd5e1;
  --scrollbar-thumb-hover: #94a3b8;
  color-scheme: light;
  --color-danger-bg: #fee2e2;
  --color-danger: #7f1d1d;
  --color-band-stark: #0f6e66;
  --color-band-mittel: #0f172a;
  --color-band-leicht: #475569;
  --color-band-kalt: #64748b;
  --font-sans: "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
  --radius: 8px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --duration: 150ms;
  color: var(--color-text);
  background: var(--color-bg);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
}

html[data-theme="dark"] {
    --color-bg: #0b1220;
    --color-surface: #111827;
    --color-head: #1e293b;
    --color-text: #e5e7eb;
    --color-muted: #94a3b8;
    --color-border: #334155;
    --color-primary: #2dd4bf;
    --color-primary-hover: #5eead4;
    --color-on-primary: #042f2e;
    --color-primary-soft: #134e4a;
    --color-sidebar: #020617;
    --color-danger-bg: #450a0a;
    --color-danger: #fecaca;
    --color-band-stark: #5eead4;
    --scrollbar-thumb: #475569;
    --scrollbar-thumb-hover: #64748b;
    color-scheme: dark;
    --color-band-mittel: #e5e7eb;
    --color-band-leicht: #94a3b8;
    --color-band-kalt: #64748b;
}

* { box-sizing: border-box; }

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

*::-webkit-scrollbar { width: 10px; height: 10px; }

*::-webkit-scrollbar-track { background: transparent; }

*::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
  background-clip: padding-box;
}

*::-webkit-scrollbar-corner { background: transparent; }

body {
  margin: 0;
  min-height: 100dvh;
  padding-bottom: 96px;
  background: var(--color-bg);
  color: var(--color-text);
}

button, input, select { font: inherit; color: inherit; }

button { cursor: pointer; }

button, tbody tr, a {
  transition: background-color var(--duration) ease;
}

button:active:not(:disabled) { transform: translateY(1px); }

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.dock {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: calc(100vw - 24px);
  padding: 6px 6px 6px 14px;
  border-radius: 999px;
  background: var(--color-sidebar);
  color: var(--color-sidebar-text);
  box-shadow: 0 12px 32px rgb(2 6 23 / 28%), 0 0 0 1px rgb(255 255 255 / 8%);
}

.brand {
  margin: 0 10px 0 2px;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.dock nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.dock nav button {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: transparent;
  color: var(--color-sidebar-muted);
  white-space: nowrap;
}

.dock nav button:hover { background: rgb(255 255 255 / 6%); color: var(--color-sidebar-text); }

.dock button:focus-visible { outline-color: var(--color-sidebar-mark); }

.dock nav button[aria-current="page"] {
  background: var(--color-sidebar-active);
  color: var(--color-sidebar-active-text);
}

.dock nav button[aria-current="page"]:hover { background: rgb(45 212 191 / 22%); }

.dock-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
  padding-left: 6px;
  border-left: 1px solid var(--color-sidebar-line);
}

.dock-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--color-sidebar-text);
}

.dock-icon:hover { background: rgb(255 255 255 / 8%); }

.dock-icon.is-busy,
.dock-icon.is-busy:disabled { padding-right: 0; }

.dock-icon.is-busy::after { content: none; }

.dock-icon.is-busy .icon { animation: spin 0.7s linear infinite; }

.icon-button.is-busy,
.icon-button.is-busy:disabled { padding-right: 0; opacity: 1; }

.icon-button.is-busy::after { content: none; }

.icon-button.is-busy .icon { animation: spin 0.7s linear infinite; }

.theme-float {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
}

main {
  padding: var(--space-5) 28px 40px;
  min-width: 0;
}

h1 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.lede {
  margin: 0 0 var(--space-4);
  max-width: 65ch;
  color: var(--color-muted);
}

.cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  margin-bottom: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-surface);
}

.card {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--color-border);
  border-radius: 0;
  padding: 12px 14px;
}

.card:last-child { border-right: 0; }

.card strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.card span { font-weight: 650; }

.card small {
  display: block;
  margin-top: 4px;
  color: var(--color-muted);
  font-size: 12px;
  line-height: 1.35;
}

.card:hover { background: var(--color-head); }

.card.active { box-shadow: inset 3px 0 0 var(--color-primary); }

.chart-row {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(280px, 1.5fr) minmax(220px, 0.9fr);
  gap: 12px;
  margin: 0 0 var(--space-4);
}

.chart-card {
  min-width: 0;
  padding: 12px 14px 10px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-surface);
}

.chart-card h2 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.band-list { display: flex; flex-direction: column; gap: 2px; }

.band-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 5px 6px;
  text-align: left;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.band-row:hover,
.band-row[aria-pressed="true"] { background: var(--color-primary-soft); }

.band-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 650;
}

.band-track {
  display: block;
  height: 7px;
  border-radius: 999px;
  background: var(--color-head);
  overflow: hidden;
}

.band-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--color-primary);
}

.band-row.is-dim,
.months button.is-dim,
.seg.is-dim,
.legend-key.is-dim { opacity: 0.38; }

.month-scroll { overflow-x: auto; }

.months,
.year-axis { min-width: calc(var(--bars, 12) * 14px); }

.months {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 96px;
}

.month-plot.is-tall .months { height: 132px; }

.months button {
  flex: 1 1 0;
  align-self: stretch;
  display: flex;
  align-items: flex-end;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 4px 4px 0 0;
  background: transparent;
}

.months button span {
  display: block;
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 1px 1px;
  background: var(--color-primary);
}

.months button.is-zero span { background: var(--color-border); }

.months button:hover span,
.months button:focus-visible span,
.months button[aria-pressed="true"] span { background: var(--color-primary-hover); }

.year-axis {
  position: relative;
  height: 16px;
  margin-top: 4px;
}

.year-axis span {
  position: absolute;
  top: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-muted);
}

.month-caption {
  margin: 6px 0 0;
  min-height: 1.2em;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-muted);
}

.mix { display: flex; flex-direction: column; gap: 12px; }

.mix-title {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 650;
  color: var(--color-muted);
}

.stack {
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--color-head);
}

.seg {
  flex: 1 1 0;
  min-width: 8px;
  padding: 0;
  border: 0;
  background: var(--color-primary);
}

.seg-free { background: color-mix(in srgb, var(--color-primary) 48%, var(--color-bg)); }

.seg-other,
.seg-no { background: color-mix(in srgb, var(--color-muted) 35%, var(--color-bg)); }

.mix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 6px;
}

.legend-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--color-text);
  font-size: 12px;
}

.legend-key[aria-pressed="true"] { color: var(--color-primary); font-weight: 650; }

.swatch {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--color-primary);
}

.swatch.seg-free { background: color-mix(in srgb, var(--color-primary) 48%, var(--color-bg)); }

.swatch.seg-other,
.swatch.seg-no { background: color-mix(in srgb, var(--color-muted) 45%, var(--color-bg)); }

.context:empty { display: none; }

.context {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip button {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 650;
}

.chip .icon { width: 12px; height: 12px; }

.chip-x { display: inline-flex; }

.drill-count {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 650;
  letter-spacing: -0.04em;
  line-height: 1;
}

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.crumbs .chip[aria-current="true"] { box-shadow: inset 0 0 0 1px var(--color-primary); }

.rules {
  margin: 4px 0 var(--space-4);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  padding: 0 14px 2px;
}

.rules summary {
  cursor: pointer;
  padding: 12px 0;
  font-weight: 650;
}

.rules .note { margin: 0 0 12px; color: var(--color-muted); }

.filterbar {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: var(--space-4);
  background: transparent;
}

.filter-line {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 14px;
}

.filter-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0;
}

.filter-foot > button { margin-left: auto; }

.filter-foot .field.check { margin-right: auto; padding: 0; border: 0; flex: none; }

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--color-muted);
}

.filterbar .field {
  min-width: 0;
  padding: 0;
  border: 0;
}

.field.grow input,
.filterbar input[type="number"],
.filterbar input[type="date"],
.filterbar input[type="search"] { width: 100%; }

input {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px 10px;
  min-height: 36px;
}

.menu { position: relative; min-width: 0; }

.menu-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  text-align: left;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.menu-button:hover { background: var(--color-head); }

.menu.open .menu-button { border-color: var(--color-primary); }

.menu-value {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.menu-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.menu-count {
  flex: none;
  margin-left: auto;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--color-muted);
}

.menu-button::after {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin-top: -3px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.55;
}

.menu-panel {
  position: absolute;
  z-index: 8;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  min-width: min(100%, 220px);
  max-width: min(320px, calc(100vw - 24px));
  max-height: 280px;
  overflow: auto;
  padding: 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgb(15 23 42 / 12%);
}

.menu-panel.up { top: auto; bottom: calc(100% + 4px); }

.menu-find {
  position: sticky;
  top: 0;
  width: 100%;
  margin-bottom: 4px;
  background: var(--color-surface);
}

.menu-option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 8px 10px;
  text-align: left;
  border: 0;
  border-radius: 6px;
  background: transparent;
}

.menu-option:hover { background: var(--color-head); }

.menu-option[aria-selected="true"] {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.menu-option[aria-selected="true"] .menu-count { color: inherit; }

.menu-empty { margin: 8px 10px; color: var(--color-muted); }

.pager .menu { width: 148px; flex: 0 0 148px; }

.icon { width: 16px; height: 16px; display: block; }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
}

.icon-button.plain { border-color: transparent; }

.icon-button:hover { background: var(--color-head); }

td .icon-button { margin-top: 4px; }

.mail {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.mail a, .mail > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail .icon-button { margin-top: 0; flex: none; }

.tick {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.tick input {
  position: absolute;
  width: 16px;
  height: 16px;
  margin: 0;
  opacity: 0;
}

.tick-box {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border: 1.5px solid var(--color-muted);
  border-radius: 4px;
  background: var(--color-surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tick:hover .tick-box { border-color: var(--color-primary); }

.tick input:checked + .tick-box {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.tick input:checked + .tick-box::after {
  content: "";
  width: 4px;
  height: 8px;
  margin-top: -2px;
  border-right: 2px solid var(--color-on-primary);
  border-bottom: 2px solid var(--color-on-primary);
  transform: rotate(45deg);
}

.tick input:focus-visible + .tick-box {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

input[type="number"] { width: 88px; }

.field.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
  padding-bottom: 8px;
  color: var(--color-text);
  font-size: 14px;
}

.toolbar, .pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-3) 0;
}

.actions, .pager { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }

.primary, .ghost, .chip {
  border-radius: var(--radius);
  padding: 8px 12px;
}

.primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
  border: 0;
}

.primary:hover { background: var(--color-primary-hover); }

.ghost {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.ghost:hover { background: var(--color-head); }

.chip {
  border: 1px solid var(--color-primary);
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

button:disabled { opacity: 0.45; cursor: default; }

button.is-busy,
button.is-busy:disabled {
  opacity: 1;
  cursor: progress;
  position: relative;
  padding-right: 34px;
}

button.is-busy::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}

table { width: 100%; border-collapse: separate; border-spacing: 0; }

th, td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  background: var(--color-head);
  z-index: 1;
  font-size: 12px;
  font-weight: 650;
  color: var(--color-muted);
}

th button {
  border: 0;
  background: transparent;
  padding: 0;
  font-weight: 650;
  color: inherit;
}

td.num, th.num, .score {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

th.num button { width: 100%; text-align: right; }

tbody tr { cursor: pointer; }

tbody tr:hover { background: var(--color-head); }

tbody tr.open { background: var(--color-primary-soft); }

.name { font-weight: 650; }

.sub { color: var(--color-muted); font-size: 12px; margin-top: 2px; }

.clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

a { color: var(--color-primary); }

.band {
  display: block;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.band-stark { color: var(--color-band-stark); }
.band-mittel { color: var(--color-band-mittel); }
.band-leicht { color: var(--color-band-leicht); }
.band-kalt { color: var(--color-band-kalt); }

.score-line {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
  white-space: nowrap;
}

.score { font-size: 15px; font-weight: 650; }

.score-of { font-size: 11px; color: var(--color-muted); }

.score-line .band { display: inline; }

.score-picture { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 16px; }

.score-head { display: flex; align-items: baseline; gap: 8px; }

.score-head strong {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.score-head span { color: var(--color-muted); }

#detail h3 {
  margin: 4px 0 8px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.meter {
  height: 6px;
  border-radius: 999px;
  background: var(--color-head);
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--color-primary);
  border-radius: inherit;
}

.score-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.score-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.score-list b {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.score-list li.empty { color: var(--color-muted); }

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin: 12px 0 16px;
}

.facts div { min-width: 0; }

.facts dt {
  margin: 0;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.facts dd {
  margin: 2px 0 0;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.chat-toggle {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--color-primary);
  font-family: var(--font-mono);
  font-weight: 650;
}

.chat-toggle[aria-expanded="true"] { text-decoration: underline; }

.empty, .boot, .foot { color: var(--color-muted); }

#detail {
  position: fixed;
  top: 12px;
  right: 12px;
  width: min(480px, calc(100vw - 24px));
  height: calc(100dvh - 96px);
  overflow: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgb(15 23 42 / 16%);
  padding: 16px 18px 20px;
  z-index: 4;
}

#detail[hidden] { display: none; }

.detail-head,
.detail-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  position: sticky;
  top: -16px;
  z-index: 2;
  margin: 0 -18px;
  background: var(--color-surface);
  padding: 2px 18px 12px;
}

.detail-identity { min-width: 0; }

.detail-identity h2,
#detail h2 { margin: 2px 0 4px; }

.detail-identity .band,
.detail-top .band { display: inline; }

.detail-identity a,
.detail-identity p { margin: 0; overflow-wrap: anywhere; }

.detail-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.detail-tools .icon-button {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-color: transparent;
  color: var(--color-muted);
}

.detail-tools .icon { width: 15px; height: 15px; }

.detail-tools .icon-button:hover {
  background: var(--color-head);
  color: var(--color-text);
}

.panel-card {
  margin: 0 0 12px;
  padding: 12px 14px 4px;
  border-radius: 12px;
  background: var(--color-head);
}

.panel-card .facts,
.panel-card .score-picture { margin: 0 0 8px; }

.panel-card .meter { background: var(--color-surface); }

.panel-card .plain,
.panel-card table { background: transparent; }

body.panel-open { overflow: hidden; }

#detail h2 {
  margin: 2px 0 4px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.detail-actions, .meta { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }

.meta { color: var(--color-muted); margin: 10px 0; }

.scroll-table {
  overflow: visible;
  border: 0;
}

.scroll-table table { font-size: 13px; }

#detail table.plain { width: 100%; border-collapse: collapse; }

.session-chat td {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.thread { display: flex; flex-direction: column; gap: 8px; }

.bubble {
  margin: 0;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.bubble time {
  display: block;
  margin-bottom: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-muted);
}

.bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.more-chats { align-self: flex-start; }

#error, .form-error {
  color: var(--color-danger);
}

#error {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  background: var(--color-danger-bg);
  padding: 10px 14px;
  border-radius: var(--radius);
  z-index: 7;
}

.gate {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  min-height: 100dvh;
}

.gate-copy {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  padding: 40px 48px;
  background: var(--color-sidebar);
  color: var(--color-sidebar-text);
}

.gate-copy h1 {
  margin: 0;
  font-size: 40px;
  letter-spacing: -0.03em;
  color: var(--color-sidebar-text);
}

.gate-copy p:last-child {
  margin: 0;
  max-width: 36ch;
  color: var(--color-sidebar-muted);
}

.gate-form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-4);
  width: 100%;
  padding: 40px 48px;
  background: var(--color-surface);
}

.gate-form .field { max-width: 360px; }

.gate-form .primary { align-self: flex-start; }

.help { margin: 4px 0 0; color: var(--color-muted); }

.form-error { margin: 0; }

@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { border-bottom: 1px solid var(--color-border); }
}

@media (max-width: 860px) {
  body { padding-bottom: 108px; }
  .dock { left: 12px; right: 12px; transform: none; width: auto; padding-left: 8px; }
  .brand { display: none; }
  .dock nav { flex: 1; }
  .dock nav button { flex: 1; text-align: center; padding: 8px 6px; }
  main { padding: 16px 14px 24px; }
  .filter-line { grid-template-columns: 1fr; }
  .chart-row { grid-template-columns: 1fr; }
  #detail {
    top: auto;
    right: 12px;
    left: 12px;
    bottom: 84px;
    width: auto;
    height: auto;
    max-height: calc(100dvh - 108px);
  }
  .gate { display: flex; flex-direction: column; }
  .gate-copy { padding: 28px 16px; }
  .gate-copy h1 { font-size: 32px; }
  .gate-form { flex: 1; padding: 24px 16px 40px; }
}

@media (prefers-reduced-motion: reduce) {
  button, tbody tr, a { transition: none; }
  button:active:not(:disabled) { transform: none; }
  button.is-busy::after { animation: none; opacity: 0.65; }
}
