/* 酸碱中和实验台 */
#app {
  --panel-w: 320px;
  --lab-border: #253447;
  --lab-panel: #0d1420;
  min-height: 520px;
}
#stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 16px 20px 12px;
  background: radial-gradient(ellipse at 28% 42%, #101b2b 0, #05070d 68%);
}
.lab-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lab-title h1 { color: var(--text); font-size: 18px; margin: 0; }
.lab-title a { display: grid; align-items: center; min-height: 40px; font-size: 12px; color: var(--accent); text-decoration: none; white-space: nowrap; }
.lab-title a:hover { text-decoration: underline; }

.lab-readings { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 6px 0 0;
  border: 1px solid var(--lab-border); border-radius: 10px; background: var(--lab-panel); }
.lab-readings > div { min-width: 0; padding: 7px 12px; }
.lab-readings > div + div { border-left: 1px solid var(--lab-border); }
.lab-readings dt { font-size: 11px; }
.lab-readings dd { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kind { font-size: 11px; font-weight: 650; vertical-align: 1px; }
.kind.acid { color: #ff947d; }
.kind.base { color: #65d0ff; }
.kind.neutral { color: #8ae49e; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px;
  vertical-align: middle; border: 1px solid rgba(255,255,255,.3); }
#indSwatch[hidden] { display: none; }

.lab-view { position: relative; min-height: 0; }
#neutral { position: absolute; inset: 0; touch-action: pan-y; }
#neutral:focus-visible { outline-offset: -2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.lab-toolbar { border-top: 1px solid var(--lab-border); padding-top: 10px; }
.actions { display: flex; gap: 8px; }
.actions button, #panelClose, #nearBtn {
  min-height: 44px; background: var(--lab-panel); color: var(--accent); border: 1px solid #4e4432;
  border-radius: 8px; padding: 0 14px; font: inherit; font-size: 12px; font-weight: 650; cursor: pointer;
}
.actions button:hover:not(:disabled), #panelClose:hover, #nearBtn:hover { border-color: var(--accent); background: #242016; }
.actions #dropBtn { min-width: 120px; }
.actions #dropBtn.hot, #panelToggle[aria-expanded=true] { background: var(--accent); color: #171003; border-color: var(--accent); }
.actions button:disabled { opacity: .48; cursor: default; }
#rProc { min-height: 2.9em; margin: 4px 0 0; color: #b8c6d7; }

#panel { background: #101620; border-color: var(--lab-border); padding-top: 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; min-height: 36px; margin-bottom: 6px; }
#panel .panel-head h2 { font-size: 16px; color: var(--text); margin: 0; }
#panel section { border-color: var(--lab-border); }
#panel h2 { font-size: 14px; letter-spacing: 0; }
#panel .note { color: #a9b8cb; }
#panel .seg { width: 100%; }
#panel .seg button { min-height: 40px; flex: 1; color: var(--accent); }
#panel .seg button.on { color: #171003; }
#nearBtn { margin-top: 9px; width: 100%; }
#panelClose { display: none; }

.opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 6px; }
.opts.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.opts button { min-height: 46px; font: inherit; color: var(--accent); background: var(--lab-panel); border: 1px solid var(--lab-border);
  border-radius: 8px; padding: 4px; cursor: pointer; line-height: 1.25; }
.opts button b { display: block; font-size: 13px; }
.opts button small { font-size: 11px; color: #acb9ca; }
.opts button:hover { border-color: var(--accent); }
.opts button.on { background: #2b2518; border-color: var(--accent); }

#panel details { border-top: 1px solid var(--lab-border); padding: 0 0 2px; }
#panel details[open] { padding-bottom: 12px; }
#panel summary { min-height: 44px; align-content: center; color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer; }
#panel summary small { margin-left: 4px; color: #a9b8cb; font-weight: 400; }
#panel .slider { grid-template-columns: auto minmax(50px, 1fr) auto; font-size: 12px; }
#panel .slider input { min-height: 44px; margin: 0; }
.checks label { display: flex; align-items: center; min-height: 44px; gap: 4px; font-size: 12px; }
.eq { font-family: var(--mono); font-size: 13px; margin: 0 0 4px; }
.eq.sub { color: var(--accent); }

.tbl { max-height: 188px; overflow-y: auto; border: 1px solid var(--lab-border); border-radius: 8px; }
.tbl table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 3px 8px; text-align: right; border-bottom: 1px solid var(--lab-border); white-space: nowrap; }
.tbl th { position: sticky; top: 0; background: var(--panel-2); color: #b6c4d6; }
.tbl td:nth-child(n+3), .tbl th:nth-child(n+3) { text-align: left; }
#panel .compare td, #panel .compare th { text-align: center; }
#panel .compare td { color: var(--text); }
.tbl:not(.compare) tbody tr:last-child td { border-bottom: 0; color: var(--accent); }
#app :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (min-width: 901px) and (max-width: 1060px) {
  #app { min-height: 600px; }
}
@media (max-width: 900px) {
  #app { display: block; position: relative; min-height: 645px; }
  #stage { position: absolute; inset: 0; padding: 5px 10px; gap: 7px; }
  .lab-title h1 { font-size: 16px; }
  .lab-readings { margin-top: 2px; }
  .lab-readings > div { padding: 5px 6px; }
  .lab-readings dd { font-size: 15px; }
  .kind { font-size: 10px; }
  .lab-toolbar { padding-top: 6px; }
  .actions { display: grid; grid-template-columns: 1.35fr 1fr 1fr 1fr; gap: 5px; }
  .actions button, .actions #dropBtn { min-width: 0; padding: 0 3px; }
  #rProc { font-size: 11px; }
  #panelToggle { position: static; z-index: auto; display: block; color: var(--accent); padding: 0 3px;
    background: var(--lab-panel); border-color: #4e4432; border-radius: 8px; font-size: 12px; white-space: nowrap; }
  #panel { position: absolute; inset: auto 0 0; width: auto; max-height: 74%; z-index: 5;
    border-left: 0; border-top: 1px solid var(--lab-border); border-radius: 14px 14px 0 0;
    padding: 0 14px 16px; overscroll-behavior: contain; transition: transform .25s; }
  #panel.collapsed { transform: translateY(100%); }
  .panel-head { position: sticky; top: 0; z-index: 1; background: #101620; margin: 0; padding: 6px 0; }
  #panelClose { display: block; }
}
@media (min-width: 720px) and (max-width: 900px) {
  #app { min-height: 510px; }
}
@media (max-width: 355px) {
  .lab-readings dd { font-size: 13px; }
  .lab-readings > div { padding-inline: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  #panel { transition: none; }
}

:lang(en) .opts.three { grid-template-columns: 1.35fr 1fr .75fr; }
:lang(en) .opts.three button b { font-size: 12px; }
