:root {
  --bg: #f4f6f9;
  --panel-bg: #ffffff;
  --border: #d7dde5;
  --text: #1f2733;
  --text-muted: #5b6675;
  --accent: #2b6cb0;
  --accent-2: #b45309;
  --ok: #1a7f37;
  --warn: #b45309;
  --bad: #c53030;
  --header-bg: #14202e;
  --header-text: #f2f5f8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --panel-bg: #1a2029;
    --border: #2c3543;
    --text: #e6e9ee;
    --text-muted: #97a2b3;
    --accent: #6fa8dc;
    --accent-2: #e0a458;
    --ok: #4fbf6b;
    --warn: #e0a458;
    --bad: #e0645f;
    --header-bg: #0c1118;
    --header-text: #f2f5f8;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.app-header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 0.7rem 1.2rem;
}
.app-header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}
.app-header h1 span {
  font-weight: 400;
  font-size: 0.85rem;
  color: #aab6c5;
  margin-left: 0.6rem;
}

.app-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1px;
  height: calc(100vh - 106px);
  min-height: 480px;
}

.sidebar {
  background: var(--bg);
  overflow-y: auto;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  border-right: 1px solid var(--border);
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem 0.9rem;
}
.panel h2 {
  margin: 0 0 0.6rem 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
}

.control-select {
  width: 100%;
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--text);
  font-size: 0.9rem;
}

.type-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0.5rem 0 0 0;
  line-height: 1.35;
}

.slider-row {
  display: block;
  margin-bottom: 0.85rem;
}
.slider-row:last-child { margin-bottom: 0; }
.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  margin-bottom: 0.25rem;
  color: var(--text);
}
.slider-label b {
  color: var(--accent);
  font-weight: 600;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--text);
  margin-top: 0.6rem;
}
.checkbox-row.inline { margin-top: 0; }

.fit-status {
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  display: inline-block;
}
.fit-status.ok { background: rgba(26,127,55,0.15); color: var(--ok); }
.fit-status.bad { background: rgba(197,48,48,0.15); color: var(--bad); }
.fit-detail {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.key-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 0.6rem;
  font-size: 0.82rem;
}
.key-facts .kf-item {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
}
.key-facts .kf-label { color: var(--text-muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.03em; }
.key-facts .kf-value { font-weight: 700; font-size: 0.95rem; }

.compliance-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.78rem;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.check-row .icon { font-size: 0.9rem; line-height: 1.1; }
.check-row.ok { border-color: rgba(26,127,55,0.35); }
.check-row.warn { border-color: rgba(180,83,9,0.4); background: rgba(180,83,9,0.06); }
.check-row.bad { border-color: rgba(197,48,48,0.4); background: rgba(197,48,48,0.06); }
.check-row .txt b { display: block; color: var(--text); }
.check-row .txt span { color: var(--text-muted); }

.main-view {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.tabs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel-bg);
}
.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}
.tab-btn.active {
  background: var(--accent);
  color: white;
  font-weight: 600;
}
.tab-spacer { flex: 1; }

.view-pane {
  display: none;
  flex: 1;
  min-height: 0;
  position: relative;
}
.view-pane.active { display: block; }

#planSvg {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--panel-bg);
}
#view3d { background: #e8edf3; }
#canvas3d { width: 100%; height: 100%; display: block; }
.no-3d-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 3rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* --- SVG plan drawing styles --- */
.grid-minor { stroke: #e3e8ee; stroke-width: 1; }
.grid-major { stroke: #cdd6e0; stroke-width: 1; }
@media (prefers-color-scheme: dark) {
  .grid-minor { stroke: #232b36; }
  .grid-major { stroke: #2e3947; }
}
.wall-outline { fill: none; stroke: var(--text); stroke-width: 4; }
.step { fill: #eef2f7; stroke: #33475b; stroke-width: 1.2; }
.step-winder { fill: #e4ecf5; }
.step-oob { fill: #fbdada; stroke: #c53030; stroke-width: 1.6; }
.landing { fill: #cfe3ff; stroke: #2b6cb0; stroke-width: 1.4; }
.pole { fill: #4a4f57; stroke: #22262b; stroke-width: 1; }
.gehlinie { fill: none; stroke: #c53030; stroke-width: 2; stroke-dasharray: 6 5; }
.arrow-fill { fill: #c53030; }
.step-label {
  font-size: 9px;
  fill: #33475b;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  user-select: none;
}
.landing-label {
  font-size: 12px;
  fill: #2b6cb0;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}
.scalebar line { stroke: var(--text); stroke-width: 1.5; }
.scale-label { font-size: 11px; fill: var(--text); text-anchor: middle; }

.app-footer {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0.5rem 1.2rem;
  background: var(--header-bg);
  color: #9aa7b8;
  line-height: 1.4;
}

@media (max-width: 860px) {
  .app-layout { grid-template-columns: 1fr; height: auto; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: 46vh; }
  .main-view { height: 60vh; }
}
