
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --surface-3: #e8e8ed;
  --surface-elevated: rgba(255,255,255,.92);
  --text: #1d1d1f;
  --text-2: #424245;
  --text-3: #86868b;
  --border: #d2d2d7;
  --border-strong: #b8b8bd;
  --primary: #0071e3;
  --primary-2: #0077ed;
  --primary-soft: #eaf3ff;
  --green: #248a3d;
  --green-soft: #eaf7ed;
  --amber: #b25000;
  --amber-soft: #fff4e5;
  --danger: #d70015;
  --danger-soft: #fff0f1;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 8px 24px rgba(0,0,0,.10);
  --shadow-lg: 0 24px 64px rgba(0,0,0,.16);
  --topbar-h: 66px;
  --left-w: 282px;
  --right-w: 332px;
  --radius-sm: 8px;
  --radius-md: 13px;
  --radius-lg: 18px;
  --ease: 180ms cubic-bezier(.2,.8,.2,1);
  color-scheme: light;
}


:root[data-theme="dark"] {
  --bg: #0f0f10;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --surface-3: #3a3a3c;
  --surface-elevated: rgba(28,28,30,.93);
  --text: #f5f5f7;
  --text-2: #d1d1d6;
  --text-3: #8e8e93;
  --border: #3a3a3c;
  --border-strong: #545458;
  --primary: #0a84ff;
  --primary-2: #409cff;
  --primary-soft: #153a5d;
  --green: #30d158;
  --green-soft: #173c22;
  --amber: #ff9f0a;
  --amber-soft: #4a3210;
  --danger: #ff453a;
  --danger-soft: #4a1d1b;
  --shadow-sm: 0 2px 8px rgba(0,0,0,.28);
  --shadow-md: 0 12px 32px rgba(0,0,0,.36);
  --shadow-lg: 0 28px 80px rgba(0,0,0,.46);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary) 76%, white);
  outline-offset: 2px;
}
.hidden { display: none !important; }

.app-shell { width: 100%; height: 100%; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h);
  flex: 0 0 var(--topbar-h);
  display: grid;
  grid-template-columns: minmax(590px, 1.45fr) minmax(260px, 480px) minmax(120px, .55fr);
  align-items: center;
  gap: 20px;
  padding: 0 16px;
  background: var(--surface-elevated);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
  box-shadow: 0 1px 0 rgba(0,0,0,.025);
  backdrop-filter: blur(22px) saturate(180%);
  z-index: 40;
}
.top-left-cluster { display: flex; align-items: center; gap: 18px; min-width: 0; }
.brand-block { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 0 0 auto; }
.brand-mark {
  width: 38px; height: 38px; border: none; border-radius: 10px;
  background: transparent; color: var(--primary); cursor: pointer; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform var(--ease), background var(--ease);
}
.brand-mark:hover { transform: translateY(-1px); background: var(--surface-2); }
.brand-mark svg { width: 34px; height: 34px; display: block; }
.brand-name { font-size: 14px; font-weight: 790; letter-spacing: .005em; white-space: nowrap; }
.brand-subtitle { font-size: 10px; color: var(--text-3); white-space: nowrap; }
.project-title-wrap { display: flex; justify-content: center; align-items: center; gap: 10px; min-width: 0; }
.project-title-input {
  width: min(360px, 100%); height: 38px; border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--text); text-align: center; font-weight: 720; font-size: 15px;
  padding: 0 12px; transition: background var(--ease), border-color var(--ease);
}
.project-title-input:hover { background: var(--surface-2); }
.project-title-input:focus { background: var(--surface); border-color: var(--primary); text-align: left; }
.save-status { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 10.5px; white-space: nowrap; }
.save-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 13%, transparent); }
.save-status.saving .save-dot { background: var(--amber); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.top-actions { display: flex; justify-content: flex-end; align-items: center; gap: 5px; min-width: 0; }
.top-actions-left { justify-content: flex-start; flex: 0 1 auto; }
.top-right-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.quick-divider { width: 1px; height: 24px; background: var(--border); margin: 0 2px; }
.icon-button, .mini-icon-button, .danger-icon-button, .top-button {
  border: 1px solid transparent; background: transparent; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: background var(--ease), border-color var(--ease), color var(--ease), transform var(--ease);
}
.icon-button { width: 36px; height: 36px; }
.top-button { height: 36px; padding: 0 11px; color: var(--text-2); font-size: 12px; font-weight: 650; }
.icon-button:hover, .top-button:hover, .mini-icon-button:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.icon-button:active, .top-button:active, .mini-icon-button:active { transform: scale(.97); }
.icon-button:disabled { opacity: .35; pointer-events: none; }
.danger-icon-button { width: 34px; height: 34px; color: var(--danger); }
.danger-icon-button:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.menu-wrap { position: relative; }
.dropdown-menu {
  position: absolute; left: 0; top: calc(100% + 8px); width: 232px;
  background: var(--surface-elevated); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 7px; z-index: 100; backdrop-filter: blur(20px);
}
.dropdown-menu button {
  width: 100%; border: 0; background: transparent; color: var(--text-2); border-radius: 9px;
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; cursor: pointer; text-align: left;
}
.dropdown-menu button:hover { background: var(--surface-2); color: var(--text); }
.menu-separator { height: 1px; background: var(--border); margin: 5px 7px; }
.menu-label { padding: 5px 10px 3px; color: var(--text-3); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }

.workspace { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: var(--left-w) minmax(420px, 1fr) var(--right-w); }
.panel { min-height: 0; background: var(--surface); }
.left-panel { border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.right-panel { border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.panel-scroll { overflow: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.panel-scroll::-webkit-scrollbar { width: 8px; }
.panel-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border: 2px solid transparent; border-radius: 999px; background-clip: padding-box; }
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 12px 12px 8px; }
.mode-tab {
  height: 38px; border: 1px solid transparent; background: transparent; color: var(--text-3); border-radius: 10px;
  display: flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; font-weight: 700; font-size: 12px;
}
.mode-tab:hover { background: var(--surface-2); color: var(--text-2); }
.mode-tab.active { background: var(--primary-soft); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 17%, transparent); }
.mode-tab:disabled { opacity: .42; pointer-events: none; }
.left-panel-footer { border-top: 1px solid var(--border); padding: 10px 12px; }

.section-block { padding: 13px 12px 4px; }
.section-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 3px 8px; }
.section-title { color: var(--text-3); font-weight: 800; font-size: 10px; letter-spacing: .09em; text-transform: uppercase; }
.section-action { border: 0; background: transparent; color: var(--primary); cursor: pointer; padding: 4px 5px; border-radius: 6px; font-size: 11px; font-weight: 750; display: inline-flex; align-items: center; gap: 4px; }
.section-action:hover { background: var(--primary-soft); }
.entity-list { display: flex; flex-direction: column; gap: 5px; }
.entity-item {
  position: relative; border: 1px solid transparent; border-radius: 11px; padding: 9px 9px;
  display: grid; grid-template-columns: 31px minmax(0,1fr) auto; gap: 9px; align-items: center;
  cursor: pointer; background: transparent; transition: background var(--ease), border-color var(--ease), transform var(--ease);
}
.entity-item:hover { background: var(--surface-2); }
.entity-item.active { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 18%, transparent); }
.entity-icon {
  width: 31px; height: 31px; border-radius: 9px; background: var(--surface-3); color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
}
.entity-item.active .entity-icon { background: color-mix(in srgb, var(--primary) 16%, var(--surface)); color: var(--primary); }
.entity-main { min-width: 0; }
.entity-name { font-size: 12px; font-weight: 720; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entity-sub { font-size: 10px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.entity-open { width: 27px; height: 27px; border: 0; border-radius: 8px; background: transparent; color: var(--text-3); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.entity-open:hover { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 7px; border-radius: 999px; font-size: 9.5px; font-weight: 750; }
.badge.primary { color: var(--primary); background: var(--primary-soft); }
.badge.green { color: var(--green); background: var(--green-soft); }
.badge.amber { color: var(--amber); background: var(--amber-soft); }
.badge.danger { color: var(--danger); background: var(--danger-soft); }
.empty-list { color: var(--text-3); text-align: center; padding: 24px 14px; font-size: 11px; border: 1px dashed var(--border); border-radius: 12px; }
.summary-card {
  border: 1px solid var(--border); border-radius: 13px; padding: 12px; background: var(--surface);
}
.summary-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 11px; color: var(--text-2); }
.summary-row strong { color: var(--text); font-weight: 760; }
.primary-wide-button, .secondary-wide-button {
  width: 100%; height: 38px; border-radius: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 12px; font-weight: 740; transition: transform var(--ease), box-shadow var(--ease), background var(--ease);
}
.primary-wide-button { border: 0; background: var(--primary); color: white; box-shadow: 0 8px 18px color-mix(in srgb, var(--primary) 23%, transparent); }
.primary-wide-button:hover { transform: translateY(-1px); box-shadow: 0 10px 23px color-mix(in srgb, var(--primary) 30%, transparent); }
.secondary-wide-button { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); }
.secondary-wide-button:hover { background: var(--surface-2); color: var(--text); }

.editor-area { min-width: 0; min-height: 0; position: relative; display: flex; flex-direction: column; background: var(--bg); }
.editor-top-row { height: 42px; flex: 0 0 42px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; }
.breadcrumbs { display: flex; align-items: center; gap: 5px; min-width: 0; color: var(--text-2); font-size: 11px; }
.breadcrumb-button { border: 0; background: transparent; color: inherit; padding: 4px 5px; border-radius: 6px; cursor: pointer; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumb-button:hover { background: var(--surface); color: var(--primary); }
.breadcrumb-sep { color: var(--text-3); }
.context-meta { color: var(--text-3); font-size: 10.5px; white-space: nowrap; }
.tool-palette {
  position: absolute; left: 50%; top: 48px; transform: translateX(-50%); z-index: 15;
  display: flex; align-items: stretch; gap: 3px; padding: 5px;
  background: var(--surface-elevated); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-md); backdrop-filter: blur(18px);
}
.tool-button {
  width: 54px; min-width: 54px; height: 52px; border: 1px solid transparent; background: transparent; border-radius: 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-2); padding: 4px 3px; font-size: 9px; font-weight: 680; line-height: 1.05;
}
.tool-button .icon { flex: 0 0 auto; }
.tool-button:hover { background: var(--surface-2); color: var(--text); }
.tool-button.active { background: var(--primary-soft); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 18%, transparent); }
.tool-button .tool-label { display: block; max-width: 50px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-separator { width: 1px; height: 40px; background: var(--border); margin: 6px 2px; align-self: center; }
.canvas-frame { flex: 1 1 auto; min-height: 0; position: relative; overflow: hidden; background: var(--surface-2); border-top: 1px solid var(--border); }
.editor-canvas { width: 100%; height: 100%; display: block; user-select: none; touch-action: none; cursor: default; }
.editor-canvas {
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --surface-3: #eef1f7;
  --text: #152033;
  --text-2: #4d5a70;
  --text-3: #8791a5;
  --border: #dfe4ed;
  --border-strong: #cbd2de;
  --primary: #596cf4;
  --primary-soft: #eef0ff;
  --green: #13866a;
  --green-soft: #e9f9f3;
  --amber: #c37a12;
  --amber-soft: #fff5df;
  --danger: #d1495b;
  --danger-soft: #fff0f2;
}
:root[data-theme="dark"] .editor-canvas {
  --surface: #181e29;
  --surface-2: #202735;
  --surface-3: #283141;
  --text: #eef2fb;
  --text-2: #b5bfd1;
  --text-3: #7e8a9f;
  --border: #30394a;
  --border-strong: #465166;
  --primary: #7c8cff;
  --primary-soft: #282d51;
  --green: #4ac6a3;
  --green-soft: #183a34;
  --amber: #f2b65c;
  --amber-soft: #3b2d18;
  --danger: #f07785;
  --danger-soft: #40242a;
}

.editor-canvas[data-tool="pan"] { cursor: grab; }
.editor-canvas[data-tool="pan"].is-dragging { cursor: grabbing; }
.editor-canvas[data-tool="room"] { cursor: crosshair; }
.editor-canvas[data-tool="building"], .editor-canvas[data-tool="outdoor"], .editor-canvas[data-tool="door"], .editor-canvas[data-tool="window"], .editor-canvas[data-tool="stairs"], .editor-canvas[data-tool="exit"], .editor-canvas[data-tool="route"] { cursor: crosshair; }
.grid-small-line { stroke: color-mix(in srgb, var(--border) 72%, transparent); }
.grid-large-line { stroke: color-mix(in srgb, var(--border-strong) 72%, transparent); }
.route-arrow { fill: color-mix(in srgb, var(--primary) 78%, var(--text-2)); }
.empty-canvas-hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: min(420px, calc(100% - 40px));
  text-align: center; padding: 24px; border: 1px dashed var(--border-strong); border-radius: 16px; color: var(--text-3); background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: blur(10px);
}
.empty-canvas-hint h3 { color: var(--text); margin: 0 0 6px; font-size: 14px; }
.canvas-bottom-left, .canvas-bottom-right { position: absolute; bottom: 12px; z-index: 12; display: flex; align-items: center; gap: 6px; }
.canvas-bottom-left { left: 12px; }
.canvas-bottom-right { right: 12px; background: var(--surface-elevated); border: 1px solid var(--border); border-radius: 11px; padding: 4px; box-shadow: var(--shadow-sm); backdrop-filter: blur(14px); }
.status-chip { height: 28px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 999px; padding: 0 9px; background: var(--surface-elevated); color: var(--text-3); font-size: 10px; backdrop-filter: blur(12px) saturate(160%); }
.validation-chip { cursor: pointer; font-weight: 650; transition: background var(--ease), border-color var(--ease), transform var(--ease), box-shadow var(--ease); }
.validation-chip:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); background: var(--surface); }
.validation-chip.has-warning { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 25%, var(--border)); background: color-mix(in srgb, var(--amber-soft) 85%, transparent); }
.validation-chip.ok { color: var(--green); }
.mini-icon-button { width: 28px; height: 28px; }
.zoom-label { height: 28px; min-width: 48px; border: 0; border-radius: 7px; background: transparent; color: var(--text-2); cursor: pointer; font-size: 10.5px; font-weight: 700; }
.zoom-label:hover { background: var(--surface-2); color: var(--text); }

.inspector-header { height: 69px; flex: 0 0 69px; border-bottom: 1px solid var(--border); padding: 13px 15px 11px; display: flex; align-items: center; justify-content: space-between; }
.eyebrow { color: var(--text-3); font-size: 9px; font-weight: 850; letter-spacing: .12em; }
.inspector-header h2, .dialog-header h2 { margin: 1px 0 0; font-size: 16px; line-height: 1.2; }
.inspector-content { padding: 13px 15px 24px; }
.inspector-section { padding: 4px 0 16px; border-bottom: 1px solid var(--border); margin-bottom: 13px; }
.inspector-section:last-child { border-bottom: 0; margin-bottom: 0; }
.inspector-section-title { color: var(--text-3); font-size: 9.5px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 10px; }
.field { margin-bottom: 11px; }
.field:last-child { margin-bottom: 0; }
.field-label { display: flex; align-items: center; justify-content: space-between; gap: 9px; color: var(--text-2); font-size: 10.5px; font-weight: 710; margin-bottom: 5px; }
.field-help { color: var(--text-3); font-size: 9.5px; margin-top: 4px; }
.text-input, .number-input, .select-input, .textarea-input {
  width: 100%; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); color: var(--text); padding: 8px 9px;
  transition: border-color var(--ease), background var(--ease), box-shadow var(--ease);
}
.text-input, .number-input, .select-input { height: 36px; }
.textarea-input { min-height: 74px; resize: vertical; line-height: 1.55; }
.text-input:hover, .number-input:hover, .select-input:hover, .textarea-input:hover { border-color: var(--border-strong); }
.text-input:focus, .number-input:focus, .select-input:focus, .textarea-input:focus { border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 11%, transparent); outline: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 34px; }
.toggle { position: relative; display: inline-flex; width: 38px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--surface-3); border: 1px solid var(--border); border-radius: 999px; cursor: pointer; transition: background var(--ease), border-color var(--ease); }
.toggle-slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: white; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,.18); transition: transform var(--ease); }
.toggle input:checked + .toggle-slider { background: var(--primary); border-color: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }
.preset-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.preset-button { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 8px; padding: 5px 8px; cursor: pointer; font-size: 9.5px; }
.preset-button:hover, .preset-button.active { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.scale-preset-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin: -2px 0 12px; }
.range-field-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.range-field-head .field-label { margin: 0; }
.range-field-head strong { color: var(--text); font-size: 11px; font-variant-numeric: tabular-nums; }
.range-input { width: 100%; accent-color: var(--primary); cursor: pointer; }
.segmented { display: grid; grid-template-columns: repeat(2,1fr); gap: 4px; padding: 3px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); }
.segmented button { height: 29px; border: 0; border-radius: 7px; background: transparent; color: var(--text-3); cursor: pointer; font-size: 10px; font-weight: 700; }
.segmented button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.info-box { border: 1px solid var(--border); border-radius: 11px; padding: 10px; background: var(--surface-2); color: var(--text-2); font-size: 10.5px; }
.info-box strong { color: var(--text); }
.warning-box { border: 1px solid color-mix(in srgb, var(--amber) 28%, var(--border)); border-radius: 11px; padding: 10px; background: var(--amber-soft); color: color-mix(in srgb, var(--amber) 75%, var(--text)); font-size: 10.5px; }
.danger-button { width: 100%; height: 36px; border: 1px solid color-mix(in srgb, var(--danger) 32%, var(--border)); border-radius: 9px; background: var(--danger-soft); color: var(--danger); cursor: pointer; font-weight: 730; font-size: 11px; display: flex; align-items: center; justify-content: center; gap: 7px; }
.danger-button:hover { background: color-mix(in srgb, var(--danger-soft) 80%, var(--danger) 8%); }

/* SVG map styling */
.site-route-visible { stroke: color-mix(in srgb, var(--primary) 72%, var(--text-2)); stroke-width: 3; fill: none; }
.site-route-hit { stroke: transparent; stroke-width: 18; fill: none; cursor: pointer; }
.site-route-selected { stroke: var(--primary); stroke-width: 5; filter: url(#selectionGlow); }
.route-label-bg { fill: var(--surface); stroke: var(--border); stroke-width: 1; }
.route-label-text { fill: var(--text-2); font-size: 11px; font-weight: 750; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.site-node { cursor: move; }
.site-node-card { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1.2; rx: 16; filter: url(#softShadow); }
.site-node.outdoor .site-node-card { fill: var(--green-soft); stroke: color-mix(in srgb, var(--green) 40%, var(--border)); stroke-dasharray: 6 4; }
.site-node.selected .site-node-card { stroke: var(--primary); stroke-width: 2.5; filter: url(#selectionGlow); }
.site-node-accent { fill: var(--primary-soft); }
.site-node.outdoor .site-node-accent { fill: color-mix(in srgb, var(--green-soft) 75%, var(--green) 8%); }
.site-node-icon { color: var(--primary); }
.site-node.outdoor .site-node-icon { color: var(--green); }
.site-node-title { fill: var(--text); font-size: 13px; font-weight: 800; }
.site-node-sub { fill: var(--text-3); font-size: 10px; }
.site-node-badge-bg { fill: var(--surface-2); }
.site-node-badge-text { fill: var(--text-2); font-size: 9px; font-weight: 750; text-anchor: middle; dominant-baseline: central; }
.route-pending-line { stroke: var(--primary); stroke-width: 2.5; stroke-dasharray: 7 6; opacity: .75; pointer-events: none; }

.room-shape { stroke: color-mix(in srgb, var(--text-2) 52%, var(--border)); stroke-width: 2; fill: color-mix(in srgb, var(--primary-soft) 74%, var(--surface)); cursor: move; }
.room-shape.category-corridor { fill: var(--surface-2); }
.room-shape.category-service { fill: var(--amber-soft); }
.room-shape.category-restricted { fill: var(--danger-soft); }
.room-group.selected .room-shape { stroke: var(--primary); stroke-width: 3; filter: url(#selectionGlow); }
.room-group.overlap .room-shape { stroke: var(--danger); stroke-dasharray: 7 5; }
.room-label { fill: var(--text); font-size: 14px; font-weight: 820; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.room-size-label { fill: var(--text-3); font-size: 9px; text-anchor: middle; pointer-events: none; }
.resize-handle { fill: var(--surface); stroke: var(--primary); stroke-width: 2; cursor: nwse-resize; }
.resize-handle[data-handle="n"], .resize-handle[data-handle="s"] { cursor: ns-resize; }
.resize-handle[data-handle="e"], .resize-handle[data-handle="w"] { cursor: ew-resize; }
.resize-handle[data-handle="ne"], .resize-handle[data-handle="sw"] { cursor: nesw-resize; }
.resize-handle[data-handle="nw"], .resize-handle[data-handle="se"] { cursor: nwse-resize; }
.room-overlap-badge { fill: var(--danger); }
.room-overlap-mark { fill: white; font-size: 10px; font-weight: 900; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.fixture-hit { stroke: transparent; fill: transparent; stroke-width: 18; cursor: pointer; }
.fixture-door-line { stroke: var(--text); stroke-width: 4; stroke-linecap: round; }
.fixture-door-arc { stroke: var(--text-2); stroke-width: 1.5; fill: none; stroke-dasharray: 3 2; }
.fixture-window-line { stroke: #3f91dc; stroke-width: 3; stroke-linecap: round; }
.fixture-window-inner { stroke: color-mix(in srgb, #3f91dc 55%, white); stroke-width: 1.5; }
.fixture-selected { filter: url(#selectionGlow); }
.fixture-point-bg { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1.5; filter: url(#softShadow); }
.fixture-point.selected .fixture-point-bg { stroke: var(--primary); stroke-width: 2.5; filter: url(#selectionGlow); }
.fixture-point-icon { color: var(--text-2); }
.fixture-label { fill: var(--text-2); font-size: 9px; font-weight: 700; text-anchor: middle; pointer-events: none; }
.fixture-locked { stroke: var(--danger) !important; }
.fixture-sliding-panel { stroke: var(--text); stroke-width: 4; stroke-linecap: round; }
.fixture-slide-arrow { stroke: var(--text-2); stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.door-lock-marker { color: var(--danger); pointer-events: none; }
.door-lock-icon { color: var(--danger); }

.map-item { transition: opacity var(--ease); }
.map-item-shape {
  fill: color-mix(in srgb, var(--surface) 82%, var(--surface-3));
  stroke: color-mix(in srgb, var(--text-2) 48%, var(--border));
  stroke-width: 1.6;
  stroke-dasharray: 5 3;
  filter: url(#softShadow);
}
.map-item.selected .map-item-shape { stroke: var(--primary); stroke-width: 2.6; stroke-dasharray: none; filter: url(#selectionGlow); }
.map-item-text { fill: var(--text); font-weight: 760; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.map-item-label { fill: var(--text-2); font-size: 9px; font-weight: 720; text-anchor: middle; pointer-events: none; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.item-resize-handle { fill: var(--surface); stroke: var(--primary); stroke-width: 2; }
.item-resize-handle[data-handle="n"], .item-resize-handle[data-handle="s"] { cursor: ns-resize; }
.item-resize-handle[data-handle="e"], .item-resize-handle[data-handle="w"] { cursor: ew-resize; }
.item-resize-handle[data-handle="ne"], .item-resize-handle[data-handle="sw"] { cursor: nesw-resize; }
.item-resize-handle[data-handle="nw"], .item-resize-handle[data-handle="se"] { cursor: nwse-resize; }
.drawing-item { fill: color-mix(in srgb, var(--primary) 7%, var(--surface)); stroke: var(--primary); stroke-width: 2; stroke-dasharray: 6 4; }
.drawing-item-text { fill: var(--text-2); font-size: 26px; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.drawing-room { fill: color-mix(in srgb, var(--primary) 10%, transparent); stroke: var(--primary); stroke-width: 2; stroke-dasharray: 6 4; }
.floor-boundary { fill: none; stroke: color-mix(in srgb, var(--border-strong) 85%, transparent); stroke-width: 2; stroke-dasharray: 8 6; }
.preview-mode .resize-handle, .preview-mode .item-resize-handle, .preview-mode .room-size-label, .preview-mode .room-overlap-badge, .preview-mode .room-overlap-mark { display: none; }
.preview-mode .room-shape, .preview-mode .site-node { cursor: default; }

.app-dialog {
  width: min(720px, calc(100vw - 34px)); max-height: min(720px, calc(100vh - 34px));
  border: 1px solid var(--border); border-radius: 18px; padding: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.app-dialog::backdrop { background: rgba(10,14,24,.52); backdrop-filter: blur(5px); }
.dialog-header { height: 70px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 13px 18px; }
.dialog-body { padding: 20px; overflow: auto; max-height: calc(100vh - 140px); }
.dialog-close { flex: 0 0 auto; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.help-card { border: 1px solid var(--border); border-radius: 12px; padding: 13px; background: var(--surface-2); }
.help-card h3 { margin: 0 0 8px; font-size: 12px; }
.shortcut-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; color: var(--text-2); font-size: 10.5px; }
kbd { min-width: 24px; text-align: center; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; padding: 2px 6px; background: var(--surface); color: var(--text); font-size: 9px; font-family: inherit; }
.confirm-dialog { width: min(460px, calc(100vw - 34px)); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.primary-button, .secondary-button { height: 37px; border-radius: 9px; padding: 0 14px; cursor: pointer; font-weight: 720; font-size: 11px; }
.primary-button { border: 0; background: var(--primary); color: white; }
.secondary-button { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); }

.toast-container { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.toast { min-width: 260px; max-width: 390px; display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px; background: var(--surface-elevated); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md); color: var(--text-2); animation: toastIn .22s ease-out; backdrop-filter: blur(18px); }
.toast.success { border-color: color-mix(in srgb, var(--green) 27%, var(--border)); }
.toast.warning { border-color: color-mix(in srgb, var(--amber) 30%, var(--border)); }
.toast.error { border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
.toast-title { color: var(--text); font-weight: 750; font-size: 11px; }
.toast-message { font-size: 10px; margin-top: 1px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) scale(.98); } }

@media (max-width: 1180px) {
  :root { --left-w: 250px; --right-w: 300px; }
  .brand-subtitle { display: none; }
  .topbar { grid-template-columns: minmax(210px,1fr) minmax(240px,410px) minmax(290px,1fr); gap: 10px; }
}
@media (max-width: 920px) {
  .workspace { grid-template-columns: 220px minmax(420px,1fr); }
  .right-panel { display: none; }
  .topbar { grid-template-columns: 220px 1fr 270px; }
  .save-status { display: none; }
}
@media print {
  .topbar, .left-panel, .right-panel, .editor-top-row, .tool-palette, .canvas-bottom-left, .canvas-bottom-right { display: none !important; }
  html, body, .app-shell, .workspace, .editor-area, .canvas-frame { height: auto !important; overflow: visible !important; background: white !important; }
  .workspace { display: block !important; }
  .canvas-frame { border: 0 !important; }
  .editor-canvas { width: 100vw !important; height: 100vh !important; }
}

/* v2: vertical-transport fixtures and direct canvas panning */
.editor-canvas[data-tool="select"] { cursor: grab; }
.editor-canvas[data-tool="select"].is-dragging,
.editor-canvas[data-tool="pan"].is-dragging { cursor: grabbing; }
.editor-canvas[data-tool="elevator"],
.editor-canvas[data-tool="escalator"],
.editor-canvas[data-tool="item"] { cursor: crosshair; }

.transport-fixture { transition: opacity var(--ease); }
.transport-fixture.selected { filter: url(#selectionGlow); }
.transport-fixture.selected .transport-base { stroke: var(--primary); stroke-width: 3; }
.transport-fixture.transport-disabled { opacity: .58; }
.transport-base {
  stroke: color-mix(in srgb, var(--text-2) 62%, var(--border));
  stroke-width: 2;
  fill: var(--surface);
  filter: url(#softShadow);
}
.transport-hit { fill: transparent; stroke: transparent; pointer-events: all; }
.transport-label { font-size: 9.5px; font-weight: 820; fill: var(--text); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.transport-symbol { fill: color-mix(in srgb, var(--text) 70%, var(--primary)); font-size: 10px; font-weight: 900; text-anchor: middle; dominant-baseline: central; pointer-events: none; letter-spacing: .04em; }

.stair-base { fill: color-mix(in srgb, var(--surface-2) 82%, var(--primary-soft)); }
.stair-landing { fill: color-mix(in srgb, var(--surface-3) 84%, var(--primary-soft)); stroke: color-mix(in srgb, var(--text-2) 42%, var(--border)); stroke-width: 1.1; pointer-events: none; }
.stair-side-rail { stroke: color-mix(in srgb, var(--text) 76%, var(--text-2)); stroke-width: 1.8; stroke-linecap: round; pointer-events: none; }
.stair-tread { stroke: color-mix(in srgb, var(--text-2) 70%, var(--border-strong)); stroke-width: 1.6; pointer-events: none; }
.stair-direction-line { stroke: var(--primary); stroke-width: 2.25; stroke-linecap: round; pointer-events: none; opacity: .84; }
.stair-direction-head { stroke: var(--primary); stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; fill: none; pointer-events: none; opacity: .84; }
.transport-direction-line { stroke: var(--primary); stroke-width: 2.35; stroke-linecap: round; pointer-events: none; }
.transport-direction-head { stroke: var(--primary); stroke-width: 2.35; stroke-linecap: round; stroke-linejoin: round; fill: none; pointer-events: none; }

.elevator-base { fill: color-mix(in srgb, #dceaff 72%, var(--surface)); }
.elevator-car { fill: none; stroke: color-mix(in srgb, var(--text-2) 58%, var(--border-strong)); stroke-width: 1.5; }
.elevator-door { fill: color-mix(in srgb, var(--surface-3) 78%, #b9cee9); stroke: color-mix(in srgb, var(--text-2) 55%, var(--border-strong)); stroke-width: 1.7; }
.elevator-door-split { stroke: color-mix(in srgb, var(--text-2) 58%, var(--border)); stroke-width: 1.4; }
.elevator-threshold { stroke: var(--primary); stroke-width: 2.4; stroke-linecap: round; }
.elevator-arrows { fill: none; stroke: var(--primary); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.elevator-symbol { fill: color-mix(in srgb, var(--primary) 78%, var(--text)); font-size: 11px; }

.escalator-base { fill: color-mix(in srgb, var(--green-soft) 77%, var(--surface)); }
.escalator-step { stroke: color-mix(in srgb, var(--text-2) 55%, var(--border-strong)); stroke-width: 1.8; pointer-events: none; }
.escalator-rail { stroke: color-mix(in srgb, var(--green) 78%, var(--text-2)); stroke-width: 3; stroke-linecap: round; pointer-events: none; }

.exit-marker line { stroke: var(--green); stroke-width: 2.4; stroke-linecap: round; }
.exit-marker path { stroke: var(--green); fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.checkbox-list { display: grid; gap: 6px; }
.checkbox-option {
  display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 7px 9px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2);
  color: var(--text-2); font-size: 11px; cursor: pointer;
}
.checkbox-option:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); background: var(--primary-soft); color: var(--text); }
.checkbox-option input { accent-color: var(--primary); }


.validation-dialog { width: min(560px, calc(100vw - 32px)); }
.validation-dialog-summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 2px 1px 14px; }
.validation-count-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; height: 27px; padding: 0 10px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); font-size: 11px; font-weight: 760; }
.validation-dialog-note { padding: 11px 13px; border-radius: 11px; background: var(--surface-2); color: var(--text-2); font-size: 11px; line-height: 1.55; margin-bottom: 12px; }
.validation-item-list { display: grid; gap: 8px; }
.validation-item { display: grid; grid-template-columns: 28px minmax(0,1fr); gap: 10px; align-items: start; border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--surface); }
.validation-item-number { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--amber-soft); color: var(--amber); font-size: 10px; font-weight: 800; }
.validation-item-title { color: var(--text); font-size: 12px; line-height: 1.55; font-weight: 620; padding-top: 2px; }
.validation-empty-state { text-align: center; color: var(--green); padding: 24px 10px 18px; }
.validation-empty-state h3 { color: var(--text); margin: 10px 0 5px; font-size: 16px; }
.validation-empty-state p { color: var(--text-3); margin: 0 auto; max-width: 390px; font-size: 12px; }

.validation-chip { user-select: none; }
.validation-chip:active { transform: translateY(0) scale(.98); }
.validation-chip svg:last-child { opacity: .58; }
.validation-item-help { color: var(--text-3); font-size: 10.5px; line-height: 1.55; margin-top: 5px; }


/* v4 refinements */
.validation-chip { appearance: none; }
.validation-chip:hover { border-color: color-mix(in srgb, var(--primary) 22%, var(--border)); }

/* v6 — Windows-like top-left command layout and labeled tool palette */
.topbar {
  grid-template-columns: minmax(610px, 1fr) minmax(260px, 420px) auto;
  gap: 16px;
}
.top-left-cluster {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 16px;
}
.top-actions-left {
  justify-content: flex-start;
  flex: 0 0 auto;
}
.top-right-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 88px;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.brand-mark .icon { width: 23px; height: 23px; }
.menu-wrap .dropdown-menu { left: 0; right: auto; }
.menu-label {
  padding: 5px 10px 4px;
  color: var(--text-3);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.tool-palette {
  gap: 3px;
  padding: 6px;
  border-radius: 15px;
}
.tool-button {
  width: 54px;
  min-width: 54px;
  height: 52px;
  padding: 5px 4px 4px;
  flex-direction: column;
  gap: 2px;
  line-height: 1;
}
.tool-button .tool-label {
  display: block;
  max-width: 50px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: currentColor;
  font-size: 9px;
  font-weight: 680;
  letter-spacing: -.01em;
}
.tool-separator { height: 34px; }

@media (max-width: 1260px) {
  .topbar { grid-template-columns: minmax(540px,1fr) minmax(240px,360px) auto; gap: 10px; }
  .brand-subtitle { display:none; }
  .brand-block { gap:8px; }
  .top-left-cluster { gap:10px; }
  .top-button { padding:0 9px; }
}
@media (max-width: 1040px) {
  .brand-name { display:none; }
  .topbar { grid-template-columns: minmax(470px,1fr) minmax(220px,1fr) auto; }
  .tool-button { width:49px; min-width:49px; }
  .tool-button .tool-label { font-size:8.5px; max-width:46px; }
}

/* v8: one-page native print surface */
.native-print-surface { display: none; }
@media print {
  body > .app-shell,
  body > dialog,
  body > .toast-container { display: none !important; }
  html, body { margin: 0 !important; padding: 0 !important; width: 100% !important; height: 100% !important; overflow: hidden !important; background: #fff !important; }
  body > .native-print-surface {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    background: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .native-print-surface svg {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
  }
}
