/* =========================================================
   lab.css — styles for the interactive tools under /lab/
   Theme-aware (html[data-theme]) and RTL-safe: logical
   properties only, no left/right.
   Loaded after blog.css and components.css.
   ========================================================= */

.tool-head{
  max-width: 1080px; margin: 0 auto; padding: 46px 24px 8px;
}
.tool-head h1{
  font-size: clamp(1.55rem, 3.4vw, 2.35rem); line-height: 1.28; letter-spacing: -.01em;
  margin: 10px 0 12px;
}
.tool-head .lead{
  font-size: 1.02rem; line-height: 1.95; color: var(--text-muted); max-width: 74ch;
}
.tool-src{
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .76rem; color: var(--text-dim); text-decoration: none;
  border: 1px solid var(--border-soft); border-radius: 100px; padding: 5px 12px;
  transition: color .2s ease, border-color .2s ease;
}
.tool-src:hover{ color: var(--teal); border-color: var(--teal); }

/* ---------- layout ---------- */
.lab-main{ max-width: 1080px; margin: 0 auto; padding: 0 24px 40px; }
.tool-layout{
  display: grid; gap: 18px; margin-top: 26px;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
  align-items: start;
}
@media (max-width: 900px){ .tool-layout{ grid-template-columns: 1fr; } }

.panel{
  background: var(--glass); border: 1px solid var(--border);
  border-radius: 20px; padding: 20px; backdrop-filter: blur(22px) saturate(180%);
  box-shadow: var(--card-shadow);
}
.panel + .panel{ margin-top: 18px; }
.panel-head{
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  flex-wrap: wrap; margin-bottom: 14px;
}
.panel-head h2{ font-size: 1.02rem; font-weight: 700; letter-spacing: -.01em; }
.panel-hint{ font-size: .74rem; color: var(--text-dim); }

/* ---------- input ---------- */
.preset-row{ display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

.field-label{
  display: block; font-size: .72rem; color: var(--text-muted);
  margin-bottom: 7px; letter-spacing: .01em;
}
.wf-input{
  width: 100%; min-height: 208px; resize: vertical;
  font-family: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: .8rem; line-height: 1.75; letter-spacing: .01em;
  color: var(--text); background: var(--glass-2);
  border: 1px solid var(--border); border-radius: 14px; padding: 13px 15px;
  direction: ltr; text-align: left; tab-size: 4;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.wf-input:focus{
  outline: none; border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-dim);
}

.controls-row{
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-top: 14px;
}
.controls-label{ font-size: .76rem; color: var(--text-muted); }
.seg{
  display: inline-flex; gap: 3px; padding: 3px;
  background: var(--glass-2); border: 1px solid var(--border); border-radius: 100px;
}
.seg-opt{
  font-family: inherit; font-size: .76rem; font-weight: 600; cursor: pointer;
  border: 0; border-radius: 100px; padding: 7px 14px;
  background: transparent; color: var(--text-muted);
  transition: background .18s ease, color .18s ease;
}
.seg-opt:hover{ color: var(--text); }
.seg-opt.is-on{
  background: linear-gradient(135deg, var(--teal), var(--teal-2)); color: #08090D;
}
html[data-theme="light"] .seg-opt.is-on{ color: #fff; }

.actions{ display: flex; gap: 9px; flex-wrap: wrap; margin-top: 16px; }
.btn.sm{ padding: 8px 16px; font-size: .78rem; }
.btn.ghost{ background: transparent; }

.cols-help{
  margin-top: 14px; padding-top: 13px; border-top: 1px dashed var(--border-soft);
  font-size: .73rem; line-height: 2; color: var(--text-dim);
}
.cols-help code{
  font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: .72rem;
  background: var(--glass-2); border: 1px solid var(--border-soft);
  border-radius: 5px; padding: 1px 6px; color: var(--text-muted);
}

/* ---------- summary ---------- */
.summary{ position: sticky; top: 84px; }
@media (max-width: 900px){ .summary{ position: static; } }

.big{ text-align: center; padding: 4px 0 14px; }
.big-label{ font-size: .72rem; color: var(--text-dim); letter-spacing: .02em; }
.big-num{
  font-size: clamp(2.6rem, 7vw, 3.5rem); font-weight: 800; line-height: 1.05;
  letter-spacing: -.03em; font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, var(--teal), var(--teal-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin: 6px 0 4px;
}
.big-num.is-empty{
  background: none; -webkit-text-fill-color: currentColor; color: var(--text-dim);
}
.big-sub{ font-size: .73rem; color: var(--text-muted); line-height: 1.8; }

.mini-grid{
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
  padding: 13px 0; border-top: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft);
}
.mini{ text-align: center; }
.mini b{
  display: block; font-size: 1.06rem; font-weight: 700;
  font-variant-numeric: tabular-nums; color: var(--text);
}
.mini small{ font-size: .68rem; color: var(--text-dim); }

.checks{ margin-top: 13px; display: grid; gap: 8px; }
.check{
  display: grid; grid-template-columns: 18px 1fr; gap: 9px;
  font-size: .75rem; line-height: 1.7; color: var(--text-muted);
}
.check-mark{
  width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
  font-size: .68rem; font-weight: 700; flex: none;
}
.check.ok .check-mark{ background: var(--teal-dim); color: var(--teal); }
.check.bad .check-mark{ background: rgba(246,178,85,.18); color: var(--amber); }
.check.info .check-mark{ background: var(--glass-2); color: var(--text-dim); }
.check b{ color: var(--text); font-weight: 600; display: block; }
.check span{ color: var(--text-dim); font-size: .72rem; }

.notices{ margin-top: 13px; display: grid; gap: 7px; }
.notice{
  font-size: .73rem; line-height: 1.75; border-radius: 11px; padding: 9px 12px;
  border: 1px solid var(--border-soft); background: var(--glass-2); color: var(--text-muted);
}
.notice.err{ border-color: rgba(246,178,85,.4); color: var(--amber); }

/* ---------- results table ---------- */
.table-wrap{
  overflow-x: auto; border: 1px solid var(--border-soft); border-radius: 14px;
  -webkit-overflow-scrolling: touch;
}
.wf-table{ width: 100%; border-collapse: collapse; font-size: .8rem; min-width: 540px; }
.wf-table th{
  position: sticky; top: 0; z-index: 1;
  background: var(--glass-2); backdrop-filter: blur(14px);
  font-size: .69rem; font-weight: 600; color: var(--text-dim);
  text-align: start; padding: 10px 12px; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.wf-table td{
  padding: 9px 12px; border-bottom: 1px solid var(--border-soft);
  color: var(--text-muted); white-space: nowrap;
}
.wf-table tbody tr:last-child td{ border-bottom: 0; }
.wf-table tbody tr:hover td{ background: rgba(127,127,127,.06); }
.wf-table td.num{ font-variant-numeric: tabular-nums; direction: ltr; text-align: start; }
.wf-table td.key{ color: var(--text); font-weight: 600; }
.wf-table td.name{ color: var(--text); white-space: normal; min-width: 190px; }
.wf-table tr.is-summary td.name{ font-weight: 700; }
.wf-table tr.is-summary td{ background: rgba(127,127,127,.045); }
.wf-table tfoot td{
  font-weight: 700; color: var(--text); border-top: 1px solid var(--border);
  background: var(--glass-2);
}
.tree-indent{ display: inline-block; vertical-align: middle; }
.dot{
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--border); margin-inline-end: 8px; vertical-align: middle;
}
tr.is-summary .dot{ background: var(--teal); }
.wf-bar{
  display: inline-block; height: 5px; border-radius: 100px; vertical-align: middle;
  background: linear-gradient(90deg, var(--teal), var(--teal-2));
  min-width: 2px; max-width: 84px;
}
.wf-bar-track{
  display: inline-block; width: 84px; height: 5px; border-radius: 100px;
  background: var(--glass-2); vertical-align: middle; margin-inline-start: 8px;
  overflow: hidden;
}
.legend{ margin-top: 12px; font-size: .72rem; color: var(--text-dim); line-height: 1.9; }
.empty-state{
  padding: 34px 16px; text-align: center; color: var(--text-dim); font-size: .82rem;
}

/* ---------- /lab/ landing page ---------- */
.lab-grid{
  display: grid; gap: 16px; margin-top: 26px;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
}
.lab-card{
  display: block; text-decoration: none; color: inherit;
  background: var(--glass); border: 1px solid var(--border);
  border-radius: 20px; padding: 20px;
  backdrop-filter: blur(22px) saturate(180%); box-shadow: var(--card-shadow);
  transition: transform .25s ease, border-color .25s ease;
}
.lab-card:hover, .lab-card:focus-visible{ transform: translateY(-3px); border-color: var(--teal); }
.lab-card h2{ font-size: 1.04rem; font-weight: 700; line-height: 1.6; margin-bottom: 8px; }
.lab-card p{ font-size: .82rem; line-height: 1.95; color: var(--text-muted); }
.lab-card-top{ display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.lab-card .ic{ width: 20px; height: 20px; fill: none; stroke: var(--teal); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.lab-card-foot{
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 15px; padding-top: 13px; border-top: 1px dashed var(--border-soft);
  font-size: .73rem; color: var(--text-dim);
}
.lab-card-foot .ic{ width: 15px; height: 15px; stroke: currentColor; transform: rotate(-45deg); }
.lab-card:hover .lab-card-foot{ color: var(--teal); }
.lab-card.is-soon{ opacity: .72; }
.lab-card.is-soon:hover{ transform: none; border-color: var(--border); }

/* ---------- prose blocks inside the lab ---------- */
.lab-main .prose{ max-width: 1080px; margin: 0 auto; }
.lab-main .prose h2{ margin-top: 34px; }

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------- restored-input notice ---------- */
.restored{
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; padding: 9px 12px; border-radius: 10px;
  background: rgba(125,224,201,.10); border: 1px solid var(--border-soft);
  font-size: .74rem; color: var(--text-muted);
}
.restored[hidden]{ display: none; }
.restored button{
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; color: var(--teal); text-decoration: underline;
}
.print-note{ display: none; }

/* ---------- print: a planner exports this table into a report ---------- */
@media print{
  @page{ margin: 14mm 12mm; }
  html{ background: #fff !important; }
  body{ color: #111 !important; }
  header, footer, .cursor-glow, .reading-progress, .toc, .cmdk-hint, .cmdk-overlay,
  .tool-head .post-meta, .panel-head .copy-btn, .preset-row, .controls-row, .actions,
  .cols-help, .restored, .legend, .tool-layout > .panel:first-child,
  section.panel:last-of-type, .site-nav, .hero, .bento, .term-card{ display: none !important; }

  .tool-layout, .lab-main, .panel, .summary, .table-wrap{ display: block; width: auto; max-width: none;
    background: none !important; border: 0 !important; box-shadow: none !important;
    backdrop-filter: none !important; padding: 0 !important; margin: 0 0 10pt !important; }
  .table-wrap{ overflow: visible !important; }
  .wf-table{ min-width: 0; width: 100%; font-size: 9.5pt; }
  .wf-table th{ position: static; background: #fff !important; color: #111;
    border-bottom: 1.2pt solid #111; font-size: 8.5pt; }
  .wf-table td{ color: #333; border-bottom: .4pt solid #bbb; padding: 4pt 6pt; white-space: nowrap; }
  .wf-table td.name{ white-space: normal; }
  .wf-table td.key{ color: #111; }
  .wf-table tfoot td{ background: #f2f2f2 !important; color: #111; border-top: 1.2pt solid #111; }
  .wf-table thead{ display: table-header-group; }        /* repeat headers across pages */
  .wf-table tr{ break-inside: avoid; }
  .big-num, .mini b{ color: #111 !important; }
  .big, .mini-grid, .checks{ break-inside: avoid; }
  .check{ background: none !important; border: .4pt solid #999; color: #111; }
  .check-mark{ border-color: #999 !important; color: #111 !important; }
  .wf-bar, .wf-bar-track{ -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-note{ display: block; margin-top: 8pt; font-size: 8pt; color: #666; }
  a[href]::after{ content: ""; }                          /* no URL spam on a printed page */
}

/* ---------- /lab/evm/ ---------- */
.num-row{ display: flex; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.num-field{ display: flex; flex-direction: column; gap: 5px; flex: 1 1 180px; }
.num-field[hidden]{ display: none; }
.num-field span{ font-size: .7rem; color: var(--text-dim); }
.num-field input{
  background: var(--glass-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 11px; color: var(--text); font: inherit; font-size: .8rem;
  font-variant-numeric: tabular-nums;
}
.num-field input:focus{ outline: none; border-color: var(--teal); }

.chart-wrap{ width: 100%; }
.chart-wrap svg{ width: 100%; height: auto; display: block; }
.chart-empty{
  padding: 40px 10px; text-align: center; font-size: .78rem; color: var(--text-dim);
  border: 1px dashed var(--border-soft); border-radius: 12px;
}
.chart-legend{ display: flex; gap: 14px; flex-wrap: wrap; }
.chart-legend .lg{ display: inline-flex; align-items: center; gap: 6px; font-size: .7rem; color: var(--text-dim); }
.chart-legend .lg::before{ content: ""; width: 18px; height: 0; border-top: 2.2px solid currentColor; }
.chart-legend .lg.pv{ color: var(--text-dim); }
.chart-legend .lg.ev{ color: var(--teal); }
.chart-legend .lg.ac{ color: var(--amber); }
.chart-wrap .gl{ stroke: var(--border-soft); stroke-width: 1; }
.chart-wrap .yl, .chart-wrap .xl, .chart-wrap .bact{
  fill: var(--text-dim); font-size: 10.5px; font-family: inherit;
}
.chart-wrap .cl{ fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart-wrap .cl.pv{ stroke: var(--text-dim); stroke-dasharray: 5 4; }
.chart-wrap .cl.ev{ stroke: var(--teal); }
.chart-wrap .cl.ac{ stroke: var(--amber); }
.chart-wrap .pt.ev{ fill: var(--teal); stroke: none; }
.chart-wrap .bac{ stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 3; }

.evm-table td.dim{ color: var(--text-dim); }
.evm-table td.neg{ color: #E07A6A; }
.evm-table td.pos{ color: var(--teal); }
.evm-table tr.is-cpe td{ background: rgba(125,224,201,.07); }
.mini b.good{ color: var(--teal); }
.mini b.bad{ color: var(--amber); }
.mini b.ugly{ color: #E07A6A; }

@media print{
  .chart-panel{ display: block !important; }
  .chart-legend, .chart-wrap{ display: block; }
  .chart-wrap .cl, .chart-wrap .pt{ -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .evm-table{ font-size: 8pt; }
  .evm-table td.neg, .evm-table td.pos{ color: #111 !important; }
  .mini b.good, .mini b.bad, .mini b.ugly{ color: #111 !important; }
}
