:root {
  color-scheme: dark;
  --bg: #02040a; --panel: #070c18; --glass: rgba(9, 15, 28, .82); --glass-strong: rgba(8, 13, 24, .94); --line: rgba(140, 190, 255, .14); --line-strong: rgba(140, 190, 255, .3);
  --text: #e7f0ff; --muted: #8fa3c2; --accent: #36e0ff; --accent-2: #8b7bff; --ok: #6ff0a6; --warn: #ffc35a; --bad: #ff6b7d;
  --radius: 12px; --font: "Segoe UI Variable", "Segoe UI", Inter, system-ui, -apple-system, sans-serif; --mono: "Cascadia Mono", "JetBrains Mono", Consolas, ui-monospace, monospace;
  --side: 268px; --right: 300px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 13px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
body { display: grid; grid-template-rows: 52px 1fr; user-select: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: 12px; margin: 6px 0; }
.warning { color: var(--warn); white-space: pre-wrap; }
h2 { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; font-weight: 650; margin: 0; color: #cfe0ff; }
h3 { margin: 0 0 6px; font-size: 15px; }
a { color: var(--accent); }
.mono { font-family: var(--mono); }
sub, sup { font-size: .72em; }

/* ------------------------------------------------------------ top bar */
#topbar { display: flex; align-items: center; gap: 12px; padding: 0 12px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #0a1326, #060a16); }
.brand { display: flex; align-items: center; gap: 9px; font-size: 15px; white-space: nowrap; }
.brand img { width: 26px; height: 26px; }
.brand b { font-weight: 700; background: linear-gradient(90deg, #9fe7ff, #a99bff); -webkit-background-clip: text; background-clip: text; color: transparent; }
#tabs { display: flex; gap: 2px; background: rgba(255, 255, 255, .04); padding: 3px; border-radius: 10px; }
#tabs button { border: 0; background: none; padding: 6px 11px; border-radius: 8px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
#tabs button[aria-selected="true"] { background: rgba(54, 224, 255, .14); color: var(--text); box-shadow: inset 0 0 0 1px rgba(54, 224, 255, .25); }
.status { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.right { display: flex; gap: 6px; align-items: center; }
.chip { border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .04); border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 700; letter-spacing: .04em; white-space: nowrap; color: var(--text); }
.chip.mono { font-weight: 600; letter-spacing: 0; }
#backend-chip.gpu { color: var(--ok); border-color: rgba(111, 240, 166, .5); }
#backend-chip.cpu { color: var(--warn); border-color: rgba(255, 195, 90, .5); }
#tier-badge.pro { color: var(--accent); border-color: rgba(54, 224, 255, .5); }
#tier-badge.premium { color: #d3c8ff; border-color: rgba(169, 155, 255, .6); background: rgba(139, 123, 255, .14); }
.icon { border: 0; background: none; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.icon:hover { background: rgba(255, 255, 255, .07); color: var(--text); }
.icon svg { width: 19px; height: 19px; }
.tag { font-size: 9px; letter-spacing: .08em; font-weight: 800; color: var(--accent); border: 1px solid rgba(54, 224, 255, .4); border-radius: 5px; padding: 0 4px; line-height: 1.5; vertical-align: middle; }
.tag.premium, .tag[data-feature="les"], .tag[data-feature="solver3d"], .tag[data-feature="stlImport"], .tag[data-feature="batchQueue"], .tag[data-feature="fieldExport"], .tag[data-feature="video"], .tag[data-feature="ultraResolution"] { color: #d3c8ff; border-color: rgba(169, 155, 255, .5); }
.tag.unlocked { display: none; }

/* ------------------------------------------------------------ layout */
#main { display: grid; grid-template-columns: var(--side) 1fr var(--right); min-height: 0; }
body:not([data-tab="tunnel"]) #main { grid-template-columns: 1fr; }
.panel { background: var(--panel); border-right: 1px solid var(--line); overflow: auto; padding: 10px 12px; display: grid; gap: 14px; align-content: start; }
#readouts { border-right: 0; border-left: 1px solid var(--line); }
.panel section { display: grid; gap: 7px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 2px; }
label { display: grid; gap: 3px; color: var(--muted); font-size: 12px; min-width: 0; }
label.check { display: flex; align-items: center; gap: 7px; color: var(--text); }
label.inline { display: flex; align-items: center; gap: 6px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row.three { grid-template-columns: 1fr 1fr 1fr; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; }
input:not([type]), input[type=number], input[type=search], input[type=text], select, textarea { background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; color: var(--text); outline: none; width: 100%; min-width: 0; }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 2px 0; }
input[type=checkbox] { accent-color: var(--accent); }
textarea { font-family: var(--mono); font-size: 12px; resize: vertical; user-select: text; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.btn { border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .05); border-radius: 9px; padding: 6px 11px; font-weight: 600; white-space: nowrap; }
.btn:hover { background: rgba(255, 255, 255, .1); }
.btn.primary { background: linear-gradient(135deg, #2fb8ff, #7c6cff); border-color: transparent; color: #fff; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.link { border: 0; background: none; color: var(--accent); padding: 0; }
.list { display: grid; gap: 4px; }
.item { border: 1px solid var(--line); background: rgba(255, 255, 255, .025); border-radius: 9px; padding: 6px 9px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.item.active { border-color: rgba(54, 224, 255, .55); }
.item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 12px; margin: 4px 0 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; font-family: var(--mono); overflow-wrap: anywhere; }
.kv.shortcuts dd { text-align: left; font-family: var(--font); }
.kv.shortcuts dt { font-family: var(--mono); color: var(--text); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stat { background: rgba(255, 255, 255, .035); border: 1px solid var(--line); border-radius: 9px; padding: 6px 9px; }
.stat dt { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.stat dd { margin: 1px 0 0; font-family: var(--mono); font-size: 15px; }
.status-pill { font-size: 10px; font-weight: 750; letter-spacing: .06em; padding: 1px 7px; border-radius: 6px; border: 1px solid currentColor; text-transform: uppercase; color: var(--muted); }
.status-pill.ok { color: var(--ok); } .status-pill.warn { color: var(--warn); } .status-pill.bad { color: var(--bad); }
.seg { display: flex; background: rgba(255, 255, 255, .04); border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 10px; border-radius: 7px; color: var(--muted); font-weight: 600; }
.seg button.active { background: rgba(54, 224, 255, .14); color: var(--text); }
.seg.small button { padding: 3px 8px; font-size: 12px; }
.gate-overlay { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 14px; background: rgba(5, 9, 18, .82); border-radius: 9px; backdrop-filter: blur(3px); }
.gate-overlay p { margin: 0 0 10px; color: #c8dbf5; }
.gate-overlay.large { border-radius: 0; }
.gate-overlay.large > div { max-width: 460px; }
.gate { border: 1px dashed rgba(54, 224, 255, .4); border-radius: 10px; padding: 10px; background: rgba(54, 224, 255, .05); }
.gate p { margin: 0 0 8px; color: #c8dbf5; }

/* ------------------------------------------------------------ stage */
#stage { display: grid; grid-template-rows: 1fr auto; min-width: 0; min-height: 0; background: radial-gradient(ellipse at 50% 40%, #0a1326 0%, #02040a 75%); }
.viewport { position: relative; display: grid; place-items: center; min-height: 0; padding: 10px; overflow: hidden; }
.viewport canvas { grid-area: 1 / 1; display: block; border-radius: 6px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); image-rendering: auto; }
#overlay { cursor: default; touch-action: none; }
body[data-tool="probe"] #overlay, body[data-tool="polygon"] #overlay { cursor: crosshair; }
body[data-tool="ruler"] #overlay { cursor: col-resize; }
.warnings { position: absolute; left: 18px; top: 18px; max-width: 60%; background: rgba(50, 36, 6, .85); border: 1px solid rgba(255, 195, 90, .5); color: #ffe2a8; border-radius: 9px; padding: 6px 10px; font-size: 12px; }
.tool-hint { position: absolute; right: 18px; top: 18px; background: var(--glass-strong); border: 1px solid var(--line); border-radius: 9px; padding: 5px 10px; font-size: 12px; color: #cfe0ff; }
#transport { border-top: 1px solid var(--line); background: var(--panel); display: grid; grid-template-columns: 1fr 360px; min-height: 118px; }
#transport .controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 10px; align-content: start; }
#transport .spacer { flex: 1; }
.chart { width: 100%; height: 110px; display: block; }
.chart.tall { height: 170px; }
.chart.big { height: 320px; }
.chart-wrap { position: relative; }
#force-chart { height: 100%; min-height: 110px; border-left: 1px solid var(--line); }
.menu-wrap { position: relative; }
.menu { position: absolute; bottom: calc(100% + 6px); right: 0; background: var(--glass-strong); border: 1px solid var(--line-strong); border-radius: 10px; padding: 4px; display: grid; gap: 2px; min-width: 260px; z-index: 20; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.menu button { border: 0; background: none; text-align: left; padding: 7px 10px; border-radius: 7px; display: flex; justify-content: space-between; gap: 10px; }
.menu button:hover { background: rgba(255, 255, 255, .07); }

/* ------------------------------------------------------------ pages */
.page { min-height: 0; overflow: hidden; display: grid; }
.page-grid { display: grid; grid-template-columns: 330px 1fr; min-height: 0; }
.page-main { padding: 14px 18px; overflow: auto; min-width: 0; display: grid; gap: 10px; align-content: start; }
.doc-page { max-width: 980px; user-select: text; }
.view3d-wrap { position: relative; padding: 0; display: block; }
.viewport3d { position: absolute; inset: 0; }
.viewport3d canvas { width: 100%; height: 100%; display: block; }
.progress { position: relative; height: 18px; border-radius: 9px; background: rgba(255, 255, 255, .06); overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: linear-gradient(90deg, #2fb8ff, #7c6cff); transition: width .2s; }
.progress .label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; color: #fff; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.table { width: 100%; border-collapse: collapse; font-size: 12px; user-select: text; }
.table th, .table td { padding: 6px 9px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.table td.num { font-family: var(--mono); text-align: right; }
.table td.ok { color: var(--ok); } .table td.warn { color: var(--warn); } .table td.bad { color: var(--bad); }
.doc { user-select: text; line-height: 1.55; color: #d6e2f7; }
.doc h2 { font-size: 20px; text-transform: none; letter-spacing: 0; margin: 4px 0 10px; color: var(--text); }
.doc h3 { font-size: 15px; margin: 18px 0 6px; color: #cfe0ff; }
.doc p { margin: 6px 0; }
.doc ul, .doc ol { padding-left: 20px; }
.doc li { margin: 4px 0; }
.doc .eq { font-family: var(--mono); font-size: 12.5px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 8px 0; overflow-x: auto; }
.doc .refs li { font-size: 12px; color: #b9c8e2; }
.doc .refs a { overflow-wrap: anywhere; }

/* ------------------------------------------------------------ toast */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30; display: grid; gap: 8px; pointer-events: none; }
#toast .t { background: var(--glass-strong); border: 1px solid var(--line-strong); border-radius: 11px; padding: 9px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); animation: rise .25s ease-out; pointer-events: auto; max-width: 560px; }
#toast .t.error { border-color: rgba(255, 107, 125, .5); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------ dialogs */
.dialog { border: 1px solid var(--line-strong); border-radius: 16px; padding: 0; background: #070c18; color: var(--text); width: min(680px, 94vw); max-height: 90vh; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); user-select: text; }
.dialog.wide { width: min(880px, 94vw); }
.dialog::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(4px); }
.dialog-body { padding: 20px; display: grid; gap: 12px; }
.dialog h2 { font-size: 16px; text-transform: none; letter-spacing: 0; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 14px; display: grid; gap: 8px; margin: 0; }
legend { color: var(--accent); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; padding: 0 6px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.tiers { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.tiers article { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: rgba(255, 255, 255, .03); }
.tiers ul { margin: 0; padding-left: 18px; color: #c2d1ea; font-size: 12px; }
.tiers h3 span { color: var(--accent); font-size: 13px; margin-left: 6px; }
details summary { cursor: pointer; color: var(--muted); }
#feature-table td.yes { color: var(--ok); } #feature-table td.no { color: var(--muted); }

/* ------------------------------------------------------------ loading */
#loading { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; background: radial-gradient(circle at 50% 45%, #0b1830, #02040a 60%); z-index: 50; transition: opacity .6s; }
#loading.done { opacity: 0; pointer-events: none; }
.ring { width: 54px; height: 54px; border-radius: 50%; border: 2px solid rgba(54, 224, 255, .15); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ small screens (1024×768 is the floor) */
@media (max-width: 1280px) { :root { --side: 236px; --right: 250px; } #transport { grid-template-columns: 1fr 280px; } .brand span { display: none; } .status .chip.mono:last-child { display: none; } .page-grid { grid-template-columns: 290px 1fr; } }
@media (max-width: 1100px) { :root { --side: 222px; --right: 232px; } #tabs button { padding: 6px 8px; } #tabs .tag { display: none; } #transport { grid-template-columns: 1fr 220px; } .stats { grid-template-columns: 1fr 1fr; } .tiers { grid-template-columns: 1fr; } }
::-webkit-scrollbar { width: 9px; height: 9px; } ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 9px; border: 2px solid transparent; background-clip: padding-box; }
