:root {
  --bg: #ffffff; --fg: #1d2330; --muted: #667085; --line: #e4e7ec; --soft: #f5f7fa; --panel: #ffffff;
  --accent: #0f5fd7; --accent-soft: #dbe8ff; --text2: #344054; --drop-bg: #f7faff; --drop-line: #b2c6ee;
  --shadow: 0 8px 24px rgba(16,24,40,.12); --hl: #fff4d6;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --fg: #e6e9ef; --muted: #98a2b3; --line: #2a303b; --soft: #171b23; --panel: #161a22;
    --accent: #5b9cff; --accent-soft: #1b2a44; --text2: #cfd5df; --drop-bg: #131a26; --drop-line: #34507f;
    --shadow: 0 8px 24px rgba(0,0,0,.5); --hl: #2d2a17;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1218; --fg: #e6e9ef; --muted: #98a2b3; --line: #2a303b; --soft: #171b23; --panel: #161a22;
  --accent: #5b9cff; --accent-soft: #1b2a44; --text2: #cfd5df; --drop-bg: #131a26; --drop-line: #34507f;
  --shadow: 0 8px 24px rgba(0,0,0,.5); --hl: #2d2a17;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; color: var(--fg); background: var(--bg); display: flex; flex-direction: column; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pad { padding: 0 10px; }
.linklike { font: inherit; background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--fg); text-decoration: none; white-space: nowrap; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.lang { font: inherit; font-size: 13px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); max-width: 150px; }
.icon-btn { font: inherit; font-weight: 700; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); cursor: pointer; }
.icon-btn:hover { background: var(--soft); }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--soft); color: var(--muted); border: 1px solid var(--line); }
.badge.pro { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.btn { font: inherit; border: 1px solid var(--accent); background: var(--accent); color: #fff; padding: 5px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--accent); border-color: var(--line); }
.btn.ghost:hover { background: var(--soft); }
.btn.ghost.on { background: var(--accent-soft); border-color: var(--accent); }
.btn.icon { min-width: 32px; padding: 5px 8px; font-weight: 700; }
.btn.small { padding: 3px 10px; font-size: 13px; }

.landing { max-width: 780px; margin: 0 auto; padding: 44px 16px 24px; overflow: auto; flex: 1 1 auto; width: 100%; }
.landing h1 { font-size: 30px; line-height: 1.2; margin: 0 0 8px; letter-spacing: -.01em; }
.sub { color: var(--muted); font-size: 16px; margin: 0 0 22px; }
.drop { display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; text-align: center; border: 2px dashed var(--drop-line); background: var(--drop-bg); border-radius: 14px; padding: 40px 16px; cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop:focus-visible { border-color: var(--accent); outline: none; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-ico { color: var(--accent); margin-bottom: 4px; }
.drop strong { font-size: 17px; }
.drop span { color: var(--muted); font-size: 13px; }
.or { margin: 12px 0 0; text-align: center; font-size: 13px; color: var(--muted); display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; }
.note { margin-top: 16px; padding: 12px; border-radius: 8px; background: var(--accent-soft); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.points { margin: 26px 0 0; padding-inline-start: 18px; color: var(--text2); }
.points li { margin: 6px 0; }
.ai-link { margin: 16px 0 0; font-size: 14px; }
.faq { margin-top: 30px; border-top: 1px solid var(--line); padding-top: 8px; }
.faq h2 { font-size: 17px; margin: 12px 0 6px; }
.faq details { border-bottom: 1px solid var(--line); padding: 8px 0; }
.faq summary { cursor: pointer; font-weight: 600; color: var(--text2); }
.faq details p { margin: 8px 0 2px; color: var(--muted); }
.more { margin-top: 24px; font-size: 13px; color: var(--text2); }
.foot { margin-top: 18px; color: var(--muted); font-size: 12px; }

.viewer { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.title { display: flex; flex-direction: column; min-width: 0; }
.title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 36vw; }
.title .muted { font-size: 12px; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.menu { position: relative; }
.menu-list { position: absolute; inset-inline-end: 0; top: 110%; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); z-index: 20; display: flex; flex-direction: column; min-width: 190px; padding: 4px; }
.menu-list button { font: inherit; text-align: start; background: none; border: 0; padding: 7px 10px; border-radius: 6px; cursor: pointer; color: var(--fg); }
.menu-list button:hover { background: var(--soft); }

.stage-wrap { flex: 1 1 auto; display: flex; min-height: 0; position: relative; }
/* the drawing area keeps CAD orientation in right-to-left languages */
.stage { position: relative; flex: 1 1 auto; min-width: 0; overflow: hidden; background: #212830; touch-action: none; direction: ltr; }
.stage.light { background: #ffffff; }
.stage.paper { background: #8a929c; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
.stage canvas.panning { cursor: grabbing; }
.stage canvas.measuring { cursor: crosshair; }
.coords { position: absolute; left: 8px; bottom: 6px; font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: #c9d1db; background: rgba(0,0,0,.35); padding: 2px 6px; border-radius: 4px; pointer-events: none; }
.stage.light .coords, .stage.paper .coords { color: #344054; background: rgba(255,255,255,.8); }
.measure-box { position: absolute; right: 10px; top: 10px; background: #fff; color: #1d2330; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); padding: 10px 12px; font-size: 13px; min-width: 210px; max-width: calc(100% - 20px); }
.measure-box .muted { color: #667085; }
.measure-box b { font-size: 15px; }
.measure-box .row { justify-content: flex-start; margin-top: 6px; }
.measure-box .btn.ghost { color: #0f5fd7; border-color: #e4e7ec; }
.unit-pick { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.unit-pick select { font: inherit; font-size: 12px; padding: 1px 4px; }

.side { flex: 0 0 290px; border-inline-start: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.side-head { display: flex; align-items: center; border-bottom: 1px solid var(--line); padding: 0 4px 0 6px; }
.side-tabs { display: flex; flex: 1 1 auto; }
.side-tabs button { font: inherit; font-size: 13px; border: 0; background: none; padding: 9px 10px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.side-tabs button.on { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }
.side .x { border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--muted); padding: 4px 8px; }
.pane { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.pane-tools { display: flex; gap: 10px; align-items: center; padding: 8px 10px; font-size: 13px; }
.pane-tools input { flex: 1 1 auto; min-width: 0; font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); }
.pane-foot { border-top: 1px solid var(--line); padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
#block-sum, #find-sum { margin: 0 0 6px; }
.list { overflow: auto; flex: 1 1 auto; padding: 0 4px 8px; }
.layer { display: flex; align-items: center; gap: 8px; padding: 3px 6px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.layer:hover { background: var(--soft); }
.layer .sw { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.2); flex: 0 0 auto; }
.layer .nm, .blk .nm, .hit .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; min-width: 0; text-align: start; }
.layer.off .nm { color: var(--muted); text-decoration: line-through; }
.layer .only { visibility: hidden; font: inherit; font-size: 11px; border: 1px solid var(--line); background: var(--bg); color: var(--accent); border-radius: 4px; padding: 0 6px; cursor: pointer; }
.layer:hover .only, .layer:focus-within .only { visibility: visible; }
.blk, .hit { display: flex; width: 100%; gap: 8px; align-items: center; font: inherit; font-size: 13px; border: 0; background: none; color: var(--fg); padding: 5px 6px; border-radius: 6px; cursor: pointer; }
.blk:hover, .hit:hover { background: var(--soft); }
.blk.on, .hit.on { background: var(--hl); }
.blk .ct, .hit .ct { color: var(--muted); font-size: 12px; flex: 0 0 auto; font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: 2px; padding: 0 8px; border-top: 1px solid var(--line); background: var(--soft); overflow-x: auto; flex: 0 0 auto; }
.tabs button { font: inherit; font-size: 13px; border: 0; background: none; padding: 6px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--fg); border-bottom-color: var(--accent); background: var(--bg); }

.overlay { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 75%, transparent); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 50; text-align: center; padding: 16px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; background: #1d2330; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 60; max-width: calc(100vw - 32px); }

dialog { border: 0; border-radius: 12px; padding: 0; box-shadow: 0 24px 48px rgba(16,24,40,.24); width: min(460px, calc(100vw - 32px)); background: var(--panel); color: var(--fg); }
dialog::backdrop { background: rgba(16,24,40,.4); }
.dlg { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.dlg h2 { margin: 0; font-size: 19px; }
.dlg p { margin: 0; }
.dlg dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
.dlg dt { color: var(--muted); }
.dlg dd { margin: 0; overflow-wrap: anywhere; }
.keys dt { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--fg); background: var(--soft); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; justify-self: start; }
.trial { font-size: 13px; color: var(--text2); background: var(--soft); border-radius: 8px; padding: 8px 10px; }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.plans.three { grid-template-columns: 1fr 1fr 1fr; }
.plan { display: flex; flex-direction: column; align-items: center; padding: 14px 8px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--fg); text-align: center; }
.plan b { font-size: 22px; }
.plan span { color: var(--muted); font-size: 12px; }
.plan.best { border-color: var(--accent); background: var(--drop-bg); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text2); }
.field input { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); }
.row { display: flex; gap: 8px; justify-content: flex-end; }

.rate { position: fixed; left: 16px; bottom: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 10px 36px 10px 14px; font-size: 13px; z-index: 14; max-width: calc(100vw - 32px); }
.rate .x { position: absolute; right: 6px; top: 4px; border: 0; background: none; font-size: 18px; cursor: pointer; color: var(--muted); }

/* help, privacy, terms, AI pages */
.doc { max-width: 760px; margin: 0 auto; padding: 32px 16px 48px; line-height: 1.6; }
.doc h1 { font-size: 26px; line-height: 1.25; }
.doc h2 { font-size: 18px; margin-top: 28px; }
.doc pre { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; font-size: 13px; }
.doc table { border-collapse: collapse; width: 100%; font-size: 14px; }
.doc td, .doc th { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: start; vertical-align: top; }
.doc kbd { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--soft); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }

.print-area { display: none; }
@media print {
  @page { size: landscape; margin: 8mm; }
  body.printing > *:not(#print-area) { display: none !important; }
  body.printing #print-area { display: block; }
  #print-area img { width: 100%; max-height: 180mm; object-fit: contain; display: block; }
  #print-area p { font-size: 9px; margin: 2px 0 0; color: #555; }
}

@media (max-width: 860px) {
  .tools .btn { padding: 5px 9px; }
}
@media (max-width: 720px) {
  .top { padding: 8px 10px; }
  .brand { font-size: 14px; }
  /* language picker becomes a globe button; the native list still shows the language names */
  .lang { width: 32px; height: 30px; padding: 0; color: transparent; -webkit-appearance: none; appearance: none; cursor: pointer;
    background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M3 12h18M12 3c2.5 2.6 3.8 5.6 3.8 9s-1.3 6.4-3.8 9c-2.5-2.6-3.8-5.6-3.8-9S9.5 5.6 12 3z'/%3E%3C/svg%3E") center / 18px no-repeat; }
  .lang option { color: var(--fg); background: var(--bg); }
  #btn-help { display: none; }
  .title strong { max-width: 90vw; }
  .landing { padding-top: 28px; }
  .landing h1 { font-size: 23px; }
  .side { position: absolute; inset-inline-end: 0; top: 0; bottom: 0; width: min(300px, 88vw); z-index: 10; box-shadow: -8px 0 24px rgba(0,0,0,.2); }
  #btn-info, #btn-bg, #btn-zin, #btn-zout { display: none; }
  .plans.three { grid-template-columns: 1fr; }
  .layer .only { visibility: visible; }
}
@media (max-width: 420px) {
  #btn-theme { display: none; }
  .top-actions { gap: 6px; }
  #btn-upgrade { padding: 5px 10px; }
}

/* object properties and scale calibration */
.pick-box { left: 10px; right: auto; top: 10px; max-width: min(320px, calc(100% - 20px)); }
.pick-box .pick-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.pick-box .icon-btn.small { width: 24px; height: 24px; background: #fff; color: #1d2330; border-color: #e4e7ec; }
.pick-box .pick-text { white-space: pre-wrap; word-break: break-word; margin-top: 4px; padding: 6px; background: #f5f7fa; border-radius: 6px; }
.measure-box .cal-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.measure-box .cal-form label { flex: 1 0 100%; }
.measure-box .cal-form input { width: 100px; font: inherit; padding: 3px 6px; border: 1px solid #d0d5dd; border-radius: 6px; }
.measure-box .cal-form select { font: inherit; padding: 3px; border: 1px solid #d0d5dd; border-radius: 6px; }
.measure-box .linkish { font: inherit; background: none; border: 0; color: #0f5fd7; cursor: pointer; padding: 0; text-decoration: underline; }
@media (max-width: 640px) { .pick-box { top: auto; bottom: 30px; } }

/* header name never clips mid-word; install button */
.brand { min-width: 0; }
.brand img { flex: 0 0 auto; }
.brand-name { overflow: hidden; text-overflow: ellipsis; }
.top-actions { flex: 0 0 auto; }
.install { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 12px; margin: 16px 0 0; text-align: center; }
.install-btn { display: inline-flex; align-items: center; gap: 10px; padding: 9px 18px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--fg); font-weight: 600; text-decoration: none; box-shadow: 0 1px 2px rgba(16,24,40,.06); }
.install-btn:hover { border-color: var(--accent); background: var(--soft); }
.install .small { font-size: 13px; }
.demo { margin: 22px 0 6px; }
.demo video { display: block; width: 100%; height: auto; aspect-ratio: 960 / 600; border-radius: 12px; border: 1px solid var(--line); background: var(--soft); box-shadow: 0 8px 24px rgba(16,24,40,.08); }
