/* ── experiment shell — full-screen with fixed header ── */

html, body {
  height: 100%; height: 100dvh;
  overflow: hidden;
}

.exp-shell {
  display: flex;
  flex-direction: column;
  height: 100%; height: 100dvh;
}

/* header bar */
.exp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  flex-shrink: 0;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.exp-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.exp-breadcrumb {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.exp-breadcrumb a { color: var(--dim); text-decoration: none; }
.exp-breadcrumb a:hover { color: var(--cyan); }
.exp-breadcrumb strong { color: var(--text); font-weight: 500; }

.exp-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--dim);
  font-size: 0.85rem;
  line-height: 1;
  text-decoration: none;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.exp-close:hover { color: #fff; border-color: #fff; }
.exp-close:active { background: var(--surface2); }

/* theme toggle button — same shape as close, sits beside it */
.exp-theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--dim);
  background: none;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.exp-theme-btn:hover { color: var(--text); border-color: var(--dim); background: var(--surface2); }

/* language toggle button — pill shape, sits between theme btn and close */
.exp-lang-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 30px; padding: 0 10px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 15px;
  color: var(--dim);
  background: none;
  cursor: pointer;
  font-size: 0.62rem;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.exp-lang-btn:hover { color: var(--text); border-color: var(--dim); background: var(--surface2); }

/* scrollable body */
.exp-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ── experiment layout — widget-first ──
   .exp-intro becomes transparent (display:contents) so its children
   participate directly in the .exp-stage flex layout via `order`.
   Visual order: label → title → interactive elements → desc → shock → info
*/
.exp-stage {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 20px 16px 24px;
  max-width: 640px;
  margin: 0 auto;
  gap: 14px;
  width: 100%;
}

.exp-intro {
  display: contents; /* children become direct flex items of .exp-stage */
}

.exp-label {
  order: -3;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cyan);
}

.exp-title {
  order: -2;
  font-family: var(--font-mono);
  font-size: clamp(1.4rem, 6vw, 2rem);
  font-weight: 700;
  line-height: 1.1;
  color: #fff;
  margin-bottom: 2px;
}
[data-theme="light"] .exp-title { color: var(--text); }

.exp-desc {
  order: 10;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.75;
  opacity: 0.8;
}

/* shock box — appears after the interactive widget */
.shock {
  order: 11;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: 4px;
  padding: 13px 16px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--text);
}
.shock strong { color: var(--red); font-weight: 600; }
.shock code {
  font-family: var(--font-mono);
  background: var(--muted);
  padding: 1px 5px;
  border-radius: 2px;
  font-size: 0.68rem;
}

/* action button */
.exp-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 1px solid var(--cyan);
  border-radius: 6px;
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 13px 24px;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.12s, color 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.exp-btn:hover, .exp-btn:active { background: var(--cyan); color: #000; }
.exp-btn.stop { border-color: var(--red); color: var(--red); }
.exp-btn.stop:hover { background: var(--red); color: #000; }
.exp-btn.ghost { border-color: var(--border); color: var(--dim); }
.exp-btn.ghost:hover { border-color: var(--dim); color: var(--dim); }

/* stat row */
.stat-row {
  display: flex;
  gap: 0;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.stat-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 8px;
  border-right: 1px solid var(--border);
}
.stat-cell:last-child { border-right: none; }
.stat-val {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--cyan);
}
.stat-lbl {
  font-family: var(--font-mono);
  font-size: 0.52rem;
  color: var(--dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* vis canvas area */
.vis-frame {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}
.vis-frame canvas { width: 100%; display: block; }
.vis-label {
  position: absolute;
  top: 8px; left: 12px;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

/* info accordion — appears last */
.exp-info {
  order: 15;
  width: 100%;
}
.exp-info details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
}
.exp-info summary {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--dim);
  cursor: pointer;
  letter-spacing: 0.04em;
  list-style: none;
}
.exp-info summary::-webkit-details-marker { display: none; }
.exp-info details[open] summary { color: var(--cyan); margin-bottom: 10px; }
.exp-info p, .exp-info li {
  font-family: var(--font-body);
  font-size: 0.82rem;
  color: var(--text);
  opacity: 0.75;
  line-height: 1.8;
  margin-top: 8px;
}
.exp-info ul, .exp-info ol {
  padding-left: 18px;
}
.exp-info code {
  font-family: var(--font-mono);
  background: var(--muted);
  padding: 1px 5px;
  border-radius: 2px;
  font-size: 0.67rem;
}
