/* ChemLab — Virtual Lab view */

.lab-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(340px, 1fr) minmax(340px, 460px);
  gap: 16px;
  align-items: start;
}

/* ---------------------------------------------------------- inventory rail */

.inv {
  position: sticky; top: calc(var(--topbar-h) + 16px);
  max-height: calc(100vh - var(--topbar-h) - 34px);
  display: flex; flex-direction: column; overflow: hidden;
}
.inv-head { padding: 14px 14px 10px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.inv-title { font-size: 1.05rem; }

.cat-rail { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 3px; scrollbar-width: none; }
.cat-rail::-webkit-scrollbar { display: none; }
.cat-btn {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  padding: 5px 10px; border-radius: 99px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(120,170,220,0.06);
  color: var(--ink-2); font-size: 0.75rem; font-weight: 600; transition: all 0.15s var(--ease);
}
.cat-btn:hover { color: var(--ink); background: rgba(120,170,220,0.14); }
.cat-btn.active {
  color: #05121a; background: linear-gradient(140deg, var(--cyan), #6fe3c6);
  border-color: transparent;
}

.tile-grid { overflow-y: auto; padding: 10px; display: grid; gap: 6px; }

.tile {
  position: relative; display: grid;
  grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--radius-sm); cursor: pointer; text-align: left;
  border: 1px solid var(--line); background: rgba(10,17,29,0.5);
  transition: all 0.14s var(--ease);
}
.tile:hover { background: rgba(24,38,60,0.8); border-color: var(--line-strong); transform: translateX(2px); }
.tile.selected {
  border-color: rgba(53,224,216,0.6); background: rgba(53,224,216,0.1);
  box-shadow: inset 3px 0 0 var(--cyan);
}
.tile[draggable='true']:active { cursor: grabbing; }
.tile-swatch {
  width: 13px; height: 24px; border-radius: 4px; flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.18) inset, 0 0 10px -2px currentColor;
}
.tile-main { min-width: 0; display: grid; }
.tile-name { font-size: 0.82rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-formula { font-size: 0.7rem; color: var(--ink-3); }
.tile-tags { display: flex; align-items: center; gap: 4px; }
.tile-state {
  font-family: var(--mono); font-size: 0.6rem; padding: 2px 5px; border-radius: 5px;
  background: rgba(126,168,214,0.14); color: var(--ink-2);
}
.tile-hazard { font-size: 0.7rem; color: var(--amber); }
.tile-info {
  position: absolute; right: 6px; top: 6px; width: 17px; height: 17px;
  display: grid; place-items: center; border-radius: 50%;
  font-size: 0.62rem; font-weight: 800; font-family: var(--mono);
  background: rgba(126,168,214,0.18); color: var(--ink-2);
  opacity: 0; transition: opacity 0.15s;
}
.tile:hover .tile-info, .tile-info:focus { opacity: 1; }
.tile-info:hover { background: var(--cyan); color: #05121a; }
@media (hover: none) { .tile-info { opacity: 0.7; } }

/* category accents on the tile swatch edge */
.tile.cat-acid { box-shadow: inset 2px 0 0 rgba(255,93,122,0.5); }
.tile.cat-base { box-shadow: inset 2px 0 0 rgba(158,240,26,0.5); }
.tile.cat-salt { box-shadow: inset 2px 0 0 rgba(74,168,255,0.5); }
.tile.cat-metal { box-shadow: inset 2px 0 0 rgba(169,189,214,0.6); }
.tile.cat-indicator { box-shadow: inset 2px 0 0 rgba(139,123,255,0.6); }
.tile.cat-gas { box-shadow: inset 2px 0 0 rgba(53,224,216,0.5); }
.tile.cat-condition { box-shadow: inset 2px 0 0 rgba(255,179,64,0.7); }
.tile.selected { box-shadow: inset 3px 0 0 var(--cyan); }

/* ------------------------------------------------------------------ bench */

.bench { display: grid; gap: 14px; }

.flow {
  display: flex; align-items: center; gap: 0; list-style: none; margin: 0; padding: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 99px;
  padding: 6px; overflow-x: auto; scrollbar-width: none;
}
.flow::-webkit-scrollbar { display: none; }
.flow-step {
  display: flex; align-items: center; gap: 7px; padding: 4px 12px;
  border-radius: 99px; color: var(--ink-3); font-size: 0.76rem; font-weight: 600;
  white-space: nowrap; transition: all 0.25s var(--ease); flex: 1; justify-content: center;
}
.flow-dot {
  width: 19px; height: 19px; border-radius: 50%; display: grid; place-items: center;
  font-size: 0.62rem; font-family: var(--mono); font-weight: 700;
  background: rgba(126,168,214,0.16); color: var(--ink-3);
}
.flow-step.done { color: var(--ink-2); }
.flow-step.done .flow-dot { background: rgba(53,224,216,0.25); color: var(--cyan); }
.flow-step.active { color: #05121a; background: linear-gradient(140deg, var(--cyan), #6fe3c6); }
.flow-step.active .flow-dot { background: rgba(0,0,0,0.22); color: #05121a; }

.lesson-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border-color: rgba(139,123,255,0.4); background: rgba(139,123,255,0.08);
}
.lesson-banner p { flex: 1; margin: 0; min-width: 180px; }

.stage { position: relative; overflow: hidden; }
.stage-drop {
  position: relative; min-height: 420px; display: grid; place-items: center;
  transition: background 0.2s;
}
.stage-drop.over { background: rgba(53,224,216,0.08); box-shadow: inset 0 0 0 2px rgba(53,224,216,0.4); }
.beaker-canvas { display: block; width: 100%; height: 440px; max-height: 52vh; }
.stage-hint {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  padding: 7px 14px; border-radius: 99px; font-size: 0.76rem; color: var(--ink-3);
  background: rgba(6,11,20,0.75); border: 1px dashed var(--line-strong); white-space: nowrap;
}
.stage-readout {
  position: absolute; top: 12px; left: 12px; display: flex; flex-wrap: wrap; gap: 6px; max-width: 70%;
}
.readout-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 99px; font-size: 0.7rem;
  background: rgba(6,11,20,0.72); border: 1px solid var(--line); color: var(--ink-2);
}
.readout-chip i { width: 8px; height: 8px; border-radius: 50%; display: block; }

/* ------------------------------------------------------------------- tray */

.tray { display: grid; gap: 12px; }
.tray-title { font-size: 1rem; }
.tray-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.slot {
  display: flex; align-items: center; gap: 9px; min-height: 58px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: rgba(10,17,29,0.45);
}
.slot.empty {
  border-style: dashed; flex-direction: column; gap: 2px; justify-content: center;
  color: var(--ink-3);
}
.slot-plus { font-size: 1.15rem; line-height: 1; color: var(--ink-3); }
.slot-hint { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.08em; }
.slot.filled { border-color: var(--line-strong); background: rgba(24,38,60,0.7); }
.slot-swatch { width: 9px; height: 34px; border-radius: 4px; flex-shrink: 0; box-shadow: 0 0 10px -2px currentColor; }
.slot-body { min-width: 0; display: grid; flex: 1; }
.slot-name { font-size: 0.76rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-formula { font-size: 0.66rem; color: var(--ink-3); }
.slot-x {
  width: 21px; height: 21px; flex-shrink: 0; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--ink-3); line-height: 1;
}
.slot-x:hover { color: var(--rose); border-color: rgba(255,93,122,0.45); background: rgba(255,93,122,0.1); }

.tray-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tray-actions .btn-primary { flex: 1; min-width: 170px; }

/* ---------------------------------------------------------------- results */

.results { position: sticky; top: calc(var(--topbar-h) + 16px); max-height: calc(100vh - var(--topbar-h) - 34px); overflow-y: auto; }

.results-idle { display: grid; gap: 12px; }
.idle-tips { display: grid; gap: 8px; }
.idle-tip {
  display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: rgba(10,17,29,0.4);
}
.idle-tip-icon { font-size: 1rem; }
.idle-tip b { font-size: 0.8rem; }

.result-card { overflow: hidden; animation: resultIn 0.45s var(--ease); }
@keyframes resultIn { from { opacity: 0; transform: translateY(14px); } }
.result-card.inert { opacity: 0.96; }

.result-head {
  padding: 16px 17px 14px; display: grid; gap: 9px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(140deg, rgba(53,224,216,0.1), transparent 65%);
}
.accent-violet .result-head { background: linear-gradient(140deg, rgba(139,123,255,0.13), transparent 65%); }
.accent-rose .result-head { background: linear-gradient(140deg, rgba(255,93,122,0.12), transparent 65%); }
.accent-amber .result-head { background: linear-gradient(140deg, rgba(255,179,64,0.12), transparent 65%); }
.accent-lime .result-head { background: linear-gradient(140deg, rgba(158,240,26,0.1), transparent 65%); }
.accent-blue .result-head { background: linear-gradient(140deg, rgba(74,168,255,0.12), transparent 65%); }

.result-head-top { display: flex; gap: 11px; align-items: flex-start; }
.result-icon {
  font-size: 1.5rem; line-height: 1; width: 42px; height: 42px; flex-shrink: 0;
  display: grid; place-items: center; border-radius: 12px;
  background: rgba(6,11,20,0.6); border: 1px solid var(--line-strong);
}
.result-head-text h2 { font-size: 1.12rem; margin-top: 2px; }
.result-chips { gap: 5px; }

.sim-warning {
  margin: 12px 17px 0; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid rgba(139,123,255,0.45); background: rgba(139,123,255,0.1);
}
.sim-warning.hazard { border-color: rgba(255,179,64,0.45); background: rgba(255,179,64,0.09); }
.sim-warning b { display: block; font-size: 0.76rem; letter-spacing: 0.05em; color: var(--amber); margin-bottom: 3px; }
.sim-warning p { margin: 0; color: var(--ink-2); }

.result-section { padding: 14px 17px; border-top: 1px solid var(--line); }
.result-section:first-of-type { border-top: 0; }
.result-section-title {
  display: flex; align-items: center; gap: 7px; margin-bottom: 8px;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.13em;
  color: var(--cyan); font-weight: 700;
}
.result-section p { color: var(--ink-2); font-size: 0.88rem; }

.obs-list { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.obs-list li { font-size: 0.86rem; color: var(--ink); }
.obs-list li::marker { color: var(--cyan); }

.eq-label { margin: 9px 0 5px; }
.eq-ionic { background: rgba(53,224,216,0.06); border-color: rgba(53,224,216,0.22); font-size: 0.86rem; }

.chart-grid { display: grid; gap: 12px; }

.product-grid { display: grid; gap: 9px; }
.product {
  display: flex; gap: 11px; padding: 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: rgba(10,17,29,0.45);
}
.product-swatch {
  width: 11px; border-radius: 4px; flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.16) inset, 0 0 12px -2px currentColor;
}
.product-body { min-width: 0; flex: 1; }
.product-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 650; font-size: 0.88rem; }
.product-formula { font-size: 0.74rem; color: var(--ink-3); margin-top: 1px; }
.product-props { margin: 7px 0 0; padding-left: 16px; display: grid; gap: 2px; }
.product-props li { font-size: 0.77rem; color: var(--ink-2); }
.product-props li::marker { color: var(--ink-3); }
.product-real { margin-top: 7px; color: var(--ink-2); }
.product-real b { color: var(--cyan); font-weight: 650; }

.result-foot {
  display: flex; gap: 8px; flex-wrap: wrap; padding: 13px 17px;
  border-top: 1px solid var(--line); background: rgba(6,11,20,0.35);
}

/* --------------------------------------------------------------- responsive */

@media (max-width: 1420px) {
  .lab-layout { grid-template-columns: minmax(240px, 290px) 1fr; }
  .results { grid-column: 1 / -1; position: static; max-height: none; }
}
@media (max-width: 900px) {
  .lab-layout { grid-template-columns: 1fr; }
  .inv { position: static; max-height: none; order: 2; }
  .tile-grid { max-height: 340px; }
  .bench { order: 1; }
  .results { order: 3; }
  .beaker-canvas { height: 360px; }
  .stage-drop { min-height: 340px; }
}
@media (max-width: 560px) {
  .tray-slots { grid-template-columns: 1fr; }
  .flow-step .flow-label { display: none; }
  .flow-step.active .flow-label { display: inline; }
  .beaker-canvas { height: 300px; }
  .stage-drop { min-height: 290px; }
  .result-section, .result-head, .result-foot { padding-left: 13px; padding-right: 13px; }
  .sim-warning { margin-left: 13px; margin-right: 13px; }
}
