/* qlab.css — Live Quantum Lab, circuit inspector, story mode and share links */

:root { --ql-nav-h: 64px; }

/* ---------- Lab section ---------- */
#qlab .ql-lead { color: #57534e; font-size: 14px; margin-bottom: 18px; max-width: 900px; }
.ql-step { border-top: 1px solid #e7e5e4; padding-top: 18px; margin-top: 20px; }
.ql-step:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.ql-step-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.ql-step-num {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: #0f172a; color: #fff; font: 700 13px 'JetBrains Mono', monospace; flex: none;
}
.ql-step-head h3 { font-size: 18px; color: #1c1917; margin: 0; }
.ql-step-head p { font-size: 13px; color: #78716c; margin: 0; flex-basis: 100%; padding-left: 36px; }
.ql-row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 12px; }
.ql-row label { font-size: 12.5px; font-weight: 600; color: #44403c; display: inline-flex; align-items: center; gap: 6px; }
.ql-row select, .ql-row input[type=number] {
  font: 500 13px 'Plus Jakarta Sans', sans-serif; padding: 6px 8px; border: 1px solid #d6d3d1;
  border-radius: 6px; background: #fff; color: #1c1917; max-width: 100%;
}
.ql-row input[type=number] { width: 80px; }
.ql-row input[type=range] { width: min(320px, 60vw); }
.ql-drop {
  border: 1.5px dashed #a8a29e; border-radius: 10px; padding: 14px 16px; font-size: 13px; color: #57534e;
  background: #fafaf9; transition: background .15s, border-color .15s;
}
.ql-drop.drag { background: #ecfeff; border-color: #0891b2; }
.ql-drop code { background: #f5f5f4; padding: 1px 5px; border-radius: 4px; }
.ql-stats { margin-top: 10px; font-size: 13px; color: #1c1917; display: flex; flex-wrap: wrap; gap: 8px; }
.ql-chip { background: #f5f5f4; border: 1px solid #e7e5e4; border-radius: 999px; padding: 3px 10px; font: 600 12px 'JetBrains Mono', monospace; }
.ql-chip.warn { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.ql-err { color: #b91c1c; font-weight: 600; }
.ql-grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 960px) { .ql-grid2 { grid-template-columns: minmax(0, 1fr); } }
.ql-card { background: #fff; border: 1px solid #e7e5e4; border-radius: 10px; padding: 14px; min-width: 0; }
.ql-card.dark { background: #0b1120; border-color: #1e293b; color: #e2e8f0; }
.ql-card canvas, #qlPrecision { display: block; width: 100%; height: auto; border: 0 !important; border-radius: 6px; background: transparent; }
#qlTopPairs td { white-space: nowrap; }
.ql-note { font-size: 12.5px; color: #57534e; margin-top: 10px; line-height: 1.6; }
.ql-progress { font-size: 12.5px; color: #0369a1; font-weight: 600; min-height: 1em; }
.ql-bar { height: 4px; background: #e0f2fe; border-radius: 4px; overflow: hidden; width: 180px; }
.ql-bar > i { display: block; height: 100%; background: #2f5f9e; width: 0; transition: width .2s; }

/* results table */
.ql-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ql-table th { text-align: left; font: 700 11px 'JetBrains Mono', monospace; color: #78716c; text-transform: uppercase; padding: 6px 6px; border-bottom: 1px solid #e7e5e4; }
.ql-table td { padding: 7px 6px; border-bottom: 1px solid #f5f5f4; vertical-align: middle; }
.ql-table tr[data-id] { cursor: pointer; }
.ql-table tr[data-id]:hover td { background: #fafaf9; }
.ql-table tr.off td { opacity: .4; }
.ql-sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; }
.ql-tag { font: 700 10px 'JetBrains Mono', monospace; padding: 1px 6px; border-radius: 4px; margin-left: 6px; }
.ql-tag.q { background: #ece6f6; color: #6b21a8; }
.ql-tag.c { background: #f1f5f9; color: #475569; }
.ql-auc { display: flex; align-items: center; gap: 8px; font-family: 'JetBrains Mono', monospace; font-weight: 700; }
.ql-auc i { display: block; height: 6px; border-radius: 3px; background: #2f5f9e; }
.ql-mono { font-family: 'JetBrains Mono', monospace; }
.ql-btn-sm { font: 600 12px 'Plus Jakarta Sans', sans-serif; padding: 4px 9px; border-radius: 6px; border: 1px solid #c4b5fd; background: #f5f3ff; color: #5b21b6; cursor: pointer; }
.ql-btn-sm:hover { background: #ede9fe; }
.ql-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: #cbd5e1; margin-top: 10px; }
.ql-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ql-legend i { display: inline-block; width: 22px; height: 0; border-top: 3px solid; }
.ql-legend i.dash { border-top-style: dashed; }
.ql-tlinfo { font-size: 13px; margin-top: 8px; color: #1c1917; }

/* ---------- Circuit inspector (dark, used in overview and lab) ---------- */
.qi { background: #0b1120; border: 1px solid #1e293b; border-radius: 12px; padding: 14px; color: #e2e8f0; font-size: 13px; }
.qi h4 { font: 700 12px 'JetBrains Mono', monospace; color: #a9c6ec; text-transform: uppercase; letter-spacing: .04em; margin: 0 0 8px; }
.qi-title { font-weight: 700; color: #f8fafc; margin-bottom: 4px; }
.qi-sub { color: #94a3b8; font-size: 12.5px; margin-bottom: 12px; }
.qi-circuit { overflow-x: auto; background: #060a12; border: 1px solid #1e293b; border-radius: 8px; padding: 6px 4px; margin-bottom: 14px; }
.qi-circuit svg { display: block; max-width: none !important; } /* scroll sideways, never shrink */
.qi-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 14px; }
@media (max-width: 860px) { .qi-grid { grid-template-columns: minmax(0, 1fr); } }
.qi-amps { display: flex; align-items: flex-end; gap: 3px; height: 130px; padding: 0 2px; border-bottom: 1px solid #334155; }
.qi-amps > div { flex: 1 1 0; min-width: 6px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.qi-amps b { display: block; width: 100%; border-radius: 3px 3px 0 0; min-height: 1px; }
.qi-amps em { font-style: normal; font: 600 10px 'JetBrains Mono', monospace; color: #cbd5e1; margin-bottom: 2px; }
.qi-labels { display: flex; gap: 3px; padding: 4px 2px 0; }
.qi-labels span { flex: 1 1 0; min-width: 6px; text-align: center; font: 500 9.5px 'JetBrains Mono', monospace; color: #94a3b8; overflow: hidden; }
.qi-labels.v span { writing-mode: vertical-rl; transform: rotate(180deg); height: 34px; line-height: 1; }
.qi-blochs { display: flex; flex-wrap: wrap; gap: 10px; }
.qi-blochs figure { margin: 0; text-align: center; font: 500 11px 'JetBrains Mono', monospace; color: #cbd5e1; }
.qi-metrics { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.qi-metrics span { background: #111827; border: 1px solid #1f2937; border-radius: 6px; padding: 4px 8px; font: 600 12px 'JetBrains Mono', monospace; }
.qi-metrics span b { color: #86c4a4; }
.qi-export { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; align-items: center; }
.qi-export button, .qi-export a {
  font: 600 12px 'Plus Jakarta Sans', sans-serif; padding: 6px 10px; border-radius: 6px; cursor: pointer;
  border: 1px solid #334155; background: #1e293b; color: #e2e8f0; text-decoration: none;
}
.qi-export button:hover, .qi-export a:hover { border-color: #8db4e6; color: #fff; }
.qi-export button.primary { background: #6d28d9; border-color: #5a3f96; }
.qi-export pre {
  flex-basis: 100%; max-height: 220px; overflow: auto; background: #060a12; border: 1px solid #1e293b;
  border-radius: 8px; padding: 10px; font: 12px/1.5 'JetBrains Mono', monospace; color: #cbd5e1; white-space: pre; margin: 4px 0 0;
}
.qi-hint { color: #94a3b8; font-size: 12px; flex-basis: 100%; }
.ql-details { margin-top: 12px; }
.ql-details > summary {
  cursor: pointer; list-style: none; font-weight: 700; color: #a9c6ec; font-size: 13.5px;
  padding: 8px 12px; background: #090d16; border: 1px solid #334155; border-radius: 8px;
}
.ql-details > summary::-webkit-details-marker { display: none; }
.ql-details > summary::before { content: '▸ '; }
.ql-details[open] > summary::before { content: '▾ '; }
.ql-details[open] > summary { border-radius: 8px 8px 0 0; }
.ql-details > .qi { border-radius: 0 0 12px 12px; border-top: 0; }

/* ---------- Story mode ---------- */
.story-on #bridgeStoryCanvas { position: sticky; top: calc(var(--ql-nav-h) + 6px); z-index: 6; box-shadow: 0 10px 30px rgba(2, 6, 23, .55); }
.story-on #bridgeStoryExplainBox { display: none; }
#bridgeStory { margin-top: 10px; }
.story-step { min-height: 72vh; display: flex; align-items: center; justify-content: center; padding: 8vh 0; }
.story-card {
  max-width: 680px; width: 100%; background: rgba(15, 23, 42, .96); border: 1px solid #334155; border-radius: 12px;
  padding: 18px 20px; color: #e2e8f0; font-size: 14px; line-height: 1.7; transition: border-color .2s, transform .2s;
}
.story-step.active .story-card { border-color: #8db4e6; transform: scale(1.01); }
.story-card h4 { color: #86c4a4; font-size: 15.5px; margin: 0 0 8px; }
.story-card .story-k { font: 700 11px 'JetBrains Mono', monospace; color: #a9c6ec; text-transform: uppercase; margin-bottom: 4px; }
.story-live { margin-top: 10px; font: 600 12px 'JetBrains Mono', monospace; color: #dcb56a; }
.story-end { text-align: center; padding: 10px 0 20px; }

/* ---------- Toast ---------- */
.ql-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; z-index: 2000;
  background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .3); transition: opacity .2s, transform .2s; pointer-events: none;
  max-width: calc(100vw - 32px);
}
.ql-toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 768px) {
  .ql-step-head p { padding-left: 0; }
  .ql-card { padding: 10px; }
  .story-step { min-height: 60vh; }
}
@media (prefers-reduced-motion: reduce) {
  .story-card, .ql-toast, .ql-bar > i { transition: none; }
}

/* brief highlight so a re-run is visibly a re-run */
@keyframes qlFlash { from { background: #fff7d6; } to { background: transparent; } }
.ql-flash { animation: qlFlash 1.2s ease-out; }
.ql-progress { font-weight: 500; }

/* ---------- qexp.js: real experiments, claim checker, guide ---------- */
.qx-plain { font-size: 14px; line-height: 1.65; color: #34322f; margin: 8px 0 12px; max-width: 900px; }
.qx-small { font-size: 12.5px; line-height: 1.55; color: #6f6b65; margin: 6px 0; }
.qx-callout:empty { display: none; }
.qx-callout { background: #f3f1ec; border: 1px solid #e6e2db; border-left: 3px solid #1f4f8f; border-radius: 6px; padding: 10px 14px; font-size: 13.5px; line-height: 1.6; color: #34322f; margin: 12px 0; }
.qx-h3 { font-family: 'Newsreader', Georgia, serif; font-size: 21px; font-weight: 600; color: #1c1917; margin: 0 0 4px; }
.qx-h4 { font-size: 13px; font-weight: 600; color: #44403c; margin: 0 0 6px; }
.qx-race { background: #fff; border: 1px solid #e6e2db; border-radius: 8px; padding: 18px 20px; margin-top: 16px; color: #34322f; }
.qx-race .ql-row label { color: #44403c; }
.qx-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: #57534e; margin: 8px 0 0; align-items: center; }
.qx-legend i { display: inline-block; width: 18px; height: 4px; border-radius: 2px; margin-right: -10px; vertical-align: middle; }
.qx-key { display: inline-flex; align-items: center; gap: 6px; }
.qx-key i { display: inline-block; width: 11px; height: 11px; }
.qx-key i.ring { border: 2px solid #78716c; border-radius: 50%; background: #fff; }
.qx-key i.dot { background: #5a3f96; border-radius: 50%; }
.qx-key i.sq { background: #1f4f8f; }
.qx-key i.dia { background: #a87526; transform: rotate(45deg) scale(0.85); }
.qx-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.qx-tab { font: 600 13px 'Plus Jakarta Sans', sans-serif; padding: 7px 14px; border-radius: 6px; border: 1px solid #d4cec4; background: #fff; color: #34322f; cursor: pointer; }
.qx-tab:hover { background: #f3f1ec; }
.qx-tab.on { background: #1f4f8f; border-color: #1f4f8f; color: #fff; }
.qx-list { margin: 6px 0 0 18px; padding: 0; font-size: 13.5px; line-height: 1.6; color: #34322f; }
.qx-list li { margin-bottom: 6px; }
.qx-hbar { display: grid; grid-template-columns: minmax(150px, 230px) 1fr 60px; gap: 10px; align-items: center; font-size: 13px; margin: 6px 0; }
.qx-hbar i { display: block; height: 14px; border-radius: 3px; min-width: 2px; }
.ql-tag.x { background: #f6efe1; color: #8a6420; }
#qxClaimCanvas, #qxRaceCanvas, #qxNoiseSpread, #qxNoiseFaith { display: block; width: 100%; background: #fff !important; border: 0 !important; }
.qx-guide { border: 1px solid #e6e2db; border-radius: 10px; padding: 0; max-width: 560px; width: calc(100vw - 32px); color: #34322f; }
.qx-guide::backdrop { background: rgba(28, 27, 25, 0.45); }
.qx-guide form { padding: 22px 24px; }
.qx-guide h2 { font-family: 'Newsreader', Georgia, serif; font-size: 24px; margin: 0 0 8px; color: #1c1917; }
.qx-steps { list-style: none; margin: 14px 0; padding: 0; display: grid; gap: 12px; }
.qx-steps li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; font-size: 14px; line-height: 1.5; }
.qx-num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 1px solid #1f4f8f; color: #1f4f8f; font-weight: 600; font-size: 13px; }
.qx-link { background: none; border: 0; padding: 0; color: #1f4f8f; text-decoration: underline; text-underline-offset: 3px; font: inherit; cursor: pointer; }
@media (max-width: 640px) { .qx-hbar { grid-template-columns: 1fr 50px; } .qx-hbar span { grid-column: 1 / -1; } }
