:root {
  --paper: #f6f3ec;
  --paper-deep: #ebe5d9;
  --ink: #1e2a2d;
  --muted: #677477;
  --line: #d7d0c4;
  --blue: #226f8c;
  --blue-soft: #dcecf1;
  --wood: #bc7a42;
  --wood-soft: #f0dfce;
  --green: #3f7c5d;
  --amber: #aa6b14;
  --red: #a34338;
  --white: #fffdf8;
  --shadow: 0 14px 40px rgba(50, 42, 31, .08);
  --radius: 14px;
}

* { box-sizing: border-box; }

html { color-scheme: light; scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(rgba(55, 75, 78, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(55, 75, 78, .035) 1px, transparent 1px),
    var(--paper);
  background-size: 24px 24px;
  font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  font-size: 15px;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

[hidden] { display: none !important; }
.engineering-copy { display: none; }
.engineering-mode .engineering-copy { display: inline; }
.engineering-mode .owner-copy { display: none; }

.mode-switch {
  display: inline-flex;
  padding: 3px;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.mode-button {
  min-height: 36px;
  padding: 7px 12px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  font-weight: 800;
}

.mode-button.active {
  color: var(--white);
  background: var(--ink);
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  padding: 26px clamp(18px, 3.5vw, 54px) 18px;
  background: rgba(246, 243, 236, .93);
  border-bottom: 1px solid var(--line);
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(25px, 3vw, 38px); letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 19px; letter-spacing: -.02em; }
.subhead { margin-bottom: 0; color: var(--muted); }
.eyebrow { margin-bottom: 5px; color: var(--blue); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }

.header-actions, .view-switch { display: flex; gap: 8px; flex-wrap: wrap; }
.button, .small {
  min-height: 42px;
  border: 1px solid var(--blue);
  border-radius: 10px;
  padding: 9px 14px;
  color: var(--white);
  background: var(--blue);
  font-weight: 700;
}
.button:hover, .button:focus-visible, .small:hover, .small:focus-visible { filter: brightness(.94); }
.button.secondary { color: var(--blue); background: transparent; }
.small { min-height: 34px; padding: 6px 10px; color: var(--muted); background: transparent; border-color: var(--line); }
.small.active { color: var(--white); background: var(--blue); border-color: var(--blue); }
.small-button { min-height: 36px; padding-block: 6px; }

.preset-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 1px;
  padding: 0 clamp(18px, 3.5vw, 54px);
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
.preset {
  display: grid;
  gap: 4px;
  padding: 14px 18px;
  text-align: left;
  color: var(--muted);
  background: var(--white);
  border: 0;
  border-bottom: 3px solid transparent;
}
.preset strong { color: var(--ink); font-size: 16px; }
.preset.active { background: var(--blue-soft); border-bottom-color: var(--blue); }

.owner-dashboard {
  display: grid;
  gap: 20px;
  max-width: 1740px;
  margin: 0 auto;
  padding: 24px clamp(14px, 2.6vw, 42px) 48px;
  min-width: 0;
}

.owner-dashboard > * { min-width: 0; max-width: 100%; }

.owner-mode .app-shell { display: none; }
.engineering-mode .owner-dashboard { display: none; }
.engineering-mode .preset-strip { display: none; }
.owner-mode #resetScheme { display: none; }

.owner-intro,
.owner-comparison,
.tradeoff-section,
.owner-boundary,
.site-reference {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.owner-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 32px;
  align-items: center;
  padding: 24px clamp(18px, 2vw, 32px);
}
.owner-intro h2 { margin-bottom: 8px; font-size: clamp(23px, 2.3vw, 34px); line-height: 1.3; }
.owner-intro p:last-child { max-width: 70ch; margin-bottom: 0; color: var(--muted); font-size: 16px; line-height: 1.7; }

.person-height-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(84px, 1fr));
  gap: 6px;
  flex: 0 0 auto;
  min-width: 210px;
  padding: 5px;
  margin: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 13px;
}
.person-height-control legend {
  grid-column: 1 / -1;
  padding: 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.person-height-button {
  min-height: 44px;
  padding: 8px 12px;
  color: var(--muted);
  background: var(--white);
  border: 0;
  border-radius: 9px;
  font-weight: 900;
}
.person-height-button.active { color: var(--white); background: var(--ink); }

.owner-hero-case { grid-column: 1 / -1; width: 100%; min-width: 0; }
.owner-hero-card {
  width: min(1100px, 100%);
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid #cfc7ba;
  border-radius: 15px;
}
.owner-hero-heading {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 16px 20px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.owner-hero-heading > div { display: flex; gap: 12px; align-items: center; }
.owner-hero-heading p { margin-bottom: 3px; color: var(--wood); font-size: 12px; font-weight: 900; letter-spacing: .08em; }
.owner-hero-heading h3 { margin: 0; font-size: clamp(19px, 1.7vw, 25px); }
.owner-hero-heading > strong { color: var(--blue); font-size: clamp(21px, 2vw, 29px); font-variant-numeric: tabular-nums; white-space: nowrap; }
.owner-hero-diagram { width: 100%; background: #fffdf8; }

.owner-comparison,
.tradeoff-section { padding: clamp(18px, 2vw, 28px); }

.comparison-heading {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 18px;
}
.comparison-heading h2 { font-size: clamp(21px, 2vw, 28px); }
.comparison-heading > p { max-width: 48ch; margin: 0; color: var(--muted); text-align: right; line-height: 1.6; }
.scale-note span {
  display: inline-block;
  width: 36px;
  height: 0;
  margin: 0 7px 3px 0;
  border-top: 3px solid var(--blue);
}

.owner-case-pairs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.owner-case-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
}
.owner-case-card.pair-left { grid-column: 1; grid-row: 1; }
.owner-case-card.pair-right { grid-column: 2; grid-row: 1; }
.owner-case-card {
  min-width: 0;
  overflow: hidden;
  background: var(--white);
  border: 1px solid #cfc7ba;
  border-radius: 14px;
  outline: 3px solid transparent;
  outline-offset: -3px;
}
.owner-case-card.active { outline-color: rgba(34, 111, 140, .52); }
.case-card-heading {
  display: flex;
  gap: 11px;
  align-items: center;
  min-height: 92px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
}
.case-letter {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  color: var(--white);
  background: var(--blue);
  border-radius: 50%;
  font-size: 24px;
  font-weight: 900;
}
.case-card-heading p { margin-bottom: 3px; color: var(--wood); font-size: 12px; font-weight: 900; letter-spacing: .08em; }
.case-card-heading h3 { margin: 0; font-size: clamp(16px, 1.35vw, 20px); line-height: 1.35; }

.case-diagram { background: #fffdf8; border-bottom: 1px solid var(--line); }
.owner-scale-svg { display: block; width: 100%; height: auto; aspect-ratio: 470 / 348; font-family: "Microsoft JhengHei", "Noto Sans TC", sans-serif; }
.owner-scale-svg .room-zone { fill: #f1ece3; }
.owner-scale-svg .balcony-zone { fill: #fffdf8; }
.owner-scale-svg .clearance-zone { fill: rgba(34, 111, 140, .045); stroke: rgba(34, 111, 140, .18); stroke-width: 1; }
.owner-scale-svg .game-room-occupation { fill: #bc7a42; fill-opacity: .16; }
.owner-scale-svg .floor-line { stroke: #26363a; stroke-width: 2; }
.owner-scale-svg .room-boundary { stroke: #226f8c; stroke-width: 2; stroke-dasharray: 7 5; }
.owner-scale-svg .zone-label { fill: #26363a; font-size: 13px; font-weight: 900; }
.owner-scale-svg .occupation-dimension { stroke: #bc7a42; stroke-width: 1.4; }
.owner-scale-svg .occupation-label { fill: #8b552c; font-size: 11px; font-weight: 900; paint-order: stroke; stroke: #fffdf8; stroke-width: 3px; stroke-linejoin: round; }
.owner-scale-svg .stair-body { fill: #f0dfce; stroke: #bc7a42; stroke-width: 2; stroke-linejoin: round; }
.owner-scale-svg .drawer-pull { stroke: #bc7a42; stroke-width: 2.5; stroke-linecap: round; }
.owner-scale-svg .box-step { fill: #d6a273; stroke: #bc7a42; stroke-width: 2; }
.owner-scale-svg .loft-board { fill: #bc7a42; stroke: #26363a; stroke-width: 1.5; }
.owner-scale-svg .launch-deck { stroke: #26363a; stroke-width: 5; stroke-linecap: square; }
.owner-scale-svg .slide-board-structure { fill: none; stroke: #bc7a42; stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.owner-scale-svg .slide-surface { fill: none; stroke: #226f8c; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.owner-scale-svg .slide-geometry { stroke: none; }
.owner-scale-svg .angle-label { fill: #226f8c; font-size: 14px; font-weight: 900; paint-order: stroke; stroke: #fffdf8; stroke-width: 4px; }
.owner-card-svg .card-angle-label { transform: translateY(8px); }
.owner-scale-svg .figure-adult { color: #26363a; }
.owner-scale-svg .figure-child { color: #718084; }
.owner-scale-svg .ruler-axis,
.owner-scale-svg .ruler-tick line { stroke: #718084; stroke-width: 1; }
.owner-scale-svg .ruler-tick text { fill: #718084; font-size: 8px; font-weight: 800; font-variant-numeric: tabular-nums; paint-order: stroke; stroke: #fffdf8; stroke-width: 3.5px; }
.owner-scale-svg .ruler-tick.active line { stroke: #26363a; stroke-width: 2.6; }
.owner-scale-svg .ruler-tick.active text { fill: #26363a; font-size: 9px; font-weight: 900; }

.case-metrics {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin: 0;
  padding: 8px 14px 12px;
}
.case-metrics > div { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 12px; align-items: baseline; min-width: 0; padding: 10px 0; border-top: 1px solid var(--line); }
.case-metrics > div:first-child { border-top: 0; }
.case-metrics dt { color: var(--muted); font-size: 11px; font-weight: 800; line-height: 1.45; }
.case-metrics dd { display: flex; justify-content: flex-end; min-width: 0; gap: 4px; align-items: baseline; margin: 0; font-variant-numeric: tabular-nums; }
.case-metrics dd strong { min-width: 0; font-size: clamp(28px, 1.7vw, 32px); line-height: 1; letter-spacing: -.045em; white-space: nowrap; }
.case-metrics dd span { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.case-metrics small { grid-column: 1 / -1; display: block; color: var(--muted); font-size: 10px; line-height: 1.45; text-align: right; }

.lowering-note {
  grid-column: 1 / -1;
  grid-row: 2;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 13px 15px;
  color: #254c5b;
  background: #e3eff2;
  border: 1px solid #bfd6de;
  border-radius: 11px;
  line-height: 1.65;
}
.lowering-note strong { color: var(--blue); white-space: nowrap; }

.owner-table-wrap { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; }
.owner-tradeoff-table { font-size: 14px; }
.owner-tradeoff-table th,
.owner-tradeoff-table td { padding: 15px 16px; }
.owner-tradeoff-table thead th { color: var(--white); background: var(--ink); border-color: var(--ink); }
.owner-tradeoff-table tbody th { width: 28%; text-align: left; font-weight: 800; }
.owner-tradeoff-table tbody th > span {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-right: 10px;
  color: var(--white);
  background: var(--blue);
  border-radius: 50%;
  font-size: 16px;
}
.owner-tradeoff-table tbody th small { display: block; margin: 4px 0 0 42px; color: var(--wood); font-size: 11px; }
.owner-tradeoff-table td strong { font-size: 20px; font-variant-numeric: tabular-nums; }

.owner-boundary { display: flex; gap: 12px; padding: 16px 20px; color: var(--muted); line-height: 1.65; }
.owner-boundary strong { color: var(--ink); white-space: nowrap; }

.site-reference { padding: 0; overflow: hidden; }
.site-reference > summary { padding: 16px 20px; color: var(--blue); }
.reference-copy { padding: 0 20px 15px; color: #435154; }
.reference-copy p { margin: 6px 0 0; line-height: 1.65; }
.reference-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 0 20px 20px; }
.reference-photos figure { margin: 0; overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; }
.reference-photos img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.reference-photos figcaption { padding: 8px 10px; color: var(--muted); font-size: 11px; }

.app-shell {
  display: grid;
  grid-template-columns: minmax(270px, 320px) minmax(520px, 1fr) minmax(250px, 300px);
  gap: 18px;
  align-items: start;
  max-width: 1760px;
  margin: 0 auto;
  padding: 22px clamp(14px, 2vw, 30px) 36px;
}

.controls, .inspector, .model-panel, .drawing-panel, .detail-panel, .variants-panel {
  background: rgba(255, 253, 248, .96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.controls, .inspector { position: static; }
.control-title { display: flex; justify-content: space-between; align-items: center; padding: 17px 18px; border-bottom: 1px solid var(--line); }
.control-title > div { display: grid; gap: 3px; }
.label { color: var(--muted); font-size: 12px; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 5px rgba(170, 107, 20, .12); }
.status-dot.good { background: var(--green); box-shadow: 0 0 0 5px rgba(63, 124, 93, .12); }
.status-dot.bad { background: var(--red); box-shadow: 0 0 0 5px rgba(163, 67, 56, .12); }
.mobile-jump { display: none; width: calc(100% - 36px); min-height: 42px; margin: 13px 18px; color: var(--blue); background: var(--blue-soft); border: 0; border-radius: 9px; font-weight: 700; }

details { border-bottom: 1px solid var(--line); }
details:last-child { border-bottom: 0; }
summary { padding: 14px 18px; font-weight: 700; cursor: pointer; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; padding: 0 18px 16px; }
.field-grid label { display: grid; grid-template-columns: 1fr auto; gap: 5px; color: var(--muted); font-size: 12px; }
.field-grid label.wide { grid-column: 1 / -1; }
.field-grid input, .field-grid select {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 39px;
  padding: 7px 9px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid #aebfc4;
  border-radius: 8px;
}
.field-grid input[type="range"] { min-height: 28px; padding: 0; accent-color: var(--blue); }
.primary-field { font-size: 14px !important; font-weight: 800; }
.primary-field input[type="number"] { min-height: 48px; font-size: 20px; font-weight: 800; }
.primary-field output { color: var(--blue); font-size: 18px; font-weight: 900; }
.fixed-slide-assumptions {
  display: grid;
  gap: 5px;
  margin: 0 18px 13px;
  padding: 12px 13px;
  color: #435154;
  background: var(--blue-soft);
  border-radius: 9px;
  font-size: 12px;
  line-height: 1.55;
}
.fixed-slide-assumptions strong { color: var(--blue); }
.check { display: flex; gap: 8px; align-items: center; padding: 0 18px 17px; color: var(--muted); }
.check input { width: 18px; height: 18px; accent-color: var(--blue); }
.field-note { padding: 0 18px 16px; margin-bottom: 0; color: var(--muted); font-size: 12px; }

.workspace { min-width: 0; max-width: 100%; display: grid; gap: 18px; }
.live-summary {
  min-height: 52px;
  display: flex;
  align-items: center;
  padding: 13px 18px;
  color: var(--white);
  background: var(--ink);
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.model-panel, .drawing-panel, .detail-panel, .variants-panel { padding: 18px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-bottom: 14px; }
.panel-heading .eyebrow { margin-bottom: 2px; }
#drawingWrap { min-height: 440px; overflow: hidden; background: linear-gradient(180deg, rgba(220, 236, 241, .55), rgba(255, 253, 248, .15)); border-radius: 10px; }
#sectionDrawing { display: block; width: 100%; min-height: 440px; }

.model-stage {
  position: relative;
  min-height: 480px;
  overflow: hidden;
  background: linear-gradient(180deg, #eef3f1, #f8f1e5);
  border: 1px solid var(--line);
  border-radius: 10px;
}
#model3d { display: block; width: 100%; min-height: 480px; touch-action: none; cursor: grab; }
#model3d:active { cursor: grabbing; }
.model-direction {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 42px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 9px 13px;
  color: var(--ink);
  background: rgba(255, 253, 248, .88);
  border: 1px solid rgba(215, 208, 196, .9);
  border-radius: 9px;
  backdrop-filter: blur(5px);
  pointer-events: none;
}
.model-direction b:last-child { text-align: right; }
.model-direction span { color: var(--red); font-weight: 900; }
.model-help {
  position: absolute;
  right: 15px;
  bottom: 13px;
  color: var(--muted);
  font-size: 11px;
  pointer-events: none;
}

.result-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.metric { container-type: inline-size; min-width: 0; min-height: 118px; padding: 16px; overflow: hidden; background: rgba(255, 253, 248, .93); border: 1px solid var(--line); border-radius: 12px; }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; max-width: 100%; margin: 7px 0 4px; color: var(--ink); font-size: clamp(22px, 18cqw, 36px); line-height: 1.05; letter-spacing: -.045em; white-space: nowrap; }
.metric small { display: block; color: var(--muted); line-height: 1.45; }

.engineering-details { padding: 0; }
.engineering-details > summary { color: var(--blue); font-size: 15px; }
.engineering-details-content { padding: 0 18px 18px; }

.table-wrap { width: 100%; min-width: 0; max-width: 100%; overflow-x: auto; }
.detail-panel, .variants-panel, .drawing-panel { min-width: 0; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { color: var(--muted); text-align: left; font-size: 12px; }
th, td { padding: 10px 9px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td:nth-child(2) { font-variant-numeric: tabular-nums; font-weight: 700; }
.panel-copy { color: var(--muted); font-size: 13px; }
.tag { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.tag.good { color: var(--green); background: rgba(63, 124, 93, .12); }
.tag.warn { color: var(--amber); background: rgba(170, 107, 20, .12); }
.tag.bad { color: var(--red); background: rgba(163, 67, 56, .12); }
.apply-variant { min-height: 32px; padding: 5px 9px; color: var(--blue); background: transparent; border: 1px solid var(--blue); border-radius: 8px; font-weight: 700; }

.inspector { padding: 18px; }
.inspector h2 { margin-bottom: 13px; font-size: 27px; }
.inspector-section { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--line); }
.warning { display: grid; grid-template-columns: 9px 1fr; gap: 9px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.warning:last-child { border-bottom: 0; }
.warning::before { content: ""; width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--amber); }
.warning.good::before { background: var(--green); }
.warning.bad::before { background: var(--red); }
.transition-number { display: block; margin: 5px 0; font-size: 30px; font-weight: 700; letter-spacing: -.04em; }
.transition-copy { color: var(--muted); line-height: 1.7; }
.action-stack { display: grid; gap: 8px; }
.action-stack .button { width: 100%; }
.file-button { display: flex; justify-content: center; align-items: center; cursor: pointer; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.disclaimer { padding: 14px; margin-top: 18px; color: var(--muted); background: var(--paper-deep); border-radius: 10px; font-size: 12px; line-height: 1.6; }
.disclaimer strong { color: var(--ink); }
.disclaimer p { margin: 5px 0 0; }

footer { display: flex; justify-content: space-between; gap: 20px; padding: 17px clamp(18px, 3.5vw, 54px); color: var(--muted); background: var(--paper-deep); border-top: 1px solid var(--line); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.mobile-route-summary,
.mobile-actionbar { display: none; }

@media (min-width: 1241px) and (min-height: 900px) {
  .inspector {
    position: sticky;
    top: 14px;
    max-height: calc(100dvh - 28px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
  }
}

@media (pointer: coarse) {
  button,
  select,
  input { min-height: 44px; }
  .preset { min-height: 68px; }
}

@media (max-width: 1240px) {
  .owner-dashboard { grid-template-columns: minmax(0, 1fr); }
  .owner-case-pairs { grid-template-columns: minmax(0, 1fr); }
  .app-shell { grid-template-columns: minmax(270px, 310px) minmax(0, 1fr); }
  .inspector { position: static; grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
  .inspector-section { padding-top: 0; margin-top: 0; border-top: 0; }
  .disclaimer { margin-top: 0; }
  .result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .owner-dashboard { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .app-header { align-items: flex-start; flex-direction: column; padding-block: 17px 12px; }
  .app-header h1 { font-size: clamp(25px, 7.2vw, 30px); line-height: 1.24; }
  .app-header .subhead { max-width: 34em; font-size: 13px; line-height: 1.55; }
  .owner-mode #resetScheme,
  .owner-mode #printPlan { display: none; }
  .header-actions { width: 100%; }
  .mode-switch { width: 100%; }
  .mode-button { flex: 1; }
  .header-actions .button { flex: 1; }
  .preset-strip {
    grid-template-columns: repeat(4, minmax(42vw, 158px));
    overflow-x: auto;
    padding-inline: max(10px, env(safe-area-inset-left));
    scroll-snap-type: x mandatory;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
  }
  .preset-strip::-webkit-scrollbar { display: none; }
  .preset { min-height: 68px; padding: 12px 14px; scroll-snap-align: center; }
  .app-shell { display: flex; flex-direction: column; padding-inline: 12px; }
  .controls, .inspector { position: static; width: 100%; }
  .mobile-jump { display: block; }
  .workspace { width: 100%; min-width: 0; max-width: 100%; overflow: hidden; }
  .controls details:not([open]) { display: block; }
  .model-panel, .drawing-panel, .detail-panel, .variants-panel { padding: 14px; }
  .model-stage, #model3d { min-height: 430px; }
  .model-direction { left: 10px; right: 10px; grid-template-columns: 1fr; gap: 3px; bottom: 42px; }
  .model-direction b:last-child { text-align: left; }
  #drawingWrap, #sectionDrawing { min-height: 390px; }
  .inspector { display: block; }
  .inspector-section { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--line); }
  .disclaimer { margin-top: 18px; }
  .variant-table { min-width: 760px; }
  footer { flex-direction: column; gap: 4px; }
  .owner-dashboard { padding: 12px 10px 28px; }
  .owner-intro { grid-template-columns: minmax(0, 1fr); align-items: flex-start; gap: 18px; padding: 20px 18px; }
  .person-height-control { width: 100%; min-width: 0; }
  .owner-hero-case { grid-column: 1; }
  .comparison-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .comparison-heading > p { text-align: left; }
  .reference-photos { grid-template-columns: 1fr; }
  .mobile-actionbar {
    position: fixed;
    z-index: 200;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: .9fr 1.1fr;
    gap: 8px;
    padding: 8px max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    background: rgba(246, 243, 236, .96);
    border-top: 1px solid var(--line);
    box-shadow: 0 -10px 28px rgba(50, 42, 31, .1);
  }
  .mobile-action {
    min-height: 46px;
    padding: 9px 12px;
    color: var(--white);
    background: var(--blue);
    border: 1px solid var(--blue);
    border-radius: 11px;
    font-weight: 900;
  }
  .mobile-action.secondary { color: var(--blue); background: var(--white); }
}

@media (max-width: 560px) {
  .preset-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: visible;
    padding-inline: 10px;
    scroll-snap-type: none;
    overscroll-behavior-inline: auto;
  }
  .preset { min-width: 0; padding: 10px 12px; scroll-snap-align: none; }
  .preset span { font-size: 12px; line-height: 1.35; }
  .preset strong { font-size: 15px; line-height: 1.35; }
}

@media (max-width: 480px) {
  .field-grid { grid-template-columns: 1fr; }
  .field-grid label.wide { grid-column: auto; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 110px; padding: 12px; }
  .metric strong { font-size: clamp(22px, 18cqw, 31px); }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .live-summary { font-size: 14px; }
  .owner-comparison,
  .tradeoff-section { padding: 16px 10px; }
  .owner-hero-heading { align-items: flex-start; flex-direction: column; gap: 10px; padding: 14px; }
  .owner-hero-heading > strong { white-space: normal; }
  .owner-case-pair { grid-template-columns: minmax(0, 1fr); }
  .owner-case-card.pair-left { grid-column: 1; grid-row: 1; }
  .lowering-note { grid-column: 1; grid-row: 2; grid-template-columns: 1fr; gap: 3px; font-size: 14px; }
  .owner-case-card.pair-right { grid-column: 1; grid-row: 3; }
  .case-card-heading { min-height: 82px; }
  .case-metrics { grid-template-columns: minmax(0, 1fr); }
  .case-metrics > div { padding-inline: 0; }
  .case-metrics dd strong { font-size: 30px; }
  .owner-boundary { align-items: flex-start; flex-direction: column; gap: 4px; }
  .owner-boundary strong { white-space: normal; }
  .owner-table-wrap { overflow: visible; border: 0; }
  .owner-tradeoff-table,
  .owner-tradeoff-table tbody,
  .owner-tradeoff-table tr,
  .owner-tradeoff-table th,
  .owner-tradeoff-table td { display: block; width: 100%; }
  .owner-tradeoff-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .owner-tradeoff-table tr { overflow: hidden; margin-bottom: 10px; background: var(--white); border: 1px solid var(--line); border-radius: 12px; }
  .owner-tradeoff-table tbody th { padding-bottom: 11px; background: var(--paper); }
  .owner-tradeoff-table td { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding-block: 11px; text-align: right; }
  .owner-tradeoff-table td::before { content: attr(data-label); color: var(--muted); text-align: left; font-size: 12px; font-weight: 800; }
}

@media (max-width: 350px) {
  .result-grid { grid-template-columns: 1fr; }
  .metric { min-height: 96px; }
  .metric strong { font-size: 30px; }
}

@media (max-height: 640px) {
  .inspector { position: static !important; max-height: none; overflow: visible; }
}

@media print {
  body { background: #fff; }
  .app-header, .preset-strip, .controls, .header-actions, .view-switch, .variants-panel, .action-stack, .mobile-actionbar, footer { display: none !important; }
  .app-shell { display: block; max-width: none; padding: 0; }
  .workspace { display: block; }
  .drawing-panel, .detail-panel, .inspector { box-shadow: none; border: 1px solid #bbb; break-inside: avoid; margin-bottom: 12px; }
  .inspector { display: block; }
  .live-summary { color: #000; background: #eee; margin-bottom: 12px; }
  .owner-dashboard { display: block !important; padding: 0; }
  .owner-intro,
  .owner-comparison,
  .tradeoff-section,
  .owner-boundary { break-inside: avoid; margin-bottom: 12px; }
  .site-reference { display: none; }
}

/* === 業主模式：即時調整滑桿（高度 / 斜度） === */
.owner-live-controls {
  margin-top: 20px;
  padding: 18px 20px 20px;
  border: 1px solid #e2ded3;
  border-radius: 14px;
  background: #fffdf8;
  display: grid;
  gap: 16px;
}
.owner-live-controls .live-controls-hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: #718084;
}
.owner-slider { display: grid; gap: 8px; }
.owner-slider label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  font-weight: 700;
  color: #26363a;
}
.owner-slider output {
  font-size: 22px;
  font-weight: 900;
  color: #226f8c;
  font-variant-numeric: tabular-nums;
}
.owner-slider input[type="range"] {
  width: 100%;
  accent-color: #226f8c;
  height: 26px;
  cursor: pointer;
}
.owner-slider .slider-ends {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #9aa5a7;
}
.owner-live-readout {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid #ece8dd;
}
.owner-live-fact { display: grid; gap: 3px; }
.owner-live-fact span { font-size: 12px; color: #718084; }
.owner-live-fact strong {
  font-size: 19px;
  font-weight: 900;
  color: #26363a;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 560px) {
  .owner-live-readout { grid-template-columns: 1fr; gap: 8px; }
  .owner-live-fact { grid-template-columns: 1fr auto; align-items: baseline; }
  .owner-slider input[type="range"] { height: 34px; }
}

/* 四個數字＋工法護欄 */
.owner-live-fact small { font-size: 11px; color: #9aa5a7; line-height: 1.5; }
.owner-live-readout { grid-template-columns: repeat(4, 1fr); }
.owner-build-issues { display: grid; gap: 6px; }
.build-issue {
  margin: 0;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 13px;
  line-height: 1.6;
  border-left: 4px solid;
}
.build-issue.ok   { background: #eef5f0; border-color: #3f7c5d; color: #2c5a43; }
.build-issue.warn { background: #fdf4e3; border-color: #aa6b14; color: #7d4f0f; }
.build-issue.bad  { background: #fbeceb; border-color: #a34338; color: #7c332b; }
@media (max-width: 900px) { .owner-live-readout { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .owner-live-readout { grid-template-columns: 1fr; } }

/* === 手機：老婆要一邊拉滑桿一邊看圖，所以圖要釘住不能捲走 === */
@media (max-width: 620px) {
  /* 上方說明在手機上太佔位，收起來 */
  .owner-intro > div > p { display: none; }
  .owner-intro h2 { font-size: 20px; line-height: 1.35; }
  .owner-intro { gap: 12px; padding: 14px 12px; }
  .person-height-control { grid-template-columns: auto repeat(2, 1fr); align-items: center; min-width: 0; }
  .person-height-control legend { grid-column: auto; }
  .person-height-button { min-height: 38px; font-size: 14px; }

  /* 圖釘在畫面上方，滑桿在下面拉的時候看得到 */
  .owner-hero-case {
    position: sticky;
    top: 0;
    z-index: 5;
    padding-bottom: 6px;
    background: var(--white);
    box-shadow: 0 8px 12px -8px rgba(50, 42, 31, .28);
  }
  .owner-hero-heading { padding: 9px 12px; }
  .owner-hero-heading h3 { font-size: 16px; }
  .owner-hero-heading p { font-size: 11px; }
  .owner-hero-heading > strong { font-size: 15px; }

  /* 四個數字排成兩排兩個，不要拉成長長一條 */
  .owner-live-readout { grid-template-columns: 1fr 1fr; gap: 12px 10px; }
  .owner-live-fact { grid-template-columns: 1fr; }
  .owner-live-fact strong { font-size: 21px; }

  .owner-live-controls { padding: 14px 12px 16px; }
  .live-controls-hint { font-size: 12px; }
  .owner-slider label { font-size: 13px; }
  .owner-slider output { font-size: 20px; }
}

/* === 貼在母圖上的滑梯 === */
.owner-hero-toggle {
  display: flex;
  gap: 6px;
  padding: 10px 14px 0;
  background: var(--white);
}
.hero-view-button {
  flex: 1;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 800;
  font-size: 14px;
}
.hero-view-button.active { color: var(--white); background: var(--ink); border-color: var(--ink); }
.master-photo-svg { display: block; width: 100%; height: auto; }
.master-photo-svg .photo-veil { fill: #fffdf8; opacity: .3; }
.master-photo-svg .photo-slide-structure { fill: none; stroke: #7c4a18; stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.master-photo-svg .photo-slide-surface { fill: none; stroke: #e29a45; stroke-width: 5.5; stroke-linecap: round; stroke-linejoin: round; }
.master-photo-svg .game-room-occupation { fill: #bc7a42; opacity: .3; }
.master-photo-svg .figure-adult, .master-photo-svg .figure-child { color: #26363a; }
.master-photo-svg .figure-child { color: #6d7c80; }
.master-photo-svg .photo-boundary { stroke: #226f8c; stroke-width: 4; stroke-dasharray: 16 12; }
.master-photo-svg .photo-label { fill: #26363a; font-size: 36px; font-weight: 900; paint-order: stroke; stroke: #fffdf8; stroke-width: 7px; }
.master-photo-svg .photo-occupation-label { fill: #8a5620; font-size: 36px; font-weight: 900; paint-order: stroke; stroke: #fffdf8; stroke-width: 7px; }
@media (max-width: 620px) {
  .owner-hero-toggle { padding: 8px 10px 0; }
  .hero-view-button { font-size: 12px; min-height: 36px; padding: 6px 6px; }
  /* 照片縮到手機寬度後字會變超小，字級要放大回來 */
  .master-photo-svg .photo-label,
  .master-photo-svg .photo-occupation-label { font-size: 68px; stroke-width: 13px; }
  .master-photo-svg .photo-boundary { stroke-width: 7; stroke-dasharray: 26 18; }
  .master-photo-svg .photo-slide-structure { stroke-width: 13; }
  .master-photo-svg .photo-slide-surface { stroke-width: 8; }
}

.derived-start {
  margin: -4px 0 0;
  padding: 10px 12px;
  background: var(--blue-soft);
  border-radius: 9px;
  font-size: 14px;
  line-height: 1.6;
  color: #1c5266;
}
.derived-start b { font-size: 17px; font-variant-numeric: tabular-nums; }

.recommend-button { justify-self: start; min-height: 38px; padding: 7px 16px; font-size: 14px; }
.owner-live-readout { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .owner-live-readout { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .owner-live-readout { grid-template-columns: 1fr 1fr; } }

.band-readout {
  margin: 4px 0 0;
  padding: 9px 11px;
  background: var(--paper);
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted);
}
.band-readout b { color: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; }

.section-row td {
  padding-top: 16px !important;
  color: var(--blue);
  font-weight: 900;
  font-size: 13px;
  letter-spacing: .06em;
  background: var(--paper);
}

/* === 俯視圖 === */
#drawingWrap { padding: 10px; min-height: 0 !important; background: var(--white); border-radius: 12px; }
.plan-svg, .width-svg { max-height: 62vh; }
.plan-svg, .width-svg { display: block; width: 100%; height: auto; }
.plan-svg .plan-stair { fill: #f0dfce; stroke: #bc7a42; stroke-width: 1.6; }
.plan-svg .plan-platform { fill: #e6d0b6; stroke: #bc7a42; stroke-width: 1.6; }
.plan-svg .plan-boxstep { fill: #d0aa7c; stroke: #8a5620; stroke-width: 1.6; }
.plan-svg .plan-tread { stroke: #bc7a42; stroke-width: 1; opacity: .75; }
.plan-svg .plan-chute { fill: #e6b878; stroke: #8a5620; stroke-width: 1.6; }
.plan-svg .plan-siderail { stroke: #7c4a18; stroke-width: 2.6; }
.plan-svg .plan-seat { fill: #cfe3ea; stroke: #226f8c; stroke-width: 1.6; }
.plan-svg .plan-loft { fill: #dcecf1; stroke: #226f8c; stroke-width: 1.6; }
.plan-svg .plan-bed { fill: none; stroke: #226f8c; stroke-width: 1.2; stroke-dasharray: 5 4; }
.plan-svg .plan-buffer { fill: #bc7a42; opacity: .22; }
.plan-svg .plan-wall { stroke: #26363a; stroke-width: 4; }
.plan-svg .plan-boundary { stroke: #226f8c; stroke-width: 2; stroke-dasharray: 7 5; }
.plan-svg .plan-dim { stroke: #8a5620; stroke-width: 1; }
.plan-svg .plan-dim.room { stroke: #a34338; }
.plan-svg text { font-family: "Microsoft JhengHei", "Noto Sans TC", sans-serif; paint-order: stroke; stroke: #fffdf8; stroke-width: 3px; }
.plan-svg .plan-label { fill: #26363a; font-size: 11px; font-weight: 800; }
.plan-svg .plan-zone { fill: #26363a; font-size: 13px; font-weight: 900; }
.plan-svg .plan-small { fill: #718084; font-size: 9px; font-weight: 700; }
.plan-svg .plan-small.room { fill: #a34338; }
.width-svg .w-stair { fill: #f0dfce; stroke: #bc7a42; stroke-width: .6; }
.width-svg .w-chute { fill: #e6b878; stroke: #8a5620; stroke-width: .6; }
.width-svg .w-panel { fill: #7c4a18; }
.width-svg .w-gap { fill: #e2ded3; }
.width-svg text { font-family: "Microsoft JhengHei", sans-serif; paint-order: stroke; stroke: #fffdf8; stroke-width: 2px; }
.width-svg .w-name { fill: #26363a; font-size: 7px; font-weight: 800; }
.width-svg .w-num { fill: #26363a; font-size: 9px; font-weight: 900; }
.width-svg .w-title { fill: #26363a; font-size: 9px; font-weight: 900; }
.width-svg .w-note { fill: #718084; font-size: 7px; font-weight: 700; }

.field-note.delegated { padding: 11px 13px; background: var(--blue-soft); border-radius: 9px; color: #1c5266; line-height: 1.75; }
.field-note.delegated b { color: #0f3a4a; }
