:root {
  --bg0: #ffffff;
  --bg1: #f4f7f9;
  --panel: #ffffff;
  --panel-dark: #004d6d;
  --ink: #004d6d;
  --muted: #4a6a7a;
  --accent: #e95327;
  --accent-deep: #c4431f;
  --line: rgba(0, 77, 109, 0.14);
  --err: #c45a48;
  --warn: #c4a035;
  --ok: #2f8a4a;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "DM Sans", system-ui, sans-serif;
  --display: "DM Sans", system-ui, sans-serif;
  --ide-fg: #e8eef2;
  --ide-muted: #8aa0b0;
  --ide-gutter: #003a52;
  --header: #e95327;

  /* Neutral field / surface tints (teal-based, was cream) */
  --field: #f6f9fa;
  --ink-tint-4: rgba(0, 77, 109, 0.04);
  --ink-tint-6: rgba(0, 77, 109, 0.06);
  --ink-tint-8: rgba(0, 77, 109, 0.08);
  --on-ink: #eef6f9;

  /* Status surfaces: base colours above only gave us text/border colours */
  --ok-soft: #ebf6ee;
  --ok-line: rgba(47, 138, 74, 0.38);
  --ok-ink: #1f6b38;
  --warn-soft: #fbf5e3;
  --warn-line: rgba(196, 160, 53, 0.45);
  --warn-ink: #856611;
  --err-soft: #fbeeeb;
  --err-line: rgba(196, 90, 72, 0.42);
  --err-ink: #a13a28;
  --accent-soft: #fdeee8;
  --accent-line: rgba(233, 83, 39, 0.35);

  /* Step states, shared by the progress spine, wizard pills and flash rail */
  --step-todo-bg: var(--ink-tint-4);
  --step-todo-fg: var(--muted);
  --step-active-bg: var(--accent-soft);
  --step-active-fg: var(--accent-deep);
  --step-done-bg: var(--ok-soft);
  --step-done-fg: var(--ok-ink);

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(0, 77, 109, 0.05), 0 3px 10px rgba(0, 77, 109, 0.06);
  --shadow-2: 0 8px 24px rgba(0, 77, 109, 0.1);
  --shadow-3: 0 18px 44px rgba(0, 77, 109, 0.18);

  /* IDE dark ramp, derived from --panel-dark (was olive green) */
  --ide-chrome: #003b56;
  --ide-panel: #00334c;
  --ide-log: #002a3e;
  --ide-btn: #0a5b7d;
  --ide-line: rgba(255, 255, 255, 0.09);
}

* { box-sizing: border-box; }

/* Class-level display rules (flex/grid) beat the UA [hidden] rule, so make
   the attribute win everywhere. Zonder dit blijven hidden knoppen zichtbaar. */
[hidden] { display: none !important; }

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

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg0);
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(233, 83, 39, 0.08), transparent 55%),
    radial-gradient(ellipse 50% 35% at 0% 100%, rgba(0, 77, 109, 0.06), transparent 50%),
    linear-gradient(180deg, #ffffff, #f7fafb);
}

.top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.35rem;
  color: #ffffff;
  background: var(--header);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 11rem;
  z-index: 1;
}

.brand-mark {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.45rem;
  background: #000 url("/logo.png") center / contain no-repeat;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2);
}

.brand-name {
  margin: 0;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
}

.brand-sub {
  margin: 0.05rem 0 0;
  font-size: 0.75rem;
  opacity: 0.85;
  color: #fff;
}

.view-tabs {
  position: absolute;
  left: 50%;
  translate: -50% 0;
  display: flex;
  gap: 0.2rem;
  padding: 0.18rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.38rem 1rem;
  border-radius: 999px;
  cursor: pointer;
}

.tab.active {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.tab-dev {
  padding: 0.38rem 0.55rem;
  opacity: 0.55;
}

.tab-dev:hover,
.tab-dev.active {
  opacity: 1;
}

.tab-dev .ico {
  width: 1.05rem;
  height: 1.05rem;
  display: block;
}

.badge {
  display: none;
  margin: 0;
  padding: 0.32rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  font-size: 0.72rem;
  white-space: nowrap;
  color: #fff;
}

.badge.api { border-color: rgba(255, 255, 255, 0.55); color: #fff; }
.badge.demo { border-color: rgba(255, 255, 255, 0.55); color: #fff; }

.view {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.2rem 1.6rem;
}

/* display:grid op .layout-* overschrijft anders [hidden] */
.view[hidden] {
  display: none !important;
}

.layout-studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 0.85rem;
  min-height: calc(100vh - 8.2rem);
  align-content: start;
  max-width: 920px;
  transition: max-width 0.2s ease;
}

/* Collapsed: chat eerst (wizard/flash), code-balk eronder */
body.code-collapsed .layout-studio {
  grid-template-rows: minmax(0, 1fr) auto auto;
}

body.code-collapsed .layout-studio .chat-shell {
  grid-row: 1;
}

body.code-collapsed .layout-studio .ide {
  grid-row: 2;
  grid-column: 1 / -1;
}

body.code-expanded .layout-studio {
  max-width: 1280px;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.95fr);
  grid-template-rows: minmax(420px, 1fr) auto;
}

body.code-expanded .layout-studio .api-panel {
  grid-column: 1 / -1;
}

.layout-dev {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 0.95rem;
}

.dev-banner {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.65rem 1.1rem;
  padding: 0.7rem 1rem;
  border-radius: 0.75rem;
  background: var(--ink-tint-8);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.88rem;
}

.dev-banner strong {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.panel {
  background: var(--panel);
  border-radius: 0.95rem;
  padding: 1rem 1.1rem 1.15rem;
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 77, 109, 0.08);
}

.eyebrow {
  margin: 0 0 0.15rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.side h1, .panel h2, .chat-shell h1, .wizard-card h2 {
  margin: 0 0 0.25rem;
  font-family: var(--display);
  font-size: 1.3rem;
  letter-spacing: -0.02em;
}

.wizard-card h2 {
  font-size: 1.15rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.subhead {
  margin: 1rem 0 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.lede {
  margin: 0 0 0.9rem;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.88rem;
  text-align: left;
}

.model-hint {
  margin-top: -0.35rem;
  margin-bottom: 0.85rem;
  font-size: 0.78rem;
}

.model-hint a {
  color: var(--accent-deep);
}

.lede code, .panel code {
  font-family: var(--mono);
  font-size: 0.84em;
  background: var(--ink-tint-6);
  padding: 0.05em 0.28em;
  border-radius: 0.22rem;
}

label { display: block; margin-bottom: 0.7rem; }

label > span {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  margin-bottom: 0.28rem;
  color: var(--muted);
}

textarea, select, input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.55rem 0.65rem;
  font: inherit;
  background: var(--field);
  color: var(--ink);
}

textarea:focus, select:focus, input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 1px;
}

textarea.invalid {
  border-color: var(--err);
  background: var(--err-soft);
}

.field-error {
  margin: 0.22rem 0 0;
  font-size: 0.72rem;
  color: var(--err);
  font-weight: 600;
}

.slider-block { margin-top: 0.65rem; }

.slider-head {
  margin: 0 0 0.15rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.slider-head em {
  font-style: normal;
  color: var(--accent);
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  margin: 0.25rem 0 0.15rem;
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.35rem 0 0.5rem;
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: 0.86rem;
  padding: 0.48rem 0.8rem;
  border-radius: 0.45rem;
  cursor: pointer;
}

.btn.compact { font-size: 0.78rem; padding: 0.32rem 0.65rem; }

.btn.btn-lg {
  font-size: 0.95rem;
  padding: 0.62rem 1.15rem;
  border-radius: 0.55rem;
}
.btn:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent-deep);
  color: #fff7ef;
}
.btn.primary:hover:not(:disabled) { background: var(--accent-deep); }
.btn.ghost { background: transparent; }

/* ── Chat shell (wizard + refine) ── */
.chat-shell {
  display: flex;
  flex-direction: column;
  min-height: min(70vh, 640px);
  padding: 1.15rem 1.25rem 1.2rem;
}

.wizard-flow,
.chat-flow {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.wizard-flow[hidden],
.chat-flow[hidden],
.intro-flow[hidden],
#driversFlow[hidden] {
  display: none !important;
}

.intro-flow {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.intro-body {
  flex: 1;
  overflow: auto;
  color: var(--ink);
  line-height: 1.5;
}

.intro-board {
  margin: 0 0 1.1rem;
}

.intro-board-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 9.5rem;
  width: 100%;
  border-radius: 0.75rem;
  border: 2px dashed color-mix(in srgb, var(--ink) 28%, transparent);
  background:
    linear-gradient(135deg, rgba(0, 77, 109, 0.06), rgba(233, 83, 39, 0.05)),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 8px,
      rgba(0, 77, 109, 0.03) 8px,
      rgba(0, 77, 109, 0.03) 16px
    );
  color: var(--muted);
  text-align: center;
}

.intro-board-placeholder span {
  font-size: 1rem;
  font-weight: 650;
  color: var(--ink);
}

.intro-board-placeholder em {
  font-style: normal;
  font-size: 0.78rem;
  opacity: 0.85;
}

.intro-board-placeholder .ico {
  color: color-mix(in srgb, var(--ink) 45%, transparent);
  margin-bottom: 0.1rem;
}

.driver-video {
  margin: 0 0 1.1rem;
}

.driver-video-placeholder {
  min-height: 0;
  aspect-ratio: 16 / 9;
  max-height: 16rem;
}

.driver-video-placeholder .ico {
  color: var(--accent);
}

/* ── Visual intro / drivers screens ── */
.intro-lead {
  margin: 0 0 1.15rem;
  font-size: 1.05rem;
  line-height: 1.5;
}

.intro-lead .info-btn { margin-left: 0.15rem; }

.intro-section-label {
  margin: 0 0 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.sensor-cards {
  list-style: none;
  margin: 0 0 1.35rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}

.sensor-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.9rem 0.7rem 0.85rem;
  border-radius: 0.75rem;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow-1);
  text-align: center;
}

.sensor-card img {
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: 0.25rem;
}

.sensor-card-name {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
}

.sensor-card-when {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--muted);
}

.sensor-card-when[data-tip] {
  border-bottom: 1px dotted color-mix(in srgb, var(--ink) 35%, transparent);
  cursor: help;
}

/* Icon step row with chevrons, replaces the numbered prose lists */
.flow-strip {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: stretch;
  gap: 0.3rem;
}

.flow-strip > li {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.85rem 0.6rem;
  border-radius: 0.7rem;
  background: var(--ink-tint-4);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
}

.flow-strip > li .ico { color: var(--accent); }

.flow-strip > li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -0.42rem;
  width: 0.55rem;
  height: 0.55rem;
  border-top: 2px solid var(--accent-line);
  border-right: 2px solid var(--accent-line);
  rotate: 45deg;
  translate: 0 -50%;
}

.flow-strip-note {
  margin: 0.7rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.download-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 0 0 1.35rem;
  padding: 0.9rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow-1);
}

.download-card > .ico {
  color: var(--accent);
  flex-shrink: 0;
}

.download-card-text {
  flex: 1;
  min-width: 0;
}

.download-card-title {
  margin: 0;
  font-weight: 650;
  font-size: 0.95rem;
  color: var(--ink);
}

.download-card-sub {
  margin: 0.1rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.download-card .btn {
  flex-shrink: 0;
  text-decoration: none;
}

.wizard-sensor-head {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  margin-bottom: 0.85rem;
}

.wizard-sensor-head img {
  flex-shrink: 0;
  width: 2.9rem;
  height: 2.9rem;
}

/* De trigger als kopje: de conditie, de prompt eronder is het gevolg */
.trigger-when {
  margin: 0;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ink);
}

.io-strip {
  margin: 0 0 1.15rem;
  padding: 1rem 1.05rem 1.05rem;
  border-radius: 0.75rem;
  background:
    linear-gradient(135deg, rgba(0, 77, 109, 0.07), rgba(233, 83, 39, 0.05)),
    #fff;
  border: 2px solid color-mix(in srgb, var(--ink) 22%, var(--line));
  box-shadow: 0 6px 18px rgba(0, 77, 109, 0.07);
}

.io-strip-label {
  margin: 0;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.io-strip-hint {
  margin: 0.15rem 0 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.io-strip-label + .io-strip-hint { margin-top: 0.1rem; }

.io-chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: 0.5rem;
}

/* Chip = knop die het voorbeeld van dat onderdeel in de prompt zet */
.io-chip {
  appearance: none;
  position: relative;
  z-index: 0;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.55rem 0.5rem 0.6rem;
  border-radius: 0.6rem;
  background: #fff;
  border: 1.5px solid color-mix(in srgb, var(--ink) 18%, transparent);
  box-shadow: var(--shadow-1);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease, transform 0.14s ease;
}

.io-chip:hover {
  z-index: 8;
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.io-chip:active { transform: none; }

.io-chip img {
  width: 1.6rem;
  height: 1.6rem;
  flex-shrink: 0;
}

.io-chip-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  line-height: 1.2;
}

.io-chip-text code {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--ink);
  background: none;
  padding: 0;
}

.io-chip-text em {
  font-style: normal;
  font-size: 0.72rem;
  color: var(--muted);
}

.io-chip-mark {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  color: color-mix(in srgb, var(--ink) 40%, transparent);
}

.io-chip:hover .io-chip-mark { color: var(--accent); }

.io-chip-done { display: none; }

/* Net toegevoegd */
.io-chip.is-added {
  border-color: var(--ok-line);
  background: var(--ok-soft);
}

.io-chip.is-added .io-chip-mark { display: none; }

.io-chip.is-added .io-chip-done {
  display: block;
  color: var(--ok);
}

/* Stond er al in */
.io-chip.is-dup {
  border-color: var(--warn-line);
  background: var(--warn-soft);
}

/* ── Flash rail: de twee stappen naar het bord ── */
.flash-rail {
  margin: 0 0 1.1rem;
  padding: 0.9rem 1rem 1rem;
  border-radius: 0.8rem;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--ink-tint-4), #fff);
  box-shadow: var(--shadow-1);
}

.flash-rail-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.fr-step {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.6rem;
  border-radius: 0.7rem;
  border: 1.5px solid transparent;
  transition: background 0.18s ease, border-color 0.18s ease;
}

/* Pijl naar de volgende stap */
.fr-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -0.5rem;
  width: 0.6rem;
  height: 0.6rem;
  border-top: 2.5px solid var(--line);
  border-right: 2.5px solid var(--line);
  rotate: 45deg;
  translate: 0 -50%;
  z-index: 1;
}

/* De pijl wijst naar de stap die nu moet: knippert richting stap 2 */
.fr-step.is-done:not(:last-child)::after {
  border-color: var(--accent);
  animation: frArrowNudge 1.5s ease-in-out infinite;
}

@keyframes frArrowNudge {
  0%, 100% { translate: 0 -50%; opacity: 0.55; }
  50% { translate: 0.18rem -50%; opacity: 1; }
}

.fr-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--ink-tint-8);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
}

.fr-num i { font-style: normal; }
.fr-num .ico { display: none; width: 1rem; height: 1rem; stroke-width: 2.8; }

.fr-btn {
  appearance: none;
  position: relative;
  overflow: hidden;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  border-radius: 0.6rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.fr-btn-label { position: relative; z-index: 1; }
.fr-btn .ico { position: relative; z-index: 1; }

.fr-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* Voortgangsvulling tijdens het schrijven */
.fr-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: color-mix(in srgb, #fff 28%, transparent);
  transition: width 0.15s linear;
  z-index: 0;
}

/* Stap-states */
.fr-step.is-todo .fr-btn {
  background: var(--ink-tint-4);
}

.fr-step.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.fr-step.is-active .fr-num {
  background: var(--accent);
  color: #fff;
}

.fr-step.is-active .fr-btn {
  background: var(--accent);
  border-color: var(--accent-deep);
  color: #fff7ef;
  box-shadow: 0 4px 14px rgba(233, 83, 39, 0.35);
}

.fr-step.is-active .fr-btn:hover:not(:disabled) {
  background: var(--accent-deep);
}

.fr-step.is-done {
  background: var(--ok-soft);
  border-color: var(--ok-line);
}

.fr-step.is-done .fr-num {
  background: var(--ok);
  color: #fff;
}

.fr-step.is-done .fr-num i { display: none; }
.fr-step.is-done .fr-num .ico { display: block; }

.fr-step.is-done .fr-btn {
  background: #fff;
  border-color: var(--ok-line);
  color: var(--ok-ink);
}

.fr-info { margin-left: -0.15rem; }

/* ── Statusbanner: één prominente regel over verbinden/flashen ── */
.flash-status {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin: 0.85rem 0 0;
  padding: 0.7rem 0.85rem;
  border-radius: 0.65rem;
  border: 1px solid var(--line);
  background: var(--ink-tint-4);
}

.flash-status-icon { flex-shrink: 0; color: var(--muted); margin-top: 0.05rem; }

.flash-status-text { flex: 1; min-width: 0; }

.flash-status-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.3;
  color: var(--ink);
}

.flash-status-detail {
  margin: 0.3rem 0 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--muted);
}

.flash-status-detail p { margin: 0.25rem 0; }
.flash-status-detail ul { margin: 0.3rem 0 0; padding-left: 1.15rem; }
.flash-status-detail li { margin: 0.15rem 0; }

.flash-status[data-state="busy"] {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.flash-status[data-state="busy"] .flash-status-icon { color: var(--accent); }

.flash-status[data-state="ok"] {
  border-color: var(--ok-line);
  background: var(--ok-soft);
}

.flash-status[data-state="ok"] .flash-status-icon { color: var(--ok); }
.flash-status[data-state="ok"] .flash-status-title { color: var(--ok-ink); }

.flash-status[data-state="warn"] {
  border-color: var(--warn-line);
  background: var(--warn-soft);
}

.flash-status[data-state="warn"] .flash-status-icon { color: var(--warn-ink); }
.flash-status[data-state="warn"] .flash-status-title { color: var(--warn-ink); }

.flash-status[data-state="error"] {
  border-color: var(--err-line);
  background: var(--err-soft);
}

.flash-status[data-state="error"] .flash-status-icon { color: var(--err); }
.flash-status[data-state="error"] .flash-status-title { color: var(--err-ink); }

/* Geflasht: even opvallend vieren */
.flash-status[data-state="ok"] {
  animation: flashCelebrate 0.6s ease;
}

@keyframes flashCelebrate {
  0% { transform: scale(0.97); opacity: 0.4; }
  55% { transform: scale(1.015); }
  100% { transform: none; opacity: 1; }
}

button.linkish {
  display: inline;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  color: var(--accent-deep);
  font: inherit;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 0.12em;
  cursor: pointer;
}

button.linkish:hover {
  color: var(--accent);
}

.generating-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  background: color-mix(in srgb, #fff 72%, transparent);
  backdrop-filter: blur(4px);
  text-align: center;
}

.generating-overlay[hidden] {
  display: none !important;
}

.generating-skel {
  display: grid;
  gap: 0.4rem;
  width: min(22rem, 80vw);
  margin-bottom: 0.4rem;
}

.generating-skel span {
  display: block;
  height: 0.7rem;
  border-radius: 0.35rem;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--ink) 8%, #fff) 25%,
    color-mix(in srgb, var(--accent) 18%, #fff) 50%,
    color-mix(in srgb, var(--ink) 8%, #fff) 75%
  );
  background-size: 200% 100%;
  animation: skelShimmer 1.2s ease-in-out infinite;
}

.generating-skel span:nth-child(1) { width: 92%; }
.generating-skel span:nth-child(2) { width: 76%; }
.generating-skel span:nth-child(3) { width: 84%; }
.generating-skel span:nth-child(4) { width: 58%; }

@keyframes skelShimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.generating-title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.8rem, 5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
  animation: generatingPulse 1.4s ease-in-out infinite;
}

.generating-sub {
  margin: 0;
  font-size: 1.05rem;
  color: var(--muted);
}

@keyframes generatingPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.72; transform: scale(1.02); }
}

.wizard-head {
  margin-bottom: 1rem;
  text-align: left;
}

.wizard-head h1,
.chat-head-title h1 {
  margin: 0.1rem 0 0.35rem;
  text-align: left;
}

.wizard-card {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.wizard-card[hidden] {
  display: none !important;
}

.wizard-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 1rem;
  align-items: center;
  position: sticky;
  bottom: 0;
  z-index: 2;
  flex-shrink: 0;
  background: linear-gradient(180deg, transparent, var(--panel) 28%);
  padding-top: 0.55rem;
}

.wizard-nav-spacer {
  flex: 1 1 auto;
  min-width: 0.5rem;
}

.chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
  text-align: left;
}

.chat-head-title {
  margin: 0;
  flex: 1;
  min-width: 0;
  text-align: left;
}

.chat-head-title .eyebrow {
  margin-bottom: 0.15rem;
}

.chat-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex-shrink: 0;
  padding-top: 0.15rem;
}

/* Eenmalige melding: opnieuw genereren overschrijft de hele code */
.regen-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin: 0 0 1rem;
  padding: 0.7rem 0.85rem;
  border-radius: 0.7rem;
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  color: var(--ink);
}

.regen-notice-text {
  flex: 1;
  min-width: 0;
}

.regen-notice-text p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.4;
}

.regen-notice-text .linkish {
  margin-top: 0.35rem;
}

.notice-dismiss {
  appearance: none;
  flex-shrink: 0;
  width: 1.6rem;
  height: 1.6rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.notice-dismiss:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--ink);
}

.post-flash-hint {
  margin: 0 0 1.1rem;
  padding: 0.85rem 1rem;
  border-radius: 0.75rem;
  border: 1.5px dashed var(--ok-line);
  background: var(--ok-soft);
}

.post-flash-ready {
  margin: 0 0 0.45rem;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--ok-ink);
}

.post-flash-prompt {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--ink);
}

.post-flash-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
}

.post-flash-or {
  font-size: 0.8rem;
  color: var(--muted);
}

.chat-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 0.7rem 0.75rem 0.75rem;
  border-radius: 0.95rem;
}

.chat-trace {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 4;
}

.chat-trace path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  vector-effect: non-scaling-stroke;
}

.chat-pane.is-tracing .chat-trace path {
  animation: chatTraceDraw 0.95s cubic-bezier(0.4, 0, 0.15, 1) forwards;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--accent) 55%, transparent));
}

.chat-pane.is-outlined .chat-trace path {
  stroke-dashoffset: 0;
  stroke-width: 1.5;
}

@keyframes chatTraceDraw {
  0% { stroke-dashoffset: 1; }
  100% { stroke-dashoffset: 0; }
}

.icon-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn .ico {
  width: 1.1rem;
  height: 1.1rem;
}

.icon-btn:hover {
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

body.code-collapsed .api-panel {
  display: none !important;
}

.wizard-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.wizard-steps {
  list-style: none;
  margin: 0 0 1.1rem;
  padding: 0;
  display: flex;
  gap: 0.4rem;
}

.wizard-steps > li {
  flex: 1;
  min-width: 0;
}

.wizard-step {
  width: 100%;
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 0.4rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--step-todo-fg);
  background: var(--step-todo-bg);
  border: 1px solid transparent;
  cursor: pointer;
}

.wizard-step:hover {
  color: var(--ink);
  border-color: var(--line);
}

.wizard-step .ws-dot {
  display: inline-flex;
  width: 1.35rem;
  height: 1.35rem;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--ink-tint-8);
  font-family: var(--mono);
  font-size: 0.68rem;
}

.wizard-step .ws-dot i { font-style: normal; }

.wizard-step .ws-dot .ico {
  display: none;
  width: 0.8rem;
  height: 0.8rem;
  stroke-width: 2.8;
}

.wizard-step.active {
  color: var(--ink);
  border-color: var(--accent-line);
  background: color-mix(in srgb, var(--accent) 10%, #fff);
}

.wizard-step.active .ws-dot {
  background: var(--accent);
  color: #fff7ef;
}

.wizard-step.done {
  color: var(--step-done-fg);
  background: var(--step-done-bg);
}

.wizard-step.done .ws-dot {
  background: var(--ok);
  color: #fff;
}

.wizard-step.done .ws-dot i { display: none; }
.wizard-step.done .ws-dot .ico { display: block; }

.wizard-card textarea {
  min-height: 8.5rem;
  font-size: 0.95rem;
  line-height: 1.45;
  background: #fff;
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
}

.panel-hint {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Chat thread */
.chat-thread {
  flex: 1;
  min-height: 220px;
  max-height: min(52vh, 480px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.85rem 0.35rem 1rem;
  scrollbar-gutter: stable;
}

.chat-thread:empty::before {
  content: "Nog geen berichten. Vraag om een kleine wijziging.";
  margin: auto;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  max-width: 16rem;
  line-height: 1.45;
}

.chat-msg {
  max-width: min(92%, 36rem);
  padding: 0.75rem 0.95rem;
  border-radius: 1.1rem;
  font-size: 0.92rem;
  line-height: 1.45;
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--ink);
  color: var(--on-ink);
  border-bottom-right-radius: 0.35rem;
}

.chat-msg.assistant {
  align-self: flex-start;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-bottom-left-radius: 0.35rem;
}

.chat-msg.error {
  align-self: stretch;
  background: color-mix(in srgb, var(--err) 10%, #fff);
  border: 1px solid color-mix(in srgb, var(--err) 30%, transparent);
  color: color-mix(in srgb, var(--err) 85%, #000);
  border-radius: 0.75rem;
}

.chat-composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
  align-items: end;
  padding: 0.65rem;
  border-radius: 1.1rem;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.chat-composer textarea {
  border: 0;
  background: transparent;
  resize: none;
  min-height: 2.8rem;
  max-height: 8rem;
  padding: 0.35rem 0.4rem;
  font-size: 0.95rem;
}

.chat-composer textarea:focus {
  outline: none;
}

.chat-composer .btn {
  border-radius: 0.85rem;
  padding: 0.55rem 1rem;
}

.status { margin: 0.55rem 0 0; font-size: 0.76rem; color: var(--muted); }

/* Foldable IDE */
.ide-fold-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ide-fg);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.28rem 0.6rem;
  border-radius: 0.4rem;
  cursor: pointer;
}

.ide-fold-chevron {
  width: 0.85rem;
  height: 0.85rem;
  rotate: 90deg;
  transition: rotate 0.15s ease;
}

body.code-expanded .ide-fold-chevron {
  rotate: -90deg;
}

.ide-fold-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

body.code-collapsed .ide-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Collapsed: hide editor + lint, keep flash status + terminal visible */
body.code-collapsed .editor-wrap,
body.code-collapsed .lint-list,
body.code-collapsed .mem-panel,
body.code-collapsed .ide-footer {
  display: none !important;
}

/* Eerste stappen: alleen een slanke balk (fold + lint), geen log */
body.code-collapsed #viewStudio[data-phase="intro"] .ide-body,
body.code-collapsed #viewStudio[data-phase="drivers"] .ide-body,
body.code-collapsed #viewStudio[data-phase="wizard"] .ide-body,
body.code-collapsed #viewStudio[data-phase="intro"] .ide-actions,
body.code-collapsed #viewStudio[data-phase="drivers"] .ide-actions,
body.code-collapsed #viewStudio[data-phase="wizard"] .ide-actions,
body.code-collapsed #viewStudio[data-phase="intro"] .ide-tab,
body.code-collapsed #viewStudio[data-phase="drivers"] .ide-tab,
body.code-collapsed #viewStudio[data-phase="wizard"] .ide-tab {
  display: none !important;
}

body.code-collapsed #viewStudio[data-phase="intro"] .ide-chrome,
body.code-collapsed #viewStudio[data-phase="drivers"] .ide-chrome,
body.code-collapsed #viewStudio[data-phase="wizard"] .ide-chrome {
  border-bottom: 0;
  border-radius: 0.95rem;
}

body.code-collapsed .layout-studio .ide {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  min-height: 0;
}

body.code-collapsed .ide-chrome {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0.95rem 0.95rem 0 0;
}

body.code-collapsed .ide-body {
  border-radius: 0 0 0.95rem 0.95rem;
}

/* Technische log: alleen vanaf de chat-fase. Tijdens uitleg/driver/wizard
   blijft hij weg, ook als iemand de code-balk openklapt. */
#viewStudio[data-phase="intro"] .log-details,
#viewStudio[data-phase="drivers"] .log-details,
#viewStudio[data-phase="wizard"] .log-details {
  display: none !important;
}

body.code-collapsed .log-details {
  max-height: 11rem;
}

body.code-collapsed .log {
  max-height: 8rem;
}

body.code-expanded .ide-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

body.code-expanded .layout-studio .ide {
  min-height: 420px;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

/* ── API / Bouwstenen panel (full width under studio) ── */
.api-panel {
  grid-column: 1 / -1;
  padding: 0;
  overflow: hidden;
}

.api-panel-summary {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem 1rem;
  cursor: pointer;
  padding: 0.85rem 1.15rem;
  user-select: none;
}

.api-panel-summary::-webkit-details-marker { display: none; }

.api-panel-summary::before {
  content: "▸";
  font-size: 0.75rem;
  color: var(--accent);
  transition: transform 0.15s ease;
}

.api-panel[open] > .api-panel-summary::before {
  transform: rotate(90deg);
}

.api-panel-title {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

.api-panel-title em {
  font-style: normal;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-left: 0.25rem;
}

.api-panel-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.api-panel-hint {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--muted);
  opacity: 0.85;
}

.api-panel > .api-note,
.api-panel > .api-filters,
.api-panel > .api-grid {
  padding-left: 1.15rem;
  padding-right: 1.15rem;
}

.api-panel > .api-note { padding-top: 0; }
.api-panel > .api-grid { padding-bottom: 1.1rem; }

.api-note {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.api-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.api-filter {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
}

.api-filter:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--ink); }
.api-filter.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
}

.api-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.7rem;
  max-height: min(48vh, 520px);
  overflow: auto;
  padding-right: 0.35rem;
  scrollbar-gutter: stable;
}

.api-group {
  margin: 0;
  border-radius: 0.65rem;
  border: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
  border-left-width: 4px;
  border-left-color: var(--api-tone, #8a9680);
}

.api-group.tone-geluid { --api-tone: #c45c26; --api-soft: #f8ebe3; }
.api-group.tone-leds,
.api-group.tone-ogen { --api-tone: #3d7ea6; --api-soft: #e5f0f6; }
.api-group.tone-strips { --api-tone: #5a8f3c; --api-soft: #e8f2e0; }
.api-group.tone-servos,
.api-group.tone-vleugels { --api-tone: #8b6bb0; --api-soft: #f0eaf6; }
.api-group.tone-root { --api-tone: #2f5d3a; --api-soft: #e4efe6; }
.api-group.tone-sensor { --api-tone: #8a7a40; --api-soft: #f4efd8; }
.api-group.tone-comm { --api-tone: #5c6e8a; --api-soft: #e8edf3; }
.api-group.tone-contract { --api-tone: var(--accent); --api-soft: #f7ebe3; }
.api-group.tone-low,
.api-group.tone-neutral { --api-tone: #6a7564; --api-soft: #eef0eb; }

.api-group-sum {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.65rem;
  cursor: pointer;
  background: var(--api-soft, #eef0eb);
  font-weight: 600;
  font-size: 0.86rem;
}

.api-group-sum::-webkit-details-marker { display: none; }

.api-layer {
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--api-tone) 18%, #fff);
  color: color-mix(in srgb, var(--api-tone) 85%, #000);
}

.api-group-title { flex: 1; min-width: 0; }
.api-group-count {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
}

.api-items {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.55rem 0.6rem 0.7rem;
}

.api-item {
  margin: 0;
  padding: 0.45rem 0.5rem;
  border-radius: 0.4rem;
  background: var(--ink-tint-4);
}

.api-sig {
  display: block;
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.4;
  color: var(--ink);
  background: none;
  padding: 0;
  word-break: break-word;
  white-space: pre-wrap;
}

.api-comp { color: color-mix(in srgb, var(--api-tone) 75%, #1a2018); font-weight: 500; }
.api-meth { color: var(--api-tone); font-weight: 600; }
.api-args { color: var(--muted); }

.api-tip {
  margin: 0.35rem 0 0;
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--muted);
  font-weight: 400;
}

/* IDE */
.ide {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  background: var(--panel-dark);
  border-color: rgba(0, 0, 0, 0.45);
  color: var(--ide-fg);
}

.ide-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.ide-chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.5rem 0.7rem;
  background: var(--ide-chrome);
  border-bottom: 1px solid var(--ide-line);
}

.ide-tabs { display: flex; align-items: center; gap: 0.45rem; }

.ide-tab {
  font-family: var(--mono);
  font-size: 0.76rem;
  padding: 0.32rem 0.7rem;
  border-radius: 0.35rem 0.35rem 0 0;
  background: var(--panel-dark);
  color: var(--ide-fg);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-bottom: 0;
}

.lint-badge {
  appearance: none;
  border: 0;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ide-muted);
}

.lint-badge.ok { background: rgba(74, 154, 92, 0.2); color: #7dce8f; }
.lint-badge.warn { background: rgba(196, 160, 53, 0.2); color: #e0c56a; }
.lint-badge.error { background: rgba(196, 90, 72, 0.22); color: #f0a090; }

.ide-actions { display: flex; gap: 0.35rem; }

.ide .btn {
  background: var(--ide-btn);
  color: var(--ide-fg);
  border-color: rgba(255, 255, 255, 0.16);
}

.ide .btn.primary {
  background: var(--accent);
  border-color: var(--accent-deep);
  color: #fff7ef;
}

.editor-wrap {
  display: grid;
  grid-template-columns: 2.75rem 1fr;
  flex: 1;
  min-height: 20rem;
  overflow: hidden;
}

.line-numbers {
  margin: 0;
  padding: 0.85rem 0;
  text-align: right;
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--ide-muted);
  background: var(--ide-gutter);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  overflow: hidden;
  user-select: none;
}

.line-numbers .ln {
  display: block;
  padding: 0 0.45rem 0 0.2rem;
  min-height: 1.5em;
}

.line-numbers .ln.mark-error {
  background: rgba(196, 90, 72, 0.35);
  color: #ffb4a8;
  font-weight: 700;
}

.line-numbers .ln.mark-warn {
  background: rgba(196, 160, 53, 0.28);
  color: #f0d78a;
  font-weight: 700;
}

.code-stack {
  position: relative;
  min-height: 20rem;
  overflow: hidden;
}

.code-empty {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 1.5rem;
  pointer-events: none;
  color: var(--ide-muted);
  text-align: center;
}

.code-empty[hidden] { display: none !important; }

.code-empty p {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  color: var(--ide-fg);
}

.code-empty em {
  font-style: normal;
  font-size: 0.8rem;
  max-width: 18rem;
  line-height: 1.4;
}

.code-empty .ico { color: var(--accent); opacity: 0.85; }

.code-highlight,
.code-editor {
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 0.85rem 0.95rem;
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.5;
  tab-size: 4;
  overflow: auto;
  position: absolute;
  inset: 0;
}

.code-highlight {
  background: var(--panel-dark);
  color: var(--ide-fg);
  pointer-events: none;
  z-index: 0;
  white-space: normal;
}

.code-highlight .code-line {
  white-space: pre;
  min-height: 1.5em;
  padding: 0 0.25rem;
  margin: 0 -0.25rem;
  border-radius: 0.15rem;
}

.code-highlight .code-line.mark-error {
  background: rgba(196, 90, 72, 0.22);
  box-shadow: inset 3px 0 0 #e07060;
}

.code-highlight .code-line.mark-warn {
  background: rgba(196, 160, 53, 0.16);
  box-shadow: inset 3px 0 0 #d4b24a;
}

.code-highlight .code-line.flash {
  animation: lintFlash 0.9s ease;
}

@keyframes lintFlash {
  0%,
  100% {
    filter: brightness(1);
  }
  40% {
    filter: brightness(1.45);
  }
}

.code-editor {
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: #f0c56e;
  z-index: 1;
  white-space: pre;
}

.code-editor:focus { outline: none; }
.code-editor::placeholder { color: var(--ide-muted); }

/* syntax tokens */
.tok-kw { color: #d4a0ff; }
.tok-fn { color: #7ec8ff; }
.tok-str { color: #9fd67a; }
.tok-num { color: #f0b070; }
.tok-com { color: #6d8b9c; font-style: italic; }
.tok-op { color: #a8bfcc; }

.ide-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0.8rem;
  border-top: 1px solid var(--ide-line);
  background: var(--ide-panel);
}

.ide .status { color: var(--ide-muted); }

.mem-panel {
  padding: 0.55rem 0.8rem 0.65rem;
  border-top: 1px solid var(--ide-line);
  background: var(--ide-panel);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.mem-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr auto;
  gap: 0.55rem;
  align-items: center;
}

.mem-label {
  font-size: 0.7rem;
  color: var(--ide-muted);
  font-weight: 600;
}

.mem-bar {
  height: 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.mem-bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: #4a9a5c;
  transition: width 0.25s ease, background 0.25s ease;
}

.mem-bar i.warn { background: #c4a035; }
.mem-bar i.danger { background: #c45a48; }

.mem-text {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: #c2d6e0;
  white-space: nowrap;
  min-width: 9rem;
  text-align: right;
}

.lint-list {
  list-style: none;
  margin: 0;
  padding: 0.4rem 0.8rem;
  border-top: 1px solid var(--ide-line);
  background: var(--ide-panel);
  max-height: 5.5rem;
  overflow: auto;
}

.lint-list:empty { display: none; }

.lint-list li {
  font-family: var(--mono);
  font-size: 0.68rem;
  line-height: 1.4;
  padding: 0.12rem 0;
  color: #a9c2ce;
}

.lint-list li.clickable {
  cursor: pointer;
}

.lint-list li.clickable:hover {
  color: #eaf3f7;
}

.lint-list .lint-line {
  display: inline-block;
  min-width: 2.2rem;
  margin-right: 0.35rem;
  padding: 0.05rem 0.3rem;
  border-radius: 0.25rem;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 700;
}

.lint-list li.error { color: #f0a090; }
.lint-list li.warn { color: #e0c56a; }
.lint-list li.ok { color: #7dce8f; }
.lint-list li.info { color: #8aa0b8; }

.log {
  margin: 0;
  max-height: 6.5rem;
  overflow: auto;
  padding: 0.5rem 0.8rem;
  border: 0;
  background: var(--ide-log);
  color: #9fb9c6;
  font-family: var(--mono);
  font-size: 0.68rem;
  line-height: 1.4;
  white-space: pre-wrap;
}

.log-details {
  border-top: 1px solid var(--ide-line);
  background: var(--ide-log);
}

.log-summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ide-muted);
  user-select: none;
}

.log-summary::-webkit-details-marker { display: none; }

.log-summary .ico {
  width: 0.9rem;
  height: 0.9rem;
}

.log-count {
  margin-left: auto;
  min-width: 1.2rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-family: var(--mono);
  font-size: 0.65rem;
  text-align: center;
}

.log-line { display: block; }
.log-line.lvl-info { color: #c5d8e2; }
.log-line.lvl-success { color: #7dce8f; }
.log-line.lvl-warn { color: #e0c56a; }
.log-line.lvl-error { color: #f0a090; }

.prompt-editor {
  min-height: 20rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  background: var(--field);
  color: var(--ink);
  border: 1px solid var(--line);
}

.dev-status {
  margin: 0.65rem 0 0;
  padding: 0.7rem;
  border-radius: 0.5rem;
  background: var(--field);
  color: var(--ink);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.45;
  white-space: pre-wrap;
  max-height: 14rem;
  overflow: auto;
}

.dev-status.muted { opacity: 0.85; max-height: 9rem; }

.panel-dev-models .lede {
  margin-bottom: 0.85rem;
}

.model-picker {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}

.model-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 0.75rem;
  align-items: start;
  width: 100%;
  text-align: left;
  padding: 0.7rem 0.85rem;
  border-radius: 0.65rem;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.model-card:hover {
  border-color: color-mix(in srgb, var(--ink) 45%, var(--line));
  background: #fff;
}

.model-card.is-active {
  border-color: var(--ink);
  background: color-mix(in srgb, var(--ink) 8%, #fff);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 35%, transparent);
}

.model-card-name {
  font-weight: 650;
  font-size: 0.95rem;
  line-height: 1.25;
}

.model-card-id {
  grid-column: 1 / -1;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: color-mix(in srgb, var(--ink) 65%, transparent);
  word-break: break-all;
}

.model-card-price {
  justify-self: end;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.model-card-usage {
  grid-column: 1 / -1;
  font-size: 0.78rem;
  color: color-mix(in srgb, var(--ink) 72%, transparent);
}

.model-card.is-active .model-card-usage {
  color: var(--ink);
}

.model-custom-label {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.model-custom-label span {
  font-size: 0.82rem;
  font-weight: 600;
}

.model-select-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.usage-panel {
  margin: 0.4rem 0 1rem;
  padding: 0.85rem 0.9rem;
  border-radius: 0.7rem;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--ink) 5%, #fff);
}

.usage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.usage-head .subhead {
  margin: 0;
}

.usage-model-name {
  margin: 0 0 0.45rem;
  font-weight: 650;
  font-size: 0.92rem;
}

.usage-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
  margin: 0;
}

.usage-stats div {
  padding: 0.45rem 0.5rem;
  border-radius: 0.45rem;
  background: #fff;
  border: 1px solid var(--line);
}

.usage-stats dt {
  margin: 0;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: color-mix(in srgb, var(--ink) 55%, transparent);
}

.usage-stats dd {
  margin: 0.15rem 0 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 650;
}

.usage-last {
  margin: 0.55rem 0 0;
}

.usage-by-model {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.usage-by-model li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8rem;
  padding: 0.35rem 0.45rem;
  border-radius: 0.4rem;
  background: #fff;
  border: 1px solid var(--line);
}

.usage-by-model .um-id {
  font-family: var(--mono);
  font-size: 0.72rem;
  word-break: break-all;
}

.usage-by-model .um-cost {
  font-family: var(--mono);
  font-weight: 650;
  white-space: nowrap;
  color: var(--accent);
}

/* ══════════════════════════════════════════════════════════════
   Progress spine: where am I, what is done
   ══════════════════════════════════════════════════════════════ */

.progress-spine {
  max-width: 920px;
  margin: 0 auto;
  padding: 0.8rem 1.2rem 0.1rem;
}

body.code-expanded .progress-spine {
  max-width: 1280px;
}

body.mode-dev .progress-spine { display: none !important; }
body.hide-dev .view-tabs { display: none !important; }

.ps-list {
  list-style: none;
  margin: 0 auto;
  padding: 0 0 0.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: auto;
  scrollbar-width: none;
}

.ps-list::-webkit-scrollbar { display: none; }

.ps-item {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.ps-item:not(:last-child)::after {
  content: "";
  width: 0.85rem;
  height: 2px;
  border-radius: 2px;
  background: var(--line);
  margin: 0 0.15rem;
}

.ps-step {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.26rem 0.6rem 0.26rem 0.28rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--step-todo-fg);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.ps-step:hover {
  color: var(--ink);
  background: var(--ink-tint-6);
}

.ps-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 50%;
  background: var(--ink-tint-8);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
}

.ps-dot i { font-style: normal; }

.ps-dot .ico {
  display: none;
  width: 0.85rem;
  height: 0.85rem;
  stroke-width: 2.8;
}

.ps-step.is-done { color: var(--step-done-fg); }

.ps-step.is-done .ps-dot {
  background: var(--ok);
  color: #fff;
}

.ps-step.is-done .ps-dot i { display: none; }
.ps-step.is-done .ps-dot .ico { display: block; }

.ps-step.is-active {
  color: var(--step-active-fg);
  background: var(--step-active-bg);
  border-color: var(--accent-line);
}

.ps-step.is-active .ps-dot {
  background: var(--accent);
  color: #fff;
}

.ps-step.is-active:hover {
  color: var(--step-active-fg);
  background: var(--step-active-bg);
}

.ps-step.is-done:hover {
  color: var(--step-done-fg);
  background: color-mix(in srgb, var(--ok) 14%, #fff);
}

/* ══════════════════════════════════════════════════════════════
   Primitives: icons, hover tooltips, info disclosure
   ══════════════════════════════════════════════════════════════ */

.ico {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ico-lg { width: 1.6em; height: 1.6em; }
.ico-xl { width: 2.4em; height: 2.4em; }

/* ── Hover tooltip: short context without permanent copy ──
   display:none rather than visibility:hidden — a hidden-but-laid-out
   tooltip still adds to the scroll area of the panel around it. */
[data-tip] { position: relative; }

[data-tip]:hover,
[data-tip]:focus-visible {
  z-index: 80;
}

[data-tip]::after {
  content: attr(data-tip);
  display: none;
  position: absolute;
  bottom: calc(100% + 0.45rem);
  left: 50%;
  translate: -50% 0;
  z-index: 60;
  width: max-content;
  max-width: 17rem;
  padding: 0.45rem 0.6rem;
  border-radius: 0.45rem;
  background: var(--ink);
  color: #fff;
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  white-space: normal;
  box-shadow: var(--shadow-2);
  pointer-events: none;
}

[data-tip]:hover::after,
[data-tip]:focus-visible::after {
  display: block;
}

/* Inside scroll containers a tooltip above the element gets clipped */
[data-tip].tip-below::after {
  bottom: auto;
  top: calc(100% + 0.45rem);
}

/* ── Info disclosure: (i) button revealing a body ── */
.info-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.4rem;
  height: 1.4rem;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--ink) 28%, transparent);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
  vertical-align: middle;
}

.info-btn .ico {
  width: 0.95rem;
  height: 0.95rem;
  stroke-width: 2.1;
}

.info-btn:hover {
  color: var(--accent-deep);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.info-btn[aria-expanded="true"] {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent-deep);
}

.info-body {
  margin: 0.55rem 0 0;
  padding: 0.7rem 0.85rem;
  border-radius: 0.55rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: var(--ink-tint-4);
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--ink);
  animation: infoReveal 0.16s ease;
}

.info-body[hidden] { display: none !important; }

.info-body > :first-child { margin-top: 0; }
.info-body > :last-child { margin-bottom: 0; }

.info-body p,
.info-body ul,
.info-body ol {
  margin: 0.4rem 0;
}

.info-body ul,
.info-body ol {
  padding-left: 1.15rem;
}

.info-body li { margin: 0.2rem 0; }

@keyframes infoReveal {
  from { opacity: 0; transform: translateY(-0.25rem); }
  to { opacity: 1; transform: none; }
}

/* A heading with its info toggle sitting next to it */
.with-info {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .usage-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sensor-cards { grid-template-columns: 1fr; }

  .flow-strip { flex-direction: column; }

  .flow-strip > li:not(:last-child)::after {
    top: auto;
    right: 50%;
    bottom: -0.42rem;
    rotate: 135deg;
    translate: 50% 0;
  }

  .download-card { flex-wrap: wrap; }
  .download-card .btn { width: 100%; }

  .flash-rail-steps {
    flex-direction: column;
    align-items: stretch;
  }

  .fr-step:not(:last-child)::after {
    top: auto;
    right: 50%;
    bottom: -0.45rem;
    rotate: 135deg;
    translate: 50% 0;
  }
}

/* Narrow: keep the spine readable by showing only the current label */
@media (max-width: 780px) {
  .ps-step .ps-label { display: none; }
  .ps-step.is-active .ps-label { display: inline; }
  .progress-spine { padding-left: 0.9rem; padding-right: 0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 960px) {
  .layout-studio, .layout-dev { grid-template-columns: 1fr; }
  body.code-expanded .layout-studio {
    grid-template-columns: 1fr;
    max-width: 920px;
  }
  .api-grid { max-height: min(55vh, 480px); }
  .top { flex-wrap: wrap; justify-content: center; }
  .brand { min-width: auto; }
  .view-tabs {
    position: static;
    translate: none;
    margin-top: 0.15rem;
  }
}
