:root {
  --bg: #f6f5f1; --panel: #ffffff; --ink: #1d2433; --muted: #667085; --line: #d9dce3; --accent: #1f5fbf; --accent-ink: #fff;
  --room: #fbfaf6; --wall: #3c4454; --wet: #e8f1f8; --sel: #e8742a; --danger: #b42318; --ok: #18794e; --warn-bg: #fff6e5;
  --light: #c58b00; --outlet: #b42318; --switch: #1d2433; --panel-dev: #1d2433;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171d; --panel: #1c2028; --ink: #e6e8ee; --muted: #9aa3b2; --line: #343a46; --accent: #6ea8ff; --accent-ink: #0d1117;
    --room: #20252e; --wall: #aab3c5; --wet: #1d2c3a; --warn-bg: #3a2f17; --light: #f2c14e; --outlet: #ff8a80; --switch: #e6e8ee; --panel-dev: #e6e8ee;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; background: var(--bg); color: var(--ink); }
header { display: flex; align-items: center; gap: 16px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
header h1 { font-size: 18px; margin: 0; }
header a { color: var(--accent); font-size: 14px; }
header .spacer { flex: 1; }
main { display: grid; grid-template-columns: 300px 1fr; gap: 0; min-height: calc(100vh - 56px); }
aside { background: var(--panel); border-right: 1px solid var(--line); padding: 14px; overflow-y: auto; max-height: calc(100vh - 56px); }
aside h2 { font-size: 15px; margin: 18px 0 8px; display: flex; gap: 8px; align-items: center; }
aside h2 span { background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 1px 8px; font-size: 12px; }
aside h3 { font-size: 14px; margin: 4px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
button, .btn { font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .btn:hover { border-color: var(--accent); }
button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; padding: 9px 14px; }
button.danger { color: var(--danger); margin-top: 8px; }
button:disabled { opacity: .5; cursor: wait; }
label { display: block; font-size: 13px; margin: 6px 0; color: var(--muted); }
label input, label select { display: block; width: 100%; margin-top: 3px; padding: 6px; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 6px 0; }
.note { color: var(--muted); font-size: 12px; }
#selbox { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-top: 14px; background: var(--bg); }
.stage { position: relative; display: flex; flex-direction: column; min-width: 0; }
.tabs { display: flex; gap: 4px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.tabs button { border-radius: 6px 6px 0 0; border-bottom: none; }
.view { flex: 1; overflow: auto; padding: 12px; }
.view[hidden] { display: none; }
svg.plan { width: 100%; height: calc(100vh - 140px); min-height: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; touch-action: none; user-select: none; }
svg.plan[data-tool="device"], svg.plan[data-tool="door"], svg.plan[data-tool="window"] { cursor: crosshair; }
.grid line { stroke: var(--line); stroke-width: 8; }
.room rect:first-child { fill: var(--room); stroke: var(--wall); stroke-width: 90; cursor: move; }
.room.wet rect:first-child { fill: var(--wet); }
.room.sel rect:first-child { stroke: var(--sel); }
.room .handle { fill: var(--sel); opacity: .0; cursor: nwse-resize; }
.room.sel .handle, .room:hover .handle { opacity: .8; }
.rname { font-size: 300px; text-anchor: middle; fill: var(--ink); pointer-events: none; font-weight: 600; }
.rsize { font-size: 210px; text-anchor: middle; fill: var(--muted); pointer-events: none; }
.door rect, .window rect { fill: var(--panel); stroke: none; cursor: pointer; }
.window rect { fill: #9cc3e6; }
.door.sel rect, .window.sel rect { fill: var(--sel); }
.leaf { stroke: var(--ink); stroke-width: 40; }
.swing { fill: none; stroke: var(--muted); stroke-width: 18; stroke-dasharray: 60 50; }
.dev { cursor: grab; color: var(--ink); }
.dev.light { color: var(--light); }
.dev.outlet { color: var(--outlet); }
.dev .hit { fill: transparent; stroke: none; }
.dev.sel { color: var(--sel); }
.symg, .hexa, svg.sym { stroke: currentColor; }
svg.sym .fill, .symg .fill { fill: currentColor; stroke: none; }
svg.sym .paper, .symg .paper, .hexa .paper { fill: var(--panel); }
svg.sym .thick, .symg .thick { stroke-width: 40; }
.symtext { font-size: 150px; text-anchor: middle; fill: currentColor; stroke: none; font-weight: 700; }
.symtext.small { font-size: 120px; }
.symtext.two { font-size: 112px; letter-spacing: -6px; }
.hexa { color: var(--ink); }
button.devbtn { display: inline-flex; align-items: center; gap: 4px; }
button.devbtn svg.sym { width: 22px; height: 22px; flex: none; }
button.devbtn svg.sym.hexa { width: 22px; height: 18px; }
button.devbtn.on svg.sym .paper { fill: var(--accent); }
.overlay polyline { fill: none; stroke-width: 45; opacity: .8; pointer-events: none; }
.overlay .floor { stroke-dasharray: 160 80; }
.sheet { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 4px; }
.sheet svg { width: 100%; height: auto; display: block; }
table { border-collapse: collapse; width: 100%; font-size: 13px; background: var(--panel); }
th, td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; }
th { background: var(--bg); }
td.n { text-align: right; white-space: nowrap; }
tr.sum td { font-weight: 700; }
.bad { color: var(--danger); font-weight: 600; }
.okc { color: var(--ok); }
ul.warn { background: var(--warn-bg); border-radius: 8px; padding: 10px 10px 10px 28px; font-size: 13px; line-height: 1.6; }
p.ok { color: var(--ok); }
.quote-big { font-size: 26px; font-weight: 700; margin: 6px 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.notice { background: var(--warn-bg); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; }
.files a { margin: 0 6px 6px 0; }
.busy::after { content: " …"; }
@media (max-width: 860px) {
  main { grid-template-columns: 1fr; }
  aside { max-height: none; border-right: none; border-bottom: 1px solid var(--line); }
  svg.plan { height: 60vh; }
}
