/* ============================================================
   ATLAS — Tolerance Stack tab (tol-ui.js owns the markup; this file its look)
   Three panes like the Analysis tab: the set-up rail (assembly, direction, gap, the
   selected part's faces), the 3-D view over the chain (links + the link editor), and
   the results rail (spec, methods, charts, report). Everything here is prefixed tol-
   (the wiring gate checks it), so shared components are wrapped, never restyled.
   ============================================================ */

#panel-tol { display: flex; }

.tol-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 330px;
  min-width: 0;
  min-height: 0;
}

/* Labels carry units and symbols ('σ level', 'LSL (mm)', 'Cpk min', 'Monte Carlo n'), and
   styles.css uppercases .field label: σ became Σ — the summation sign, in a stack-up tab —
   and mm MM (WebKit). Sentence case here, as fbd.css does for its own labels. (An element
   selector under the panel id: this sheet may not name the shared .field class.) */
#panel-tol label { text-transform: none; letter-spacing: 0.03em; font-size: 10.5px; }

/* ---- rails ---- */

.tol-rail,
.tol-results {
  background: var(--panel-solid);
  overflow-y: auto;
  min-height: 0;
  padding: 16px 16px 40px;
}
.tol-rail { border-right: 1px solid var(--aether-faint); }
.tol-results { border-left: 1px solid var(--aether-faint); }

.tol-title {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.25;
  color: var(--white);
  margin: 8px 0 4px;
}

.tol-sec {
  border-top: 1px solid var(--aether-faint);
  margin-top: 14px;
  padding-top: 12px;
}

.tol-sec-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.tol-sec-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--aether);
  width: 16px;               /* two digits, as the other tabs number their sections */
}

.tol-sec-title {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--aether);
}

.tol-results > .tol-sec-head { margin-top: 2px; }

.tol-drop { padding: 14px 10px; }

.tol-wide {
  width: 100%;
  margin-top: 8px;
  letter-spacing: 0.12em;
}

.tol-small {
  padding: 5px 10px;
  font-size: 9.5px;
  letter-spacing: 0.12em;
}

.tol-study { margin: 10px 0 6px; }

.tol-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}

/* read notes */
.tol-notes-wrap { margin: 6px 0 10px; }
.tol-notes-sum {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--white-faint);
  cursor: pointer;
}
.tol-notes {
  margin: 6px 0 0;
  padding: 0 0 0 14px;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--white-dim);
}
.tol-note { margin-bottom: 4px; }
.tol-note-warn { color: var(--caution); }

.tol-colors { margin: 10px 0 8px; }

/* the part tree */
.tol-parts { margin-top: 4px; }

.tol-node {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--white-faint);
  padding: 6px 0 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tol-prow {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 4px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
}
.tol-prow:hover { background: var(--aether-ghost); }
.tol-prow.tol-sel { border-color: var(--aether-dim); background: var(--aether-ghost); }
.tol-prow.tol-off .tol-part { color: var(--white-faint); text-decoration: line-through; }

.tol-eye {
  background: none;
  border: none;
  color: var(--aether);
  font-size: 10px;
  width: 14px;
  padding: 0;
  cursor: pointer;
  flex: none;
}

.tol-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex: none;
}

/* the part and face rows are <button>s (Tab reaches them, Enter / Space pick): they look
   like the rows they were */
button.tol-part, button.tol-face {
  background: none;
  border: none;
  margin: 0;
  color: inherit;
  text-align: left;
  line-height: inherit;
  cursor: pointer;
}
button.tol-part { padding: 0; }
button.tol-face { width: 100%; border-bottom: 1px solid var(--aether-ghost); }

.tol-part {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--white);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tol-inst {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--aether-dim);
  border: 1px solid var(--aether-faint);
  border-radius: 8px;
  padding: 0 5px;
  flex: none;
}

/* direction and gap */
.tol-dirs button { padding: 7px 0; font-family: var(--mono); letter-spacing: 0.02em; font-size: 10.5px; }

.tol-gaprow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.tol-gapbtn { width: 58px; padding: 6px 0; flex: none; letter-spacing: 0.1em; font-size: 9.5px; }
.tol-gapbtn[aria-pressed="true"],
#tol-dir-face[aria-pressed="true"],
#tol-pick-chain[aria-pressed="true"] {
  background: var(--aether-faint);
  border-color: var(--aether);
  color: var(--aether-bright);
}
.tol-gap-why { margin: -2px 0 8px; font-size: 10.5px; line-height: 1.45; }

.tol-face-read {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--white-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* faces of the selected part */
.tol-faces { margin-top: 6px; }
.tol-face {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 8px;
  padding: 5px 6px;
  border-bottom: 1px solid var(--aether-ghost);
  font-family: var(--mono);
  font-size: 10.5px;
  cursor: pointer;
}
.tol-face:hover { background: var(--aether-ghost); }
.tol-face-pos { color: var(--white); min-width: 86px; }
.tol-face-sense { color: var(--aether); }
.tol-face-id { color: var(--white-faint); font-size: 10px; }
.tol-face-tag { color: var(--caution); font-size: 9.5px; width: 100%; }

/* ---- centre: the view over the chain ---- */

.tol-center {
  display: grid;
  grid-template-columns: minmax(0, 1fr);   /* an auto track grows to its widest child (WebKit, 1000 px) */
  grid-template-rows: minmax(180px, 1fr) minmax(0, 46%);
  min-width: 0;
  min-height: 0;
}

.tol-viewport { min-height: 0; }

.tol-pickbar {
  position: absolute;
  bottom: 12px;
  right: 12px;                             /* clear of the axis gizmo, bottom left */
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 190px);
  background: var(--panel);
  border: 1px solid var(--aether-dim);
  border-radius: var(--radius);
  padding: 6px 8px 6px 12px;
  font-size: 11px;
  color: var(--aether-bright);
  z-index: 3;
}
/* up to two lines, then cut (its title carries the whole prompt): one nowrap line lost
   the instruction's second half at 1100 px ('Chain: click the far face of each part in turn; t…') */
.tol-pick-text {
  min-width: 0;
  overflow: hidden;
  white-space: normal;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.tol-pick-cancel {
  flex: none;
  background: none;
  border: 1px solid var(--aether-faint);
  border-radius: var(--radius);
  color: var(--white-dim);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  padding: 3px 7px;
  cursor: pointer;
}

.tol-hover {
  position: absolute;
  left: 12px;
  top: 10px;
  max-width: calc(100% - 24px);
  background: var(--panel);
  border: 1px solid var(--aether-faint);
  border-radius: var(--radius);
  padding: 5px 9px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--white);
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tol-hover.tol-bad { color: var(--caution); }

.tol-chain {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-top: 1px solid var(--aether-faint);
  background: var(--panel-solid);
}

.tol-chain-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--aether-ghost);
}
.tol-grow { flex: 1; }
.tol-closure {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--white-dim);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tol-closure.tol-ok { color: var(--aether); }
.tol-closure.tol-bad { color: var(--alarm); }

.tol-chain-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
}

.tol-links {
  overflow-y: auto;
  min-height: 0;
  padding: 6px 12px 24px;
}

.tol-links-empty {
  font-size: 11px;
  line-height: 1.6;
  color: var(--white-faint);
  padding: 14px 4px;
  max-width: 560px;
}

.tol-link {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) 78px 118px 46px auto;
  align-items: center;
  gap: 8px;
  padding: 6px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}
.tol-link:hover { background: var(--aether-ghost); }
.tol-link.tol-sel { border-color: var(--aether-dim); background: var(--aether-ghost); }
.tol-link.tol-bad .tol-link-sub { color: var(--alarm); }

/* the column heads over the links: which number is the loop's and which the dimension's */
.tol-link-headrow {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) 78px 118px 46px auto;
  gap: 8px;
  padding: 2px 7px 4px;
  border-bottom: 1px solid var(--aether-ghost);
  margin-bottom: 2px;
}
.tol-link-headrow > span {
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--white-faint);
}

.tol-link-idx { font-family: var(--mono); font-size: 10px; color: var(--white-faint); }
.tol-link-main { min-width: 0; }
.tol-link-name,
.tol-link-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tol-link-name { font-size: 11.5px; color: var(--white); }
.tol-link-sub { font-family: var(--mono); font-size: 10px; color: var(--white-faint); margin-top: 1px; }
.tol-link-val,
.tol-link-tol,
.tol-link-pct {
  font-family: var(--mono);
  font-size: 11px;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tol-link-val { color: var(--white); }
.tol-link-tol { color: var(--aether); }
.tol-link-pct { color: var(--white-faint); font-size: 10px; }
.tol-link-act { display: flex; gap: 2px; }
.tol-mv {
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--white-faint);
  font-size: 11px;
  width: 20px;
  height: 20px;
  padding: 0;
  cursor: pointer;
}
.tol-mv:hover { color: var(--aether); border-color: var(--aether-faint); }

.tol-junction {
  font-family: var(--mono);
  font-size: 9.5px;
  line-height: 1.4;
  padding: 1px 6px 1px 30px;
  color: var(--white-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tol-junction::before { content: '↳ '; }
.tol-j-ok { color: var(--aether-dim); }
.tol-j-warn { color: var(--caution); }
.tol-j-bad { color: var(--alarm); }

.tol-pending {
  margin: 8px 0 0;
  padding: 6px 8px;
  border: 1px dashed var(--aether-dim);
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--aether-bright);
}
.tol-pending-cancel {
  background: none;
  border: 1px solid var(--aether-faint);
  border-radius: 3px;
  color: var(--white-dim);
  font-size: 10px;
  padding: 2px 8px;
  cursor: pointer;
}

/* the link editor */
#tol-ed-body div, #tol-ed-body input, #tol-ed-body select { min-width: 0; }
.tol-editor {
  border-left: 1px solid var(--aether-ghost);
  overflow-y: auto;
  min-height: 0;
  padding: 10px 14px 28px;
}
.tol-ed-empty { font-size: 11px; color: var(--white-faint); padding: 6px 0; }
.tol-ed-title {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--aether);
  margin-bottom: 8px;
}
.tol-ed-faces {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -2px 0 10px;
}
.tol-ed-facetext {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--white-dim);
}
.tol-ed-devcap { font-size: 10px; line-height: 1.45; color: var(--white-dim); margin: -4px 0 6px; }
.tol-ed-cell {
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--white);
  margin: -2px 0 2px;
}
.tol-ed-cell.tol-bad { color: var(--alarm); }
.tol-ed-honesty { margin: 2px 0 6px; }
.tol-ed-basis { margin: 0 0 10px; font-size: 10px; color: var(--white-faint); }
.tol-ed-basis summary { cursor: pointer; letter-spacing: 0.08em; text-transform: uppercase; font-size: 9.5px; }
.tol-ed-basistext { margin-top: 4px; line-height: 1.5; color: var(--white-dim); }

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

.tol-input-err {
  font-size: 11px;
  color: var(--alarm);
  margin: -4px 0 10px;
}

.tol-hero {
  border-top: 1px solid var(--aether-faint);
  padding-top: 12px;
  margin-top: 4px;
}
.tol-hero-cap { font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--aether-dim); }
.tol-hero-val {
  font-family: var(--serif);
  font-size: 30px;
  color: var(--white);
  line-height: 1.15;
  margin: 2px 0 2px;
}
.tol-hero-sub { font-size: 10.5px; color: var(--white-faint); line-height: 1.5; }

.tol-methods { margin: 12px 0 8px; }
.tol-mrow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 60px 60px 50px;
  gap: 6px;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px solid var(--aether-ghost);
  font-size: 11px;
}
.tol-mhead { font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--white-faint); }
.tol-mname { color: var(--white-dim); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tol-mnum { font-family: var(--mono); text-align: right; color: var(--white); font-variant-numeric: tabular-nums; }
.tol-mhead .tol-mnum { font-family: var(--sans); color: var(--white-faint); }
.tol-mv-cell { text-align: right; font-family: var(--mono); font-size: 10.5px; }
.tol-mhead .tol-mv-cell { font-family: var(--sans); font-size: 9.5px; }
/* what the verdict is judged on: its own line under the method's row */
.tol-mcrit {
  grid-column: 1 / -1;
  font-size: 9.5px;
  line-height: 1.4;
  color: var(--white-faint);
  margin-top: -2px;
}
.tol-pass { color: var(--aether); }
.tol-fail { color: var(--alarm); font-weight: 600; }
.tol-na { color: var(--white-faint); }

.tol-detail {
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.55;
  color: var(--white-dim);
  margin-bottom: 6px;
}

.tol-chart {
  border-top: 1px solid var(--aether-faint);
  margin-top: 12px;
  padding-top: 10px;
}
.tol-chart-head { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--aether-dim); margin-bottom: 6px; }
.tol-svgbox { min-height: 0; }
.tol-svg { display: block; width: 100%; max-width: 440px; height: auto; }

.tol-contrib { margin-top: 6px; }
.tol-crow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px 40px 44px 40px;
  gap: 4px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--white-dim);
  padding: 2px 0;
  border-bottom: 1px solid var(--aether-ghost);
}
.tol-chead { font-family: var(--sans); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--white-faint); }
.tol-cname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tol-cnum { text-align: right; font-variant-numeric: tabular-nums; }

.tol-warnings {
  margin: 0;
  padding: 0 0 0 14px;
  font-size: 10.5px;
  line-height: 1.5;
}
.tol-warn { color: var(--caution); margin-bottom: 4px; }
.tol-info { color: var(--white-faint); margin-bottom: 4px; }

.tol-report {
  display: flex;
  gap: 8px;
  margin: 16px 0 8px;
}
.tol-report button { flex: 1; }

.tol-honesty { line-height: 1.55; }

.tol-bad { color: var(--alarm); }
.tol-ok { color: var(--aether); }

/* ---- narrower windows: slimmer rails; the link editor goes under the list ---- */
@media (max-width: 1180px) {
  .tol-layout { grid-template-columns: 250px minmax(0, 1fr) 290px; }
  .tol-rail, .tol-results { padding: 14px 12px 36px; }
  .tol-center { grid-template-rows: minmax(160px, 38%) minmax(0, 1fr); }
  .tol-chain-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; overflow-y: auto; }
  /* min-height auto: with 0 the row shrank below its content and the editor painted over it */
  .tol-links { overflow: visible; min-height: auto; padding-bottom: 8px; }
  .tol-editor { border-left: none; border-top: 1px solid var(--aether-ghost); overflow: visible; min-height: auto; }
  .tol-link, .tol-link-headrow { grid-template-columns: 14px minmax(0, 1fr) 70px 104px auto; }
  .tol-link-pct { display: none; }
  .tol-pickbar { max-width: calc(100% - 170px); }
  .tol-mrow { grid-template-columns: minmax(0, 1fr) 52px 52px 40px; }
}

/* One column that scrolls as a whole. The panes were still height-limited here (min-height
   0, a 50 vh row inside a split grid): at 860 × 900 the rows came out 298 / 247 / 298 px,
   the rail ran under the viewport, the chain list and editor were 1 px tall and 12 of 14
   controls were covered (WebKit hit test). Every pane is now as tall as its content. */
@media (max-width: 900px) {
  .tol-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; align-content: start; overflow-y: auto; }
  .tol-rail, .tol-results { border: none; border-bottom: 1px solid var(--aether-faint); overflow: visible; min-height: auto; }
  .tol-center { grid-template-rows: 60vh auto; min-height: auto; }
  .tol-chain { min-height: auto; }
  .tol-chain-body { grid-template-rows: auto auto; overflow: visible; }
  /* a viewBox chart scales its text with its width: capped near a rail's width, its labels
     stay the size of the rest of the UI instead of ~2× in the full-width column */
  .tol-svg { max-width: 360px; }
}
