* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root { color-scheme: dark; --bg: #101820; --surface: #18252f; --surface-raised: #213440; --stroke: #36505f; --ink: #e3edf3; --muted: #9eb7c6; --accent: #ffb66e; --accent-ink: #082129; --accent-hover: #ffca97; --accent-soft: #3f3e3a; --accent-soft-strong: #46423c; --accent-line: #af8d68; --accent-glow: #ffb66e44; --amber: #f4b96b; }
html, body { margin: 0; height: 100%; background: #101820; color: #e3edf3; font: 14px/1.4 system-ui, Roboto, "Segoe UI", sans-serif; overflow: hidden; user-select: none; -webkit-user-select: none; }
#app { display: flex; flex-direction: column; height: 100%; }
button { font: inherit; cursor: pointer; }

#topbar { display: flex; background: #18252f; border-bottom: 1px solid #2c414f; flex: none; }
#tools { display: flex; overflow-x: auto; flex: 1; scrollbar-width: none; }
#tools::-webkit-scrollbar, .row::-webkit-scrollbar { display: none; }
.tb { flex: none; width: 58px; height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: none; border: 0; color: #a6bcc9; font-size: 10px; padding: 0; }
.tb svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tb.on { color: var(--accent); background: #233c48; box-shadow: inset 0 -2px var(--accent); }
.tb:active { background: #294451; }
.tsep { flex: none; width: 1px; background: #36505f; margin: 9px 3px; }
#sys { display: flex; border-left: 1px solid #2c414f; flex: none; }
#sys .tb { width: 42px; }

#stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
#prompt { position: absolute; left: 8px; right: 8px; top: 6px; text-align: center; pointer-events: none; color: #9fd8ff; font-size: 13px; text-shadow: 0 1px 2px #000, 0 0 6px #000; }
#hud { position: absolute; left: 6px; bottom: 6px; pointer-events: none; font: 12px ui-monospace, Menlo, Consolas, monospace; color: #cfd8e0; background: #101820d0; padding: 3px 7px; border-radius: 4px; white-space: pre; }
/* низький екран (телефон горизонтально): кнопки, що не вміщаються, — у другий стовпчик ліворуч, а не під верхню панель */
#fab { position: absolute; right: 6px; bottom: 34px; display: flex; flex-direction: column; flex-wrap: wrap-reverse; align-content: flex-start; gap: 8px; max-height: calc(100% - 40px); }
#fab button { width: 42px; height: 42px; border-radius: 21px; border: 1px solid #36505f; background: #18252fd8; color: #c1d1dc; display: flex; align-items: center; justify-content: center; padding: 0; }
#fab button:active { background: #2b4352; }
#fab button.on { color: var(--accent); border-color: var(--accent); background: #2a2212d8; }
#fab svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#toast { position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); background: #263a4c; color: #fff; padding: 8px 14px; border-radius: 18px; font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90%; text-align: center; }
#toast.show { opacity: 1; }

#panel { flex: none; background: #18252f; border-top: 1px solid #2c414f; padding: 3px 6px 5px; max-height: 60%; overflow-y: auto; }
.row { display: flex; gap: 6px; overflow-x: auto; padding: 3px 0; align-items: center; scrollbar-width: none; }
.chip { flex: none; border: 1px solid #36505f; background: #20313d; color: #c1d1dc; border-radius: 16px; padding: 6px 11px; font-size: 13px; }
.chip.on { background: #2a3f52; border-color: #7accec; color: #fff; }
.btn { flex: none; border: 0; background: #2b4352; color: #e6eef5; border-radius: 6px; padding: 7px 11px; font-size: 13px; }
.btn.ok { background: #176b5d; }
.btn.pri { background: #247e76; }
.btn.warn { background: #743a46; }
.sp { flex: 1; }
.lbl { flex: none; color: #8faab9; font-size: 12px; }
.fields { flex-wrap: wrap; overflow: visible; }
.fld { display: flex; align-items: center; background: #101820; border: 1px solid #36505f; border-radius: 6px; flex: 1 1 var(--b, 72px); min-width: min(var(--b, 72px), 100%); max-width: 100%; height: 34px; overflow: hidden; }
.fld .lb { flex: none; padding: 0 6px; color: #8faab9; font-size: 12px; border-right: 1px solid #22313e; min-width: 30px; text-align: center; line-height: 32px; white-space: nowrap; }
/* довгий вираз не влазить — видно кінець (де курсор), а не початок */
.fld .val { flex: 1; min-width: 0; display: flex; justify-content: flex-end; padding: 0 6px; font: 15px ui-monospace, Menlo, Consolas, monospace; color: #fff; white-space: nowrap; overflow: hidden; }
.fld:not(.act) .val { justify-content: flex-start; }
.fld.act { border-color: var(--accent); }
.fld.act .val::after { content: ''; display: inline-block; width: 1px; height: 16px; background: var(--accent); vertical-align: middle; margin-left: 1px; animation: blink 1s steps(1) infinite; }
.fld.bad .val { color: #ff6b6b; }
@keyframes blink { 50% { opacity: 0; } }
.kp { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding-top: 4px; }
.kp button { height: 40px; border: 0; border-radius: 6px; background: #243947; color: #fff; font-size: 17px; }
.kp button:active { background: #2f4558; }
.kp .k2 { background: #172430; color: #9eb7c6; font-size: 14px; }
.kp .ent { grid-row: span 2; height: auto; background: #176b5d; font-size: 22px; }
.info { font: 12px ui-monospace, Menlo, Consolas, monospace; color: #9eb7c6; padding: 2px 2px 3px; white-space: pre-wrap; user-select: text; -webkit-user-select: text; }

#modal { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 10; padding: 8px; }
#modal.hidden { display: none; }
.mbox { background: #18252f; border: 1px solid #36505f; border-radius: 10px; width: 100%; max-width: 680px; max-height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.mhead { display: flex; align-items: center; padding: 8px 10px; border-bottom: 1px solid #2c414f; font-weight: 600; }
.mhead span { flex: 1; }
.mhead button { background: none; border: 0; color: #a6bcc9; font-size: 18px; padding: 2px 8px; }
#mbody { overflow-y: auto; padding: 10px; flex: 1; min-height: 0; user-select: text; -webkit-user-select: text; }
#mfoot { display: flex; gap: 8px; padding: 8px 10px; border-top: 1px solid #2c414f; flex-wrap: wrap; }
#mfoot:empty { display: none; }
#mfoot .btn { flex: 1; padding: 10px; }

.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.frm { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: #9ab2bf; }
.frm input, .frm select { background: #101820; color: #fff; border: 1px solid #36505f; border-radius: 6px; padding: 7px 8px; font: 14px ui-monospace, Menlo, Consolas, monospace; width: 100%; }
.frm.chk { flex-direction: row; align-items: center; gap: 8px; color: #c1d1dc; font-size: 13px; }
.frm.chk input { width: 20px; height: 20px; accent-color: var(--accent); }
.frm.wide { grid-column: 1 / -1; }
details { margin-bottom: 8px; }
summary { cursor: pointer; padding: 6px 0; color: var(--accent); }
#gout { width: 100%; min-height: 260px; height: 46vh; background: #0c141c; color: #b8f5c8; border: 1px solid #36505f; border-radius: 6px; font: 13px/1.35 ui-monospace, Menlo, Consolas, monospace; padding: 8px; resize: vertical; white-space: pre; }
.warn { background: #3a2a12; border: 1px solid #7a5a1c; color: #ffd08a; border-radius: 6px; padding: 6px 8px; margin: 6px 0; font-size: 12px; }
.menu { display: flex; flex-direction: column; gap: 6px; }
.menu .btn { text-align: left; padding: 11px 12px; font-size: 14px; }
.htabs { position: sticky; top: -10px; background: #18252f; z-index: 2; margin: -10px -10px 8px; padding: 6px 10px; border-bottom: 1px solid #2c414f; }
.hbody h4 { margin: 14px 0 6px; color: var(--accent); font-size: 14px; }
.hres { margin: 8px 0; }
.hbig { font-size: 20px; font-weight: 700; color: #fff; margin: 4px 0 8px; }
.hbig span { display: block; font-size: 13px; font-weight: 400; color: #7fd1a0; margin-top: 2px; }
.hn { font-size: 12px; color: #9eb7c6; margin: 6px 0; line-height: 1.45; }
.tw { overflow-x: auto; margin: 4px 0 8px; }
.ht { border-collapse: collapse; font: 12.5px ui-monospace, Menlo, Consolas, monospace; min-width: 100%; }
.ht th, .ht td { border: 1px solid #22313e; padding: 4px 6px; text-align: left; white-space: nowrap; }
.ht th { background: #20313d; color: #9eb7c6; font-weight: 600; }
.ht td { color: #dfe7ee; }
.ht tr:nth-child(even) td { background: #14212b; }
.about { text-align: center; padding: 6px 4px; }
.about img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 2px solid #36505f; }
.about-author { display: flex; justify-content: center; align-items: center; gap: 14px; margin: 18px 0 4px; text-align: left; }
.aname { font-size: 15px; font-weight: 600; color: #fff; }
.arole { font-size: 12px; color: var(--accent); margin-top: 3px; }
.aapp { font-size: 20px; font-weight: 600; color: #e8eef4; }
.aapp span { display: block; margin-top: 4px; font-size: 12px; font-weight: 400; color: #8faab9; }
.about p { max-width: 34ch; font-size: 13px; color: #9eb7c6; margin: 12px auto 0; line-height: 1.45; }
.help h4 { margin: 12px 0 4px; color: var(--accent); }
.help p, .help li { font-size: 13px; color: #c1d1dc; margin: 3px 0; }
.help ul { padding-left: 18px; margin: 4px 0; }
/* каркас (дерево) CAM */
.tree { display: flex; flex-direction: column; gap: 3px; }
.tn { display: flex; align-items: stretch; gap: 3px; padding-left: calc(var(--d) * 16px); position: relative; }
.tn::before { content: ''; position: absolute; left: calc(var(--d) * 16px - 9px); top: 0; bottom: 0; border-left: 1px dashed #36505f; display: var(--line, block); }
.tn[style*="--d:0"]::before { display: none; }
.tn .tx { flex: none; width: 30px; border: 0; border-radius: 6px; background: #20313d; color: var(--accent); font-size: 15px; padding: 0; display: flex; align-items: center; justify-content: center; }
.tn span.tx { background: none; }
/* ліва смуга — колір кроку (1 Верстат … 5 Програма) або типу операції (--ac); стан — окремою плашкою ✓ / ⚠ */
.tn .tl { flex: 1; min-width: 0; text-align: left; border: 0; border-radius: 6px; background: #243947; background: linear-gradient(90deg, color-mix(in srgb, var(--ac) 16%, #243947), #243947 55%); color: #e6eef5; padding: 7px 9px; display: flex; flex-direction: column; gap: 2px; box-shadow: inset 4px 0 var(--ac); }
.tn.top .tl { padding: 9px 10px; background: linear-gradient(90deg, color-mix(in srgb, var(--ac) 26%, #243947), #243947 70%); }
.tn.top .tt { font-size: 15px; }
.tn.bad .tl { outline: 1px solid var(--accent-line); outline-offset: -1px; }
.tn.need .tl { outline: 1px solid #7accec99; outline-offset: -1px; }
.tn .tt { font-size: 14px; font-weight: 600; display: flex; align-items: center; flex-wrap: wrap; gap: 0 4px; }
.tn .tnum { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 11px; background: var(--ac); color: #101820; font-size: 13px; font-weight: 800; margin-right: 4px; flex: none; }
.tn .tst { margin-left: 6px; padding: 0 6px; border-radius: 9px; font-size: 12px; line-height: 18px; font-weight: 700; }
.tn .tst.ok { background: #1f4d35; color: #8ff0b6; }
.tn .tst.bad { background: #5a3d10; color: #ffd08a; }
/* смужка кроків над деревом: порядок роботи й стан */
.tn .ts { font-size: 12px; color: #9eb7c6; white-space: normal; overflow-wrap: anywhere; }
.tn .ts.wn { color: #ffd08a; }
.tn .ta { flex: none; border: 0; border-radius: 6px; background: #2b4352; color: #e6eef5; padding: 0 10px; font-size: 13px; min-width: 38px; }
.tn .ta.pri { background: #247e76; }
.tn .ta.warn { background: #743a46; }
.btn.on { box-shadow: inset 0 0 0 2px #7accec; }
#camBackBtn { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3; padding: 11px 18px; font-size: 14px; border-radius: 22px; box-shadow: 0 4px 14px #0009; }
#camBackBtn.hidden { display: none; }
#fab button.camb { font: 700 12px system-ui, Roboto, sans-serif; color: var(--accent); border-color: #7a5a1c; letter-spacing: .5px; }
#fab button.camb.on { background: #3a2a12; color: #ffd08a; border-color: var(--accent); }
.menu .mh { color: var(--accent); font-size: 12px; margin: 8px 2px 0; text-transform: uppercase; letter-spacing: .6px; }
.menu .mh:first-child { margin-top: 0; }
.menu .btn.off { opacity: .45; }
.menu [data-g="show"] svg { width: 22px; height: 22px; vertical-align: middle; margin-right: 6px; }
.btn.need { box-shadow: inset 3px 0 var(--accent); }
.row.wrap { flex-wrap: wrap; overflow: visible; }
/* меню варіантів «Відрізка» — помітна перша кнопка рядка */
.chip.lvar { background: #2a2212; color: #ffd08a; box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }
.menu.cam .row .btn { flex: 1 1 auto; text-align: center; }
.trow { display: flex; gap: 6px; align-items: stretch; }
.trow .btn:first-child { flex: 1; text-align: left; }
.tsub { font-size: 11px; color: #9ab2bf; }
#gcinfo:empty { display: none; }
#toast { z-index: 12; }

/* ---------- редактор G-коду ---------- */
#ed { position: fixed; inset: 0; z-index: 8; background: #101820; display: flex; flex-direction: column; }
#ed.hidden { display: none; }
.ed-top { display: flex; align-items: center; background: #18252f; border-bottom: 1px solid #2c414f; flex: none; }
.ed-tabs { flex: 1; display: flex; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.ed-tabs::-webkit-scrollbar { display: none; }
.ed-tab { flex: none; padding: 10px 12px; color: #9eb7c6; background: none; border: 0; border-right: 1px solid #2c414f; font-size: 13px; white-space: nowrap; -webkit-touch-callout: none; touch-action: pan-x; }
.ed-tab.on { color: #fff; background: #233c48; box-shadow: inset 0 -2px var(--accent); }
.ed-tab i { font-style: normal; color: var(--accent); font-size: 10px; }
.ed-b { background: none; border: 0; color: #c1d1dc; font-size: 17px; padding: 6px 10px; flex: none; }
.ed-b:active { background: #294451; }
.ed-bar { flex: none; padding: 4px 6px; background: #18252f; border-bottom: 1px solid #2c414f; }
.ed-find { flex: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 5px 6px; background: #14212b; border-bottom: 1px solid #2c414f; align-items: center; }
.ed-find.hidden, .ed-asst.hidden { display: none; }
.ed-find input { flex: 1 1 140px; min-width: 110px; background: #101820; color: #fff; border: 1px solid #36505f; border-radius: 6px; padding: 7px 8px; font: 14px ui-monospace, "Roboto Mono", Menlo, Consolas, monospace; user-select: text; -webkit-user-select: text; }
.ed-find .row { flex: 1 1 100%; }
.ed-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
@media (orientation: landscape) { .ed-body { flex-direction: row; } .ed-body .ed-plot { border-top: 0; border-left: 1px solid #2c414f; } }
.ed-body.code .ed-plot, .ed-body.plot .ed-code { display: none; }
.ed-code { flex: 1 1 50%; min-height: 0; min-width: 0; display: flex; background: #0c141c; }
.ed-gut { flex: none; width: 34px; position: relative; overflow: hidden; background: #14212b; border-right: 1px solid #2c414f; color: #4f6475; font: 13px/20px "Roboto Mono", "Droid Sans Mono", ui-monospace, Menlo, Consolas, monospace; text-align: right; }
.ed-gin { position: absolute; left: 0; right: 0; top: 0; }
.ed-gl { padding: 0 6px 0 2px; white-space: nowrap; }
.ed-gl.cur { color: var(--accent); background: #16222d; }
.ed-gl.run { color: #7fe08a; }
.ed-gl.bm { box-shadow: inset 4px 0 #7accec; color: #7accec; }
.ed-main { flex: 1; position: relative; min-width: 0; overflow: hidden; }
.ed-hl { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.ed-hin, .ed-ta { font: 14px/20px "Roboto Mono", "Droid Sans Mono", ui-monospace, Menlo, Consolas, monospace; font-variant-ligatures: none; letter-spacing: 0; tab-size: 4; -webkit-text-size-adjust: none; text-size-adjust: none; }
.ed-hin { position: absolute; left: 0; top: 0; padding: 0 6px; white-space: pre; color: #dfe7ee; }
.ed-l { position: relative; }
.ed-l.cur { background: #16222d; }
.ed-l.run { background: #183020; }
.ed-sel { position: absolute; top: 0; bottom: 0; background: #3a6ea57a; }
.ed-ta { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; border: 0; outline: 0; resize: none; background: transparent; color: transparent; caret-color: var(--accent); padding: 4px 6px; white-space: pre; overflow: auto; user-select: text; -webkit-user-select: text; }
.ed-ta::selection { background: transparent; color: transparent; }
.h-g { color: #5fb8ff; } .h-g0 { color: #ff9f43; } .h-m { color: #ff7ab8; } .h-x { color: #8be08b; } .h-z { color: #ffd166; }
.h-a { color: #c9a4ff; } .h-f { color: var(--accent); } .h-s { color: #4dd0c8; } .h-t { color: #ff6b6b; } .h-n { color: #5d7386; }
.h-p { color: #a6bcc9; } .h-o { color: #dfe7ee; } .h-c { color: #8faab9; } .h-pc { color: #ff9f43; } .h-v { color: #4dd0c8; } .h-sk { color: #ff5555; }
.ed-plot { flex: 1 1 50%; min-height: 0; min-width: 0; display: flex; flex-direction: column; border-top: 1px solid #2c414f; }
.ed-cvw { flex: 1; position: relative; min-height: 0; }
.ed-cv { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.ed-cv3 { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: none; }
.ed-cvw.d3 .ed-cv { display: none; }
.ed-cvw.d3 .ed-cv3 { display: block; }
.ed-nost { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(300px, 86%); background: #18252fee; border: 1px solid #7a5a1c; border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 8px; text-align: center; color: #c1d1dc; font-size: 13px; }
.ed-nost b { color: #ffd08a; font-size: 15px; }
.ed-nost.hidden { display: none; }
.ed-pinfo { position: absolute; left: 6px; top: 6px; pointer-events: none; font: 12px ui-monospace, "Roboto Mono", Menlo, Consolas, monospace; color: #cfd8e0; background: #101820d0; padding: 3px 7px; border-radius: 4px; white-space: pre; }
.ed-pinfo:empty { display: none; }
.ed-pctl { flex: none; padding: 2px 6px 5px; background: #18252f; }
.ed-slw { flex: none; padding: 6px 12px 2px; background: #18252f; border-top: 1px solid #2c414f; }
.ed-sl { display: block; width: 100%; height: 26px; margin: 0; accent-color: var(--accent); }
.ed-asst { flex: none; max-height: 30%; overflow-y: auto; background: #14212b; border-top: 1px solid #2c414f; padding: 4px 8px; font-size: 12px; color: #c1d1dc; user-select: text; -webkit-user-select: text; }
.ed-asst .ah { color: var(--accent); margin-bottom: 2px; }
.ed-asst .ar { padding: 1px 0; }
.ed-asst .ar b { display: inline-block; min-width: 64px; color: #5fb8ff; font: 12px ui-monospace, "Roboto Mono", Menlo, Consolas, monospace; }
.ed-keys { flex: none; padding: 3px 4px; gap: 4px; background: #18252f; border-top: 1px solid #2c414f; }
.ek { flex: none; min-width: 34px; height: 34px; border: 0; border-radius: 6px; background: #243947; color: #fff; font: 15px ui-monospace, "Roboto Mono", Menlo, Consolas, monospace; padding: 0 6px; }
.ek:active { background: #2f4558; }
.ed-status { flex: none; padding: 3px 8px; font: 11px ui-monospace, "Roboto Mono", Menlo, Consolas, monospace; color: #8faab9; background: #14212b; border-top: 1px solid #2c414f; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-w { color: #ffd08a; font-weight: 400; cursor: pointer; }
.ed-diff { font: 12px/1.5 ui-monospace, "Roboto Mono", Menlo, Consolas, monospace; white-space: pre; overflow-x: auto; }
.ed-diff span { display: inline-block; width: 3.6em; color: #4f6475; text-align: right; margin-right: 4px; }
.ed-diff .da { background: #143018; color: #9fe8a8; } .ed-diff .dd { background: #3a1616; color: #ffaaaa; } .ed-diff .de { color: #c1d1dc; } .ed-diff .dg { color: #4f6475; text-align: center; }

/* ---------- тема Slate / Mint: чіткі поверхні, великі цілі дотику ---------- */
button { transition: background-color .12s ease, border-color .12s ease, color .12s ease; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .45; cursor: default; }
#topbar { box-shadow: 0 3px 12px #0002; }
.tb { width: 64px; height: 58px; font-size: 11px; gap: 4px; }
.tb svg { width: 24px; height: 24px; }
.tb.on { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 -3px var(--accent); }
#sys .tb { width: 48px; }
#prompt { color: #a8cddd; }
#panel { padding: 6px 8px 8px; border-top-color: #36505f; }
.row { gap: 7px; padding: 4px 0; }
.btn { min-height: 44px; padding: 10px 14px; border: 1px solid #3c5666; border-radius: 10px; background: #294250; color: var(--ink); font-size: 14px; font-weight: 600; line-height: 1.3; }
.btn:active { background: #3b5a69; }
.btn.ok, .btn.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ok:active, .btn.pri:active { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.warn { background: #472c35; border-color: #86505c; color: #ffc0c6; }
.chip { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; background: #203541; border-color: #3b5667; color: #c5d7e2; }
.chip.on { background: var(--accent-soft-strong); border-color: var(--accent); color: var(--accent); }
.chip.lvar { background: var(--accent-soft); border: 1px solid var(--accent-line); box-shadow: none; color: var(--accent); }
.fld { height: 40px; border-radius: 8px; background: #101e28; }
.fld .lb { line-height: 38px; color: #a5bccb; }
.fld.act { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-glow); }
.kp { gap: 5px; }
.kp button { height: 44px; border-radius: 8px; background: #29404d; }
.kp .k2 { background: #20333f; color: #b7cbd7; }
.kp .ent { background: var(--accent); color: var(--accent-ink); }
#fab { right: 9px; gap: 9px; }
#fab button { width: 44px; height: 44px; border-radius: 12px; border-color: #3d5a6c; background: #1b2e3bea; color: #bcd0df; box-shadow: 0 3px 10px #0003; }
#fab button.on { border-color: var(--accent); background: var(--accent-soft-strong); color: var(--accent); }
#fab button.camb { color: var(--accent-ink); background: var(--accent); border-color: var(--accent-line); font-size: 11px; letter-spacing: .6px; }
#fab button.camb.on { background: var(--accent-hover); color: var(--accent-ink); border-color: var(--accent-line); }
#toast { background: #294858; border: 1px solid #466474; border-radius: 12px; padding: 10px 14px; box-shadow: 0 5px 24px #0005; }
#modal { background: #020a12b8; padding: 10px; }
.mbox { border-color: #3b5667; border-radius: 16px; box-shadow: 0 22px 70px #0008; }
.mhead { min-height: 54px; padding: 4px 8px 4px 16px; font-size: 16px; font-weight: 700; background: #1c2f3d; border-bottom-color: #36505f; }
.mhead button { width: 44px; height: 44px; padding: 0; border-radius: 10px; color: #b8ccd8; font-size: 25px; }
.mhead button:active { background: #304956; }
#mbody { padding: 14px; }
#mfoot { padding: 12px 14px; background: #14232e; border-top-color: #36505f; }
#mfoot .btn { min-height: 44px; }
.form { gap: 13px 10px; }
.frm { font-size: 13px; line-height: 1.4; color: #aec4d1; gap: 6px; }
.frm input, .frm select { min-height: 44px; border-radius: 9px; background: #101e28; border-color: #405b6c; padding: 10px; font-size: 15px; }
.frm.chk { min-height: 40px; }
.frm.chk input { width: 22px; height: 22px; min-height: 22px; }
.info { font-size: 13px; line-height: 1.5; color: #a6bfce; }
.warn { border-radius: 10px; background: #3c3020; border-color: #8c6739; color: #ffcf93; padding: 10px 12px; font-size: 13px; }
.menu { gap: 8px; }
.menu .btn { border-color: #344e5e; padding: 13px 14px; }
.menu .mh { color: var(--accent); font-size: 11px; letter-spacing: 1px; margin: 12px 3px 1px; }
.htabs { top: -14px; margin: -14px -14px 10px; padding: 8px 14px; }
.tn .tl, .tn.top .tl { background: #213643; box-shadow: inset 3px 0 var(--ac); border: 1px solid #344f60; border-radius: 10px; padding: 10px 12px; }
.tn .tx, .tn .ta { min-height: 44px; border-radius: 9px; }
.tn .ta { min-width: 44px; border: 1px solid #3a5666; }
.tn .ta.pri { color: var(--accent-ink); background: var(--accent); border-color: var(--accent-line); }
.tn .ta.warn { color: #ffc0c6; background: #472c35; border-color: #86505c; }
.tn .tst { border-radius: 5px; margin-left: auto; font-size: 11px; }
.tn .tst.ok { background: #204d45; color: #9ff3d7; }
.tn .tst.bad { background: #533e23; color: #ffd08e; }
.tn .ts { color: #aac0ce; line-height: 1.45; }
.ed-b { min-width: 40px; min-height: 44px; border-radius: 8px; }
.ed-tab { min-height: 44px; }
.ed-tab.on { background: var(--accent-soft); color: #eafffa; box-shadow: inset 0 -3px var(--accent); }
.ed-pctl .chip, .ed-bar .chip { min-height: 40px; }
.ed-pinfo { border: 1px solid #304b5b; border-radius: 8px; padding: 6px 9px; background: #13242fdf; }
.ed-slw { padding: 7px 14px 3px; }
.ed-sl { accent-color: var(--accent); }
.ek { height: 40px; min-width: 38px; border-radius: 8px; background: #29414f; }

/* ---------- робочий простір CAM ---------- */
.cam-workspace { display: flex; flex-direction: column; gap: 18px; color: var(--ink); }
.cam-workspace svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.cam-hero { padding: 2px 1px 0; }
.cam-kicker { color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: 1.7px; text-transform: uppercase; }
.cam-hero h2, .cam-hero h3 { font-size: 23px; line-height: 1.2; margin: 7px 0 8px; font-weight: 750; letter-spacing: -.4px; overflow-wrap: anywhere; }
.cam-hero p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.cam-progress { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; color: #9bb5c4; font-size: 12px; }
.cam-progress > span:first-child { color: #d5e7ef; font: 12px ui-monospace, Consolas, monospace; background: #243e4b; border: 1px solid #385766; border-radius: 6px; padding: 4px 7px; }
.cam-section { display: flex; flex-direction: column; gap: 10px; }
.cam-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 1px; }
.cam-section-head h3, .cam-section-head h4 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.15px; }
.cam-section-head > span, .cam-section-head > small { color: #8eacbd; font-size: 11px; }
.cam-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.cam-card { min-width: 0; }
.cam-workspace .tn { padding-left: 0; gap: 6px; flex-wrap: wrap; }
.cam-workspace .tn::before { display: none; }
.cam-workspace .tx { font-size: 0; }
.cam-workspace .tx::after { content: ''; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin-top: -3px; }
.cam-workspace .tx[aria-expanded="true"]::after { transform: rotate(225deg); margin-top: 3px; }
.cam-workspace .cam-card { display: block; position: relative; }
.cam-workspace .cam-card > .tl { width: 100%; }
.cam-workspace .cam-card > .tx { position: absolute; right: 7px; top: 8px; z-index: 1; width: 34px; min-height: 40px; background: #294553; color: #a7dcd4; border: 1px solid #42606c; }
.cam-workspace .cam-card > .tx + .tl { padding-right: 49px; }
.cam-workspace .cam-card > .cam-actions { margin-top: 7px; }
.cam-workspace .tn .tl { box-shadow: none; background: #203440; border: 1px solid #344e5f; min-height: 62px; }
.cam-workspace .tn .tl:active { background: #2c4958; }
.cam-workspace .tn .tt { font-size: 14px; font-weight: 650; gap: 6px; }
.cam-workspace .tn .tnum { width: 22px; height: 22px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 11px; }
.cam-workspace .tn .ts { font-size: 12px; line-height: 1.45; }
.cam-workspace .tn.bad .tl { outline: none; border-color: #8c6a3f; }
.cam-workspace .tn.need .tl { outline: none; border-color: #407486; }
.cam-icon { width: 38px; height: 38px; min-width: 38px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #3d5c69; border-radius: 10px; color: var(--accent); background: var(--accent-soft); }
.cam-card-title { flex: 1; min-width: 0; display: inline-flex; align-items: center; gap: 6px; font-size: 14px; line-height: 1.35; font-weight: 650; color: #e6f1f7; }
.cam-card-detail { display: block; color: #a9c0cd; font-size: 12px; line-height: 1.45; margin-top: 4px; overflow-wrap: anywhere; }
.cam-state { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; color: #9bb8c6; font-size: 10px; font-weight: 650; white-space: nowrap; }
.cam-state.ok { color: #8bdfbf; }
.cam-state.bad, .cam-state.need { color: #f4c387; }
.cam-operation { border: 1px solid #385362; border-radius: 12px; background: #1a2d38; padding: 10px; }
.cam-operation .tn .tl { background: transparent; border-color: transparent; min-height: 48px; padding: 7px 8px; }
.cam-operation .tn.top .tl { padding: 8px; }
.cam-operation .tn .tx { background: #243e4c; border: 1px solid #3a5565; color: var(--accent); }
.cam-operation .tn .ta { background: #243e4c; }
.cam-operation .tn .ts { color: #a3bdca; }
.cam-op-number { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; color: var(--accent); background: var(--accent-soft-strong); font-weight: 750; font-size: 12px; }
.cam-actions { display: flex; flex-wrap: wrap; flex: 1 1 100%; gap: 8px; }
.cam-actions > .btn, .cam-actions > .ta { flex: 1 1 110px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 12px; font-size: 13px; line-height: 1.3; }
.cam-actions > .ta svg { width: 18px; height: 18px; }
.cam-actions > .ta[data-a="add"] { background: var(--accent); border-color: var(--accent-line); color: var(--accent-ink); }
.cam-actions > .btn.pri, .cam-actions > .ta.pri { flex-basis: 100%; }
.cam-op-heading .cam-actions > .ta { flex-basis: 68px; font-size: 12px; padding: 8px 6px; }
.cam-tool-list { display: flex; flex-direction: column; gap: 7px; }
.cam-detail .cam-icon { width: 30px; height: 30px; min-width: 30px; border-radius: 8px; color: #99b9c7; background: #213b49; }
.cam-detail .cam-icon svg { width: 18px; height: 18px; }
.cam-detail .cam-card-title { font-size: 13px; }
.cam-empty { padding: 20px 16px; border: 1px dashed #496574; border-radius: 12px; text-align: center; color: #a8c1ce; background: #172c37; }
.cam-empty .cam-icon { margin: 0 auto 10px; width: 44px; height: 44px; }
.cam-empty h3, .cam-empty h4 { margin: 0 0 6px; color: #e3eef5; font-size: 15px; }
.cam-empty p { margin: 0 0 14px; font-size: 13px; line-height: 1.5; }
.cam-empty .btn { width: 100%; }
.cam-next { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--accent-soft-strong); border: 1px solid var(--accent-line); border-radius: 12px; color: var(--ink); padding: 13px 14px; text-align: left; font-size: 14px; font-weight: 650; min-height: 56px; }
.cam-next small { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; font-weight: 400; }
.cam-next:active { background: var(--accent-soft); }
@media (min-width: 560px) {
  .cam-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cam-grid .tt { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 2px 7px; }
  .cam-grid .cam-icon { grid-row: 1 / span 2; }
  .cam-grid .cam-card-title { grid-column: 2; }
  .cam-grid .cam-state { grid-column: 2; margin-left: 0; }
  .cam-actions > .btn.pri { flex-basis: 160px; }
}
@media (max-height: 500px) {
  #modal { padding: 5px; }
  .mhead { min-height: 46px; }
  #mbody { padding: 10px 12px; }
  .cam-workspace { gap: 12px; }
  .cam-hero .cam-kicker { display: none; }
  .cam-hero h2, .cam-hero h3 { font-size: 18px; margin: 0; }
  .cam-progress { margin-top: 6px; font-size: 11px; }
  .cam-next { min-height: 48px; padding: 8px 12px; }
}
@media (prefers-reduced-motion: reduce) { button { transition: none; } }

/* Особистий акцент: список із назвами кольорів унизу налаштувань. */
.settings-accent { margin-top: 18px; grid-template-columns: minmax(0, 1fr); }
:root #stockEditBar{position:absolute;top:8px;left:8px;right:8px;z-index:8;display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:6px;align-items:center;padding:7px;background:var(--surface,#18252f);border:1px solid var(--accent-line);border-radius:10px;box-shadow:0 3px 12px #0005}
#stockEditBar.hidden{display:none}
#stockEditBar span{font-size:12px;color:var(--accent);font-weight:600}
#stockEditBar .btn{min-height:44px;padding:8px 10px;font-size:12px}
#stage.stock-editing #prompt{top:76px}
/* запит поверх діалогу: файл уже існує, назва проєкту */
#ask { position: fixed; inset: 0; background: #000b; display: flex; align-items: center; justify-content: center; z-index: 30; padding: 8px; }
#ask .mbox { max-width: 460px; }
#ask .abody { padding: 10px; overflow-y: auto; }
#ask .abody .frm input { width: 100%; }
#ask .afoot { display: flex; gap: 8px; padding: 8px 10px; border-top: 1px solid #2c414f; flex-wrap: wrap; }
#ask .afoot .btn { flex: 1; padding: 10px; min-width: 120px; }
/* групи операцій: у виборі типу й у плані обробки */
.wz-group { color: var(--accent); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; margin: 12px 2px 6px; }
.wz-group:first-of-type { margin-top: 4px; }
.cam-op-group { color: var(--accent); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; margin: 6px 2px -2px; }
/* форма кнопок (Налаштування → «Форма кнопок») */
html[data-btn=round] :is(.btn, .chip, .fld, .kp button, #fab button, .tn .tl, .tn .tx, .tn .ta, .ed-b, .ek, .mhead button, .frm input, .frm select, .cam-icon, .cam-op-number, .cam-next) { border-radius: 18px; }
html[data-btn=round] .tb.on { border-radius: 14px; }
html[data-btn=pill] :is(.btn, .chip, .fld, .kp button, .tn .tl, .tn .tx, .tn .ta, .ed-b, .ek, .mhead button, .frm input, .frm select, .cam-next) { border-radius: 999px; }
html[data-btn=pill] :is(#fab button, .cam-icon, .cam-op-number) { border-radius: 50%; }
html[data-btn=pill] .tn .tl, html[data-btn=pill] .cam-next { padding-left: 16px; padding-right: 16px; }
html[data-btn=pill] .tb.on { border-radius: 999px; }
html[data-btn=square] :is(.btn, .chip, .fld, .kp button, #fab button, .tn .tl, .tn .tx, .tn .ta, .ed-b, .ek, .mhead button, .frm input, .frm select, .cam-icon, .cam-op-number, .cam-next, .cam-operation, .mbox, #toast) { border-radius: 2px; }
html[data-btn=outline] :is(.btn, .chip, .kp button, #fab button, .tn .tx, .tn .ta, .ed-b, .ek) { background: transparent; border: 1px solid #4d6b7c; box-shadow: none; }
html[data-btn=outline] :is(.btn.ok, .btn.pri, .btn.on) { background: transparent; border-color: var(--accent); color: var(--accent); }
html[data-btn=outline] .tn .tl { background: transparent; }
html[data-btn=outline] .tb.on { background: transparent; }
html[data-btn=flat] :is(.btn, .chip, .kp button, #fab button, .tn .tl, .tn .tx, .tn .ta, .ed-b, .ek, .mhead button, .cam-next) { border-color: transparent; box-shadow: none; border-radius: 4px; }
html[data-btn=flat] .tn .tl { box-shadow: inset 3px 0 var(--ac); }
/* світла (біла) тема: Налаштування → «Тема» */
html[data-theme=light] { filter: invert(1) hue-rotate(180deg); background: #101820; }
html[data-theme=light] :is(img, video, .about img) { filter: invert(1) hue-rotate(180deg); }
