#app {
  --panel-w: 302px;
  --base-group: #ffd277;
  --exp-group: #7bd9ff;
  --label: #9cadc3;
  --edge: #243247;
  --surface: #0b111c;
  background: #05070d;
  color-scheme: dark;
}
#app [hidden] { display: none !important; }
#stage {
  display: grid;
  grid-template-rows: auto auto minmax(180px, 1.12fr) auto minmax(228px, 1fr);
  gap: 10px;
  padding: 20px clamp(16px, 3vw, 44px);
  overflow: auto;
}
.workbench-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.workbench-head h1 { margin: 0; font-size: 21px; line-height: 1.28; }
.workbench-head p { margin: 4px 0 0; color: var(--label); font-size: 12px; }
.bench-link, #panel .learn-link { color: var(--accent); font-size: 12px; text-decoration: none; }
.bench-link { flex: none; padding: 10px 0 10px 6px; }
.bench-link:hover, #panel .learn-link:hover { text-decoration: underline; }
.presets { display: flex; gap: 8px; }
#app button {
  color: var(--accent); background: #121a28; border: 1px solid var(--edge);
  border-radius: 8px; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600;
}
#app button:hover { border-color: var(--accent); }
#app button.on { background: var(--accent); border-color: var(--accent); color: #191405; }
#app :focus-visible { outline: 2px solid #fff1b9; outline-offset: 2px; }
.presets button { min-height: 38px; padding: 0 17px; }
.chambers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; min-height: 0; }
.base-group { --group: var(--base-group); color: var(--group); }
.exp-group { --group: var(--exp-group); color: var(--group); }
.chamber, .analysis-card { border: 1px solid var(--edge); border-radius: 13px; background: var(--surface); overflow: hidden; }
.chamber { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.chamber header { padding: 11px 14px 8px; display: flex; justify-content: space-between; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; }
.chamber header h2 { font-size: 18px; line-height: 1.15; margin: 0; }
.chamber header p { color: var(--label); font-size: 12px; margin: 0; font-variant-numeric: tabular-nums; }
.chamber header br { display: none; }
.chamber canvas { width: 100%; height: 100%; min-height: 0; min-width: 0; }
.chamber footer {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 4px 6px;
  padding: 7px 14px 10px; border-top: 1px solid #202c3d; background: #101827;
}
.chamber footer span { color: var(--label); font-size: 11px; }
.chamber footer strong { font-size: 18px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.conversion-track { grid-column: 1 / -1; height: 3px; border-radius: 5px; background: #233146; overflow: hidden; }
.conversion-track i { display: block; height: 100%; width: 0; background: var(--group); border-radius: inherit; }
.species { display: flex; align-items: center; justify-content: center; gap: 8px; color: #c1ccda; font-size: 12px; }
.species span, .bond { display: inline-flex; align-items: center; gap: 4px; }
.species b { color: var(--label); font-weight: 400; }
.atom { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.atom-a { background: radial-gradient(circle at 33% 27%, #fff2bd, #f8b743 58%, #95541d); }
.atom-b { background: radial-gradient(circle at 33% 27%, #d8faff, #54c7f6 58%, #265ca0); }
.bond { gap: 0; }
.bond .atom + .atom { margin-left: -2px; }
.species small { color: var(--label); font-size: 11px; margin-left: 4px; }
.analysis-card { display: grid; grid-template-rows: auto minmax(74px, 1fr) auto auto; }
.chart-top { padding: 7px 12px 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chart-top .seg { gap: 4px; }
.chart-top .seg button { border: 1px solid var(--edge); border-radius: 7px; padding: 0 11px; min-height: 35px; }
.curve-key { display: flex; gap: 11px; font-size: 11px; white-space: nowrap; }
.curve-key span::before { content: ""; display: inline-block; width: 13px; margin-right: 4px; vertical-align: 3px; border-top: 2px solid var(--group); }
.curve-key .base-group::before { border-top-style: dashed; }
.plot { position: relative; min-height: 0; }
.plot canvas { position: absolute; width: 100%; height: 100%; }
.plot canvas.scrubbable { cursor: ew-resize; touch-action: none; }
.probe { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 0 13px 5px; margin: 0; min-height: 21px; color: var(--label); font-size: 11px; }
.probe-hint { margin-right: auto; }
.probe b { font-variant-numeric: tabular-nums; }
.timeline {
  display: grid; grid-template-columns: 42px 42px minmax(0, 1fr) 61px; align-items: center;
  gap: 8px; padding: 3px 11px; border-top: 1px solid #202c3d; background: #101827;
}
.timeline button { min-height: 38px; font-size: 18px !important; line-height: 1; }
.timeline input { margin: 0; min-height: 40px; cursor: ew-resize; }
.timeline output { color: #e6ebf2; white-space: nowrap; }
#panel { background: #0e1521; padding: 21px 16px; border-color: var(--edge); }
#panel h2 { font-size: 14px; margin: 0; }
.settings-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 13px; }
#panel .settings-head h2 { font-size: 16px; }
#closePanel { display: none; }
#panel .rate-summary { padding: 12px; margin-bottom: 14px; border: 1px solid var(--edge); border-radius: 12px; background: #151e2d; }
.ratio-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.ratio-row small, .rate-values small { color: var(--label); display: block; font-size: 11px; }
.ratio-row strong { color: var(--accent); font-size: 26px; line-height: 1; font-variant-numeric: tabular-nums; }
#panel .note { color: var(--label); }
.rate-values { border-top: 1px solid var(--edge); margin-top: 10px; padding-top: 9px; }
.rate-values p { display: flex; justify-content: space-between; gap: 4px; margin: 0; font-size: 12px; }
.rate-values dl { grid-template-columns: 1fr auto; margin-top: 6px; }
.rate-values dd { font-variant-numeric: tabular-nums; }
#panel .slider { grid-template-columns: 1fr auto; gap: 0 8px; margin: 11px 0 0; font-size: 13px; }
#panel .slider output { color: #c6d3e2; }
#panel .slider input { grid-column: 1 / -1; margin: 0; min-height: 33px; cursor: pointer; }
#panel .switch { min-height: 38px; font-size: 13px; }
#panel .switch input { margin: 0 5px 0 0; width: 17px; height: 17px; }
.actions button { min-height: 40px; width: 100%; }
#shareStatus { overflow-wrap: anywhere; }
#panel .learn-link { margin: 12px 0 0; }
#panel .related a { display: grid; grid-template-columns: 1fr auto; gap: 3px 8px; }
#panel .related a small { grid-column: 1; }
#panel .related a::after { grid-column: 2; grid-row: 1 / 3; align-self: center; white-space: nowrap; }
@media (max-width: 850px) {
  #app { display: block; position: relative; }
  #stage { position: absolute; inset: 0; grid-template-rows: auto auto minmax(157px, 1.04fr) auto minmax(228px, 1fr) auto; gap: 7px; padding: 9px 10px 10px; }
  .workbench-head h1 { font-size: 16px; }
  .workbench-head p { margin-top: 2px; font-size: 11px; }
  .presets { gap: 5px; }
  .presets button { flex: 1; min-width: 0; min-height: 44px; padding: 0 2px; }
  .chambers { gap: 7px; }
  .chamber { border-radius: 10px; }
  .chamber header { display: block; padding: 8px 8px 5px; }
  .chamber header h2 { font-size: 16px; }
  .chamber header p { margin-top: 3px; font-size: 11px; line-height: 1.4; }
  .chamber header p br { display: initial; }
  .condition-sep { display: none; }
  .chamber footer { padding: 5px 8px 7px; }
  .chamber footer strong { font-size: 16px; }
  .chart-top { padding: 4px 7px 0; }
  .chart-top .seg button { min-height: 44px; padding-inline: 8px; }
  .curve-key { gap: 7px; }
  .probe { gap: 7px; padding-inline: 8px; }
  .timeline { grid-template-columns: 44px 44px minmax(0, 1fr) 51px; gap: 5px; padding: 2px 6px; }
  .timeline button, .timeline input { min-height: 44px; }
  #app #panelToggle { display: block; position: static; z-index: auto; min-height: 44px; padding: 0 12px; border-radius: 8px; }
  #panel .settings-head { position: sticky; top: 0; z-index: 1; background: #0e1521; }
  #closePanel { display: block; min-width: 44px; min-height: 44px; font-size: 21px !important; }
  #panel { position: absolute; inset: auto 0 0; width: auto; max-height: 76%; z-index: 5; border: 1px solid var(--edge); border-radius: 14px 14px 0 0; padding: 10px 14px 20px; transform: none; transition: none; }
  #panel.collapsed { display: none; }
  #panel .slider input, #panel .switch, .actions button { min-height: 44px; }
}
@media (min-width: 851px) and (max-height: 680px) {
  #stage { padding-block: 12px; gap: 8px; }
}
@media (max-width: 350px) {
  .probe-hint { display: none; }
}
