/* SliceSense 0.7.9 GUI: single screen (viewport left, ranked issues right,
   action bar bottom). Text colours are chosen for WCAG AA (>= 4.5:1) on the
   panel colours; see docs/GUI_0.7.9.md for the measured ratios. */
:root {
  --bg: #0a0f14; --bg2: #0e151c; --panel: #111a22; --panel2: #16212b; --line: #1f2c38; --line2: #3a4f61;
  --text: #e6edf3; --muted: #a9b8c6; --accent: #2dd4bf; --accent2: #84cc16; --accent-ink: #04201c;
  --good: #22c55e; --warn: #f59e0b; --bad: #f43f5e;
  --t-crit: #ffb3c1; --t-high: #fdba74; --t-med: #fde68a; --t-low: #a5f3fc; --t-ok: #86efac;
  --focus: #ffd166; --radius: 14px; --bar-h: 96px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); min-height: 100%; }
body { font-size: 15px; line-height: 1.45; }
button, select, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--focus); color: #111; padding: 8px 14px; border-radius: 8px; font-weight: 700; }
.skip:focus { top: 8px; }
/* One visible focus ring for everything. */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.app { display: flex; flex-direction: column; min-height: 100vh; padding: 10px 16px calc(var(--bar-h) + 30px); }

/* Header */
.top { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 36px; height: 36px; border-radius: 10px; }
.logo.big { width: 72px; height: 72px; }
.brand-name { font-weight: 700; font-size: 18px; }
.brand-sub { color: var(--muted); font-size: 12px; letter-spacing: .6px; }
.printer-pill { display: flex; align-items: center; gap: 10px; padding: 6px 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line2); flex-wrap: wrap; }
.printer-pill svg { width: 18px; height: 18px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); }
.status.busy .dot { background: var(--warn); animation: pulse 1s infinite alternate; }
.status.err .dot { background: var(--bad); }
@keyframes pulse { to { opacity: .3; } }

/* Buttons and inputs */
.btn { border: 1px solid var(--line2); background: var(--panel2); padding: 9px 16px; border-radius: 10px; cursor: pointer; transition: background .2s, border-color .2s; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border: 0; font-weight: 700; }
.btn.primary:hover { background: #5eead4; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.danger:hover { border-color: var(--bad); color: #ffd4dc; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font-size: inherit; }
.link:disabled { opacity: .55; cursor: not-allowed; text-decoration: none; }
a.btn { display: inline-block; text-decoration: none; color: inherit; }
select { appearance: none; background: var(--panel2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23a9b8c6' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 12px center; border: 1px solid var(--line2); border-radius: 10px; padding: 8px 34px 8px 12px; cursor: pointer; max-width: 100%; }
select:hover { border-color: var(--accent); }
option, optgroup { background: #0e151c; }
input[type=search], input[type=text], input[type=number] { background: var(--panel2); border: 1px solid var(--line2); border-radius: 10px; padding: 8px 12px; }
.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg button { padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line2); background: var(--panel2); cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 700; }
.seg button.on::before { content: "● "; }
.hint { color: var(--muted); font-size: 12.5px; }
.toggle { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; cursor: pointer; }
.toggle input { accent-color: var(--warn); width: 18px; height: 18px; }
.label, .ab-field > label { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .8px; }

/* Single-screen workspace */
.workspace { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 34%); grid-template-areas: "stage side"; gap: 14px; min-height: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.panel-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 1.1px; }
.sub-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; margin: 10px 0 6px; }
.stage { grid-area: stage; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.side { grid-area: side; display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: hidden; }
.side > :not(.side-scroll-pane) { flex: none; }
.side > .details { max-height: 45%; overflow-y: auto; }
.side-scroll-pane { flex: 1 1 0; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.02); box-shadow: inset 0 1px 0 rgba(255,255,255,.02); }
.stage-head { display: flex; justify-content: space-between; align-items: center; }

/* Viewport */
.viewport { position: relative; flex: 1; min-height: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: radial-gradient(closest-side at 50% 55%, #14232c, #0b1117); }
#view { width: 100%; height: 100%; display: block; position: absolute; inset: 0; cursor: grab; touch-action: none; }
#view:active { cursor: grabbing; }
.drop-hint { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; }
.drop-card { text-align: center; padding: 26px 34px; border: 2px dashed var(--line2); border-radius: 16px; background: rgba(10,15,20,.8); }
.drop-card svg { width: 44px; height: 44px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.drop-title { font-size: 19px; font-weight: 700; margin: 8px 0 2px; }
.drop-sub { color: var(--muted); margin-bottom: 14px; }
.drag-over { position: absolute; inset: 0; display: none; place-items: center; background: rgba(45,212,191,.12); border: 3px dashed var(--accent); border-radius: 12px; font-size: 22px; font-weight: 700; }
.viewport.dragging .drag-over { display: grid; }
.busy { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; background: rgba(8,12,16,.82); font-weight: 600; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--line2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { width: 220px; height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.bar.indet span { width: 35% !important; animation: indet 1.1s ease-in-out infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
.view-help, .legend { position: absolute; bottom: 8px; font-size: 12px; color: var(--text); background: rgba(10,15,20,.85); padding: 4px 10px; border-radius: 8px; }
.view-help { left: 10px; max-width: 60%; }
.legend { right: 10px; display: flex; gap: 6px; align-items: center; }
.sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.sw.ok { background: #7dd3c8; } .sw.ov { background: var(--warn); margin-left: 8px; }
.plate-tags { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; pointer-events: none; }
.plate-tags span { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: rgba(15,23,42,.85); border: 1px solid rgba(45,212,191,.6); color: #99f6e4; }
.file-bar { display: flex; flex-direction: column; gap: 6px; }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 110px; overflow: auto; }
.file-list li { display: flex; align-items: center; gap: 10px; }
.file-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copies-wrap { font-size: 12px; white-space: nowrap; }
.copies { width: 64px; }
.file-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; }

/* Summary */
.summary .panel-title { margin-bottom: 8px; }
.sum-top { display: flex; gap: 14px; align-items: center; }
.score { font-size: 38px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; padding: 8px 12px; border-radius: 12px; border: 2px solid var(--line2); white-space: nowrap; }
.score small { font-size: 14px; color: var(--muted); font-weight: 600; }
.score.good { border-color: var(--good); } .score.warn { border-color: var(--warn); } .score.bad { border-color: var(--bad); }
.grade { font-weight: 700; font-size: 16px; }
.fit { display: inline-block; margin-top: 6px; padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: 13px; }
.fit.yes { background: rgba(34,197,94,.14); color: var(--t-ok); border: 1px solid rgba(34,197,94,.5); }
.fit.no { background: rgba(244,63,94,.14); color: var(--t-crit); border: 1px solid rgba(244,63,94,.55); }
.sev-counts { list-style: none; padding: 0; margin: 12px 0 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.sev-count { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line2); font-size: 13px; background: var(--panel2); }
.top-issues { margin: 6px 0 8px; padding-left: 20px; display: grid; gap: 4px; font-size: 14px; }
.keynums { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0 0; font-size: 13.5px; }
.keynums dt { color: var(--muted); }
.keynums dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.na { color: var(--muted) !important; font-style: italic; font-weight: 500 !important; }

/* Severity: icon + word + colour */
.sev { display: inline-flex; align-items: center; gap: 2px; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; border: 1px solid currentColor; white-space: nowrap; }
.sev-critical .sev, .sev.sev-critical, .sev-count.sev-critical { color: var(--t-crit); }
.sev-high .sev, .sev.sev-high, .sev-count.sev-high { color: var(--t-high); }
.sev-medium .sev, .sev.sev-medium, .sev-count.sev-medium { color: var(--t-med); }
.sev-low .sev, .sev.sev-low, .sev-count.sev-low { color: var(--t-low); }
.sev-ok .sev, .sev.sev-ok, .sev-count.sev-ok { color: var(--t-ok); }

/* Evidence badges: different icon, border style and words */
.ev-badge { display: inline-flex; align-items: center; gap: 2px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--panel2); }
.ev-predicted { border: 2px dashed #a9b8c6; color: #dbe4ec; }
.ev-verified_by_slicer { border: 2px solid #5eead4; color: #99f6e4; }
.ev-physically_tested { border: 4px double #fcd34d; color: #fde68a; }
.ev-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.ev-list li { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.ev-list li.on .ev-state { font-weight: 700; color: var(--text); }
.ev-list li.off .ev-state { color: var(--muted); }
.ev-list li.on::before { content: "▶"; color: var(--focus); font-size: 11px; }
.ev-list li.off::before { content: "▷"; color: var(--muted); font-size: 11px; }
.help-ev { padding-left: 0; list-style: none; display: grid; gap: 8px; }

/* Issues */
.issues-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.issue-list { display: grid; gap: 8px; }
.issue { background: var(--panel2); border: 1px solid var(--line); border-left: 6px solid var(--muted); border-radius: 10px; padding: 8px 10px; }
.issue.sev-critical { border-left-color: var(--bad); } .issue.sev-high { border-left-color: var(--warn); }
.issue.sev-medium { border-left-color: #eab308; } .issue.sev-low { border-left-color: var(--accent); } .issue.sev-ok { border-left-color: var(--good); }
.issue.forced { border-left-style: double; border-left-width: 8px; }
.issue-head { display: flex; gap: 8px; align-items: flex-start; width: 100%; text-align: left; background: none; border: 0; padding: 2px 0; cursor: pointer; }
.issue-head::after { content: "▸"; margin-left: auto; color: var(--muted); }
.issue.open .issue-head::after { content: "▾"; }
.issue.forced .issue-head::after { content: ""; }
.issue-title { font-weight: 650; }
.issue-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; align-items: center; }
.always { font-size: 12px; font-weight: 700; color: var(--focus); }
.always::before { content: "🔒 "; }
.cat { font-size: 12px; color: var(--muted); }
.issue-fields { display: grid; grid-template-columns: 78px 1fr; gap: 3px 10px; margin: 0; font-size: 13.5px; }
.issue-fields dt { color: var(--muted); font-weight: 700; }
.issue-fields dd { margin: 0; }
.mode-beginner .issue-fields { font-size: 14px; }
.issue-more { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line2); font-size: 13px; }
.issue-more p { margin: 0; color: var(--muted); }
.raw-line code { white-space: pre-wrap; word-break: break-word; color: #b8f5ea; }
.mode-beginner .expert-only { display: none; }
.key { color: var(--muted); font-size: 11.5px; }
.raw { color: var(--muted); font-weight: 500; }
.stale-note { margin: 0 0 8px; padding: 8px 12px; border-left: 4px solid var(--warn); border-radius: 8px; background: rgba(245,158,11,.12); }
.stale-note::before { content: "⚠ "; }

/* Details folds */
.details { display: grid; gap: 12px; }
.fold > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: "▸"; color: var(--muted); }
.fold[open] > summary::before { content: "▾"; }
.fold[open] > summary { margin-bottom: 10px; }
.scale-ask { margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; border: 1px solid rgba(245,158,11,.5); background: rgba(245,158,11,.1); }
.scale-ask p { margin: 0 0 8px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; text-align: right; }
.parts-scroll { overflow-x: auto; }
table.parts { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
table.parts th, table.parts td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line2); }
table.parts tr.bad td { color: var(--t-crit); }
.decisions { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.group { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.group h3 { margin: 0 0 6px; font-size: 14px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.group h3 small { color: var(--muted); font-weight: 500; font-size: 12px; }
.row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 5px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.row:first-of-type { border-top: 0; }
.row .val { font-weight: 700; font-variant-numeric: tabular-nums; color: #b8f5ea; text-align: right; }
.tip { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line2); background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; cursor: help; padding: 0; }
.tip:hover, .tip:focus { border-color: var(--accent); color: var(--accent); }
.tip-pop { position: fixed; z-index: 50; max-width: 300px; background: #0b1217; border: 1px solid var(--accent); color: var(--text); padding: 10px 12px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); pointer-events: none; }
.why { margin-top: 12px; }
.why h4 { margin: 0 0 4px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.why li { font-size: 14px; color: #d3dde6; }
.fine { color: var(--muted); font-size: 12.5px; margin: 12px 0 0; }

/* Alert */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid rgba(244,63,94,.6); background: #2a1219; }
.alert-icon { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--bad); color: #fff; display: grid; place-items: center; font-weight: 800; }
.alert > div:nth-child(2) { flex: 1; }
.alert p { margin: 4px 0; color: #f8d3da; }
.alert code { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.alert summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }

/* Bottom action bar (fixed) */
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; gap: 12px; align-items: flex-start; flex-wrap: nowrap; padding: 8px 14px; background: #0c131a; border-top: 2px solid var(--line2); box-shadow: 0 -8px 24px rgba(0,0,0,.4); min-height: var(--bar-h); }
.ab-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ab-printer { flex: 1 1 220px; max-width: 420px; }
.ab-field > label, .ab-field > .label { white-space: nowrap; }
.ab-goal .seg { flex-wrap: nowrap; }
.mode-opt, .seg button { white-space: nowrap; }
.ab-field select { min-width: 0; }
#material { width: 150px; } #nozzle { width: 112px; }
/* Desktop: the ranked list sits right below, so the summary skips its top-3 copy. */
@media (min-width: 901px) { .top-issues { display: none; } }
.ab-printer-row { display: flex; gap: 6px; }
.ab-printer-row input { width: 92px; flex: none; }
.ab-printer-row select { flex: 1; min-width: 0; }
.printer-specs { line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-goal .hint, .ab-mode .hint { max-width: 230px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ab-goal .seg button { padding: 7px 7px; }
.ab-go, .ab-export { justify-content: flex-start; }
.ab-export { gap: 6px; }
.ab-mode { margin-left: auto; }
.mode-toggle { display: inline-flex; padding: 3px; border-radius: 999px; border: 1px solid var(--line2); background: var(--panel2); cursor: pointer; }
.mode-opt { padding: 6px 14px; border-radius: 999px; font-weight: 600; }
.mode-opt.on { background: var(--accent); color: var(--accent-ink); font-weight: 800; }
.mode-opt.on::before { content: "✓ "; }

.foot { text-align: center; color: var(--muted); font-size: 11px; padding: 0 4px; }

/* Send to slicer */
.send-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 10px; }
.send-choice { background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.send-choice > b { font-size: 15px; }
#prusaChoice { grid-column: 1 / -1; }
.send-choice p { margin: 0; color: #c9d5df; font-size: 13.5px; }
.send-choice select, .send-choice input[type=text] { width: 100%; }
.send-choice input[type=text] { background: var(--bg2); border: 1px solid var(--line2); border-radius: 10px; padding: 9px 12px; margin: 6px 0; }
.choose summary, .howto summary { cursor: pointer; color: var(--accent); font-size: 13.5px; }
.choose code { font-size: 12px; color: var(--text); word-break: break-all; }
.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font-size: inherit; }
.send-note { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.4); font-size: 13.5px; }
.howto { margin-top: 14px; }
.howto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 10px; }
.howto-grid > div { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 13.5px; }
.howto-grid ol { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 6px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line2); color: var(--muted); margin-left: 6px; white-space: nowrap; }
.tag.ok { color: #86efac; border-color: rgba(34,197,94,.45); }

.foot a { color: var(--accent); }

/* Modal / toast */
.modal { position: fixed; inset: 0; background: rgba(3,6,9,.78); display: grid; place-items: center; z-index: 40; padding: 20px; }
.modal-card { position: relative; max-width: 600px; max-height: 90vh; overflow: auto; background: var(--panel); border: 1px solid var(--line2); border-radius: 16px; padding: 24px 26px; box-shadow: var(--shadow); }
.modal-card.center { text-align: center; }
.modal-card h2 { margin: 0 0 12px; }
.modal-card h3 { margin: 14px 0 8px; font-size: 15px; }
.modal-card .close { position: absolute; right: 14px; top: 14px; }
.help-steps { padding-left: 22px; display: grid; gap: 10px; margin: 0 0 12px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--bar-h) + 20px); transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--accent); padding: 10px 18px; border-radius: 12px; z-index: 60; box-shadow: var(--shadow); }

.check-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.check-out { margin-top: 12px; white-space: pre-wrap; font-size: 12.5px; line-height: 1.5; max-height: 420px; overflow: auto; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }

/* Website add-ons: Where to buy, tip link, privacy page (not used by the desktop app) */
.shop-list { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 8px; }
.shop-foot a, .shop-panel a:not(.btn), .doc-page a { color: var(--accent); }
.doc-page { max-width: 760px; margin: 0 auto; }
.doc-page h1 { font-size: 24px; margin: 0 0 6px; }
.doc-page h2 { font-size: 17px; margin: 22px 0 6px; }

/* Narrow screens: stack; the compact summary comes first, then issues,
   then the model, then the details. The action bar stays at the bottom. */
/* Medium desktop: hints stay available to screen readers (aria-describedby) but are not drawn. */
@media (max-width: 1700px) {
  .ab-goal .hint, .ab-mode .hint { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}
@media (max-width: 1280px) and (min-width: 901px) {
  .ab-goal .seg button { padding: 6px 6px; font-size: 13px; }
  .ab-printer-row input { width: 80px; }
  #material { width: 120px; } #nozzle { width: 108px; }
  .mode-opt { padding: 6px 10px; }
  .ab-export .btn.primary { padding: 9px 10px; }
}
@media (max-width: 900px) {
  .app { padding: 8px 10px 20px; }
  .workspace { display: flex; flex-direction: column; }
  .side { display: contents; }
  .summary { order: 1; } #errorBox { order: 2; } .issues-panel { order: 3; } .stage { order: 4; } .details { order: 5; } .check-panel { order: 6; }
  .stage, .side { height: auto; position: static; overflow: visible; }
  .stage { min-height: 0; }
  .viewport { min-height: 300px; flex: none; height: 52vh; }
  .printer-pill { order: 3; width: 100%; }
  .brand-sub { display: none; }
  .actionbar { position: static; margin-top: 0; border: 1px solid var(--line2); border-radius: var(--radius); min-height: 0; flex-wrap: wrap; }
  #material, #nozzle { width: 100%; }
  .printer-specs { white-space: normal; max-width: none; overflow: visible; }
  .ab-field { flex: 1 1 140px; }
  .ab-goal .seg { flex-wrap: wrap; }
  .ab-mode, .ab-goal, .ab-export { flex-basis: 100%; margin-left: 0; }
  .ab-mode .hint, .ab-goal .hint { position: static; width: auto; height: auto; clip: auto; white-space: normal; }
  .ab-printer { flex-basis: 100%; max-width: none; }
  .ab-printer-row { flex-direction: column; }
  .ab-printer-row input { width: 100%; }
  .toast { bottom: 20px; }
  .send-grid { grid-template-columns: 1fr; }
  .keynums { font-size: 14px; }
  .issue-fields { grid-template-columns: 70px 1fr; }
}
@media (max-width: 900px) {
  /* The action bar sits right after the summary on phones so the pickers are reachable. */
  .workspace > .actionbar { order: 2; }
}
/* 0.7.17 (review of 0.7.16, lower finding): on a 390 px phone the result
   panels (crowded-layout details) and the filament-changer label ran past
   the screen. Every result panel and its fact rows now shrink to the
   viewport and long values wrap instead of widening the page. */
.details, .details > .panel, .facts, .facts dt, .facts dd { min-width: 0; max-width: 100%; }
.facts { grid-template-columns: minmax(0, auto) minmax(0, 1fr); }
.facts dt, .facts dd, .details .panel p, .details .panel li { overflow-wrap: anywhere; }
#changerField > label { white-space: normal; }
#changerName { overflow-wrap: anywhere; }
@media (max-width: 900px) {
  .workspace, .workspace > * { min-width: 0; max-width: 100%; }
  .ab-field > label, .ab-field > .label { white-space: normal; }
  .facts dd { text-align: left; }
  table.parts { table-layout: fixed; font-size: 12px; }
  table.parts th, table.parts td { padding: 5px 4px; overflow-wrap: anywhere; }
}

/* Motion: honour the user's setting. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .spinner { animation: none; border-top-color: var(--accent); }
}

/* Printing: only the report */
.print-only { display: none; }
@media print {
  body { background: #fff; color: #000; }
  .app, .modal, .toast, .tip-pop { display: none !important; }
  .print-only { display: block !important; font-size: 12px; color: #000; }
  .print-only h1 { font-size: 20px; margin: 0 0 4px; }
  .print-only h2 { font-size: 14px; margin: 14px 0 6px; border-bottom: 1px solid #999; }
  .print-only table { width: 100%; border-collapse: collapse; }
  .print-only td { padding: 2px 4px; border-bottom: 1px solid #ddd; vertical-align: top; }
  .print-only td.v { font-weight: 700; white-space: nowrap; text-align: right; }
  .print-only img { max-width: 260px; float: right; margin-left: 12px; border: 1px solid #ccc; }
  .print-only .cols { columns: 2; column-gap: 20px; }
  .print-only .grp { break-inside: avoid; }
}

/* 0.7.10: scale fix on the critical card, retry button, smoothing selector */
.card-scale { margin: 8px 0 4px; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(245,158,11,.5); background: rgba(245,158,11,.1); }
.card-scale p { margin: 0 0 8px; }
#errRetry { margin-top: 8px; }
.ab-smooth { position: relative; flex: none; }
.ab-smooth .hint { max-width: 300px; }
/* 0.7.10: buttons and the mode switch never shrink below their text; the
   printer field gives up the room instead. */
@media (min-width: 901px) { .ab-go, .ab-export, .ab-mode, .ab-goal { flex-shrink: 0; } .ab-printer { min-width: 150px; } }
/* Below 1600px one row cuts the printer and nozzle names, so the bar
   wraps to two rows instead. */
@media (max-width: 1599px) and (min-width: 901px) {
  :root { --bar-h: 180px; }
  .actionbar { flex-wrap: wrap; row-gap: 6px; }
  .ab-printer { flex: 1 1 260px; }
}
@media (max-width: 1440px) and (min-width: 901px) {
  .mode-opt { padding: 5px 8px; font-size: 13px; }
  .ab-export .btn.primary, .ab-go .btn.primary { padding: 9px 10px; font-size: 14px; }
  .ab-export .btn.small { font-size: 12px; padding: 5px 8px; }
}
#smoothValues { display: block; font-family: ui-monospace, monospace; font-size: 11.5px; white-space: normal; }
.mode-beginner #smoothValues { display: none; }
#smoothing { width: 140px; }
/* 0.7.19 (U6, 320 px overflow): on phones the smoothing field may shrink
   and wrap, and before a model is loaded the upload area comes first so
   "Choose files" is in the first screen. */
@media (max-width: 900px) {
  .ab-smooth { flex: 1 1 100%; min-width: 0; }
  .ab-smooth .hint { max-width: none; }
  #smoothing { width: 100%; }
  .workspace:has(#dropHint:not([hidden])) > .stage { order: 0; }
  .workspace:has(#dropHint:not([hidden])) .viewport { height: 34vh; min-height: 200px; }
}
@media (max-width: 480px) {
  /* Small phones: a compact upload card so "Choose files" fits the first screen. */
  .drop-card { padding: 12px 14px; }
  .drop-card svg, .drop-card .drop-sub { display: none; }
}
/* Medium desktop: the help text opens as a panel above the bar while the
   selector is hovered or focused, so the one-row bar still fits. Screen
   readers always get it through aria-describedby; Expert mode shows the
   exported values in the summary ("Ironing (exported)"). */
@media (max-width: 1700px) and (min-width: 901px) {
  .ab-smooth > label { letter-spacing: 0; font-size: 11px; }
  .mode-opt { padding: 6px 10px; }
  .ab-goal .seg button { padding: 6px 6px; font-size: 13px; }
  #material { width: 120px; } #nozzle { width: 108px; }
  .ab-printer-row input { width: 76px; }
}

/* 0.7.12: three-step stepper and "Needs your attention" list. */
.stepper { list-style: none; display: flex; gap: 8px; margin: 0 0 10px; padding: 0; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px; border: 1px solid var(--line2); background: var(--panel); color: var(--muted); font-size: 14px; }
.step-n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--panel2); border: 1px solid var(--line2); font-weight: 700; color: var(--text); }
.step.current { color: var(--text); border-color: var(--accent); }
.step.current .step-n { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.step.done { color: var(--t-ok); }
.step.done .step-n { background: var(--good); color: #04201c; border-color: transparent; }
.attention { border-color: var(--warn); }
.attention.clear { border-color: var(--good); }
.att-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.att { overflow: visible; border: 1px solid var(--line2); border-left: 4px solid var(--warn); border-radius: 10px; padding: 8px 10px; background: var(--panel2); }
.att p { margin: 4px 0 6px; color: var(--muted); font-size: 13.5px; }
.att.acked { border-left-color: var(--good); opacity: .85; }
.ack { display: inline-flex; gap: 6px; align-items: center; font-size: 13.5px; cursor: pointer; }
@media (max-width: 600px) {
  .stepper { gap: 4px; }
  .step { font-size: 12.5px; padding: 4px 10px 4px 4px; }
  .step-n { width: 20px; height: 20px; }
}
.app > .shop-panel { margin: 12px 0 0; }
.side-scroll-pane > .shop-panel { flex: none; }

/* 0.7.29: header branding, history strip, estimate card, editable settings,
   Models tab and the upload-to-printer dialog. */
.brand-by { color: var(--accent); text-decoration: none; white-space: nowrap; }
.brand-by:hover { text-decoration: underline; }
.rf-logo { vertical-align: -2px; margin-right: 4px; border-radius: 3px; }
.brand-ver { white-space: nowrap; }
.brand-note { color: var(--muted); font-size: 11px; margin-top: 2px; }
.side-scroll-pane > details, .side-scroll-pane > section, .side-scroll-pane > .details { flex: none; }
.ab-export-row { display: flex; gap: 6px; }
.ab-export-row > .btn { flex: 1 1 0; }
@media (max-width: 900px) {
  .estimate-panel, .finish-panel { order: 3; }
}
.issues-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.att-history { margin-top: 8px; }
.att-history > summary { cursor: pointer; font-size: 13px; color: var(--t-ok, var(--muted)); padding: 4px 0; }
.att-history .att { opacity: .8; }
.est-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.est-delta { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line2); background: var(--panel2); }
.est-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin: 6px 0 8px; background: var(--panel2); }
.est-bar > span { display: block; height: 100%; }
.est-lines { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.est-lines th, .est-lines td { text-align: right; padding: 3px 4px; border-bottom: 1px solid var(--line); }
.est-lines th:first-child, .est-lines td:first-child { text-align: left; }
.est-lines tr.off { opacity: .4; }
.est-sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; }
.est-eye { background: none; border: 0; color: inherit; cursor: pointer; padding: 0 2px; font-size: 13px; }
.est-fine { font-size: 11px; color: var(--muted); margin: 6px 0 0; }
.tune-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin: 8px 0; }
.tune-f { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.tune-f input[type=number] { width: 100%; }
.tune-f.tune-check { flex-direction: row; align-items: center; gap: 6px; }
.tune-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.printer-modal-card { max-width: 560px; }
.pm-grid { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; min-width: 0; }
.pm-file input[type=file] { display: block; max-width: 100%; }
.pm-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pm-row input[type=url], .pm-row input[type=text], .pm-row input[type=password] { flex: 1 1 200px; min-width: 0; }
.pm-found { display: flex; gap: 6px; flex-wrap: wrap; }

/* Desktop single screen: the page itself does not scroll. Header + stepper take
   their natural height, the workspace fills the rest down to the fixed action
   bar, the viewport fills the stage, and only #sideScrollPane scrolls. */
@media (min-width: 901px) {
  html:has(.workspace), body:has(.workspace) { height: 100%; overflow: hidden; }
  .app:has(> .workspace) { height: 100vh; height: 100dvh; min-height: 0; padding-bottom: calc(var(--bar-h) + 12px); }
  .top, .stepper, .foot { flex: none; }
  .workspace { flex: 1 1 0; min-height: 0; align-items: stretch; }
  .stage, .side { height: 100%; }
  /* 0.7.29 fix: the attention panel sits at the top of the side scroll pane,
     so it never gets its own nested scrollbar that clipped the last card. */
}
@media (max-width: 900px) {
  .side-scroll-pane { display: contents; }
  .side > .details { max-height: none; overflow: visible; }
}

/* 0.7.29: Analyze / Models tabs and the community Models page. */
.tabs { display: flex; gap: 4px; margin-bottom: 10px; border-bottom: 1px solid var(--line); flex: none; }
.tab { background: transparent; border: 1px solid transparent; border-bottom: 0; border-radius: 10px 10px 0 0; padding: 8px 18px; color: var(--muted); font-weight: 700; cursor: pointer; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--panel); border-color: var(--line); color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }
body.tab-models .actionbar { display: none !important; }
body.tab-models .app { padding-bottom: 30px; }
.models-tab { display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; }
.models-head { display: flex; flex-direction: column; gap: 8px; }
.models-search { display: flex; gap: 8px; flex-wrap: wrap; }
.models-search input { flex: 1 1 260px; min-width: 0; }
.models-local-note { margin: 0; padding: 10px 12px; border: 1px solid var(--warn); border-radius: 10px; background: var(--panel2); }
.models-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.mc-card { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: border-color .2s, transform .2s; }
.mc-card:hover, .mc-card:focus-visible { border-color: var(--accent); transform: translateY(-2px); }
.mc-thumb { aspect-ratio: 4 / 3; display: grid; place-items: center; background: var(--panel2); font-size: 36px; font-weight: 800; color: var(--muted); overflow: hidden; }
.mc-thumb img, .md-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mc-info { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px 12px; min-width: 0; }
.mc-info b { overflow-wrap: anywhere; }
.mc-info .tag, .md-lic { margin-left: 0; align-self: flex-start; white-space: normal; max-width: 100%; overflow-wrap: anywhere; }
.model-detail { display: flex; flex-direction: column; gap: 12px; }
.model-detail > .btn { align-self: flex-start; }
.md-body { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.md-image { aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden; background: var(--panel2); display: grid; place-items: center; font-size: 64px; font-weight: 800; color: var(--muted); border: 1px solid var(--line); }
.md-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.md-title { font-size: 20px; overflow-wrap: anywhere; }
.md-info p { margin: 0; }
.md-files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.md-files li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel2); }
.md-files .md-fname { flex: 1; min-width: 0; overflow-wrap: anywhere; }
@media (min-width: 901px) {
  html:has(body.tab-models), body.tab-models { height: auto; overflow: auto; }
  body.tab-models .app { height: auto; min-height: 100vh; }
}
@media (max-width: 900px) {
  .md-body { grid-template-columns: 1fr; }
}
