/* ============================================================
   Coframe Devtool — a floating rail with a slide-out drawer
   Tokens extracted from the MagicPath source; see brand-spec.md
   ============================================================ */

/* ---------- 1. Tokens ---------- */
:root {
  --bg:          oklch(16.5% 0.004 300);
  --surface:     oklch(19.5% 0.004 300);
  --surface-2:   oklch(23.5% 0.005 290);
  --surface-3:   oklch(26.5% 0.005 290);
  --fg:          oklch(96.5% 0.004 300);
  --fg-2:        oklch(84% 0.005 300);
  --muted:       oklch(63% 0.008 300);
  --muted-2:     oklch(52% 0.008 300);
  --border:      oklch(30% 0.006 295);
  --border-soft: oklch(25% 0.005 295);

  --accent:      oklch(60% 0.20 282);
  --accent-soft: oklch(72% 0.13 285);
  --accent-pill: oklch(35% 0.10 285);

  --ok:     oklch(72% 0.18 150);
  --warn:   oklch(80% 0.14 78);
  --danger: oklch(72% 0.16 20);

  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
  --font-body:    -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  --font-mono:    ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace;

  --r-panel: 6px;
  --r-card:  5px;
  --r-ctrl:  4px;

  --rail-w: 56px;
  --bar-h:  40px;

  /* Drawer size. The rail is the anchor; the drawer attaches flush to it. */
  --panel-w: 720px;
  --panel-h: 560px;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg);
  background: oklch(97% 0.003 260);
  overflow: hidden;
}

[hidden] { display: none !important; }

::selection { background: color-mix(in oklch, var(--accent) 45%, transparent); }

:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 1px;
  border-radius: var(--r-ctrl);
}

/* ---------- 2. Host page (the customer's site under the devtool) ---------- */
.host {
  position: absolute;
  inset: 0;
  overflow: auto;
  background: oklch(97% 0.003 260);
  color: oklch(38% 0.01 260);
  padding-bottom: 96px;
}

.host__bar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 40px;
  height: 56px;
  border-bottom: 1px solid oklch(90% 0.004 260);
  background: oklch(100% 0 0);
  font-size: 13px;
}

.host__logo {
  font-weight: 650;
  letter-spacing: -0.02em;
  color: oklch(25% 0.01 260);
  font-size: 15px;
}

.host__links { display: flex; gap: 20px; color: oklch(55% 0.01 260); }

.host__main { max-width: 940px; margin: 0 auto; padding: 56px 40px 0; }

.host__eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: oklch(62% 0.01 260);
}

.host__h1 {
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: -0.025em;
  margin: 12px 0 14px;
  color: oklch(24% 0.012 260);
  max-width: 18ch;
  text-wrap: balance;
}

.host__p { max-width: 46ch; color: oklch(48% 0.01 260); margin: 0 0 24px; }

.host__cta {
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 20px;
  border-radius: 7px;
  background: oklch(28% 0.012 260);
  color: oklch(99% 0 0);
  font-weight: 550;
  font-size: 13px;
  border: 0;
  cursor: pointer;
}

.host__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 44px;
}

.host__tile {
  border: 1px solid oklch(91% 0.004 260);
  border-radius: 10px;
  background: oklch(100% 0 0);
  padding: 18px;
}

.host__block {
  background: oklch(93% 0.004 260);
  border-radius: 4px;
  height: 8px;
}
.host__block--img { height: 76px; margin-bottom: 14px; border-radius: 6px; }
.host__block--w70 { width: 70%; margin-bottom: 8px; }
.host__block--w45 { width: 45%; }

/* Inspector highlight drawn on a real host element */
.host .is-inspected {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  position: relative;
}
.host .is-inspected::after {
  content: attr(data-selector);
  position: absolute;
  left: -2px;
  top: -24px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  background: var(--accent);
  color: oklch(99% 0 0);
  padding: 3px 7px;
  border-radius: 4px 4px 4px 0;
  white-space: nowrap;
}

/* ---------- 3. The devtool: a rail, and a drawer off it ------------------
   Invoking the devtool puts a vertical icon rail on the page, sitting above
   the collapsed launcher puck. Picking a tool slides its panel out beside
   the rail — toward whichever side has room. At rest there is only the rail. */
.dock {
  position: fixed;
  right: 18px;           /* centres the 56px rail over the 44px puck */
  bottom: 84px;          /* clears the puck plus its 24px margin */
  width: var(--rail-w);
  font-family: var(--font-body);
  z-index: 40;
}

/* With a tool open the assembly grows to the drawer's height and the rail
   stretches with it, so the two read as one object rather than two. */
.dock:has(.panel) {
  height: var(--panel-h);
  max-height: calc(100vh - 108px);
  filter: drop-shadow(0 24px 60px oklch(0% 0 0 / 0.5));
}

/* ---------- 4. The rail --------------------------------------------------
   A free-standing column, not a sidebar inside a window. It is the whole
   devtool when nothing is open, and the anchor everything else hangs off. */
.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: var(--rail-w);
  height: 100%;
  padding: 8px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Standalone it hugs its icons, carries its own shadow, and is rounded on all
   four corners at the same 6px every other surface uses. */
.dock:not(:has(.panel)) .rail {
  height: auto;
  border-radius: 6px;
  box-shadow: 0 18px 44px oklch(0% 0 0 / 0.45);
}
.dock:not(:has(.panel)).is-dragging .rail { box-shadow: 0 24px 56px oklch(0% 0 0 / 0.52); }

/* Attached it is chrome: full height, darker than the drawer body, and only
   its outer corners are round — the joint stays square so the seam reads
   as one continuous window rather than two cards touching. */
.dock:has(.panel) .rail { background: var(--bg); }
.dock[data-side="left"]:has(.panel)  .rail { border-radius: 0 6px 6px 0; border-left: 0; }
.dock[data-side="right"]:has(.panel) .rail { border-radius: 6px 0 0 6px; border-right: 0; }

.dock.is-dragging .rail { cursor: grabbing; }

.rail__mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--fg);
  margin-bottom: 6px;
  flex: none;
}

.rail__nav { display: flex; flex-direction: column; align-items: center; gap: 4px; }

.rail__item {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease;
}
.rail__item:hover { background: var(--surface-2); color: var(--fg); }

/* The one accent moment in the devtool: the tool currently open. */
.rail__item[aria-current="page"] {
  background: var(--accent);
  color: oklch(99% 0 0);
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--accent) 20%, transparent);
}

.rail__badge {
  position: absolute;
  top: 2px;
  right: 1px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 3px;
  background: var(--surface-3);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 14px;
  text-align: center;
}
.rail__item[aria-current="page"] .rail__badge {
  background: oklch(99% 0 0);
  color: var(--accent);
}

/* Tooltips open toward the drawer side, so they never leave the viewport. */
.rail__item::after {
  content: attr(data-tip);
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--fg-2);
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: var(--r-ctrl);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 110ms ease;
  z-index: 5;
}
.dock[data-side="left"]  .rail__item::after { right: calc(100% + 8px); }
.dock[data-side="right"] .rail__item::after { left: calc(100% + 8px); }
.rail__item:hover::after, .rail__item:focus-visible::after { opacity: 1; }

/* ---------- 5. The slide-out drawer --------------------------------------
   Hangs off the rail on the side with more room, bottom-aligned with it. */
.panel {
  position: absolute;
  top: 0;
  bottom: 0;                 /* height comes from the assembly, not from here */
  width: var(--panel-w);
  /* --panel-max is the real room on the open side, written by JS on every
     placement; the fallback covers first paint before JS runs. */
  max-width: var(--panel-max, calc(100vw - var(--rail-w) - 36px));
  display: grid;
  grid-template-rows: var(--bar-h) minmax(0, 1fr);
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* Flush against the rail — no gap. The joint edge loses its border and its
   radius so the seam is a single hairline, not a double one. */
.dock[data-side="left"] .panel {
  right: 100%;
  border-radius: 6px 0 0 6px;
  animation: drawer-left 220ms cubic-bezier(.32, .72, 0, 1);
}
.dock[data-side="right"] .panel {
  left: 100%;
  border-radius: 0 6px 6px 0;
  animation: drawer-right 220ms cubic-bezier(.32, .72, 0, 1);
}

/* The slide is the one orchestrated motion on this screen. */
@keyframes drawer-left  { from { opacity: 0; transform: translateX(20px); }  to { opacity: 1; transform: none; } }
@keyframes drawer-right { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: none; } }

/* Toolbar — one row, replaces three stacked header rows */
/* The drawer's header. Dragging happens on the rail, not here. */
.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  min-width: 0;
}

.bar__title {
  font-size: 13px;
  font-weight: 620;
  letter-spacing: -0.01em;
  margin: 0;
  flex: none;
}

.bar__sep { width: 1px; height: 16px; background: var(--border); flex: none; }

.bar__host {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 550;
  color: var(--fg-2);
  flex: none;
}
.status__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ok) 18%, transparent);
}
.status--off .status__dot { background: var(--muted-2); box-shadow: none; }

.bar__spacer { flex: 1; min-width: 8px; }

.bar__actions { display: flex; align-items: center; gap: 1px; flex: none; }

.iconbtn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-ctrl);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.iconbtn:hover { background: var(--surface-2); color: var(--fg); }
.iconbtn[aria-pressed="true"] { background: color-mix(in oklch, var(--ok) 20%, transparent); color: var(--ok); }

/* ---------- 6. Body + regions ---------- */
.body {
  min-height: 0;
  min-width: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
  container-type: inline-size;
  container-name: panel;
}
.body--flush { overflow: hidden; display: grid; }

.cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0;
  min-height: 100%;
}
.col {
  min-width: 0;
  padding: 14px 16px 18px;
  border-right: 1px solid var(--border-soft);
}
.col:last-child { border-right: 0; }

.sec-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}
.sec-title__count {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--muted-2);
  letter-spacing: 0.04em;
}

/* ---------- 7. Tabs ---------- */
.tabs {
  display: inline-flex;
  gap: 1px;
  padding: 2px;
  background: var(--surface-2);
  border-radius: 5px;
  flex: none;
}
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.tab:hover { color: var(--fg-2); }
.tab[aria-selected="true"], .tab[aria-current="page"] { background: var(--surface-3); color: var(--fg); }

/* ---------- 8. Key/value data ---------- */
.kv {
  border: 1px solid var(--border-soft);
  border-radius: var(--r-card);
  background: var(--surface-2);
  overflow: hidden;
}
.kv__row {
  display: grid;
  grid-template-columns: minmax(96px, 34%) minmax(0, 1fr) 24px;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-soft);
}
.kv__row:last-child { border-bottom: 0; }
.kv__row:hover { background: color-mix(in oklch, var(--fg) 3%, transparent); }

.kv__k {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.kv__k--plain { text-transform: none; letter-spacing: 0.01em; font-size: 10.5px; font-weight: 400; }

.kv__v {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kv__v--wrap { white-space: normal; word-break: break-all; line-height: 1.45; }

.copy {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
}
.copy:hover { background: var(--surface-3); color: var(--fg); }

/* ---------- 9. Cards, badges, chips ---------- */
.card {
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--surface-3);
  padding: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 17px;
  padding: 0 6px;
  border-radius: 3px;
  border: 1px solid;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge--ok     { border-color: color-mix(in oklch, var(--ok) 60%, transparent);     background: color-mix(in oklch, var(--ok) 12%, transparent);     color: var(--ok); }
.badge--warn   { border-color: color-mix(in oklch, var(--warn) 60%, transparent);   background: color-mix(in oklch, var(--warn) 12%, transparent);   color: var(--warn); }
.badge--danger { border-color: color-mix(in oklch, var(--danger) 60%, transparent); background: color-mix(in oklch, var(--danger) 12%, transparent); color: var(--danger); }
.badge--accent { border-color: color-mix(in oklch, var(--accent-soft) 55%, transparent); background: color-mix(in oklch, var(--accent) 14%, transparent); color: var(--accent-soft); }

/* ---------- 10. Master / detail split ---------- */
.split {
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(0, 1fr);
  min-height: 0;
  height: 100%;
}
.split__list {
  border-right: 1px solid var(--border);
  overflow: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}
.split__detail {
  overflow: auto;
  min-height: 0;
  padding: 14px 16px 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
  /* Content reflows against the panel, not the viewport — the panel is now
     a window the user can make narrow on a wide screen. */
  container-type: inline-size;
  container-name: detail;
}

.list__head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
  z-index: 1;
}

.row {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  border-left: 2px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 9px 12px;
  cursor: pointer;
}
.row:hover { background: var(--surface-2); }
.row[aria-selected="true"] {
  background: color-mix(in oklch, var(--accent) 13%, transparent);
  border-left-color: var(--accent);
}
.row__top { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.row__name {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.row__sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
}

.detail__head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 4px; }
.detail__title {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 620;
  letter-spacing: -0.005em;
  margin: 0;
  color: var(--fg);
  word-break: break-all;
}
.detail__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin: 8px 0 14px;
  font-size: 11.5px;
  color: var(--muted);
}
.detail__meta b { color: var(--fg-2); font-weight: 500; font-family: var(--font-mono); font-size: 11px; }
.detail__meta a { color: var(--accent-soft); text-decoration: none; font-family: var(--font-mono); font-size: 11px; }
.detail__meta a:hover { text-decoration: underline; }

/* ---------- 11. Forms ---------- */
.field { margin-bottom: 10px; }
.field__label {
  display: block;
  font-size: 11.5px;
  color: var(--fg-2);
  margin-bottom: 4px;
}
.input {
  width: 100%;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: var(--r-ctrl);
  background: var(--surface-2);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 11.5px;
}
.input::placeholder { color: var(--muted-2); }
.input:focus { border-color: var(--accent); outline: none; }
.input[aria-invalid="true"] { border-color: var(--danger); }

.field__err {
  display: block;
  font-size: 11px;
  color: var(--danger);
  margin-top: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-ctrl);
  background: var(--surface-2);
  color: var(--fg-2);
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  cursor: pointer;
}
.btn:hover { background: var(--surface-3); color: var(--fg); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:disabled:hover { background: var(--surface-2); color: var(--fg-2); }
.btn--primary:disabled:hover { background: var(--accent); color: oklch(99% 0 0); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: oklch(99% 0 0); }
.btn--primary:hover { background: color-mix(in oklch, var(--accent) 88%, white); color: oklch(99% 0 0); }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--fg-2);
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  width: 30px;
  height: 17px;
  border-radius: 9px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  position: relative;
  transition: background 140ms ease;
  flex: none;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 140ms ease, background 140ms ease;
}
.switch input:checked + .switch__track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(13px); background: oklch(99% 0 0); }

/* ---------- 12. Empty states ---------- */
.empty {
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  gap: 6px;
  height: 100%;
  padding: 24px;
}
.empty__icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--accent-soft);
  margin-bottom: 4px;
}
.empty__icon--on { background: color-mix(in oklch, var(--ok) 18%, transparent); color: var(--ok); }
.empty__title { font-size: 14px; font-weight: 620; margin: 0; letter-spacing: -0.01em; }
.empty__text { font-size: 12px; color: var(--muted); margin: 0; max-width: 44ch; line-height: 1.55; }
.empty__hint {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted-2);
  letter-spacing: 0.02em;
  margin-top: 4px;
}

kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--fg-2);
}

/* ---------- 13. Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translate(-50%, 12px);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 12px;
  padding: 7px 13px;
  border-radius: 5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
  z-index: 90;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 14. Launcher (collapsed horizontal bar) ---------- */
.launcher {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  z-index: 40;
  width: max-content;
  transform-origin: 50% 50%;
  transition: transform 240ms cubic-bezier(.32, .72, 0, 1), opacity 170ms ease;
}
/* Dragging sets transform directly — never animate that. */
.launcher.is-dragging { transition: none; }

/* Collapsed: the launcher travels to the corner and hands off to the puck.
   The travel vector is measured at runtime and written to --cf-dx/--cf-dy. */
.launcher.is-collapsed {
  opacity: 0;
  pointer-events: none;
}

.launcher__bar {
  display: flex;
  align-items: stretch;
  gap: 4px;
  height: 48px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 14px 38px oklch(0% 0 0 / 0.42);

  /* The bar itself is the drag surface. touch-action keeps the browser from
     claiming the gesture for scrolling before pointermove fires. */
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
/* Picked up: one step deeper shadow, nothing else. */
.launcher.is-dragging .launcher__bar {
  cursor: grabbing;
  box-shadow: 0 20px 48px oklch(0% 0 0 / 0.5);
}

/* Controls on the bar keep their own affordance. */
.launcher__bar .tool,
.launcher__bar .menu__item { cursor: pointer; }

/* Brand segment: the logo alone, monoline, drawn the way the source draws it.
   No tile and no wordmark — the mark is the identity. It also doubles as the
   drag handle, so the padding exists to make a 34px target. */
.brand {
  display: flex;
  align-items: center;
  align-self: center;
  height: 34px;
  padding: 0 7px;
  flex: none;
  border-radius: 4px;
  text-decoration: none;
  color: var(--fg);
  cursor: grab;
  transition: background 120ms ease;
}
.brand:active { cursor: grabbing; }
.brand:hover { background: var(--surface-2); }

.mark { display: grid; place-items: center; flex: none; }

/* Full-height dividers separate groups, so the bar reads as segments
   rather than a loose row of icons. */
.launcher__sep {
  width: 1px;
  align-self: stretch;
  margin: 8px 6px;
  background: var(--border);
  flex: none;
}
/* Trailing segment sits flush right, like the reference bar. */
.launcher__sep--end { margin-left: auto; }

.launcher__tools { display: flex; align-items: center; gap: 3px; flex: none; }

.tool {
  position: relative;
  width: 34px;
  height: 34px;
  align-self: center;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.tool:hover { background: var(--surface-2); color: var(--fg); }

/* Active tool is a raised tile with an accent glyph — legible as a mode
   without spending a second saturated fill next to the brand tile. */
.tool[aria-pressed="true"], .tool[aria-expanded="true"] {
  background: var(--surface-3);
  color: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--border);
}

/* The annotation count lives on the tool it counts, and only once there is
   something to count. A bare zero in the corner of a toolbar says nothing. */
.tool__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--accent);
  color: oklch(99% 0 0);
  border: 2px solid var(--surface);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  line-height: 11px;
  text-align: center;
}

/* Icon-only tools need names — same tooltip grammar as the rail. */
.tool[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--fg-2);
  font-size: 11.5px;
  font-weight: 450;
  padding: 3px 8px;
  border-radius: var(--r-ctrl);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 110ms ease;
  z-index: 5;
}
.tool[data-tip]:hover::after, .tool[data-tip]:focus-visible::after { opacity: 1; }

/* Overflow menu — the trailing segment, after its own divider. */
.menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  min-width: 178px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  box-shadow: 0 14px 38px oklch(0% 0 0 / 0.45);
  z-index: 6;
}
.menu__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--fg-2);
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu__item:hover { background: var(--surface-3); color: var(--fg); }
.menu__item span[data-icon] { display: grid; place-items: center; color: var(--muted); }
.menu__rule { height: 1px; background: var(--border); margin: 4px 2px; }

/* ---------- 14b. Collapsed puck -----------------------------------------
   While a feature owns the screen, the launcher is reduced to the brand mark
   and parked in the bottom-right corner. It is the way back, and nothing else. */
.puck {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: oklch(99% 0 0);
  box-shadow: 0 10px 28px oklch(0% 0 0 / 0.42);
  cursor: pointer;
  text-decoration: none;
  z-index: 41;
  opacity: 0;
  transform: scale(0.35);
  pointer-events: none;
  transition: transform 240ms cubic-bezier(.32, .72, 0, 1), opacity 170ms ease, background 120ms ease;
}
.puck.is-on { opacity: 1; transform: scale(1); pointer-events: auto; }
.puck:hover { background: color-mix(in oklch, var(--accent) 86%, white); }

/* The panel floats bottom-left by default, so the puck keeps the opposite
   corner and the two never fight for the same space. */
.puck--docked { bottom: 24px; right: 24px; }

/* Which feature is holding the screen — otherwise the corner mark is a mystery. */
.puck__state {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent-soft);
}

.puck__tip {
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 9px;
  border-radius: var(--r-ctrl);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--fg-2);
  font-size: 11.5px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 110ms ease;
}
.puck:hover .puck__tip, .puck:focus-visible .puck__tip { opacity: 1; }

/* ---------- 14c. Feature surfaces ---------------------------------------
   Each feature ships its own panel from its own module. They share this
   shell so the three read as one product, not three bolt-ons. */
.surface {
  position: fixed;
  left: 50%;
  bottom: 32px;
  width: 380px;
  transform: translateX(-50%) translateY(10px);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 14px 38px oklch(0% 0 0 / 0.42);
  opacity: 0;
  pointer-events: none;
  z-index: 40;
  transition: opacity 180ms ease, transform 220ms cubic-bezier(.32, .72, 0, 1);
}
.surface.is-on { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }

.surface__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 8px 9px 12px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--muted);
}
.surface__title { font-size: 12.5px; font-weight: 620; margin: 0; color: var(--fg); letter-spacing: -0.005em; }
.surface__count { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }

.surface__body { padding: 12px; display: grid; gap: 11px; }

.surface__hint {
  margin: 0;
  padding: 0 12px 11px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
  text-align: center;
}

.surface__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border-soft);
}

.surface .tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; }
.surface .tab { text-align: center; }

/* Session preview is a short list of variants, so it gets a narrower shell. */
.surface--compact { width: 340px; }
.surface--compact .surface__body { gap: 6px; }

/* Count of what is being previewed — same "only when it counts something"
   rule as the launcher's annotation badge. */
.chip {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  border-radius: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  white-space: nowrap;
  flex: none;
}

/* ---------- Variant rows -------------------------------------------------
   The list is the set of live previews, so a row's presence means it is
   rendering. Any number can be on at once; the rows just stack.          */
.prev-list { display: grid; gap: 6px; }

.prev-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  padding: 8px 9px;
  border: 1px solid color-mix(in oklch, var(--ok) 40%, transparent);
  border-radius: 5px;
  background: var(--surface-2);
  color: inherit;
  font: inherit;
  text-align: left;
  transition: background 120ms ease, border-color 120ms ease;
}

.prev-row__dot {
  width: 8px;
  height: 8px;
  margin-top: 4px;
  flex: none;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ok) 18%, transparent);
}

.prev-row__text { display: grid; gap: 1px; min-width: 0; }
.prev-row__name { font-size: 12.5px; font-weight: 600; color: var(--fg); }
.prev-row__id {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prev-row__stop {
  margin-left: auto;
  margin-top: 1px;
  width: 20px;
  height: 20px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
}
.prev-row__stop:hover { background: var(--surface-3); color: var(--fg); }

/* Picker rows are candidates, not previews — hollow dot, and they respond
   to hover because clicking one turns it on. */
.prev-row--pick {
  border-color: var(--border-soft);
  cursor: pointer;
}
.prev-row--pick:hover { background: var(--surface-3); border-color: var(--border); }
.prev-row--pick .prev-row__dot {
  background: transparent;
  border: 1.5px solid var(--muted-2);
  box-shadow: none;
}

.prev-add {
  width: 100%;
  padding: 7px 9px;
  border: 1px dashed var(--border);
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}
.prev-add:hover { color: var(--fg-2); border-color: var(--muted-2); }

.prev-pick { display: grid; gap: 6px; }
.prev-pick__rows { display: grid; gap: 4px; }

/* Entering an ID is the equal of picking from the list, so the field sits at
   the top of the picker rather than behind a second affordance. It also
   filters the rows below, which keeps one control doing one job. */
.prev-entry { display: flex; gap: 6px; }
.prev-entry .input { flex: 1; min-width: 0; }
.prev-entry .btn { flex: none; }

.prev-note {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted-2);
}
.prev-note--err { color: var(--danger); }
.prev-note code { font-family: var(--font-mono); color: var(--muted); }

/* A variant added by ID carries only an ID. There is no name to show and no
   published mapping to an element, so the row states that instead of
   inventing either — hence the pending amber rather than the live green. */
.prev-row--raw:not(.prev-row--pick) { border-color: color-mix(in oklch, var(--warn) 38%, transparent); }
.prev-row--raw:not(.prev-row--pick) .prev-row__dot {
  background: var(--warn);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--warn) 18%, transparent);
}
.prev-row__name--id {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prev-empty {
  margin: 0;
  padding: 10px 2px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
}

/* ---------- 15. Overview (index) ---------- */
.overview {
  position: absolute;
  inset: 0;
  overflow: auto;
  background: var(--bg);
  color: var(--fg);
  padding: 56px 40px 64px;
}
.overview__inner { max-width: 1080px; margin: 0 auto; }
.overview__eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-soft);
  margin: 0 0 12px;
}
.overview__h1 {
  font-family: var(--font-display);
  font-size: 30px;
  letter-spacing: -0.028em;
  margin: 0 0 10px;
  font-weight: 640;
}
.overview__lede { color: var(--muted); max-width: 62ch; margin: 0 0 34px; font-size: 14px; line-height: 1.6; }

.screens {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  list-style: none;
  padding: 0;
  margin: 0 0 40px;
}
.screen {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--surface);
  padding: 14px;
  text-decoration: none;
  color: inherit;
  transition: border-color 130ms ease, background 130ms ease;
}
.screen:hover { border-color: var(--accent); background: var(--surface-2); }
.screen__idx {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted-2);
}
.screen__name { font-size: 14px; font-weight: 600; margin: 6px 0 4px; letter-spacing: -0.01em; }
.screen__desc { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.5; }

.notes { border-top: 1px solid var(--border); padding-top: 22px; }
.notes h2 {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
}
.notes ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.75; max-width: 74ch; }
.notes b { color: var(--fg-2); font-weight: 550; }

/* ---------- 16. Narrow viewports ---------- */
/* Panel-internal breakpoints answer to the panel's own width, so shrinking
   the window reflows the content even on a 1920px screen. */
@container panel (max-width: 780px) {
  .split { grid-template-columns: minmax(190px, 260px) minmax(0, 1fr); }
}

@container panel (max-width: 620px) {
  .split { grid-template-columns: minmax(0, 1fr); grid-template-rows: 44% minmax(0, 1fr); }
  .split__list { border-right: 0; border-bottom: 1px solid var(--border); }
  .cols { grid-template-columns: minmax(0, 1fr); }
  .col { border-right: 0; border-bottom: 1px solid var(--border-soft); }
}

/* Viewport breakpoints are now only for the host page, the overview, and the
   panel's first-paint default before JS adopts explicit geometry. */
@media (max-width: 980px) {
  .bar__host { display: none; }
  .host__grid { grid-template-columns: 1fr; }
  .host__main { padding: 36px 20px 0; }
  .overview { padding: 36px 20px 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
