/* CONAKA Drafting — "drafting film": cool paper, graphite ink, survey-teal accent.
   Layout modes: desk (>=1280: chat | sheet | detail), tablet (760-1279: chat | sheet,
   detail slides over), phone (<760: one pane at a time + bottom nav). */

:root {
  --paper: #eef1ed;
  --sheet: #fbfcfa;
  --raised: #ffffff;
  --ink: #18201d;
  --graphite: #56615c;
  --faint: #8a948f;
  --rule: #d3dbd6;
  --rule-strong: #b5c0ba;
  --grid: #e4eae6;
  --grid-major: #d2dbd5;
  --teal: #0c7564;
  --teal-hover: #0a6656;
  --teal-ink: #ffffff;
  --teal-soft: #dcefe9;
  --teal-line: #7fbfb1;
  --amber: #8a5a0c;
  --amber-soft: #fbf0dc;
  --amber-line: #ecc98c;
  --red: #b4372a;
  --red-soft: #fcebe8;
  --wall: #26302c;
  --dim: #5b4fa0;
  --glass: #2f80b5;
  --col: #c0392b;
  --shadow: 0 1px 2px rgba(16, 28, 24, .06), 0 4px 14px rgba(16, 28, 24, .08);
  --shadow-lg: 0 18px 50px rgba(16, 28, 24, .18);
  --r-sm: 6px;
  --r: 10px;
  --font: "Archivo", ui-sans-serif, system-ui, sans-serif;
  --tap: 40px;
  color-scheme: light;
}


@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #131816; --sheet: #191f1d; --raised: #1f2623; --ink: #e6ece9; --graphite: #a2aea8; --faint: #76827c;
    --rule: #2e3834; --rule-strong: #43504a; --grid: #1e2523; --grid-major: #28312e;
    --teal: #3dbfa5; --teal-hover: #5ccdb6; --teal-ink: #08201b; --teal-soft: #1b3731; --teal-line: #2f7c6d;
    --amber: #e8b25c; --amber-soft: #33281a; --amber-line: #6b5228; --red: #f08273; --red-soft: #3a1f1c;
    --wall: #d9e1dd; --dim: #b9adf0; --glass: #6fb6e3; --col: #f08273;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .3);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] { color-scheme: dark; }

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.45; color: var(--ink); background: var(--paper);
  display: flex; flex-direction: column; height: 100dvh; overflow: hidden;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.ic { width: 16px; height: 16px; flex: none; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: var(--r-sm); }
.skip:focus { top: 8px; }

/* ------------------------------------------------------------------ buttons */
.btn, .btn-quiet {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 0 14px;
  border-radius: var(--r-sm); font-weight: 550; font-size: 14px; white-space: nowrap; text-decoration: none;
  border: 1px solid var(--rule-strong); background: var(--raised); color: var(--ink);
  transition: background-color .12s, border-color .12s, color .12s;
}
.btn:hover { border-color: var(--graphite); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: var(--teal-ink); }
.btn.primary:hover { background: var(--teal-hover); border-color: var(--teal-hover); }
.btn:disabled, .btn-quiet:disabled { opacity: .45; cursor: not-allowed; }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-quiet:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.icon { padding: 0; width: 36px; }
.sm.icon { width: 32px; }
.link { background: none; border: 0; padding: 0; color: var(--teal); text-decoration: underline; text-underline-offset: 2px; font-weight: 550; }
.danger { color: var(--red); }

/* ------------------------------------------------------------------ top bar */
.topbar {
  flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 14px; min-height: 54px;
  background: var(--sheet); border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: baseline; gap: 6px; padding-right: 6px; flex: none; }
.brand b { font-weight: 750; font-stretch: 118%; letter-spacing: .03em; font-size: 17px; }
.brand b::before {
  content: ""; display: inline-block; width: 11px; height: 11px; margin-right: 7px; vertical-align: 1px;
  border: 2.5px solid var(--teal); border-radius: 2px; box-shadow: inset -4px -4px 0 -2px var(--teal);
}
.brand span { color: var(--graphite); font-size: 15px; }
.project-switch { position: relative; min-width: 0; }
#projectBtn { font-weight: 650; font-size: 15px; max-width: min(360px, 40vw); min-height: 38px; }
#projectName { overflow: hidden; text-overflow: ellipsis; }
.menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; width: min(340px, 92vw); max-height: 65vh; overflow: auto;
  background: var(--raised); border: 1px solid var(--rule); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 6px;
  overscroll-behavior: contain;
}
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: var(--r-sm); }
.menu button:hover, .menu button:focus-visible { background: var(--paper); }
.menu button[aria-current="true"] { background: var(--teal-soft); }
.menu small { display: block; color: var(--graphite); font-size: 12px; }
.menu .new { color: var(--teal); font-weight: 650; display: flex; align-items: center; gap: 8px; }
.menu hr { border: 0; border-top: 1px solid var(--rule); margin: 6px 0; }
.version { display: flex; align-items: center; gap: 2px; color: var(--graphite); font-size: 13px; flex: none; }
.version > span { padding: 0 6px; border-left: 1px solid var(--rule); }
.downloads { margin-left: auto; display: flex; gap: 6px; flex: none; }
.downloads .short { display: none; }

/* ------------------------------------------------------------------ workspace */
.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px minmax(0, 1fr) 400px; position: relative; }
.pane { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.chat { background: var(--sheet); border-right: 1px solid var(--rule); }
.inspector { background: var(--sheet); border-left: 1px solid var(--rule); }
.scroll, .chat-log { overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }

/* ------------------------------------------------------------------ chat */
.chat-log { flex: 1; min-height: 0; padding: 18px 16px 12px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 90%; padding: 9px 12px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--teal); color: var(--teal-ink); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--raised); border: 1px solid var(--rule); border-bottom-left-radius: 4px; }
.msg.error { align-self: stretch; max-width: none; background: var(--red-soft); color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 30%, transparent); }
.msg .cost { display: block; margin-top: 5px; font-size: 12px; color: var(--graphite); }
.intro h2 { font-size: 20px; font-stretch: 112%; line-height: 1.2; margin: 0 0 8px; }
.intro p { color: var(--graphite); margin: 0 0 10px; }
.steps { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; counter-reset: s; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; }
.steps li::before {
  content: counter(s); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 650; background: var(--teal-soft); color: var(--teal);
}

.chat-foot { flex: none; border-top: 1px solid var(--rule); padding: 10px 14px 12px; display: grid; gap: 10px; background: var(--sheet); }
.survey {
  border: 1.5px dashed var(--rule-strong); border-radius: var(--r-sm); padding: 8px 11px; font-size: 13px;
  transition: border-color .12s, background-color .12s;
}
.survey { cursor: pointer; }
.survey:hover { border-color: var(--teal-line); }
.survey p { margin: 1px 0 0; color: var(--graphite); }
.survey.drag { border-color: var(--teal); background: var(--teal-soft); }
.survey.has-data { border-style: solid; border-color: var(--teal-line); background: color-mix(in srgb, var(--teal-soft) 40%, transparent); }

.mode {
  font-size: 12px; line-height: 1.4; color: var(--graphite); padding: 7px 10px; border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--amber-soft) 70%, transparent); border: 1px solid var(--amber-line);
}
.mode b { color: var(--amber); }

/* one scrollable row so chips never push the composer off screen */
.chips {
  display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 2px; margin: 0 -14px;
  padding-inline: 14px; scrollbar-width: none; mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 24px), transparent);
}
.chips::-webkit-scrollbar { display: none; }
.chips:empty { display: none; }
.chip {
  flex: none; scroll-snap-align: start; border: 1px solid var(--rule-strong); background: var(--raised); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; min-height: 32px;
}
.chip:hover { border-color: var(--teal); color: var(--teal); }

.composer {
  display: flex; align-items: flex-end; gap: 6px; border: 1px solid var(--rule-strong); border-radius: var(--r);
  background: var(--raised); padding: 6px 6px 6px 12px; transition: border-color .12s, box-shadow .12s;
}
.composer:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.composer textarea {
  flex: 1; border: 0; background: transparent; resize: none; padding: 6px 0; min-height: 44px; max-height: 180px; outline: none;
  line-height: 1.4;
}
.send { min-height: 38px; }
.usage { font-size: 12px; color: var(--graphite); margin-top: -4px; }
.usage:empty { display: none; }

/* ------------------------------------------------------------------ sheet */
.sheet { background: var(--paper); }
.canvas-wrap {
  position: relative; flex: 1; min-height: 0; overflow: hidden; cursor: grab; touch-action: none; outline-offset: -3px;
  background: var(--sheet);
}
.canvas-wrap.panning { cursor: grabbing; }
#canvas { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; }
.statusbar {
  flex: none; display: flex; gap: 16px; padding: 6px 14px; font-size: 12px; color: var(--graphite);
  border-top: 1px solid var(--rule); background: var(--sheet); overflow-x: auto; white-space: nowrap; scrollbar-width: none;
}
.statusbar:empty { display: none; }
.statusbar b { color: var(--ink); font-weight: 600; }

.float { position: absolute; z-index: 5; display: flex; gap: 6px; }
.top-left { top: 12px; left: 12px; flex-direction: column; align-items: flex-start; }
.top-right { top: 12px; right: 12px; }
.bottom-right { bottom: 12px; right: 12px; }
.bottom-left { bottom: 12px; left: 12px; }
.fab {
  display: inline-flex; align-items: center; gap: 7px; min-height: var(--tap); padding: 0 12px; border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--raised) 92%, transparent); border: 1px solid var(--rule); box-shadow: var(--shadow);
  font-size: 13px; font-weight: 550; backdrop-filter: blur(6px); position: relative;
}
.fab:hover { border-color: var(--rule-strong); }
.fab[aria-expanded="true"] { border-color: var(--teal); color: var(--teal); }
.fab.icon { width: var(--tap); padding: 0; justify-content: center; }
.zoom { flex-direction: column; gap: 0; border-radius: var(--r-sm); box-shadow: var(--shadow); }
.zoom .fab { box-shadow: none; border-radius: 0; }
.zoom .fab:first-child { border-radius: var(--r-sm) var(--r-sm) 0 0; }
.zoom .fab:last-child { border-radius: 0 0 var(--r-sm) var(--r-sm); }
.zoom .fab + .fab { border-top: 0; }
.layers {
  background: var(--raised); border: 1px solid var(--rule); border-radius: var(--r); box-shadow: var(--shadow); padding: 6px; display: grid;
}
.layers label { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: var(--r-sm); font-size: 14px; cursor: pointer; min-height: 36px; }
.layers label:hover { background: var(--paper); }
.layers input { accent-color: var(--teal); width: 16px; height: 16px; margin: 0; }
.badge {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px;
  background: var(--amber); color: #fff; display: grid; place-items: center; font-weight: 700; line-height: 1;
}

/* title block chip: scale bar + project, like the corner of a plotted sheet */
.titleblock {
  align-items: stretch; gap: 0; background: color-mix(in srgb, var(--raised) 92%, transparent); border: 1px solid var(--ink);
  border-radius: 2px; font-size: 12px; box-shadow: var(--shadow); backdrop-filter: blur(6px); max-width: calc(100% - 90px);
}
.scalebar { display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 6px 10px; border-right: 1px solid var(--ink); }
.scalebar i {
  display: block; height: 6px; border: 1.5px solid var(--ink); border-top: 0;
  background: linear-gradient(90deg, var(--ink) 0 50%, transparent 50%) bottom / 100% 3px no-repeat;
}
.scalebar span { font-size: 11px; color: var(--graphite); }
.tb-text { display: flex; flex-direction: column; justify-content: center; padding: 5px 10px; min-width: 0; }
.tb-text strong { font-weight: 650; font-stretch: 108%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-text span { color: var(--graphite); white-space: nowrap; }

.empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 24px; pointer-events: none; }
.empty-mark {
  width: 64px; height: 52px; margin: 0 auto 16px; border: 3px solid var(--rule-strong); position: relative;
  background: linear-gradient(var(--rule-strong), var(--rule-strong)) 60% 0 / 3px 45% no-repeat,
              linear-gradient(var(--rule-strong), var(--rule-strong)) 0 60% / 60% 3px no-repeat;
}
.empty h2 { font-size: 22px; font-stretch: 115%; margin: 0 0 6px; }
.empty p { max-width: 380px; color: var(--graphite); margin: 0 auto; }
.busy {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 6; background: var(--ink); color: var(--paper);
  padding: 8px 14px; border-radius: 999px; font-size: 13px; display: flex; gap: 9px; align-items: center; box-shadow: var(--shadow);
}
.spinner { width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* drawing */
.g-grid line { stroke: var(--grid); }
.g-grid line.major { stroke: var(--grid-major); }
.g-site polygon { fill: none; stroke: var(--teal); stroke-width: 1.2; stroke-dasharray: 10 4 2 4; }
.g-room rect { fill: transparent; cursor: pointer; transition: fill .12s; }
.g-room rect.open { fill: color-mix(in srgb, var(--grid) 70%, transparent); }
.g-room rect:hover, .g-room rect.hover { fill: color-mix(in srgb, var(--teal-soft) 70%, transparent); }
.g-room rect.selected { fill: var(--teal-soft); stroke: var(--teal); stroke-width: 2; }
.g-wall polygon { fill: var(--wall); }
.g-cols rect { fill: var(--col); }
.g-door line, .g-door path { stroke: var(--teal); fill: none; stroke-width: 1.2; }
.g-door path { stroke-dasharray: 3 3; }
.g-win line { stroke: var(--glass); stroke-width: 1.2; }
.g-door .sel, .g-win .sel { stroke: var(--amber); stroke-width: 3; }
.g-labels text { fill: var(--ink); text-anchor: middle; dominant-baseline: middle; font-family: var(--font); pointer-events: none; }
.g-labels .area { fill: var(--graphite); }
.g-labels .tag { fill: var(--teal); font-weight: 650; }
.g-labels .halo { stroke: var(--sheet); stroke-width: .045; stroke-linejoin: round; paint-order: stroke; } /* user units = meters */
.g-dims line { stroke: var(--dim); }
.g-dims text { fill: var(--dim); text-anchor: middle; font-family: var(--font); }

/* ------------------------------------------------------------------ inspector */
.inspector-head { flex: none; display: flex; align-items: center; border-bottom: 1px solid var(--rule); padding-right: 8px; }
.tabs { display: flex; flex: 1; padding: 0 8px; overflow-x: auto; scrollbar-width: none; }
.tabs button {
  border: 0; background: none; padding: 14px 12px 12px; color: var(--graphite); font-weight: 550; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px; min-height: 46px;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--teal); }
.close-drawer { display: none; }
.scroll { flex: 1; min-height: 0; }
.tab-body { padding: 14px 16px 32px; }
.warnings {
  margin: 14px 16px 0; padding: 10px 12px; background: var(--amber-soft); color: var(--amber);
  border: 1px solid var(--amber-line); border-radius: var(--r-sm); font-size: 13px;
}
.warnings summary { cursor: pointer; font-weight: 650; }
.warnings ul { margin: 6px 0 0; padding-left: 18px; }
.hint { color: var(--graphite); font-size: 13px; margin: 0 0 12px; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 18px 0 8px; font-size: 14px; font-weight: 650; }
.section-title:first-child { margin-top: 0; }

.list { border: 1px solid var(--rule); border-radius: var(--r-sm); overflow: hidden; background: var(--raised); }
.row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 12px;
  text-align: left; background: none; border: 0; border-top: 1px solid var(--rule);
}
.row:first-child { border-top: 0; }
.row:hover { background: var(--paper); }
.row[aria-current="true"] { background: var(--teal-soft); box-shadow: inset 3px 0 0 var(--teal); }
.row .name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { color: var(--graphite); font-size: 13px; flex: none; }
.pill { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--paper); color: var(--graphite); border: 1px solid var(--rule); margin-left: 6px; font-weight: 500; }
.add-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.editor { margin-bottom: 16px; border: 1px solid var(--teal-line); border-radius: var(--r); background: var(--raised); overflow: hidden; box-shadow: var(--shadow); }
.editor-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; background: var(--teal-soft); }
.editor-head h3 { margin: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-head .meta { font-size: 13px; color: var(--teal); font-weight: 650; margin-left: auto; }
.editor-body { padding: 12px 14px 14px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--graphite); min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field input, .field select {
  border: 1px solid var(--rule-strong); border-radius: var(--r-sm); padding: 0 10px; min-height: 38px; background: var(--raised); color: var(--ink);
  width: 100%; font-size: 15px;
}
.field input:focus, .field select:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px var(--teal-soft); }
.stepper { display: grid; grid-template-columns: 36px minmax(0, 1fr) 36px; }
.stepper button { border: 1px solid var(--rule-strong); background: var(--paper); display: grid; place-items: center; min-height: 38px; }
.stepper button:hover { background: var(--teal-soft); color: var(--teal); }
.stepper button:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); border-right: 0; }
.stepper button:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; border-left: 0; }
.stepper input { border-radius: 0; text-align: center; padding: 0 4px; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.check { flex-direction: row; align-items: flex-start; gap: 9px; color: var(--ink); cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; margin: 1px 0 0; accent-color: var(--teal); flex: none; }
.editor-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--rule); }

.total { padding: 14px; border-radius: var(--r); background: var(--raised); border: 1px solid var(--rule); margin-bottom: 14px; }
.total .label { color: var(--graphite); font-size: 13px; }
.total .big { font-size: 30px; font-weight: 720; font-stretch: 106%; letter-spacing: -.01em; line-height: 1.15; margin: 2px 0 6px; overflow-wrap: anywhere; }
.total dl { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin: 0; font-size: 13px; }
.total dt { color: var(--graphite); }
.total dd { margin: 0; text-align: right; }
.bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin: 10px 0 2px; background: var(--paper); }
.bar i { display: block; height: 100%; }
.rab-group { border-top: 1px solid var(--rule); }
.rab-group > summary {
  list-style: none; display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; padding: 11px 2px; cursor: pointer;
  font-size: 14px; font-weight: 600; min-height: 44px;
}
.rab-group > summary::-webkit-details-marker { display: none; }
.rab-group > summary i { width: 10px; height: 10px; border-radius: 2px; }
.rab-group > summary .amt { font-weight: 600; }
.rab-group[open] > summary { color: var(--teal); }
.rab-line { padding: 8px 2px 8px 18px; border-top: 1px dotted var(--rule); font-size: 13px; }
.rab-line .top { display: flex; justify-content: space-between; gap: 10px; }
.rab-line .meta { color: var(--graphite); font-size: 12px; margin-top: 2px; }
.rab-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.note { font-size: 12px; color: var(--graphite); margin-top: 12px; }

/* ------------------------------------------------------------------ dialog, toast, nav */
dialog {
  border: 1px solid var(--rule); border-radius: 14px; padding: 22px; width: min(460px, calc(100vw - 32px));
  background: var(--raised); color: var(--ink); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(16, 24, 22, .4); }
dialog h2 { margin: 0 0 16px; font-stretch: 112%; font-size: 20px; }
dialog .field { margin-bottom: 14px; font-size: 14px; color: var(--ink); }
dialog fieldset { border: 1px solid var(--rule); border-radius: var(--r-sm); padding: 6px 12px 8px; margin: 0; }
dialog legend { font-size: 13px; color: var(--graphite); padding: 0 4px; }
.radio { display: flex; align-items: center; gap: 9px; padding: 7px 0; cursor: pointer; }
.radio input { accent-color: var(--teal); width: 16px; height: 16px; margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--r-sm); font-size: 14px;
  max-width: calc(100vw - 32px); box-shadow: var(--shadow-lg);
}
.toast.error { background: var(--red); color: #fff; }

.bottom-nav { display: none; }

/* ------------------------------------------------------------------ tablet: detail slides over */
@media (max-width: 1279.98px) {
  .workspace { grid-template-columns: 320px minmax(0, 1fr); }
  .inspector {
    position: absolute; top: 0; right: 0; bottom: 0; z-index: 20; width: min(420px, 92vw);
    box-shadow: var(--shadow-lg); transform: translateX(105%); visibility: hidden;
    transition: transform .22s ease, visibility 0s linear .22s;
  }
  .workspace[data-detail="open"] .inspector { transform: none; visibility: visible; transition: transform .22s ease; }
  .close-drawer { display: inline-flex; }
}
@media not (max-width: 1279.98px) { #detailBtn { display: none; } }

/* ------------------------------------------------------------------ phone: one pane + bottom nav */
@media (max-width: 759.98px) {
  :root { --tap: 44px; }
  .topbar { padding: 6px 10px; gap: 6px; min-height: 52px; }
  .brand span, .version > span, #undoBtn span { display: none; }
  .brand b { font-size: 0; } /* keep the mark only */
  .brand b::before { margin: 0; width: 14px; height: 14px; }
  #projectBtn { max-width: none; padding: 0 6px; font-size: 14px; }
  .project-switch { flex: 1; }
  .downloads { gap: 4px; }
  .downloads .btn { padding: 0 9px; min-height: 36px; font-size: 13px; }
  .downloads .long { display: none; }
  .downloads .short { display: inline; }

  .workspace { display: block; }
  .workspace > .pane { position: absolute; inset: 0; border: 0; }
  .workspace[data-view="chat"] > .pane:not(.chat),
  .workspace[data-view="sheet"] > .pane:not(.sheet),
  .workspace[data-view="detail"] > .pane:not(.inspector) { display: none; }
  .inspector { transform: none; visibility: visible; width: auto; box-shadow: none; transition: none; }
  .close-drawer, #detailBtn { display: none !important; }
  .titleblock .tb-text span { display: none; }
  .statusbar { display: none; }
  .fields { gap: 10px; }

  .bottom-nav {
    flex: none; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--sheet); border-top: 1px solid var(--rule);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav button {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px 9px; border: 0; background: none;
    color: var(--graphite); font-size: 12px; font-weight: 550; min-height: 54px;
  }
  .bottom-nav .ic { width: 20px; height: 20px; }
  .bottom-nav button[aria-current="page"] { color: var(--teal); }
  .bottom-nav button[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; background: var(--teal); border-radius: 0 0 2px 2px; }
  .bottom-nav .badge { top: 4px; right: calc(50% - 22px); }
}
@media (max-width: 380.98px) {
  .downloads #dlDwg { display: none; } /* DXF is what AutoCAD opens; DWG stays in the RAB/Proyek tab */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
