/* Actif uniquement sur body.ds. Voir docs/design-system.md. */

body.ds {
  --bg: #14171c;
  --bg-raised: #1c2026;
  --bg-sunken: #0e1114;
  --bg-hover: #262b33;
  --line: #2c313a;
  --text: #d5d8e0;
  --muted: #8b909a;
  --accent: #3d7eff;
  --up: #2ec4b6;
  --down: #ff6b6b;
  --rail: 168px;
  --bar: 32px;
  --inspector: 280px;
  --tape: 168px;
  margin: 0;
  height: 100vh;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font: 400 13px/1.35 Inter, "Segoe UI", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  color-scheme: dark;
}

body.ds .top,
body.ds #nav { display: none; }

body.ds #app {
  max-width: none;
  height: 100vh;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
}

body.ds .term {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
}

body.ds .rail {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  padding: 8px;
  background: var(--bg-raised);
  border-right: 1px solid var(--line);
  border-bottom: 0;
}

body.ds .rail a {
  display: block;
  padding: 6px 8px;
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
}

body.ds .mark {
  margin: 4px 8px 12px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

body.ds .rail a:hover { background: var(--bg-hover); color: var(--text); }
body.ds .rail a[aria-current="page"] {
  background: rgba(61, 126, 255, 0.16);
  color: var(--text);
  border-left: 2px solid var(--accent);
  padding-left: 6px;
}

body.ds .workspace {
  display: grid;
  grid-template-rows: var(--bar) minmax(0, 1fr) 4px var(--tape);
  min-width: 0;
  min-height: 0;
}

body.ds .topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
}

body.ds .topbar .product { font-weight: 500; }
body.ds .hint { color: var(--muted); }
body.ds .topbar .spacer { flex: 1; }
body.ds .sep { width: 1px; height: 14px; background: var(--line); }

body.ds .ghost {
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

body.ds .ghost:hover { background: var(--bg-hover); }
body.ds .ghost[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

body.ds .stage-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 4px var(--inspector);
  min-height: 0;
}

body.ds .stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--bg-sunken);
}

body.ds .stage-grid {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right, rgba(255, 255, 255, 0.04) 1px, transparent 1px) 0 0 / 80px 100%,
    linear-gradient(to bottom, rgba(255, 255, 255, 0.04) 1px, transparent 1px) 0 0 / 100% 40px;
  pointer-events: none;
}

body.ds .stage-empty {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  padding: 16px;
}

body.ds .kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

body.ds .stage-title { margin: 0; font-size: 16px; font-weight: 500; }
body.ds .stage-note { max-width: 520px; margin: 8px 0 0; color: var(--muted); }

body.ds .splitter {
  background: var(--line);
  cursor: col-resize;
}
body.ds .splitter-y { cursor: row-resize; }
body.ds .splitter:hover { background: var(--accent); }

body.ds .inspector,
body.ds .tape {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: var(--bg-raised);
}

body.ds .inspector { padding: 8px 12px 12px; }
body.ds .tape { padding: 0; }

body.ds .kv {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

body.ds .kv span:first-child { color: var(--muted); }
body.ds .kv span:last-child { text-align: right; }
body.ds .kv-value { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; }

body.ds .dot {
  width: 6px;
  height: 6px;
  background: var(--muted);
}
body.ds .dot.up { background: var(--up); }
body.ds .dot.down { background: var(--down); }

body.ds .source-list { margin: 8px 0 0; padding: 0; list-style: none; }
body.ds .source-list li {
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}

body.ds table {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  border-collapse: collapse;
  display: table;
}

body.ds th,
body.ds td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  white-space: nowrap;
}

body.ds th {
  position: sticky;
  top: 0;
  background: var(--bg-raised);
  color: var(--muted);
  font-weight: 500;
  text-align: left;
}

body.ds td.num,
body.ds th.num { text-align: right; }
body.ds tbody tr:hover td { background: var(--bg-hover); }
body.ds .up { color: var(--up); }
body.ds .down { color: var(--down); }

body.ds .page-wrap {
  display: grid;
  grid-template-rows: var(--bar) minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

body.ds .page {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 16px;
}

body.ds h1 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 500;
}

body.ds h2 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 500;
}

body.ds p { margin: 0 0 8px; }
body.ds .muted { color: var(--muted); }

body.ds form,
body.ds .card {
  margin: 0 0 12px;
  padding: 12px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 2px;
}

body.ds form { max-width: 520px; }
body.ds .card { max-width: none; }

body.ds label {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

body.ds label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 8px;
}

body.ds input,
body.ds select {
  height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--bg-sunken);
  color: var(--text);
  font: inherit;
}

body.ds input[type="checkbox"] {
  width: 14px;
  height: 14px;
  padding: 0;
}

body.ds button,
body.ds .button {
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--accent);
  border-radius: 2px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-size: 12px;
  line-height: 22px;
  text-decoration: none;
  cursor: pointer;
}

body.ds button.secondary,
body.ds button.ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--text);
}

body.ds button:hover,
body.ds .button:hover { filter: brightness(1.08); }

body.ds .row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

body.ds .page a {
  color: var(--accent);
  background: transparent;
  border-radius: 0;
  padding: 0;
}

body.ds .error { color: var(--down); }

body.ds pre {
  margin: 8px 0 0;
  padding: 8px;
  overflow: auto;
  background: var(--bg-sunken);
  color: var(--text);
  border-radius: 2px;
  white-space: pre-wrap;
}

body.ds .login {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

body.ds .login form { width: min(360px, 100%); }

body.ds :focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

@media (max-width: 800px) {
  body.ds { height: auto; overflow: auto; }
  body.ds .term,
  body.ds .workspace,
  body.ds .page-wrap,
  body.ds .stage-row { display: block; height: auto; }
  body.ds .stage { height: 280px; }
  body.ds .splitter { display: none; }
}
