:root {
  /* Theme Colors - Matches main.css with additions for tool */
  --bg-color: #f8fafc;
  --surface-color: #ffffff;
  --panel-bg: rgba(255, 255, 255, 0.95);
  --border-color: #e2e8f0;

  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;

  --success-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --violet-color: #8b5cf6;

  --text-main: #0f172a;
  --text-muted: #64748b;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  --radius-md: 6px;
  --radius-lg: 10px;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  height: 100%;
  flex-direction: column;
}

.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 340px;
  min-width: 300px;
  max-width: 450px;
  background: var(--surface-color);
  border-right: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.side-inner {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--primary-light);
  border: 1px solid rgba(37, 99, 235, 0.1);
  border-radius: var(--radius-lg);
  margin-bottom: 0.5rem;
}

.brand .dot {
  width: 10px;
  height: 10px;
  background: var(--primary-color);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.brand-content {
  display: flex;
  flex-direction: column;
}

.brand .title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary-color);
}

.brand .subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Tool Sections */
.tool-section {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem;
}

.stitle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.5rem;
}

.field-row>span {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.hr {
  height: 1px;
  background: var(--border-color);
  margin: 1rem 0;
}

/* Inputs & Buttons */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: white;
  color: var(--text-main);
  transition: all 0.15s ease;
  font-family: inherit;
}

button:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

button:active {
  transform: translateY(1px);
}

button.primary,
.tool-btn.active,
.toggle-on {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

button.primary:hover,
.tool-btn.active:hover {
  background: var(--primary-hover);
}

button.success {
  background: var(--success-color);
  border-color: var(--success-color);
  color: white;
}

button.danger {
  background: var(--danger-color);
  border-color: var(--danger-color);
  color: white;
}

button.violet {
  background: var(--violet-color);
  border-color: var(--violet-color);
  color: white;
}

button.orange {
  background: var(--warning-color);
  border-color: var(--warning-color);
  color: white;
}

input[type="text"],
input[type="number"],
select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  color: var(--text-main);
  background: white;
  font-family: inherit;
  font-weight: 500;
}

input[type="number"] {
  width: 70px;
}

input[type="range"] {
  width: 100%;
}

input[type="color"] {
  width: 40px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: none;
  cursor: pointer;
}

/* Layer List */
#layers-section .layer-focus-row {
  gap: 3px;
  margin: 0 0 6px;
  flex-wrap: nowrap;
  align-items: center;
}

#layers-section .layer-focus-btn {
  flex: 0 0 auto;
  min-width: 0;
  min-height: 24px;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.63rem;
  line-height: 1.1;
  white-space: nowrap;
}

#layers-section .layer-focus-btn.active {
  color: #fff;
}

.layer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: white;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 0.5rem;
}

.layer-row:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.layer-row.active {
  background: var(--primary-light);
  border-color: var(--primary-color);
}

.layer-row.planner-filter-hidden {
  display: none !important;
}

.layer-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.layer-label-main {
  display: inline-flex;
  align-items: center;
}

.layer-label-sep {
  display: inline-block;
  width: 2px;
  height: 0.95em;
  margin: 0 0.32rem 0 0.18rem;
  background: currentColor;
  opacity: 0.5;
  border-radius: 1px;
}

.layer-label-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.2em;
  padding: 0 0.26rem;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1;
  border-bottom: 2px solid currentColor;
  border-radius: 2px;
  background: rgba(148, 163, 184, 0.2);
}

.layer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}

.layer-row.active .layer-dot {
  box-shadow: 0 0 0 2.5px var(--primary-color);
}

.layer-row label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

/* Status Bar & Info */
.statusbar {
  padding: 0.75rem;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.status-left {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.kbd {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-family: monospace;
  font-weight: 700;
  color: var(--text-main);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
}

.inline-indicators {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.mini-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.6rem;
  background: var(--primary-light);
  color: var(--primary-color);
  border: 1px solid rgba(37, 99, 235, 0.1);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.small-note {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Compact sidebar Tools section */
.sidebar #select-section {
  padding: 0.6rem 0.7rem;
}

.sidebar #select-section .stitle {
  margin-bottom: 0.45rem;
  font-size: 0.64rem;
  letter-spacing: 0.04em;
}

.sidebar #select-section .tool-row {
  gap: 0.35rem;
  justify-content: flex-start;
  flex-wrap: nowrap;
  align-items: center;
}

.sidebar #select-section button {
  padding: 0.35rem 0.5rem;
  min-height: 30px;
  font-size: 0.72rem;
}

.sidebar #select-section .tool-row>.tool-btn,
.sidebar #select-section .tool-row>#arc-toggle {
  flex: 0 0 46px !important;
  width: 46px;
  min-width: 46px;
}

.sidebar #select-section .tool-btn .icon,
.sidebar #select-section #arc-toggle .icon {
  width: 1.2em;
  height: 1.2em;
}

.sidebar #select-section .inline-indicators {
  margin-top: 0;
  gap: 0.28rem;
  flex-wrap: nowrap;
  align-items: center;
}

.sidebar #select-section .mini-pill {
  padding: 0.18rem 0.45rem;
  font-size: 0.66rem;
  gap: 0.35rem;
  white-space: nowrap;
}

/* Canvas Area */
.canvas-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #f1f5f9;
  z-index: 1;
  min-width: 0;
  /* CRITICAL: prevents flex child from growing beyond parent */
  overflow: hidden;
  /* Ensures child overflow doesn't expand the wrap */
}

/* Floating canvas-properties panel (plan + elevation) */
#canvas-properties-overlay-host {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 120;
  width: min(340px, calc(100% - 20px));
  pointer-events: auto;
}

#canvas-properties-overlay-host .tool-section {
  margin: 0;
  background: rgba(34, 34, 34, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

#canvas-properties-details {
  margin: 0;
}

#canvas-properties-details > summary {
  margin-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  cursor: pointer;
}

#canvas-properties-details > summary::-webkit-details-marker {
  display: none;
}

#canvas-properties-details > summary::after {
  content: '▸';
  font-size: 1.5rem;
  transition: transform 0.2s ease;
  transform: rotate(0deg);
  opacity: 0.6;
}

#canvas-properties-details[open] > summary::after {
  transform: rotate(90deg);
}

#canvas-properties-details[open] > summary {
  margin-bottom: 0.75rem;
}

#canvas-properties-overlay-host .stitle {
  color: #e5e7eb;
}

#canvas-properties-overlay-host label,
#canvas-properties-overlay-host span,
#canvas-properties-overlay-host .field-row span {
  color: #d1d5db;
}

#canvas-properties-overlay-host input[type="text"],
#canvas-properties-overlay-host input[type="number"],
#canvas-properties-overlay-host select {
  background: #2a2a2a;
  border-color: #4b5563;
  color: #fff;
}

#canvas-properties-overlay-host button {
  background: #2f2f2f;
  border-color: #4b5563;
  color: #fff;
}

#canvas-properties-overlay-host button:hover {
  background: #3b3b3b;
}

#canvas-properties-overlay-host .icon-toggle svg {
  color: #94a3b8;
}

#canvas-properties-overlay-host .icon-toggle input:checked+svg {
  color: var(--primary-color);
}

#canvas-properties-overlay-host .hr {
  background: rgba(255, 255, 255, 0.18);
}

/* Plan view: top-canvas tool groups (Room Planner style) */
#plan-tools-overlay-host {
  position: absolute;
  left: 8px;
  right: 8px;
  z-index: 115;
  pointer-events: none;
}

#plan-tools-overlay-shell {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(900px, calc(100% - 8px));
}

#plan-tools-overlay-tabs {
  display: flex;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
  padding: 6px 8px;
  width: max-content;
  max-width: 100%;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.14);
}

#plan-tools-overlay-tabs .plan-tool-tab {
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #fff;
  color: #334155;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

#plan-tools-overlay-tabs .plan-tool-tab:hover {
  background: #f8fafc;
}

#plan-tools-overlay-tabs .plan-tool-tab.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

#plan-tools-overlay-panels {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  max-width: min(900px, calc(100% - 8px));
}

#plan-tools-overlay-panels .tool-section {
  margin: 0;
  min-width: 0;
  max-width: 100%;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #cbd5e1;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.14);
  padding: 4px 8px;
}

#plan-tools-overlay-panels .stitle {
  color: #334155;
  margin-bottom: 0;
  font-size: 0.62rem;
}

#plan-tools-overlay-panels .tool-row {
  gap: 4px;
}

#plan-tools-overlay-panels .wall-action-row .wall-action-btn {
  flex: 1;
  min-height: 28px;
  padding: 2px 0;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
}

#plan-tools-overlay-panels .wall-action-row .wall-action-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

#plan-tools-overlay-panels .wall-action-row .wall-action-btn[data-active="true"] {
  background: #2563eb;
  border-color: #1d4ed8;
  color: #ffffff;
}

#planner-pick-line-btn[data-active="true"] {
  background: #7c3aed;
  border-color: #6d28d9;
  color: #ffffff;
}

#plan-tools-overlay-panels button {
  padding: 3px 8px;
  font-size: 11px;
  min-height: 26px;
}

#plan-tools-overlay-panels .icon {
  width: 14px;
  height: 14px;
}

#plan-tools-overlay-panels #walls-structures-section {
  width: min(760px, calc(100vw - 24px));
}

#plan-tools-overlay-panels #openings-tools-section {
  width: min(660px, calc(100vw - 24px));
}

#plan-tools-overlay-panels #construction-tools-section {
  width: min(560px, calc(100vw - 24px));
}

#plan-tools-overlay-panels #measure-tools-section {
  width: min(500px, calc(100vw - 24px));
}

#plan-tools-overlay-panels #text-tools-section {
  width: min(380px, calc(100vw - 24px));
}

#plan-tools-overlay-panels #symbols-tools-section {
  width: min(380px, calc(100vw - 24px));
}

#text-tools-details,
#symbols-tools-details {
  margin: 0;
}

#text-tools-details > summary,
#symbols-tools-details > summary {
  margin-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

#text-tools-details > summary::after,
#symbols-tools-details > summary::after {
  content: '▸';
  font-size: 0.85rem;
  transition: transform 0.2s ease;
  transform: rotate(0deg);
  opacity: 0.6;
}

#text-tools-details[open] > summary::after,
#symbols-tools-details[open] > summary::after {
  transform: rotate(90deg);
}

#text-tools-details[open] > summary,
#symbols-tools-details[open] > summary {
  margin-bottom: 4px;
}

#measure-tools-details,
#walls-structures-details,
#openings-tools-details,
#construction-tools-details {
  margin: 0;
}

#measure-tools-details > summary,
#walls-structures-details > summary,
#openings-tools-details > summary,
#construction-tools-details > summary {
  margin-bottom: 0;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#measure-tools-details > summary::-webkit-details-marker,
#walls-structures-details > summary::-webkit-details-marker,
#openings-tools-details > summary::-webkit-details-marker,
#construction-tools-details > summary::-webkit-details-marker {
  display: none;
}

#measure-tools-details > summary::after,
#walls-structures-details > summary::after,
#openings-tools-details > summary::after,
#construction-tools-details > summary::after {
  content: '▸';
  font-size: 0.85rem;
  transition: transform 0.2s ease;
  transform: rotate(0deg);
  opacity: 0.6;
}

#measure-tools-details[open] > summary::after,
#walls-structures-details[open] > summary::after,
#openings-tools-details[open] > summary::after,
#construction-tools-details[open] > summary::after {
  transform: rotate(90deg);
}

#measure-tools-details[open] > summary,
#walls-structures-details[open] > summary,
#openings-tools-details[open] > summary,
#construction-tools-details[open] > summary {
  margin-bottom: 4px;
}

#workspace-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: auto;
  padding: 2rem;
  display: flex;
  /* Required for margin auto centering */
  justify-content: flex-start;
  /* Ensure scroll starts at 0,0 */
  align-items: flex-start;
}

#workspace-scaler {
  margin: auto;
  /* Centers when small, starts at 0,0 when overflows */
  display: block;
  position: relative;
  transform-origin: 0 0;
}

#workspace {
  position: relative;
  width: 1400px;
  height: 990px;
  background: white;
  box-shadow: var(--shadow-lg);
  border-radius: 2px;
  /* Paper-like */
  overflow: hidden;
  /* Paper texture effect slightly */
  background-image: linear-gradient(#f9f9f9 1px, transparent 1px), linear-gradient(90deg, #f9f9f9 1px, transparent 1px);
  background-size: 20px 20px;
  display: inline-block;
  text-align: left;
  /* Reset text alignment for content */
}

/* SVG Elements */
#draw-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  cursor: crosshair;
}

#background-img {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.75;
  transform-origin: 50% 50%;
}

#background-img.editable {
  pointer-events: auto;
  cursor: move;
  z-index: 20;
  /* Move above #draw-layer (10) to allow dragging */
}

#background-img.invisible {
  display: none !important;
}

/* Drawing Styles */
.outer-wall {
  stroke: #1e293b;
  stroke-width: 8;
  fill: none;
  stroke-linecap: butt;
  stroke-linejoin: miter;
}

.inner-wall {
  stroke: #64748b;
  stroke-width: 4.5;
  fill: none;
  stroke-linecap: butt;
  stroke-linejoin: miter;
}

.plot-edge {
  stroke: #0f172a;
  stroke-width: 3.5;
  fill: none;
}
.plot-edge[data-layer="floor"]    { stroke: #78716c; }
.plot-edge[data-layer="roof"]     { stroke: #475569; }
.plot-edge[data-layer="building"] { stroke: #10b981; }
.plot-edge[data-layer="kloak"]    { stroke: #92400e; }
.plot-edge[data-layer="el"]       { stroke: #eab308; }
.plot-edge[data-layer="vent"]     { stroke: #f59e0b; }

.plot-selected {
  stroke: #22c55e !important;
}

/* Building Lines */
.bline {
  stroke: #dc2626;
  stroke-width: 2.5;
  stroke-dasharray: 4, 4;
  fill: none;
}

.bline-road {
  stroke: #ef4444;
  stroke-dasharray: 6, 4;
}

.bline-street {
  stroke: #b91c1c;
  stroke-dasharray: 8, 4;
}

.bline-neighbor {
  stroke: #f87171;
  stroke-dasharray: 2, 4;
}

/* Openings */
.window-frame {
  stroke: #334155;
  stroke-width: 2.2;
  fill: white;
}

.door-leaf {
  stroke: #dc2626;
  stroke-width: 3;
}

.door-swing {
  stroke: #dc2626;
  stroke-width: 1.5;
  fill: none;
  stroke-dasharray: 3, 3;
}

/* Selection */
.selected-wall {
  stroke: #2563eb !important;
  stroke-opacity: 0.8;
}

/* Multi-selection */
.multi-selected {
  stroke: #2563eb !important;
  stroke-opacity: 0.9;
}

.opening-group.multi-selected .window-frame,
.opening-group.multi-selected .door-leaf,
.opening-group.multi-selected .door-swing,
.opening-group.multi-selected rect,
.opening-group.multi-selected line,
.opening-group.multi-selected path,
.symbol-group.multi-selected rect,
.symbol-group.multi-selected line,
.symbol-group.multi-selected path,
.symbol-group.multi-selected circle,
.symbol-group.multi-selected polygon {
  stroke: #2563eb !important;
}

.symbol-group.multi-selected {
  filter: drop-shadow(0 0 2px rgba(37, 99, 235, 0.55));
}

/* Marquee selection rectangles */
.marquee-intersect {
  fill: rgba(37, 99, 235, 0.15);
  stroke: #2563eb;
  stroke-width: 1.5;
  stroke-dasharray: 5, 3;
}

.marquee-contain {
  fill: rgba(34, 197, 94, 0.15);
  stroke: #22c55e;
  stroke-width: 1.5;
  stroke-dasharray: 5, 3;
}

/* Angle measurement selection - highlight entire line */
.angle-selected-first {
  stroke: #9b59b6 !important;
  stroke-width: 10 !important;
  stroke-opacity: 0.9;
}

.angle-selected-second,
.second-selected {
  stroke: #e74c3c !important;
  stroke-width: 10 !important;
  stroke-opacity: 0.9;
}

/* Rooms - hidden stroke for easier wall selection */
.room {
  fill: transparent;
  stroke: none;
  /* Hide dotted outline */
  stroke-width: 0;
  pointer-events: none;
  /* Don't interfere with wall selection */
}

/* Dimensions */
.dim-text {
  font-size: 11px;
  font-weight: 700;
  fill: #0f172a;
  stroke: white;
  stroke-width: 2px;
  paint-order: stroke fill;
  user-select: none;
  pointer-events: none;
}

.dim-text.dim-selected {
  fill: #1d4ed8;
  stroke-width: 2.6px;
}

.auto-dim-group {
  pointer-events: none;
}

.auto-dim-line {
  stroke: #0f172a;
  stroke-width: 0.7px;
  fill: none;
  pointer-events: none;
}

.auto-dim-extension {
  stroke: #334155;
  stroke-width: 0.5px;
  fill: none;
  pointer-events: none;
}

.auto-dim-tick {
  stroke: #0f172a;
  stroke-width: 0.9px;
  fill: none;
  pointer-events: none;
}

.auto-dim-hit {
  stroke: transparent;
  stroke-width: 14px;
  fill: none;
  pointer-events: stroke;
}

.dim-text.dim-auto-text {
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 500;
  fill: #0f172a;
  stroke: #ffffff;
  stroke-width: 1.2px;
  paint-order: stroke fill;
}

.auto-dim-group.dim-selected .auto-dim-line,
.auto-dim-group.dim-selected .auto-dim-tick {
  stroke: #1d4ed8;
}

.auto-dim-group.dim-selected .dim-auto-text {
  fill: #1d4ed8;
}

/* Offset-from-building dims (Foundation/Roof outline vs. the building wall
   they're parallel-offset from) -- distinct violet so they read as a
   different kind of measurement from ordinary wall-length dims. */
.auto-dim-group.offset-dim .auto-dim-line,
.auto-dim-group.offset-dim .auto-dim-tick,
.auto-dim-group.offset-dim .auto-dim-extension {
  stroke: #7c3aed;
}

.auto-dim-group.offset-dim .dim-auto-text {
  fill: #7c3aed;
}

.dim-turn-handle-hit {
  fill: rgba(0, 0, 0, 0.001);
  stroke: none;
}

.dim-turn-handle-icon {
  fill: none;
  stroke: #0b0b0b;
  stroke-width: 1.5px;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.dim-turn-handle-axis {
  fill: none;
  stroke: #0b0b0b;
  stroke-width: 1.3px;
  stroke-linecap: round;
  pointer-events: none;
}

/* Construction */
.construction-line {
  stroke-opacity: 0.8;
  fill: none;
  pointer-events: stroke;
  cursor: pointer;
}

.construction-dual-visual,
.construction-dual-part {
  pointer-events: none;
}

.construction-dual-part {
  fill: none;
  stroke-opacity: 0.95;
  stroke-linecap: round;
}

/* Top Back Button */
.back-btn {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: var(--surface-color);
  color: var(--text-main);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.back-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.img-grid {
  display: grid;
  grid-template-columns: 1fr 80px;
  gap: 0.5rem;
  align-items: end;
}

.img-grid>div {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* Blueprint Overlay buttons aligned to Plot-Matrikel block style */
.blueprint-overlay-section .tool-row {
  gap: 6px;
}

.blueprint-overlay-section .blueprint-actions-row {
  width: 100%;
}

.blueprint-overlay-section #image-controls {
  display: flex;
  gap: 6px;
  width: 100%;
}

.blueprint-overlay-section .blueprint-action-btn {
  flex: 1;
  height: 38px;
  min-height: 38px;
  box-sizing: border-box;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  padding: 0.5rem 0.6rem;
}

.blueprint-overlay-section label.blueprint-action-btn {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: white;
  color: var(--text-main);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.blueprint-overlay-section label.blueprint-action-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.blueprint-overlay-section label.blueprint-action-btn.blueprint-action-primary {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

.blueprint-overlay-section label.blueprint-action-btn.blueprint-action-primary:hover {
  background: var(--primary-hover);
}

.blueprint-overlay-section .blueprint-action-btn svg {
  width: 16px;
  height: 16px;
}

/* UI Overlays */
#snap-marker {
  fill: rgba(255, 0, 0, 0.8);
  stroke: #ffffff;
  stroke-width: 1.5;
  pointer-events: none;
  display: none;
}

/* Selection handles - hidden by default */
#h1,
#h2,
#h3 {
  fill: rgba(255, 0, 0, 0.8);
  stroke: #ffffff;
  stroke-width: 2;
  pointer-events: all;
  cursor: crosshair;
  display: none;
}

#line-lock-toolbar {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  display: none;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.95);
  background: rgba(15, 23, 42, 0.9);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.35);
  z-index: 35;
  pointer-events: auto;
}

#line-lock-toolbar .line-lock-btn {
  position: relative;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(148, 163, 184, 0.75);
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.8);
  color: #e2e8f0;
  cursor: pointer;
  padding: 0;
}

#line-lock-toolbar .line-lock-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

#line-lock-toolbar .line-lock-btn[data-active="true"] {
  background: #2563eb;
  border-color: #60a5fa;
  color: #ffffff;
}

#line-lock-toolbar .line-lock-btn:hover {
  background: rgba(51, 65, 85, 0.95);
}

#line-lock-toolbar .line-lock-btn[data-active="true"]:hover {
  background: #1d4ed8;
}

.layer-row input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
}

.layer-row input[type="text"],
.layer-row input[type="number"] {
  font-size: 0.7rem;
  padding: 2px 4px;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 3px;
  color: #fff;
}

.layer-row button {
  font-size: 0.7rem;
  padding: 2px 5px;
  background: #e0e0e0;
  border: 1px solid #999;
  border-radius: 3px;
  color: #000;
  cursor: pointer;
  font-weight: bold;
}

.layer-row button:hover {
  background: #fff;
}

#preview-line {
  stroke: rgba(37, 99, 235, 0.6);
  stroke-width: 2.5;
  stroke-dasharray: 4, 4;
  stroke-linecap: round;
  pointer-events: none;
  display: none;
}

.guide-line {
  stroke: #9b59b6;
  stroke-width: 1.5;
  stroke-dasharray: 4, 4;
  pointer-events: none;
  opacity: 0.8;
}

#preview-arc {
  stroke: rgba(37, 99, 235, 0.6);
  stroke-width: 2.5;
  stroke-dasharray: 4, 4;
  fill: none;
  pointer-events: none;
  display: none;
}

/* HUD Info Panel */
.hud-bg {
  fill: none;
  stroke: none;
}

.hud-text {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  fill: var(--text-main);
  pointer-events: none;
}

.room-label {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  fill: var(--primary-color);
  text-shadow:
    -1px -1px 0 #fff,
    1px -1px 0 #fff,
    -1px 1px 0 #fff,
    1px 1px 0 #fff;
  pointer-events: all;
  cursor: pointer;
}

/* Hide Room labels when toggled off */
body.hide-room-labels .room-label {
  display: none !important;
}

/* User text elements */
.text-group {
  cursor: move;
}

.user-text {
  font-family: var(--font-sans);
  pointer-events: all;
  cursor: text;
}

.text-group.multi-selected .user-text,
.text-group:hover .user-text {
  text-decoration: underline;
}

/* ===== Symbol Context Bar (Floating) ===== */
#symbol-context-bar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 200;
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
}

.ctx-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ctx-label {
  font-weight: 600;
  color: #555;
  font-size: 0.7rem;
  text-transform: uppercase;
}

.ctx-sep {
  width: 1px;
  height: 24px;
  background: #ddd;
}

#symbol-context-bar input[type="range"] {
  width: 100px;
}

#symbol-context-bar input[type="number"] {
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* ===== Text Context Bar (Floating) ===== */
#text-context-bar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 200;
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
}

#text-context-bar input[type="text"],
#text-context-bar input[type="number"] {
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* ===== Matrikel Context Bar (Floating) ===== */
#matrikel-context-bar {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 200;
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
}

#matrikel-context-bar input[type="range"] {
  width: 100px;
}

#matrikel-context-bar input[type="range"],
#blueprint-context-bar input[type="range"],
.blueprint-overlay-section input[type="range"] {
  accent-color: var(--primary-color);
}

#matrikel-context-bar input[type="number"] {
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* ===== Blueprint Context Bar (Floating) ===== */
#blueprint-context-bar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 200;
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
}

#blueprint-context-bar input[type="range"] {
  width: 100px;
}

#blueprint-context-bar input[type="number"] {
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* ===== Icon Toggle for Layer Visibility ===== */
.icon-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.15s, opacity 0.15s;
}

.icon-toggle:hover {
  background: rgba(0, 0, 0, 0.08);
}

.icon-toggle input[type="checkbox"] {
  display: none;
}

.icon-toggle .icon-sm {
  width: 16px;
  height: 16px;
  opacity: 1;
  transition: opacity 0.15s;
}

.icon-toggle input[type="checkbox"]:not(:checked)+.icon-sm {
  opacity: 0.35;
}

/* ===== Modal Styles ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #999;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: #333;
}

.modal-body {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-body .input-group {
  display: flex;
  gap: 8px;
}

#matrikel-results .result-item {
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 4px;
  background: #f5f5f5;
  font-size: 0.9rem;
}

#matrikel-results .result-item:hover {
  background: #e0e7ff;
}

/* ===== Print Styles ===== */
@page {
  size: A3 landscape;
  margin: 5mm;
}

@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: visible !important;
    background: white !important;
  }

  /* Hide all UI elements */
  .sidebar,
  .back-btn,
  #symbol-context-bar,
  #blueprint-context-bar,
  #text-context-bar,
  #matrikel-context-bar,
  .modal-overlay,
  #snap-marker,
  #preview-line,
  #preview-arc,
  .guide-line,
  #h1,
  #h2,
  #h3,
  #line-lock-toolbar,
  #tb-handles,
  #grid-rect,
  #hit-rect {
    display: none !important;
  }

  .app {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    overflow: visible !important;
  }

  .main {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    overflow: visible !important;
  }

  .canvas-wrap {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    overflow: visible !important;
    position: static !important;
    background: white !important;
  }

  #workspace-container {
    position: static !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
    width: 100% !important;
    height: 100% !important;
  }

  #workspace-scaler {
    transform: none !important;
    margin: 0 !important;
    display: block !important;
    width: 100% !important;
    height: 100% !important;
  }

  #workspace {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    box-shadow: none !important;
    border: none !important;
    background: white !important;
    background-image: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    page-break-inside: avoid;
  }

  #draw-layer {
    position: static !important;
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
  }

  #background-img {
    display: none !important;
  }

  #background-img.print-visible {
    display: block !important;
  }
}

/* ===== Dark Sidebar Theme ===== */
.sidebar {
  background: #1a1a1a !important;
  border-right-color: #333 !important;
}

.side-inner {
  color: #e5e5e5;
}

.sidebar .stitle,
.sidebar .tool-section .stitle {
  color: #fff;
}

.sidebar .brand {
  background: transparent !important;
  border: none !important;
}

.sidebar .tool-section {
  background: rgba(255, 255, 255, 0.05);
  border-color: #333;
}

.sidebar .layer-row {
  background: rgba(255, 255, 255, 0.05);
  border-color: #444;
  color: #e5e5e5;
}

.sidebar .layer-row:hover {
  background: rgba(255, 255, 255, 0.1);
}

.sidebar .layer-row.active {
  background: rgba(37, 99, 235, 0.3);
  border-color: var(--primary-color);
}

.sidebar .layer-label-number {
  background: rgba(255, 255, 255, 0.14);
}

.sidebar label,
.sidebar span,
.sidebar .field-row span {
  color: #ccc;
}

.sidebar input[type="text"],
.sidebar input[type="number"],
.sidebar select {
  background: #2a2a2a;
  border-color: #444;
  color: #fff;
}

.sidebar input[type="text"]:focus,
.sidebar input[type="number"]:focus,
.sidebar select:focus {
  border-color: var(--primary-color);
  background: #333;
}

/* Keep full-width controls inside the Automated Building Lines frame */
#automated-building-lines-section .field-row > div {
  min-width: 0;
}

#automated-building-lines-section input[type="number"],
#automated-building-lines-section select,
#automated-building-lines-section button {
  box-sizing: border-box;
  max-width: 100%;
}

.sidebar button {
  background: #333;
  border-color: #444;
  color: #fff;
}

.sidebar button:hover {
  background: #444;
}

.sidebar button.active,
.sidebar button[data-tool].active {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.sidebar .icon-toggle svg {
  color: #999;
}

.sidebar .icon-toggle input:checked+svg {
  color: var(--primary-color);
}

.sidebar hr {
  border-color: #333;
}

.sidebar .subtitle {
  color: #888 !important;
}

/* Manual Dimensions */
.dim-manual-line {
  stroke: #0f172a;
  stroke-width: 1px;
  fill: none;
}

.dim-manual-extension {
  stroke: #64748b;
  stroke-width: 0.5px;
  fill: none;
}

.dim-manual-tick {
  stroke: #0f172a;
  stroke-width: 1.5px;
  fill: none;
}

.dim-manual-text {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  fill: #0f172a;
  pointer-events: none;
  /* Let clicks pass to hit box */
}

.manual-dims-layer {
  pointer-events: all;
}

/* Dimension Hover */
.manual-dim-group:hover .dim-manual-line,
.manual-dim-group:hover .dim-manual-tick {
  stroke: #3b82f6;
}

.manual-dim-group:hover .dim-manual-text {
  fill: #3b82f6;
}

/* Dimension Selected */
.manual-dim-group.dim-selected .dim-manual-line,
.manual-dim-group.dim-selected .dim-manual-tick {
  stroke: #e74c3c;
}

.manual-dim-group.dim-selected .dim-manual-text {
  fill: #e74c3c;
}

/* Dimension Grip Handles */
.dim-grip {
  fill: #3b82f6;
  stroke: white;
  stroke-width: 2px;
  cursor: crosshair;
  display: none;
  pointer-events: all;
}

.dim-grip-offset {
  fill: #10b981;
}

.manual-dim-group.dim-selected .dim-grip {
  display: block;
}

/* ===== Measurement Tool Enhancements ===== */

/* Snap indicator with smooth transitions */
#snap-indicator {
  transition: opacity 0.15s ease, fill 0.15s ease;
  opacity: 0.9;
}

#snap-indicator[style*="display: block"] {
  animation: snap-pulse 0.3s ease-out;
}

@keyframes snap-pulse {
  0% {
    r: 3;
    opacity: 0.5;
  }

  50% {
    r: 7;
    opacity: 1;
  }

  100% {
    r: 5;
    opacity: 0.9;
  }
}

/* Snap face/type label */
#snap-face-label {
  transition: opacity 0.15s ease;
  text-shadow:
    1px 1px 0 white,
    -1px -1px 0 white,
    1px -1px 0 white,
    -1px 1px 0 white;
}

/* Live dimension text during measurement */
#live-measure-text,
.dim-live-measure {
  font-size: 12px;
  font-weight: 700;
  fill: #2563eb;
  stroke: white;
  stroke-width: 3px;
  paint-order: stroke fill;
  pointer-events: none;
  user-select: none;
}

/* Dimension preview line styling */
#preview-line.dim-preview {
  stroke: #2563eb;
  stroke-width: 2;
  stroke-dasharray: 6 4;
  opacity: 0.8;
}

/* Measurement mode cursor hint */
.canvas-wrap.measure-mode #draw-layer {
  cursor: crosshair;
}

/* Dimension guides during creation */
.dim-guide {
  stroke: #9b59b6;
  stroke-width: 1;
  stroke-dasharray: 4 4;
  opacity: 0.6;
  pointer-events: none;
}

/* Manual dimension hover effect */
.manual-dim-group {
  cursor: pointer;
}

.manual-dim-group:hover .dim-manual-line,
.manual-dim-group:hover .dim-manual-extension,
.manual-dim-group:hover .dim-manual-tick {
  stroke: #3b82f6;
}

/* ===== Elevation View Tabs & Layout Fixes ===== */
.canvas-wrap {
  display: flex !important;
  flex-direction: column !important;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.view-tabs {
  flex: 0 0 auto;
  z-index: 50;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  overflow-x: auto;
  flex-wrap: nowrap;
}

.view-tab {
  flex: 0 0 auto;
  white-space: nowrap;
}

#workspace-container {
  flex: 1;
  width: 100%;
  height: auto !important;
  /* Allow flex to control height */
  position: relative;
  overflow: hidden;
}

#elevation-view {
  flex: 1;
  width: 100%;
  position: relative;
  overflow: hidden;
}

#topography-planner-view {
  color: #0f172a;
}

.topography-planner-toolbar {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.topography-toolbar-group {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 4px 6px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.topography-toolbar-title,
.topography-toolbar-group label {
  font-size: 11px;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
}

.topography-toolbar-group button {
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.1;
  white-space: nowrap;
}

.topography-tool-btn.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

#topography-height-input {
  width: 74px;
  min-height: 22px;
  padding: 2px 5px;
  font-size: 11px;
}

#topography-reference-opacity {
  width: 78px;
}

#topography-planner-stage {
  position: absolute;
  inset: 0;
  padding-top: 0;
}

#topography-planner-svg {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

#topography-planner-svg[data-tool="select"] {
  cursor: default;
}

#topography-planner-svg[data-tool="connect"] {
  cursor: cell;
}

.topography-plot-outline {
  fill: rgba(34, 197, 94, 0.06);
  stroke: rgba(21, 128, 61, 0.75);
  stroke-width: 2;
  stroke-dasharray: 9 5;
  pointer-events: none;
}

.topography-reference-image {
  pointer-events: none;
}

.topography-building-shadow-layer {
  pointer-events: none;
}

.topography-building-shadow-cast {
  fill: none;
  stroke: rgba(15, 23, 42, 0.11);
  stroke-linecap: butt;
  stroke-linejoin: round;
}

.topography-building-shadow-wall {
  fill: none;
  stroke: rgba(15, 23, 42, 0.34);
  stroke-linecap: butt;
  stroke-linejoin: round;
}

.topography-contour {
  fill: none;
  stroke: #047857;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: stroke;
}

.topography-contour.connection-round,
.topography-point-connection.connection-round,
.topography-draft.connection-round {
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topography-contour.connection-sharp,
.topography-point-connection.connection-sharp,
.topography-draft.connection-sharp {
  stroke-linecap: butt;
  stroke-linejoin: miter;
  stroke-miterlimit: 10;
}

.topography-contour.connection-square,
.topography-point-connection.connection-square,
.topography-draft.connection-square {
  stroke-linecap: square;
  stroke-linejoin: miter;
  stroke-miterlimit: 10;
}

.topography-contour.selected {
  stroke: #2563eb;
  stroke-width: 4;
}

.topography-height-point {
  fill: #f8fafc;
  stroke: #0f766e;
  stroke-width: 3;
  pointer-events: all;
}

.topography-point-connection {
  stroke: #0891b2;
  stroke-width: 2.75;
  fill: none;
  pointer-events: stroke;
}

.topography-point-connection.selected {
  stroke: #2563eb;
  stroke-width: 4;
}

.topography-height-point.selected {
  stroke: #2563eb;
  fill: #dbeafe;
}

.topography-height-point.link-pending {
  stroke: #0891b2;
  fill: #cffafe;
}

.topography-point-popup {
  position: absolute;
  z-index: 48;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 5px 7px;
  border: 1px solid rgba(148, 163, 184, 0.72);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
}

.topography-point-popup label {
  font-size: 11px;
  font-weight: 700;
  color: #334155;
  white-space: nowrap;
}

#topography-point-connection-style {
  min-height: 22px;
  padding: 2px 5px;
  font-size: 11px;
}

.topography-digging-area,
.topography-fill-area {
  stroke-width: 2.5;
  pointer-events: all;
}

.topography-digging-area {
  fill: url(#topography-digging-pattern);
  stroke: #b91c1c;
}

.topography-fill-area {
  fill: url(#topography-fill-pattern);
  stroke: #b45309;
}

.topography-digging-area.selected,
.topography-fill-area.selected {
  stroke: #2563eb;
  stroke-width: 3.5;
}

.topography-soil-area {
  fill: rgba(120, 91, 52, 0.14);
  stroke: #785b34;
  stroke-width: 2.5;
  stroke-dasharray: 8 4;
  pointer-events: all;
}

.topography-soil-area.selected {
  stroke: #2563eb;
  stroke-width: 3.5;
}

.topography-soil-area.hovered:not(.selected) {
  fill: rgba(120, 91, 52, 0.22);
}

/* Subsurface & soil panel */
/* Subsurface & soil — rendered as a full-width row of the top toolbar */
.topography-soil-bar {
  flex: 1 1 100%;
  flex-wrap: wrap;
  row-gap: 5px;
}

.topography-soil-context-row {
  display: inline-flex;
  gap: 4px;
  color: #475569;
  font-size: 11px;
  white-space: nowrap;
}

.topography-soil-context-row strong {
  color: #0f172a;
}

.topography-soil-layers-label {
  font-size: 11px;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
}

.topography-soil-sep {
  width: 1px;
  align-self: stretch;
  min-height: 18px;
  background: rgba(148, 163, 184, 0.5);
  margin: 0 2px;
}

#topography-subsurface-thickness {
  width: 74px;
  min-height: 22px;
  padding: 2px 5px;
  font-size: 11px;
}

.topography-soil-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.topography-soil-inline input[type="number"] {
  width: 74px;
  min-height: 22px;
  padding: 2px 5px;
  font-size: 11px;
}

.topography-soil-layers {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.topography-soil-row {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 4px;
  border: 1px solid rgba(148, 163, 184, 0.55);
  border-radius: 4px;
  background: #f8fafc;
}

.topography-soil-row input,
.topography-soil-row select {
  min-width: 0;
  padding: 1px 3px;
  font-size: 10.5px;
}

.topography-soil-name { width: 80px; }
.topography-soil-type { width: 72px; }
.topography-soil-thick { width: 50px; }

.topography-soil-row input[type="color"] {
  padding: 0;
  width: 22px;
  height: 20px;
  cursor: pointer;
}

.topography-soil-del {
  border: none;
  background: transparent;
  color: #b91c1c;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

.topography-soil-empty {
  color: #64748b;
  font-size: 10.5px;
  font-style: italic;
  white-space: nowrap;
}

.topography-soil-excavation-summary {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-top: 5px;
  border-top: 1px solid #dbe3ec;
}

.topography-soil-excavation-title {
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #334155;
}

.topography-soil-excavation-volume {
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #f8fafc;
  color: #0f172a;
  font-size: 10.5px;
  text-align: left;
  cursor: pointer;
}

.topography-soil-excavation-volume.selected {
  border-color: #2563eb;
  background: #eff6ff;
}

#three-d-canvas-container {
  position: relative;
}

.soil-legend-overlay {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  min-width: 132px;
  max-width: 220px;
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, 0.42);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.78);
  color: #f8fafc;
  font-size: 11px;
  pointer-events: none;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.24);
}

.soil-legend-title {
  margin-bottom: 5px;
  font-weight: 700;
}

.soil-legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  line-height: 1.25;
}

.soil-legend-swatch {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border: 1px solid rgba(248, 250, 252, 0.7);
  border-radius: 2px;
}

.topography-label {
  font-size: 12px;
  font-weight: 700;
  paint-order: stroke;
  stroke: rgba(248, 250, 252, 0.9);
  stroke-width: 4;
  stroke-linejoin: round;
  pointer-events: none;
}

.topography-label.contour {
  fill: #065f46;
}

.topography-label.point {
  fill: #0f766e;
}

.topography-label.work {
  fill: #7f1d1d;
}

.topography-dimension-label {
  fill: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
  paint-order: stroke;
  stroke: rgba(248, 250, 252, 0.96);
  stroke-width: 5;
  stroke-linejoin: round;
  cursor: text;
  pointer-events: all;
}

.topography-dimension-label.overall {
  fill: #0f766e;
}

.topography-dimension-popup {
  position: absolute;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  border: 1px solid rgba(148, 163, 184, 0.65);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
}

.topography-dimension-popup label {
  font-size: 11px;
  font-weight: 700;
  color: #334155;
  white-space: nowrap;
}

.topography-dimension-popup input {
  width: 72px;
  padding: 2px 5px;
  font-size: 11px;
}

.topography-dimension-popup button {
  padding: 2px 7px;
  font-size: 11px;
}

.topography-draft {
  fill: none;
  stroke: #2563eb;
  stroke-width: 2.5;
  stroke-dasharray: 8 5;
  pointer-events: none;
}

.topography-draft.fill {
  fill: rgba(37, 99, 235, 0.08);
}

.topography-handle {
  fill: #fff;
  stroke: #2563eb;
  stroke-width: 2;
  cursor: grab;
  pointer-events: all;
}

.topography-handle:active {
  cursor: grabbing;
}

/* Edge midpoint grips: drag to move the whole edge. */
.topography-handle.edge {
  fill: #dbeafe;
  cursor: move;
}

/* The selected corner (Delete removes just this corner). */
.topography-handle.active {
  fill: #f97316;
  stroke: #ffffff;
}

/* Live segment lengths shown while drawing a new shape. */
.topography-dimension-label.draft {
  fill: #2563eb;
  cursor: default;
  pointer-events: none;
}

.topography-draft-cursor {
  fill: #2563eb;
  stroke: #fff;
  stroke-width: 1.5;
  pointer-events: none;
}

.topography-height-point.snap-target {
  stroke: #7c3aed;
  fill: #ede9fe;
  stroke-width: 3.5;
}

.topography-height-point.hovered:not(.selected):not(.link-pending):not(.snap-target) {
  fill: #d1fae5;
}

.topography-contour.hovered:not(.selected) {
  stroke: #059669;
  stroke-width: 4.5;
}

.topography-point-connection.hovered:not(.selected) {
  stroke: #0e7490;
  stroke-width: 4;
}

.topography-digging-area.hovered:not(.selected) {
  stroke: #dc2626;
  stroke-width: 3.5;
}

.topography-fill-area.hovered:not(.selected) {
  stroke: #d97706;
  stroke-width: 3.5;
}

#topography-status {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 45;
  max-width: 520px;
  padding: 7px 10px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.78);
  color: #e2e8f0;
  font-size: 11px;
  line-height: 1.35;
}

/* ===== Landscape Planner Premium UI ===== */

#landscape-planner-view {
  background: #0f172a; /* Deeper background to contrast with UI */
}

.landscape-panel {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.landscape-panel.dark {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

.landscape-control-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 8px;
  border-right: 1px solid rgba(0, 0, 0, 0.1);
}
.landscape-control-group:last-child {
  border-right: none;
  padding-right: 0;
}

.landscape-panel.dark .landscape-control-group {
  border-right-color: rgba(255, 255, 255, 0.1);
}

.landscape-panel-title {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 4px;
}

.landscape-panel.dark .landscape-panel-title {
  color: #f8fafc;
}

.landscape-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #475569;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.landscape-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #0f172a;
}

.landscape-btn.active {
  background: #3b82f6;
  color: #ffffff;
  border-color: #2563eb;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.landscape-panel.dark .landscape-btn {
  color: #cbd5e1;
}

.landscape-panel.dark .landscape-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.landscape-panel.dark .landscape-btn.active {
  background: #3b82f6;
  color: #ffffff;
}

.landscape-input, .landscape-select {
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  color: #334155;
  transition: border-color 0.2s;
}

.landscape-input:focus, .landscape-select:focus {
  outline: none;
  border-color: #3b82f6;
}

.landscape-panel.dark .landscape-input, 
.landscape-panel.dark .landscape-select {
  background: rgba(15, 23, 42, 0.6);
  border-color: rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
}

.landscape-label {
  font-size: 12px;
  font-weight: 500;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.landscape-panel.dark .landscape-label {
  color: #cbd5e1;
}

.landscape-color-picker {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
}

/* Hide context panels gracefully */
.landscape-panel-hidden {
  opacity: 0;
  transform: translateY(-10px) scale(0.95);
  pointer-events: none;
  visibility: hidden;
}

