:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --fg: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, .08);
  --field: #f5f5f7;
  --accent: #1f8fb8;
  --accent-soft: rgba(31, 143, 184, .12);
  --ok: #1f9d55;
  --ok-soft: rgba(52, 199, 89, .14);
  --bad: #d70015;
  --bad-soft: rgba(255, 59, 48, .12);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 28px rgba(0, 0, 0, .06);
  --radius: 22px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --card: #1c1c1e;
    --fg: #f5f5f7;
    --muted: #a1a1a6;
    --line: rgba(255, 255, 255, .1);
    --field: #2c2c2e;
    --accent: #4cc2e6;
    --accent-soft: rgba(76, 194, 230, .16);
    --ok: #30d158;
    --ok-soft: rgba(48, 209, 88, .16);
    --bad: #ff6961;
    --bad-soft: rgba(255, 105, 97, .16);
    --shadow: 0 0 0 1px rgba(255, 255, 255, .06);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.47 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3 { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif; margin: 0; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 14px; }

.nav { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--line); }
.nav-inner { max-width: 1240px; margin: 0 auto; padding: 0 16px; height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 16px; letter-spacing: -.01em; }
.brand img { border-radius: 6px; }
.nav-note { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.nav-note svg { width: 15px; height: 15px; }
.nav-note { margin-left: auto; }
.lang-toggle { appearance: none; flex: none; font: inherit; font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; cursor: pointer; }
.lang-toggle:hover { color: var(--fg); background: var(--field); }
.lang-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

main { max-width: 1240px; margin: 0 auto; padding: 0 16px; display: grid; gap: 20px; }

.hero { text-align: center; padding: 56px 0 20px; }
.hero h1 { font-size: clamp(36px, 6.4vw, 56px); line-height: 1.06; letter-spacing: -.028em; font-weight: 700; }
.hero p { max-width: 600px; margin: 18px auto 0; font-size: clamp(17px, 2.2vw, 20px); color: var(--muted); letter-spacing: -.01em; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.step { padding: 24px; display: grid; gap: 20px; min-width: 0; }
.step-head { display: flex; gap: 14px; align-items: flex-start; }
.step-head h2 { font-size: 21px; letter-spacing: -.015em; }
.num { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center; font-size: 15px; }

.btn { appearance: none; border: 0; border-radius: 99px; padding: 11px 22px; font: inherit; font-size: 16px; font-weight: 500; cursor: pointer; background: var(--field); color: var(--fg); display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.btn svg { width: 19px; height: 19px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn:disabled { opacity: .4; cursor: default; }
.btn:not(:disabled):hover { filter: brightness(1.06); }

.pick, .actions { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; }

.folder-name { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
details { font-size: 14px; color: var(--muted); }
details summary { cursor: pointer; }
details ul { margin: 6px 0 0; padding-left: 18px; max-height: 220px; overflow: auto; }
details li { overflow-wrap: anywhere; }

.field { display: grid; gap: 8px; min-width: 0; }
.field label { font-size: 14px; font-weight: 600; }
select, input[type=number], input[type=text], input[type=date], input[type=search] { font: inherit; font-size: 16px; color: var(--fg); background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%; min-width: 0; }
select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }


input[type=checkbox] { accent-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; cursor: pointer; font-size: 15px; }
.check input { width: 18px; height: 18px; margin: 0; flex: none; }

.tips { padding: 8px 4px 0; color: var(--muted); font-size: 15px; }
.tips h3 { font-size: 17px; color: var(--fg); margin-bottom: 8px; }
.tips ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

/* Back to the HT Labs home page (wired by i18n.js) */
.home-link { flex: none; display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px 5px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); font-size: 13px; font-weight: 500; line-height: 1; letter-spacing: 0; white-space: nowrap; text-decoration: none; }
.home-link:hover { color: var(--fg); border-color: currentColor; text-decoration: none; }
.home-link:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.home-link svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 480px) { .home-link span { display: none; } .home-link { padding: 5px 7px; } .nav-note { display: none; } }

.grad { background: linear-gradient(90deg, #3a8fe0, #1fb89a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.foot { text-align: center; padding: 32px 16px 48px; font-size: 13px; color: var(--muted); }
.foot p { margin: 0; }
.foot a { color: var(--accent); text-decoration: none; }
.foot a:hover { text-decoration: underline; }
.bar { height: 8px; border-radius: 99px; background: var(--field); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
#progress { display: grid; gap: 8px; }
.notice { padding: 14px 16px; border-radius: 14px; font-size: 15px; overflow-wrap: anywhere; }
.notice.ok { background: var(--ok-soft); }
.notice.warn { background: rgba(255, 159, 10, .14); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.check.sub { font-weight: 500; }
.btn.small { padding: 7px 16px; font-size: 14px; justify-self: start; }
.btn.small svg { width: 16px; height: 16px; }

/* ---------- CAD Viewer ---------- */
.hero { padding: 40px 0 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 20px; align-items: end; }
@media (max-width: 700px) { .grid3 { grid-template-columns: minmax(0, 1fr); } }
.num svg { width: 16px; height: 16px; }

.app { overflow: hidden; display: grid; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tb-sep { width: 1px; height: 26px; background: var(--line); margin: 0 2px; }
.tb-group { display: flex; gap: 2px; padding: 2px; border-radius: 12px; background: var(--field); }
.tb-group[hidden] { display: none; }
.ib { appearance: none; border: 0; background: none; color: var(--fg); height: 34px; min-width: 34px; padding: 0 8px; border-radius: 10px; cursor: pointer;
  display: inline-grid; place-items: center; font: inherit; font-size: 13px; font-weight: 600; }
.ib svg { width: 19px; height: 19px; }
.ib:hover { background: var(--card); }
.ib[aria-pressed="true"] { background: var(--accent); color: #fff; }
.ib:disabled { opacity: .35; cursor: default; background: none; }
.ib:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 300px; min-height: 0; }
.workspace:has(.side[hidden]) { grid-template-columns: minmax(0, 1fr); }
.stage { position: relative; height: min(72vh, 760px); min-height: 380px; background: #1d1f23; overflow: hidden; touch-action: none; }
.stage.light { background: #f2f3f5; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage.measuring canvas { cursor: crosshair; }
.stage.dragging::after { content: ""; position: absolute; inset: 10px; border: 2px dashed var(--accent); border-radius: 16px; pointer-events: none; background: color-mix(in srgb, var(--accent) 8%, transparent); }
.empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; gap: 8px; padding: 24px; color: #e8e8ea; z-index: 2; }
.stage.light .empty { color: var(--fg); }
.empty svg { width: 56px; height: 56px; stroke-width: 1.2; opacity: .7; margin-bottom: 6px; }
.empty .muted { color: #a1a1a6; max-width: 460px; }
.empty-title { margin: 0; font-size: 19px; font-weight: 600; }
.fmt-line { letter-spacing: .02em; font-size: 12px !important; }
.busy { position: absolute; inset: 0; z-index: 5; display: grid; place-content: center; justify-items: center; gap: 12px; color: #fff; background: rgba(0, 0, 0, .45); font-weight: 600; }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .3); border-top-color: #fff; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.statusbar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; gap: 16px; padding: 6px 12px; font-size: 12px; color: #d0d0d4;
  background: linear-gradient(transparent, rgba(0, 0, 0, .55)); pointer-events: none; font-variant-numeric: tabular-nums; }
.statusbar #fileLabel { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40%; }
.statusbar #hint { margin-left: auto; text-align: right; }
.stage.light .statusbar { color: #3a3a3c; background: linear-gradient(transparent, rgba(255, 255, 255, .85)); }
.m-label { position: absolute; left: 0; top: 0; z-index: 4; padding: 3px 9px; border-radius: 6px; background: rgba(0, 0, 0, .78); color: #fff; font-size: 13px; font-weight: 600; pointer-events: none; white-space: nowrap; }

.side { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; height: min(72vh, 760px); min-height: 380px; overflow: auto; }
.panel { padding: 14px 16px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.panel.grow { flex: 1; align-content: start; min-height: 160px; }
.panel-head { display: flex; align-items: center; gap: 8px; }
.panel-head h3 { font-size: 15px; flex: 1; }
.head-btns { display: flex; gap: 10px; }
.link { appearance: none; border: 0; background: none; padding: 0; color: var(--accent); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
.link:hover { text-decoration: underline; }
.props { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 5px 12px; font-size: 13px; margin: 0; }
.props dt { color: var(--muted); }
.props dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.props dd.big-val { font-size: 18px; font-weight: 700; }
.units-field label { font-size: 13px; }
.units-field select, .export-bar select { font-size: 14px; padding: 6px 10px; border-radius: 10px; }
.seg { display: flex; gap: 4px; background: var(--field); padding: 3px; border-radius: 10px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 4px 0; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.seg input:checked + span { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.tree-filter { font-size: 14px !important; padding: 6px 10px !important; border-radius: 10px !important; }
.tree { list-style: none; margin: 0; padding: 0; font-size: 13px; overflow: auto; max-height: 420px; }
.tree ul { list-style: none; margin: 0; padding-left: 16px; }
.tree li { min-width: 0; }
.tree .row { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-radius: 7px; min-width: 0; }
.tree .row:hover { background: var(--field); }
.tree .row.sel { background: var(--accent-soft); }
.tree .row input { margin: 0; flex: none; width: 15px; height: 15px; }
.tree .tw { appearance: none; border: 0; background: none; color: var(--muted); width: 16px; height: 16px; padding: 0; cursor: pointer; flex: none; display: grid; place-items: center; }
.tree .tw svg { width: 12px; height: 12px; transition: transform .15s; }
.tree li.closed > .row .tw svg { transform: rotate(-90deg); }
.tree li.closed > ul { display: none; }
.tree .tw.leaf { visibility: hidden; }
.tree .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.tree .cnt { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.tree .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; box-shadow: inset 0 0 0 1px rgba(128, 128, 128, .5); }
.tree .more { color: var(--muted); padding: 4px; font-size: 12px; }

.export-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 18px; padding: 14px 16px; border-top: 1px solid var(--line); }
.export-bar .field { gap: 4px; min-width: 160px; }
.export-bar .field label { font-size: 13px; }
.export-bar .check { font-size: 14px; padding-bottom: 7px; }
.export-bar .btn { margin-bottom: 1px; }
.exp-note { flex-basis: 100%; }
.exp-note:empty { display: none; }
.app-notice { margin: 0 16px 16px; }

.blist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 360px; overflow: auto; }
.blist li { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; background: var(--field); border-radius: 12px; font-size: 14px; min-width: 0; }
.blist .b-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blist .b-kind { flex: none; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.blist .b-size { flex: none; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.blist .b-st { flex: none; font-size: 13px; max-width: 45%; text-align: right; }
.blist .b-st.ok { color: var(--ok); }
.blist .b-st.bad { color: var(--bad); }
.blist .b-st.skip { color: var(--muted); }
.x-btn { appearance: none; border: 0; background: none; color: var(--muted); width: 26px; height: 26px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; flex: none; }
.x-btn:hover { background: var(--card); color: var(--bad); }
.x-btn svg { width: 15px; height: 15px; }
.card.dragging { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }

.table-wrap { overflow-x: auto; }
.ftable { width: 100%; border-collapse: collapse; font-size: 14px; }
.ftable th, .ftable td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ftable th { font-size: 13px; color: var(--muted); font-weight: 600; }
.ftable td:first-child { font-weight: 600; white-space: nowrap; }
.ftable .ok { color: var(--ok); font-weight: 700; }
.ftable .no { color: var(--bad); font-weight: 700; }
.credits { margin-top: 6px !important; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .side { border-left: 0; border-top: 1px solid var(--line); height: auto; max-height: none; }
  .stage { height: 62vh; }
  .tree { max-height: 300px; }
}
@media (max-width: 600px) {
  .toolbar { gap: 6px; padding: 8px; }
  .tb-sep { display: none; }
  .statusbar #cursor { display: none; }
}
