/* Weld group — additions on top of ../calc.css (same light drawing language). */
.tabs { grid-template-columns: repeat(3, 1fr); }

/* stage bar: view, "Colour by" switch, profile toggle, then help and history at the right edge */
.stage-bar { justify-content: flex-start; gap: 10px 12px; }
.mapgrp { display: inline-flex; align-items: center; gap: 7px; }
.seg-cap { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.bar-end { position: relative; margin-left: auto; display: flex; align-items: center; gap: 6px; }
.qhelp { display: inline-grid; place-items: center; width: 20px; height: 20px; border: 1px solid var(--line-2); border-radius: 50%;
  font-size: 11.5px; font-weight: 500; color: var(--text-3); cursor: help; user-select: none; -webkit-user-select: none; }
.qhelp:hover, .qhelp:focus { color: var(--text); border-color: var(--text-2); outline: none; }
.qpop { display: none; position: absolute; right: 0; top: calc(100% + 8px); z-index: 6; width: min(290px, calc(100vw - 64px)); padding: 9px 12px; border: 1px solid var(--line-2);
  border-radius: 9px; background: var(--surface); box-shadow: 0 6px 20px rgba(0,0,0,.1); font-size: 12.5px; font-weight: 400; line-height: 1.45; color: var(--text-2); cursor: default; text-align: left; }
.qhelp:hover .qpop, .qhelp:focus .qpop, .qhelp.open .qpop { display: block; }
.hist { display: flex; gap: 2px; }
.hist .ghost { font-size: 16px; padding: 2px 8px; }
.hist .ghost:disabled { opacity: .35; cursor: default; background: none; }
.segpick { cursor: grab; }
.seglab { cursor: pointer; }
.legend-heat .ticks.wt span:first-child { transform: none; }
.legend-heat .ticks.wt span:last-child { transform: translateX(-100%); }
.legend-dots svg { vertical-align: middle; }
.warn-t { color: var(--warn); }

/* presets */
.presets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
.preset { display: grid; justify-items: center; gap: 2px; padding: 6px 6px 5px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); cursor: pointer; font-size: 11px; color: var(--text-2); line-height: 1.2; }
.preset:hover { border-color: var(--line-2); background: var(--surface-2); }
.preset.on { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); color: var(--text); }
.preset span { text-align: center; }
/* panel labels wrap rather than end in an ellipsis ("Thickness (0 = group)" on phones) */
.f > label span { white-space: normal; overflow: visible; }

/* selected segment */
.wsym { border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); padding: 4px 6px 0; margin-bottom: 8px; }
.wsym svg { display: block; }
.sidepick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; background: var(--fill-1); border-radius: 8px; padding: 2px; }
.sidepick button { display: flex; align-items: center; justify-content: center; gap: 4px; border: 0; background: none; border-radius: 6px; padding: 4px 4px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.sidepick button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.btnrow { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.btnrow .btn { flex: 1; padding: 5px 8px; font-size: 12.5px; }
.btnrow .btn:disabled { opacity: .4; cursor: default; }
.grp-h .aside .ms { min-width: 0; font-size: 11.5px; padding: 1px 7px; }
.f[title] > label span { text-decoration: underline dotted var(--line-2); text-underline-offset: 3px; }

/* sheets: stacked, segments first */
.sheets.wsheets { grid-template-columns: minmax(0, 1fr); gap: 22px; }
.sheet col.sz { width: 10%; } .sheet col.arc { width: 7%; } .sheet col.ty { width: 10%; } .sheet col.sd { width: 11%; }
/* segment sheet: columns sized to their content (coordinates never squeezed), the margin column takes the rest */
.sheet.segs col.xy { width: 72px; } .sheet.segs col.sz { width: 84px; } .sheet.segs col.arc { width: 56px; }
.sheet.segs col.ty { width: 92px; } .sheet.segs col.sd { width: 108px; } .sheet.segs col.stm { width: 80px; }
.sheet.segs col.stl { width: 64px; } .sheet.segs col.stp { width: 96px; } .sheet.segs col.tb { width: 64px; } .sheet.segs col.msc { width: auto; }
/* too narrow for 16 columns: each segment becomes a compact card "start x y → end x y · leg", the rest on a second line */
@media (max-width: 1180px) {
  .sheet.segs, .sheet.segs tbody { display: block; width: 100%; border: 0; }
  .sheet.segs colgroup, .sheet.segs thead { display: none; }
  .sheet.segs tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 8px; margin-bottom: 6px; border: 1px solid var(--line); border-radius: 8px; }
  .sheet.segs tr::after { content: ""; flex-basis: 100%; height: 0; order: 1; }
  .sheet.segs td { display: flex; align-items: center; gap: 4px; height: auto; padding: 0; border: 0; order: 2; background: none; white-space: nowrap; }
  .sheet.segs td.rn { order: 0; padding: 0; min-width: 16px; }
  .sheet.segs td.c-x1, .sheet.segs td.c-y1, .sheet.segs td.c-x2, .sheet.segs td.c-y2, .sheet.segs td.c-sz, .sheet.segs td.c-del { order: 1; }
  .sheet.segs td.c-x1, .sheet.segs td.c-x2 { margin-right: -6px; }
  .sheet.segs td.c-del { margin-left: auto; }
  .sheet.segs td input { width: 60px; height: 28px; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
  .sheet.segs td.c-x1 input, .sheet.segs td.c-y1 input, .sheet.segs td.c-x2 input, .sheet.segs td.c-y2 input { width: 64px; }
  .sheet.segs td[data-h]::before, .sheet.segs td.c-x1::before, .sheet.segs td.c-x2::before { font-size: 11.5px; color: var(--text-3); }
  .sheet.segs td[data-h]::before { content: attr(data-h); }
  .sheet.segs td.c-sz::before { content: "· " attr(data-h); }
  .sheet.segs td.c-x1::before { content: "start " attr(data-u); }
  .sheet.segs td.c-x2::before { content: "→ end"; }
  .sheet.segs td:empty, .sheet.segs td:not(.c-sz):not(.msc):has(> .na) { display: none; }
  .sheet.segs td.msc { flex: 1 1 140px; }
  .sheet.segs td.msc .na { text-align: left; }
  .sheet.segs td.msc .msbar { flex: 1; max-width: 260px; }
  .sheet.segs tr.sel { background: var(--sel-bg); border-color: var(--sel-line); }
  .sheet.segs tr.ghost { background: var(--surface-2); border-style: dashed; }
  .sheet.segs .x { opacity: .55; }
}
/* phones: start on the first line, "→ end x y · leg" on the second */
@media (max-width: 560px) {
  .sheet.segs tr { gap: 6px 8px; }
  .sheet.segs tr::before { content: ""; flex-basis: 100%; height: 0; order: 2; }
  .sheet.segs td.c-x2, .sheet.segs td.c-y2, .sheet.segs td.c-sz { order: 3; }
  .sheet.segs tr::after { order: 4; }
  .sheet.segs td { order: 5; }
  .sheet.segs td.c-sz input { width: 56px; }
}
.sheet td .na, .sheet td > .na { display: block; text-align: center; color: var(--text-3); font-size: 12px; font-style: italic; }
.pill { display: inline-flex; align-items: center; gap: 4px; border: 0; border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.pill.static { cursor: default; }
.pill.t-fillet { color: var(--x-8a4b12, #8a4b12); background: var(--x-f8ead9, #f8ead9); }
.pill.t-pjp { color: var(--x-5b3fa0, #5b3fa0); background: var(--x-ece6f7, #ece6f7); }
.pill.t-cjp { color: var(--x-1f5a8a, #1f5a8a); background: var(--x-e2edf6, #e2edf6); }
.pill.side { color: var(--text-2); background: var(--fill-1); padding: 2px 9px 2px 4px; }
.pill:not(.static):hover { filter: brightness(.96); }

/* margins table */
.margins td.rules { white-space: normal; }
.rule { display: inline-block; font-size: 11.5px; border-radius: 6px; padding: 1px 6px; margin: 1px 3px 1px 0; }
.rule.ok { color: var(--text-3); background: var(--fill-1); }
.rule.no { color: var(--bad); background: var(--bad-bg); font-weight: 600; }
.verdict .s.method { font-size: 11.5px; color: var(--text-3); margin-top: 4px; max-width: 280px; }

/* run chart key */
.key { display: inline-block; width: 16px; height: 0; vertical-align: middle; margin: 0 4px 0 10px; }
.key.l { border-top: 2px solid var(--load); }
.key.c { border-top: 1.5px dashed var(--good); }

@media (max-width: 560px) {
  .presets { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .preset span { font-size: 10px; }
  .seg-cap { display: none; }
}
.sheet.segs th { white-space: normal; line-height: 1.2; }
.stage-foot .legend-dots { flex-wrap: wrap; row-gap: 4px; }
.stage-foot .legend-dots span { white-space: nowrap; }
@media (max-width: 560px) { .legend-heat { flex-wrap: wrap; } .title h1 { white-space: nowrap; } }

/* stitches, base metal, margin chart, toggles */
.tog { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 4px 10px; font-size: 12.5px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.tog { display: inline-flex; align-items: center; gap: 6px; }
.tog::before { content: ""; width: 7px; height: 7px; border-radius: 50%; border: 1.3px solid var(--text-3); box-sizing: border-box; }
.tog:hover { border-color: var(--line-2); color: var(--text); }
.tog[aria-pressed="true"] { color: var(--text); border-color: var(--line-2); }
.tog[aria-pressed="true"]::before { background: var(--good); border-color: var(--good); }
.stage-bar { flex-wrap: wrap; }
.subgrp { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 6px; }
.subh { font-size: 11.5px; font-weight: 600; color: var(--text-3); margin: 2px 0 4px; }
.sheet col.stm { width: 7%; } .sheet col.stl { width: 6%; } .sheet col.stp { width: 8%; } .sheet col.tb { width: 6%; }
.pill.mode { color: var(--text-2); background: var(--fill-1); }
.pill.mode.on { color: var(--wip-ink); background: var(--wip-bg); }
.rule.adv { color: var(--warn); background: var(--warn-bg); }
.gov { font-size: 12px; font-weight: 600; }
.gov.weld { color: var(--text-2); }
.gov.base { color: var(--clamp); }
.key.w { border-top: 1.5px dashed var(--steel-650); }
.key.b { border-top: 1.5px solid var(--clamp); }
.key.e { border-top: 3px solid var(--x-e6a03a, #e6a03a); border-radius: 2px; }
#run { touch-action: none; }
/* inline size editor on the plan */
.stage { position: relative; }
.wpop { position: absolute; z-index: 5; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.14); padding: 10px 12px; width: 236px; font-size: 12.5px; }
.wpop .wp-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; font-weight: 600; }
.wpop .wp-h span { color: var(--text-3); font-weight: 400; font-size: 11.5px; }
.wpop .wp-row { display: grid; grid-template-columns: 1fr 96px; gap: 8px; align-items: center; margin: 4px 0; color: var(--text-2); }
.wpop input { width: 100%; border: 1px solid var(--line-2); border-radius: 7px; padding: 5px 8px; text-align: right; font-size: 13px; outline: none; }
.wpop input:focus { border-color: var(--sel); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.wpop .ro { text-align: right; font-weight: 500; color: var(--text); }
.wpop .chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.wpop .chips button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 2px 8px; font-size: 11.5px; cursor: pointer; }
.wpop .chips button.on { background: var(--text); color: var(--on-accent); border-color: var(--text); }
.wpop .wp-f { display: flex; justify-content: space-between; gap: 6px; margin-top: 8px; }
.wpop .wp-f .btn { padding: 4px 10px; font-size: 12px; }
.wpop .hintx { color: var(--text-3); font-size: 11px; }
#mapGrp[hidden], #profBtn[hidden] { display: none; }
.wpop .wp-h { white-space: nowrap; }
.wpop { width: 268px; }
.wpop .wp-row { grid-template-columns: 1fr 120px; }
.wpop .wp-side button { padding: 3px 4px; font-size: 11.5px; }
.wpop .wp-f.end { justify-content: flex-end; margin-top: 4px; }
@media (max-width: 640px) { .bar { flex-wrap: wrap; row-gap: 8px; } .bar-right { flex-wrap: wrap; gap: 8px; } }

/* first ten seconds: on narrow screens the verdict follows the drawing, the inputs come after it */
@media (max-width: 1040px) {
  .work { display: contents; }
  .work > .stage { order: -3; }
  #summary { order: -2; }
  .work > .panel { order: -1; }
}
/* the plan's frame is taller and narrower on phones (app.js frame(), same breakpoint) */
@media (max-width: 689px) { #view { aspect-ratio: 380 / 440; } }
/* reserve the space the script fills in, so nothing jumps on load */
#summary:empty { min-height: 123px; }
#legend:empty { min-height: 69px; }
@media (max-width: 1040px) { #summary:empty { min-height: 240px; } }
@media (max-width: 560px) { #summary:empty { min-height: 480px; } #legend:empty { min-height: 136px; } }

/* click-to-edit value pills on the plan (load size, weld size) */
#view .vpill { cursor: pointer; }
#view .vpill rect { fill: var(--surface); stroke: var(--line-2); stroke-width: 1; }
#view .vpill text { font-weight: 600; fill: var(--text); }
#view .vpill.load rect { stroke: color-mix(in srgb, var(--load) 45%, transparent); }
#view .vpill.load text { fill: var(--load); }
#view .vpill.mom rect { stroke: color-mix(in srgb, var(--moment) 45%, transparent); }
#view .vpill.mom text { fill: var(--moment); }
#view .vpill.dim rect { stroke: color-mix(in srgb, var(--sel) 40%, transparent); }
#view .vpill.dim text { fill: var(--sel); }
#view .vpill:hover rect, #view .vpill:focus-visible rect { stroke-width: 1.6; }
#view .vpill:focus { outline: none; }

/* the panel fades out at an edge it scrolls past (fadePanel in app.js) */
#panel.fade-b { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 32px), transparent); }
#panel.fade-t { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28px); mask-image: linear-gradient(to bottom, transparent, #000 28px); }
#panel.fade-t.fade-b { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28px, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to bottom, transparent, #000 28px, #000 calc(100% - 32px), transparent); }

/* theme-auto:start · generated by scripts/theme/hexmap.py: dark values (the rule of scripts/theme/colour.py) for
   colours that are not tokens, written as var(--x-rrggbb, #rrggbb): light is the fallback, unchanged */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --x-1f5a8a: #75a4cf; --x-3f8e64: #83c29d; --x-4a5160: #989eac; --x-5b3fa0: #a18fe4; --x-6e7177: #85827f;
    --x-6fb08a: #9bd0b0; --x-8a4b12: #cd946b; --x-a5a9af: #5a5854; --x-a8291f: #eb8071; --x-a9cf9f: #9fbd97;
    --x-d9533c: #fd9681; --x-d9583a: #fd977e; --x-d9dee3: #373532; --x-e1e1dc: #35332f; --x-e2edf6: #272e33;
    --x-e6a03a: #f8be72; --x-ec9a5c: #feb987; --x-ece6f7: #2f2c36; --x-f2cf9a: #513910; --x-f8ead9: #332a20;
  }
}
@media screen {
  :root[data-theme="dark"] {
    --x-1f5a8a: #75a4cf; --x-3f8e64: #83c29d; --x-4a5160: #989eac; --x-5b3fa0: #a18fe4; --x-6e7177: #85827f;
    --x-6fb08a: #9bd0b0; --x-8a4b12: #cd946b; --x-a5a9af: #5a5854; --x-a8291f: #eb8071; --x-a9cf9f: #9fbd97;
    --x-d9533c: #fd9681; --x-d9583a: #fd977e; --x-d9dee3: #373532; --x-e1e1dc: #35332f; --x-e2edf6: #272e33;
    --x-e6a03a: #f8be72; --x-ec9a5c: #feb987; --x-ece6f7: #2f2c36; --x-f2cf9a: #513910; --x-f8ead9: #332a20;
  }
}
/* theme-auto:end */
