:root {
  color-scheme: light;
  --bg: #f3f3f0;
  --panel: #fbfbf9;
  --paper: #fff;
  --ink: #242521;
  --muted: #74756e;
  --faint: #9d9e97;
  --line: #deded8;
  --line-strong: #cbcbc4;
  --soft: #efefeb;
  --accent: #c85d34;
  --accent-dark: #a84625;
  --accent-soft: #f8e8e1;
  --blue: #3379d0;
  --blue-soft: #e8f1fc;
  --shadow: 0 1px 2px rgba(30, 31, 27, .05), 0 14px 38px rgba(30, 31, 27, .07);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
.field input:focus-visible, .field textarea:focus-visible, .field select:focus-visible, .search-field input:focus-visible { outline: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
.app-shell { height: 100%; display: grid; grid-template-rows: 64px 35px 1fr; }

.topbar {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto minmax(410px, 1fr);
  align-items: center;
  gap: 20px;
  padding: 0 16px;
  background: rgba(251, 251, 249, .97);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark { width: 34px; height: 34px; flex: 0 0 auto; position: relative; border: 1px solid #d4d4cd; border-radius: 10px; background: white; box-shadow: 0 2px 6px rgba(40, 40, 30, .06); }
.brand-mark span { position: absolute; background: var(--ink); border-radius: 2px; }
.brand-mark span:nth-child(1) { width: 18px; height: 3px; left: 7px; top: 8px; }
.brand-mark span:nth-child(2) { width: 3px; height: 17px; left: 7px; top: 8px; }
.brand-mark span:nth-child(3) { width: 13px; height: 3px; left: 7px; top: 22px; background: var(--accent); }
.document-name-wrap { min-width: 0; }
.document-name { display: block; width: min(280px, 100%); height: 23px; padding: 1px 4px; margin-left: -4px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--ink); font-size: 13px; font-weight: 700; outline: none; }
.document-name:hover { border-color: var(--line); background: white; }
.document-name:focus { border-color: var(--blue); background: white; box-shadow: 0 0 0 2px rgba(51, 121, 208, .12); }
#save-status { display: flex; align-items: center; gap: 5px; margin: 1px 0 0; color: var(--muted); font-size: 10px; }
#save-status span { width: 6px; height: 6px; border-radius: 50%; background: #68a56a; }
.topbar-center { display: flex; align-items: center; gap: 10px; }
.history-actions { display: flex; gap: 2px; padding: 3px; background: var(--soft); border-radius: 9px; }
.selection-status { color: var(--muted); font-size: 10px; min-width: 68px; }
.document-actions { justify-self: end; display: flex; align-items: center; gap: 7px; position: relative; }

.button, .icon-button {
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .14s, color .14s, border-color .14s, transform .1s, box-shadow .14s;
}
.button:active, .icon-button:active { transform: translateY(1px); }
.button { height: 35px; border-radius: 8px; padding: 0 12px; gap: 7px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.button.primary { background: var(--ink); color: white; box-shadow: 0 2px 5px rgba(0, 0, 0, .13); }
.button.primary:hover { background: #11120f; }
.button.secondary { background: white; border: 1px solid var(--line-strong); }
.button.secondary:hover { border-color: #aaa9a1; }
.button.tertiary { background: transparent; border: 1px solid transparent; }
.button.tertiary:hover { background: var(--soft); }
#project-menu-button, #shortcuts-button { width: 34px; padding: 0; }
#project-menu-button svg { width: 18px; }
#shortcuts-button svg { width: 17px; }
.icon-button { width: 30px; height: 30px; flex: 0 0 auto; border-radius: 7px; background: transparent; }
.icon-button:hover { background: var(--soft); }
.icon-button:disabled { opacity: .3; cursor: default; transform: none; }
.icon-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button.danger:hover { background: #fae8e4; color: #b33a28; }
.menu-anchor { position: relative; display: flex; }
.menu-anchor .menu { top: calc(100% + 8px); right: 0; }
.button.tertiary[aria-expanded="true"] { background: var(--soft); }
.menu { position: absolute; top: 43px; right: 0; width: 190px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: white; box-shadow: 0 14px 40px rgba(30, 30, 25, .16); }
.menu button { width: 100%; height: 33px; display: flex; align-items: center; justify-content: flex-start; gap: 9px; padding: 0 9px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; text-align: left; font-size: 11px; }
.menu button:hover { background: var(--soft); }
.menu button > svg { width: 15px; height: 15px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .75; }
.menu kbd { margin-left: auto; }
.menu-separator { height: 1px; margin: 5px 2px; background: var(--line); }
.danger-text { color: #b13d2d; }
.export-menu { right: 0; width: 220px; }
.export-menu button { height: auto; min-height: 48px; }
.export-menu button > svg { width: 16px; height: 16px; }
.export-menu button > span { display: grid; gap: 2px; text-align: left; }
.export-menu strong { font-size: 10px; }
.export-menu small { color: var(--muted); font-size: 8px; font-weight: 500; }

.project-bar {
  display: flex;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
  padding: 0 12px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 15;
}
.project-tabs { display: flex; align-items: stretch; gap: 3px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.project-tabs::-webkit-scrollbar { display: none; }
.project-tab {
  display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto;
  max-width: 190px; height: 100%; padding: 0 6px 0 11px;
  border: 1px solid transparent; border-bottom: 0; border-radius: 9px 9px 0 0;
  background: transparent; color: var(--muted);
  font-size: 11px; font-weight: 700; white-space: nowrap; cursor: pointer;
  transition: background .14s, color .14s;
}
.project-tab:hover { background: rgba(255, 255, 255, .6); color: var(--ink); }
.project-tab.active { background: var(--paper); border-color: var(--line); color: var(--ink); }
.project-tab-name { overflow: hidden; text-overflow: ellipsis; }
.project-tab-close { display: grid; place-items: center; width: 17px; height: 17px; flex: 0 0 auto; border-radius: 5px; opacity: 0; }
.project-tab:hover .project-tab-close, .project-tab.active .project-tab-close { opacity: .45; }
.project-tab-close:hover { background: var(--line); opacity: 1; }
.project-tab-close svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.project-add {
  align-self: center; flex: 0 0 auto; display: grid; place-items: center;
  width: 24px; height: 24px; border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); cursor: pointer; transition: background .14s, color .14s;
}
.project-add:hover { background: white; color: var(--ink); }
.project-add svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.workspace { min-height: 0; display: grid; grid-template-columns: 78px auto minmax(0, 1fr) 286px; }
.tool-rail, .library-panel, .inspector { background: var(--panel); position: relative; z-index: 8; }
.tool-rail { border-right: 1px solid var(--line); padding: 10px 8px; display: flex; flex-direction: column; justify-content: space-between; gap: 12px; overflow-y: auto; scrollbar-width: none; }
.tool-rail::-webkit-scrollbar { display: none; }
.tool-group { display: grid; gap: 3px; }
.bottom-tools { flex: 0 0 auto; border-top: 1px solid var(--line); padding-top: 9px; gap: 6px; }
.rail-caption { margin: 0 0 1px; color: #a2a29b; text-transform: uppercase; letter-spacing: .1em; font-size: 8px; font-weight: 800; text-align: center; }
.zoom-row { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.rail-button { height: 29px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; border: 1px solid var(--line); border-radius: 7px; background: white; color: #6f7069; cursor: pointer; font-size: 9px; font-weight: 700; transition: border-color .14s, background .14s, color .14s; }
.rail-button:hover { border-color: #b9bab2; color: var(--ink); }
.rail-button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rail-button.wide { grid-column: 1 / -1; }
.tool {
  width: 100%; min-height: 51px; padding: 6px 2px 4px; border: 1px solid transparent; background: transparent; border-radius: 9px; cursor: pointer;
  display: grid; grid-template-columns: auto auto; grid-template-rows: 23px 16px; justify-content: center; column-gap: 4px; align-items: center; color: #6f7069; position: relative;
}
.tool:hover { background: var(--soft); color: var(--ink); }
.tool.active { background: white; border-color: #d5d5ce; color: var(--ink); box-shadow: 0 2px 6px rgba(30, 30, 25, .06); }
.tool.active::before { content: ""; position: absolute; left: -5px; top: 50%; transform: translateY(-50%); width: 3px; height: 22px; background: var(--accent); border-radius: 2px; }
.tool svg { width: 20px; height: 20px; grid-column: 1 / -1; justify-self: center; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tool > span { font-size: 9px; font-weight: 700; white-space: nowrap; }
.tool kbd { border: 0; padding: 0; background: transparent; color: #a2a29b; font-size: 8px; font-family: inherit; }

.library-panel { width: 238px; border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; transition: width .18s, opacity .18s; }
.library-panel.closed { width: 0; opacity: 0; border: 0; pointer-events: none; }
.panel-header { min-height: 64px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 16px 15px 13px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 4px; color: #999a92; text-transform: uppercase; letter-spacing: .11em; font-size: 8px; font-weight: 800; }
.panel-header h2 { margin: 0; font-size: 14px; letter-spacing: -.015em; }
.search-field { height: 34px; margin: 11px 12px 8px; display: flex; align-items: center; gap: 7px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.search-field:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(51, 121, 208, .1); }
.search-field svg { width: 15px; flex: 0 0 auto; fill: none; stroke: #999a92; stroke-width: 1.8; stroke-linecap: round; }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 11px; }
.library-content { padding: 4px 11px 20px; overflow: auto; }
.workflow-tabs { margin: 10px 12px 0; padding: 3px; display: grid; grid-template-columns: 1fr 1fr; border-radius: 8px; background: var(--soft); }
.workflow-tabs button { height: 28px; padding: 0 5px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: 8px; font-weight: 750; }
.workflow-tabs button.active { background: white; color: var(--ink); box-shadow: 0 1px 4px rgba(30, 30, 25, .09); }
.library-group { margin-top: 12px; }
.library-group h3 { margin: 0 2px 7px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 8px; }
.library-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.library-item { min-height: 76px; padding: 8px 4px 7px; display: grid; place-items: center; align-content: center; gap: 5px; border: 1px solid var(--line); border-radius: 9px; background: white; cursor: pointer; color: #50514c; }
.library-item:hover { border-color: #bbbcb4; background: #fdfdfb; box-shadow: 0 3px 9px rgba(30, 30, 25, .06); transform: translateY(-1px); }
.library-item svg { width: 42px; height: 34px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.library-item span { max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; font-weight: 700; }
.library-empty { padding: 32px 15px; text-align: center; color: var(--muted); font-size: 11px; line-height: 1.5; }

.canvas-wrap { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #eeeeea; }
#drawing { display: block; width: 100%; height: 100%; background: white; touch-action: none; cursor: default; }
#drawing[data-tool="wall"], #drawing[data-tool="room"], #drawing[data-tool="door"], #drawing[data-tool="window"], #drawing[data-tool="measure"], #drawing[data-tool="poly"] { cursor: crosshair; }
#drawing[data-tool="text"] { cursor: text; }
#drawing.pan-ready { cursor: grab; }
#drawing.panning { cursor: grabbing; }
.grid-background { pointer-events: all; }
.canvas-meta { position: absolute; z-index: 4; pointer-events: none; top: 11px; left: 13px; right: 13px; display: flex; justify-content: space-between; color: #85867f; font-size: 9px; }
.canvas-meta span { padding: 6px 8px; border: 1px solid rgba(218, 218, 212, .9); border-radius: 7px; background: rgba(255, 255, 255, .88); backdrop-filter: blur(5px); }
.canvas-footer { position: absolute; z-index: 4; pointer-events: none; bottom: 10px; left: 12px; right: 12px; display: flex; align-items: center; gap: 8px; }
.canvas-footer > span { padding: 5px 8px; border: 1px solid rgba(218, 218, 212, .9); border-radius: 6px; background: rgba(255, 255, 255, .88); color: #85867f; font-size: 8px; white-space: nowrap; backdrop-filter: blur(5px); }
.canvas-footer b { color: #555650; }
.canvas-footer .footer-help { margin-left: auto; }
.canvas-unit { pointer-events: auto; flex: 0 0 auto; min-height: 25px; display: flex; align-items: center; gap: 5px; padding: 3px 5px 3px 8px; border: 1px solid rgba(218, 218, 212, .9); border-radius: 6px; background: rgba(255, 255, 255, .9); color: #85867f; font-size: 8px; white-space: nowrap; backdrop-filter: blur(5px); }
.canvas-unit select { max-width: 92px; border: 0; outline: 0; background: transparent; color: #5f605a; font-size: 8px; cursor: pointer; }
.canvas-toggle { pointer-events: auto; flex: 0 0 auto; min-height: 25px; display: inline-flex; white-space: nowrap; align-items: center; gap: 5px; padding: 0 8px; border: 1px solid rgba(218, 218, 212, .9); border-radius: 6px; background: rgba(255, 255, 255, .9); color: #9a9b94; cursor: pointer; font-size: 8px; font-weight: 700; backdrop-filter: blur(5px); transition: color .14s, border-color .14s, background .14s; }
.canvas-toggle svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.canvas-toggle:hover { color: #5f605a; }
.canvas-toggle.active { border-color: #9abbe2; background: rgba(232, 241, 252, .95); color: #245f9f; }
#area-total { font-variant-numeric: tabular-nums; }
.empty-state { position: absolute; z-index: 3; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 330px; text-align: center; }
.empty-icon { width: 58px; height: 58px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 17px; background: var(--accent-soft); color: var(--accent); }
.empty-icon svg { width: 31px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.empty-state h2 { margin: 0 0 6px; font-size: 18px; letter-spacing: -.025em; }
.empty-state p { margin: 0 auto 17px; max-width: 285px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.empty-actions { display: flex; justify-content: center; gap: 7px; }
kbd { padding: 1px 4px; border: 1px solid #d5d5ce; border-bottom-width: 2px; border-radius: 4px; background: #fafaf8; font-size: .9em; }
.text-composer { position: absolute; z-index: 12; width: 260px; padding: 7px; border: 1px solid #b7cbe5; border-radius: 10px; background: white; box-shadow: 0 10px 30px rgba(30, 50, 80, .18); }
.text-composer textarea { width: 100%; min-height: 54px; padding: 8px; resize: vertical; border: 0; border-radius: 6px; outline: 0; background: #f7f9fc; color: var(--ink); font-size: 13px; line-height: 1.4; }
.text-composer > div { margin-top: 6px; display: flex; align-items: center; gap: 5px; }
.text-composer > div > span { margin-right: auto; color: var(--muted); font-size: 8px; }
.text-composer button { height: 27px; padding: 0 8px; border: 0; border-radius: 6px; background: var(--soft); cursor: pointer; font-size: 8px; font-weight: 750; }
.text-composer #commit-text { background: var(--ink); color: white; }

.inspector { border-left: 1px solid var(--line); display: flex; flex-direction: column; overflow: auto; }
.inspector-heading { flex: 0 0 auto; }
.inspector-empty { margin: 54px auto 0; width: 205px; text-align: center; color: #969790; }
.inspector-empty > svg { width: 30px; fill: none; stroke: #b8b9b2; stroke-width: 1.4; stroke-linejoin: round; }
.inspector-empty h3 { margin: 12px 0 5px; color: #666760; font-size: 12px; }
.inspector-empty p { margin: 0; font-size: 10px; line-height: 1.5; }
.shortcut-grid { margin-top: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; }
.shortcut-grid span { color: #888981; font-size: 8px; white-space: nowrap; }
.shortcut-grid kbd { margin-right: 3px; }
#properties { display: block; }
.inspector-section { padding: 14px 15px; display: grid; gap: 11px; border-bottom: 1px solid var(--line); }
.section-title { display: flex; align-items: center; justify-content: space-between; }
.section-title > span { color: #565752; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.section-title button { padding: 0; border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: 9px; }
.section-title small { color: var(--faint); font-size: 8px; font-weight: 500; }
.section-help { margin: -3px 0 0; color: var(--muted); font-size: 8px; line-height: 1.45; }
.field { display: grid; gap: 5px; min-width: 0; }
.field > span { color: #777871; font-size: 9px; font-weight: 700; }
.field input:not([type="color"]), .field textarea, .field select { width: 100%; min-width: 0; height: 33px; padding: 0 8px; border: 1px solid #d6d6cf; border-radius: 7px; outline: 0; background: white; color: var(--ink); font-size: 11px; }
.field textarea { height: auto; padding: 8px; resize: vertical; line-height: 1.4; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(51, 121, 208, .1); }
.field input:disabled, .field textarea:disabled, .field select:disabled, .segmented button:disabled, .check-field:has(input:disabled) { opacity: .52; cursor: not-allowed; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 25px !important; }
.input-suffix em { position: absolute; right: 8px; top: 9px; color: #8d8e87; font-size: 9px; font-style: normal; pointer-events: none; }
.color-field > div { height: 33px; display: flex; align-items: center; gap: 6px; padding: 0 7px; border: 1px solid #d6d6cf; border-radius: 7px; background: white; }
.color-field input { width: 19px; height: 19px; padding: 0; border: 0; border-radius: 5px; background: transparent; overflow: hidden; cursor: pointer; }
.color-field output { color: #777871; font-size: 9px; font-family: ui-monospace, monospace; text-transform: uppercase; }
.check-field { display: flex; align-items: flex-start; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: white; cursor: pointer; }
.check-field input { margin: 1px 0 0; accent-color: var(--accent); }
.check-field span { display: grid; gap: 3px; }
.check-field strong { font-size: 9px; }
.check-field small { color: #888981; font-size: 8px; line-height: 1.35; }
.segmented { height: 32px; display: grid; grid-template-columns: repeat(4, 1fr); padding: 2px; border-radius: 7px; background: var(--soft); }
.segmented button { display: grid; place-items: center; border: 0; border-radius: 5px; background: transparent; cursor: pointer; }
.segmented button:hover, .segmented button.active { background: white; box-shadow: 0 1px 3px rgba(30, 30, 25, .1); }
.segmented svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.action-grid button { height: 32px; padding: 0 7px; border: 1px solid var(--line); border-radius: 7px; background: white; cursor: pointer; color: #555650; font-size: 9px; }
.action-grid button:hover:not(:disabled) { border-color: #b9bab2; background: #fdfdfb; }
.action-grid button:disabled { opacity: .45; cursor: not-allowed; }
.action-grid .span-2 { grid-column: 1 / -1; }
.action-grid .danger-action { color: #b13d2d; }
.action-grid .danger-action:hover:not(:disabled) { border-color: #e6c0b4; background: #fdf3f0; }
.align-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.align-grid button { height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 7px; background: white; cursor: pointer; color: #6b6c66; }
.align-grid button:hover:not(:disabled) { border-color: #9abbe2; background: var(--blue-soft); color: #245f9f; }
.align-grid button:disabled { opacity: .4; cursor: not-allowed; }
.align-grid svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.readout { margin: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 7px; background: var(--soft); }
.readout span { color: #777871; font-size: 9px; font-weight: 700; }
.readout b { color: var(--ink); font-size: 11px; font-variant-numeric: tabular-nums; }
.text-link { margin-top: 16px; padding: 0; border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: 9px; font-weight: 700; }
.text-link kbd { margin-left: 3px; }
.dimension-options { display: flex; flex-wrap: wrap; gap: 6px; }
.dimension-option { position: relative; cursor: pointer; }
.dimension-option input { position: absolute; opacity: 0; pointer-events: none; }
.dimension-option span { min-height: 28px; display: flex; align-items: center; gap: 5px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--muted); font-size: 8px; font-weight: 700; }
.dimension-option input:checked + span { border-color: #9abbe2; background: var(--blue-soft); color: #245f9f; }
.dimension-option input:checked + span::before { content: "✓"; }
.range-field { display: flex; align-items: center; gap: 8px; }
.range-field input { flex: 1; padding: 0 !important; border: 0 !important; box-shadow: none !important; accent-color: var(--accent); }
.range-field output { min-width: 34px; color: var(--muted); font-size: 9px; font-variant-numeric: tabular-nums; text-align: right; }
.inspector-button { height: 32px; border: 1px solid var(--line); border-radius: 7px; background: white; cursor: pointer; font-size: 9px; font-weight: 700; }
.inspector-button:hover { border-color: var(--line-strong); }
.multi-inspector { padding: 16px 15px 20px; display: grid; align-content: start; gap: 16px; }
.selection-summary { padding: 17px; border-radius: 10px; background: var(--soft); text-align: center; }
.selection-summary span { display: block; font-size: 27px; font-weight: 750; line-height: 1.1; }
.selection-summary p { margin: 3px 0 0; color: var(--muted); font-size: 9px; }
.selection-summary small { display: block; margin-top: 7px; color: #8a8b84; font-size: 9px; font-variant-numeric: tabular-nums; }
.inspector-block { display: grid; gap: 9px; }
.defaults-card { margin-top: auto; padding: 14px 15px; display: grid; gap: 10px; border-top: 1px solid var(--line); }
.compact-check { padding: 8px 9px; }

#drawing[data-tool="select"] .entity:not(.locked) { cursor: grab; }
#drawing[data-tool="select"] .entity:not(.locked):active { cursor: grabbing; }
.entity.locked { cursor: not-allowed; }
.entity.locked { opacity: .86; }
.wall-line { stroke-linecap: square; }
.wall-hit, .measure-hit, .symbol-hit { stroke: transparent; stroke-width: 22; fill: none; }
.wall-label, .object-label { font-size: 10px; fill: #5e5f59; paint-order: stroke; stroke: white; stroke-width: 5px; stroke-linejoin: round; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.measure-line { stroke: var(--accent); stroke-width: 1.4; fill: none; marker-start: url(#arrow-start); marker-end: url(#arrow-end); }
.measure-label { font-size: 10px; font-weight: 750; fill: var(--accent); text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: white; stroke-width: 6px; stroke-linejoin: round; pointer-events: none; }
.text-label { dominant-baseline: hanging; user-select: none; white-space: pre; }
.selected-outline { fill: none; stroke: var(--blue); stroke-width: 1.4; stroke-dasharray: 4 3; pointer-events: none; vector-effect: non-scaling-stroke; }
.marquee { fill: rgba(51, 121, 208, .08); stroke: var(--blue); stroke-width: 1.2; stroke-dasharray: 5 4; pointer-events: none; vector-effect: non-scaling-stroke; }
.selection-handle { fill: white; stroke: var(--blue); stroke-width: 1.8; cursor: nwse-resize; vector-effect: non-scaling-stroke; }
.selection-handle[data-handle="ne"], .selection-handle[data-handle="sw"] { cursor: nesw-resize; }
.selection-handle.endpoint { cursor: move; }
.rotation-stem { stroke: var(--blue); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.rotation-handle { fill: white; stroke: var(--blue); stroke-width: 1.8; cursor: grab; vector-effect: non-scaling-stroke; }
.selection-lock { fill: var(--blue); font-size: 14px; text-anchor: middle; }
.radius-handle { fill: white; stroke: var(--accent); stroke-width: 1.6; cursor: pointer; vector-effect: non-scaling-stroke; }
.radius-handle:hover { fill: var(--accent-soft); }
.radius-handle.active { fill: var(--accent); }
.vertex-handle { fill: white; stroke: var(--blue); stroke-width: 1.8; cursor: move; vector-effect: non-scaling-stroke; }
.vertex-handle:hover { fill: var(--blue-soft); }
.vertex-handle.active { fill: var(--blue); }
.preview-poly { fill: rgba(51, 121, 208, .07); stroke: var(--blue); stroke-width: 1.4; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; pointer-events: none; }
.poly-node { fill: white; stroke: var(--blue); stroke-width: 1.6; vector-effect: non-scaling-stroke; pointer-events: none; }
.poly-node.closing { fill: var(--blue); }
.preview-wall, .preview-symbol { stroke: var(--blue); opacity: .7; }
.preview-room { stroke: var(--blue); fill: rgba(51, 121, 208, .07); opacity: .75; }
.preview-measure { stroke: var(--accent); stroke-width: 1.4; stroke-dasharray: 5 4; }
.preview-label { font-size: 10px; font-weight: 750; fill: var(--blue); text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: white; stroke-width: 6px; stroke-linejoin: round; pointer-events: none; }
.measure-preview-label { fill: var(--accent); }
.dimension-guide { fill: none; stroke: #b6512c; stroke-width: 1; vector-effect: non-scaling-stroke; marker-start: url(#arrow-start); marker-end: url(#arrow-end); pointer-events: none; }
.dimension-extension { stroke: #b6512c; stroke-width: .75; stroke-dasharray: 2 2; opacity: .7; vector-effect: non-scaling-stroke; pointer-events: none; }
.dimension-text { fill: #a34828; font-size: 9px; font-weight: 750; text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: white; stroke-width: 5px; stroke-linejoin: round; pointer-events: none; }
.image-outline { fill: none; stroke: #aaa; stroke-width: 1; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.area-text { font-size: 10px; }
.snap-marker { fill: none; stroke: #2f9e6f; stroke-width: 2; vector-effect: non-scaling-stroke; pointer-events: none; }

.modal { width: min(760px, calc(100vw - 40px)); max-height: min(690px, calc(100vh - 40px)); padding: 0; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); box-shadow: 0 28px 90px rgba(20, 20, 17, .24); }
.modal::backdrop { background: rgba(33, 34, 30, .35); backdrop-filter: blur(3px); }
.modal-header { padding: 21px 22px 17px; display: flex; align-items: flex-start; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0 0 5px; font-size: 18px; }
.modal-header p:last-child { margin: 0; color: var(--muted); font-size: 10px; }
.template-grid { padding: 18px 22px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; overflow: auto; }
.template-card { position: relative; min-height: 162px; padding: 11px; display: grid; grid-template-rows: 105px auto; gap: 9px; border: 1px solid var(--line); border-radius: 11px; background: white; cursor: pointer; text-align: left; }
.template-card:hover { border-color: #aaa9a1; box-shadow: 0 6px 18px rgba(30, 30, 25, .08); transform: translateY(-1px); }
.template-preview { display: grid; place-items: center; border-radius: 7px; background: #f4f4f1; overflow: hidden; }
.template-preview svg { width: 90%; height: 90%; }
.template-card strong { display: block; font-size: 11px; }
.template-card small { color: var(--muted); font-size: 8px; }
.delete-template { position: absolute; top: 16px; right: 16px; width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: rgba(255, 255, 255, .94); color: #74756e; opacity: 0; transition: opacity .12s, background .12s, color .12s; }
.template-card:hover .delete-template, .delete-template:focus-visible { opacity: 1; }
.delete-template:hover { background: #fae8e4; border-color: #e6c0b4; color: #b33a28; }
.delete-template svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.modal-footer { padding: 13px 22px; display: flex; justify-content: flex-end; gap: 7px; border-top: 1px solid var(--line); }
.shortcuts-modal { width: min(820px, calc(100vw - 40px)); }
.shortcuts-modal .modal-header p:last-child kbd { font-size: 9px; }
.shortcut-columns { padding: 20px 22px; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 22px 26px; overflow: auto; }
.shortcut-columns h3 { margin: 0 0 9px; padding-bottom: 7px; border-bottom: 1px solid var(--line); color: #565752; text-transform: uppercase; letter-spacing: .08em; font-size: 9px; font-weight: 800; }
.shortcut-columns dl { margin: 0; display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 7px 10px; }
.shortcut-columns dt { display: flex; align-items: center; gap: 2px; color: var(--faint); font-size: 9px; white-space: nowrap; }
.shortcut-columns dd { margin: 0; color: #56574f; font-size: 10px; }
.shortcut-columns kbd { font-size: 9px; font-family: inherit; }

#toast { position: fixed; z-index: 50; bottom: 48px; left: 50%; transform: translate(-50%, 14px); padding: 9px 13px; border-radius: 8px; background: var(--ink); color: white; font-size: 10px; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; box-shadow: 0 7px 22px rgba(0, 0, 0, .2); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-height: 780px) {
  .tool { min-height: 45px; padding-top: 4px; }
  .tool-rail { gap: 8px; }
}
@media (max-width: 1320px) {
  .footer-help { display: none; }
}
@media (max-width: 1120px) {
  .workspace { grid-template-columns: 72px auto minmax(0, 1fr) 260px; }
  .library-panel { width: 220px; }
  .selection-status { display: none; }
  #area-total { display: none !important; }
  #open-project-button, #save-project-button { width: 34px; padding: 0; font-size: 0; }
}
@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr auto; }
  .topbar-center { display: none; }
  .workspace { grid-template-columns: 68px minmax(0, 1fr); }
  .library-panel { position: absolute; top: 99px; bottom: 0; left: 68px; width: 238px; box-shadow: 10px 0 30px rgba(30, 30, 25, .1); }
  .inspector { display: none; }
  .document-actions > #open-project-button { display: none; }
  .footer-help { display: none; }
}

.project-panel-toggle { margin-left: auto; flex-shrink: 0; border: 1px solid var(--line); border-radius: 6px; background: white; padding: 5px 10px; cursor: pointer; font-size: 11px; }
.inspector-close { display: none; }
.save-warning { margin: 10px; padding: 12px; color: #793b17; background: #fff1dc; border: 1px solid #efc68d; border-radius: 8px; font-size: 12px; line-height: 1.5; }
.save-warning button { display: block; margin-top: 8px; background: white; border: 1px solid #dcbb8e; border-radius: 5px; padding: 6px 8px; cursor: pointer; }
.object-panel { flex: 0 0 auto; border-bottom: 1px solid var(--line); }
.object-panel > summary { cursor: pointer; padding: 14px 15px; font-size: 12px; font-weight: 600; }
#list-count { float: right; color: var(--muted); }
#object-list { max-height: 280px; overflow: auto; padding: 0 8px 10px; }
.object-row { display: flex; gap: 4px; align-items: center; padding: 4px; border-radius: 6px; }
.object-row.selected { background: var(--blue-soft); }
.object-row button { border: 0; background: transparent; cursor: pointer; padding: 6px; min-height: 30px; font-size: 11px; }
.object-row .object-select { flex: 1; text-align: left; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.object-row.is-hidden .object-select { color: #91918a; text-decoration: line-through; }
.object-group { margin: 7px 2px 2px; padding: 4px 6px; border-left: 2px solid #87a6ce; }
.object-group input { width: 100%; padding: 5px; border: 0; background: transparent; font-size: 11px; font-weight: 600; }
.object-group .object-row { padding-left: 7px; }
.compact-modal { width: min(480px, calc(100vw - 24px)); }
.modal-body { padding: 20px 22px; overflow: auto; }
.recent-project { display: flex; flex-direction: column; gap: 5px; width: 100%; text-align: left; padding: 14px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: white; cursor: pointer; }
.recent-project span { color: var(--muted); font-size: 12px; }
.form-error { color: #ad3623; font-size: 12px; }
.print-modal { width: min(900px, calc(100vw - 24px)); }
.print-body { display: grid; grid-template-columns: 230px 1fr; gap: 24px; padding: 22px; overflow: auto; }
.print-settings { display: grid; align-content: start; gap: 16px; }
#print-preview { min-height: 280px; display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; align-content: start; padding: 16px; background: #eeeee9; border-radius: 9px; }
.print-page-preview { background: white; box-shadow: 0 2px 5px #0001; padding: 6px; }
.print-page-preview svg { width: 100%; height: auto; display: block; }
.print-page-preview small { display: block; text-align: center; padding-top: 5px; color: #777; font-size: 9px; }
.calibration-dot { fill: #fff; stroke: #276cba; stroke-width: 2px; vector-effect: non-scaling-stroke; }
@media (min-width: 901px) {
  .project-panel-toggle { display: none; }
}
@media (max-width: 900px) {
  .inspector.open { display: flex; position: absolute; z-index: 25; top: 99px; right: 0; bottom: 0; width: min(340px, calc(100vw - 68px)); background: white; box-shadow: -8px 0 25px #0002; }
  .inspector-close { display: block; flex: 0 0 auto; margin: 10px; padding: 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--soft); cursor: pointer; }
  .inspector .field input, .inspector .field select { min-height: 36px; font-size: 14px; }
  .inspector .section-help { font-size: 11px; }
  .project-tab-close { opacity: 1; }
}
@media (max-width: 600px) {
  .topbar { padding: 8px; gap: 4px; grid-template-columns: minmax(90px, 1fr) auto; }
  .document-name { max-width: 130px; width: 100%; }
  .brand { min-width: 0; gap: 6px; }
  #templates-button, #shortcuts-button { display: none; }
  .document-actions { gap: 2px; }
  .button { padding: 7px 9px; }
  .canvas-footer { gap: 5px; padding: 6px; flex-wrap: wrap; }
  #object-count-label { display: none; }
  .print-body { grid-template-columns: 1fr; padding: 16px; }
  #print-preview { min-height: 180px; }
  .modal-header, .modal-footer { padding: 16px; }
  .modal-header h2 { font-size: 18px; }
  .template-grid { grid-template-columns: 1fr 1fr; }
  .tool-rail { overflow-y: auto; }
}

.preview-label { font-size: calc(10px * var(--canvas-unit, 1)); stroke-width: calc(6px * var(--canvas-unit, 1)); }
.preview-measure { vector-effect: non-scaling-stroke; }
.print-modal[open] { display: flex; flex-direction: column; }
.print-modal > .modal-header, .print-modal > .modal-footer { flex: 0 0 auto; }
.print-body { min-height: 0; flex: 1 1 auto; }
.print-page-preview { width: 100%; max-width: 260px; justify-self: center; }
