/* 도면 그리기 편집기 — 토큰만(design-tokens.css). 위 56px · 왼쪽 72px 줄 · 도구 패널 280px · 캔버스 · 오른쪽 268px. 아이콘 없이 글자 위계와 1px 선으로. 폰(≤768px)은 도구 패널이 아래 시트, 오른쪽 패널은 접힘, 중간 폭(769~1023px)은 위 바 메뉴를 접고 칸을 좁힘 */
:root { --t-fast: 100ms; --t-base: 200ms; --t-slow: 350ms; --ease: cubic-bezier(.645, .045, .355, 1); --ed-top: 56px; --ed-rail: 72px; --ed-panel: 280px; --ed-side: 268px; --ed-edge: 24px; }   /* 시간 토큰은 shell.css 와 같은 값 */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body.pl { margin: 0; overflow: hidden; background: var(--c-surface); color: var(--c-ink); font-family: var(--font-sans); font-size: var(--fs-3); line-height: var(--lh-3); word-break: keep-all; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.ed-vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ed-skip { position: absolute; left: var(--sp-2); top: var(--sp-2); z-index: 60; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-1); background: var(--c-surface); border: 1px solid var(--c-accent); color: var(--c-accent); transform: translateY(-200%); }
.ed-skip:focus { transform: none; }
:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }

/* 전체 격자 */
.ed-app { display: grid; height: 100dvh; grid-template-columns: var(--ed-rail) var(--ed-panel) minmax(0, 1fr) var(--ed-side); grid-template-rows: var(--ed-top) auto minmax(0, 1fr); grid-template-areas: "top top top top" "rail panel stage props" "rail panel stage side"; transition: grid-template-columns var(--t-base) var(--ease); }
.ed-app.no-panel { --ed-panel: 0px; }
.ed-app.no-side { --ed-side: 0px; }
.ed-app.no-panel .ed-panel, .ed-app.no-side .ed-side, .ed-app.no-side .ed-props { visibility: hidden; }

/* 단추 */
.ed-b { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 var(--sp-3); border: 1px solid var(--c-line-strong); border-radius: var(--r-1); background: var(--c-surface); color: var(--c-ink); font-size: var(--fs-3); font-weight: var(--fw-semi); white-space: nowrap; cursor: pointer; transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.ed-b.ghost { border-color: transparent; background: transparent; }
.ed-b.primary { border-color: var(--c-accent); background: var(--c-accent); color: var(--c-surface); font-weight: var(--fw-bold); }
.ed-b.wide { width: 100%; }
.ed-b:disabled { color: var(--c-ink-faint); cursor: default; }
.ed-b.primary:disabled { background: var(--c-line-strong); border-color: var(--c-line-strong); color: var(--c-ink-sub); }
@media (hover: hover) { .ed-b:not(:disabled):hover { background: var(--c-surface-sub); border-color: var(--c-control); } .ed-b.primary:not(:disabled):hover { background: var(--c-accent); border-color: var(--c-accent); opacity: .9; } }
.ed-x { width: 36px; height: 36px; border: 0; border-radius: var(--r-1); background: transparent; color: var(--c-ink-sub); font-size: var(--fs-1); line-height: 1; cursor: pointer; }
.ed-k { min-width: 22px; padding: 1px var(--sp-1); border: 1px solid var(--c-line); border-radius: var(--r-1); background: var(--c-surface); color: var(--c-ink-sub); font: inherit; font-size: var(--fs-4); line-height: var(--lh-4); text-align: center; }
.ed-small-only { display: none !important; }

/* 위 바 */
.ed-top { grid-area: top; display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-4) 0 0; border-bottom: 1px solid var(--c-line); background: var(--c-surface); position: relative; z-index: 12; }
.ed-logo { display: grid; place-items: center; flex: none; width: var(--ed-rail); height: 100%; border-right: 1px solid var(--c-line); }
.ed-logo img { display: block; height: 20px; width: auto; }
.ed-hist { display: flex; gap: var(--sp-1); }
.ed-title { flex: 0 1 220px; min-width: 96px; height: 36px; margin-left: var(--sp-2); padding: 0 var(--sp-2); border: 1px solid transparent; border-radius: var(--r-1); background: transparent; font-size: var(--fs-2); font-weight: var(--fw-bold); color: var(--c-ink); text-overflow: ellipsis; transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease); }
@media (hover: hover) { .ed-title:hover { border-color: var(--c-line-strong); } }
.ed-title:focus { border-color: var(--c-accent); background: var(--c-surface); outline: none; }
.ed-menu { display: flex; align-items: center; gap: var(--sp-1); margin: 0 auto; }
.ed-more { display: none; margin-left: auto; }
.ed-ss { max-width: 9em; margin-left: auto; overflow: hidden; text-overflow: ellipsis; font-size: var(--fs-4); line-height: var(--lh-4); color: var(--c-ink-sub); text-align: right; white-space: nowrap; }
.ed-more + .ed-menu + .ed-ss { margin-left: 0; }
.ed-ss[data-s="dirty"] { color: var(--c-up); font-weight: var(--fw-semi); }

/* 왼쪽 줄·도구 패널 */
.ed-rail { grid-area: rail; display: flex; flex-direction: column; border-right: 1px solid var(--c-line); background: var(--c-surface); overflow: hidden auto; }
.ed-rb { display: grid; place-items: center; flex: none; width: 100%; height: 56px; padding: 0 var(--sp-1); border: 0; border-left: 2px solid transparent; background: transparent; color: var(--c-ink-sub); font-size: var(--fs-4); line-height: var(--lh-4); font-weight: var(--fw-semi); text-align: center; cursor: pointer; transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.ed-rb:nth-last-child(2) { margin-top: var(--sp-4); border-top: 1px solid var(--c-line); }   /* 설계형 라이브러리부터는 한 줄 띄워 묶는다 */
.ed-rb.on { border-left-color: var(--c-accent); background: var(--c-accent-bg); color: var(--c-accent); font-weight: var(--fw-bold); }
.ed-rb:focus-visible { outline-offset: -2px; }   /* 줄이 overflow 상자라 바깥 링은 잘린다(첫 단추는 위가 잘리고 아래는 다음 단추에 가려진다) — 링을 단추 안쪽에 */
@media (hover: hover) { .ed-rb:not(.on):hover { background: var(--c-surface-sub); color: var(--c-ink); } }
.ed-panel { grid-area: panel; display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--c-line); background: var(--c-surface); overflow: hidden; }
.ed-panel:focus { outline: none; }   /* 폰: 줄 단추로 시트를 열면 초점이 시트 자체로 온다 — 안의 단추마다 링이 있으니 시트 테두리에는 링을 두지 않는다 */
.ed-ph { display: flex; align-items: center; justify-content: space-between; flex: none; height: 44px; padding: 0 var(--sp-3); border-bottom: 1px solid var(--c-line); }
.ed-ph h2 { margin: 0; font-size: var(--fs-2); font-weight: var(--fw-bold); }
.ed-pb { flex: 1; min-height: 0; padding: var(--sp-2) var(--sp-3) var(--sp-5); overflow: hidden auto; overscroll-behavior: contain; }
.ed-note { margin: var(--sp-3) 0; color: var(--c-ink-sub); }
.ed-note.err { color: var(--c-up); }
.ed-sh { margin: var(--sp-4) 0 var(--sp-2); font-size: var(--fs-4); line-height: var(--lh-4); font-weight: var(--fw-bold); color: var(--c-ink); }
.ed-sh:first-child { margin-top: var(--sp-2); }
.ed-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); width: 100%; min-height: 40px; margin: 0 0 var(--sp-1); padding: 0 var(--sp-3); border: 1px solid transparent; border-radius: var(--r-1); background: var(--c-surface-sub); color: var(--c-ink); font-size: var(--fs-3); font-weight: var(--fw-semi); text-align: left; text-decoration: none; cursor: pointer; transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.ed-row.link::after { content: "›"; color: var(--c-ink-faint); }
@media (hover: hover) { .ed-row:not([aria-pressed="true"]):hover { background: var(--c-line); } }
.ed-row[aria-pressed="true"] { border-color: var(--c-accent); background: var(--c-accent-bg); color: var(--c-accent); font-weight: var(--fw-bold); }
.ed-row[aria-pressed="true"] .ed-k { border-color: var(--c-accent-line); color: var(--c-accent); }
.ed-sub { display: flex; gap: var(--sp-1); margin: 0 0 var(--sp-1); padding: 0 0 0 var(--sp-3); border-left: 2px solid var(--c-accent-line); }
.ed-sub .ed-sb { flex: 1; border: 1px solid var(--c-line-strong); }

/* panels.js 의 판은 자기 제목 줄과 여백을 가지고 부모를 채운다 */
.ed-panel[data-own] .ed-ph { display: none; }
.ed-panel[data-own] .ed-pb { padding: 0; overflow: hidden; }

/* 캔버스 */
.ed-stage { grid-area: stage; position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--c-surface-sub); }
#plCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#plCanvas:focus-visible { outline: 2px solid var(--c-accent); outline-offset: -2px; }
.ed-3d { position: absolute; inset: 0; background: var(--c-surface-sub); }
.ed-3d > canvas { display: block; width: 100%; height: 100%; }
.ed-app.is3d #plCanvas { visibility: hidden; }
.ed-hint { position: absolute; top: var(--sp-3); left: var(--sp-3); z-index: 2; display: flex; align-items: baseline; gap: var(--sp-2); max-width: calc(100% - var(--sp-6) - 44px); padding: var(--sp-1) var(--sp-3); border: 1px solid var(--c-line); border-radius: var(--r-1); background: var(--c-surface); pointer-events: none; }
.ed-hint strong { flex: none; color: var(--c-accent); font-weight: var(--fw-bold); }
.ed-hint span { color: var(--c-ink-sub); font-size: var(--fs-4); line-height: var(--lh-4); }
.ed-app.is3d .ed-hint { display: none; }
.ed-edge { position: absolute; top: 50%; z-index: 3; width: var(--ed-edge); height: 48px; margin-top: -24px; border: 1px solid var(--c-line); background: var(--c-surface); color: var(--c-ink-sub); font-size: var(--fs-2); line-height: 1; cursor: pointer; }
.ed-edge.l { left: 0; border-left: 0; border-radius: 0 var(--r-1) var(--r-1) 0; }
.ed-edge.r { right: 0; border-right: 0; border-radius: var(--r-1) 0 0 var(--r-1); }
@media (hover: hover) { .ed-edge:hover { color: var(--c-ink); background: var(--c-surface-sub); } }
.ed-ctls { position: absolute; left: calc(var(--sp-3) + var(--ed-edge)); right: calc(var(--sp-3) + var(--ed-edge)); bottom: var(--sp-3); z-index: 3; display: flex; flex-wrap: wrap-reverse; justify-content: space-between; align-items: flex-end; gap: var(--sp-2); pointer-events: none; }   /* 두 줄이 한 줄에 못 들어가면 오른쪽 줄이 왼쪽 줄 위로 올라간다 — 폭 기준 값 없이 */
.ed-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1); max-width: 100%; padding: var(--sp-1); border: 1px solid var(--c-line); border-radius: var(--r-1); background: var(--c-surface); pointer-events: auto; }
.ed-ctl.r { margin-left: auto; }
.ed-seg { display: flex; gap: var(--sp-1); padding: var(--sp-1); border-radius: var(--r-1); background: var(--c-surface-sub); }
.ed-seg.wide { width: 100%; }
.ed-seg.wide .ed-sb { flex: 1; }
.ed-sb { min-width: 40px; min-height: 32px; padding: 0 var(--sp-2); border: 0; border-radius: var(--r-1); background: transparent; color: var(--c-ink-sub); font-size: var(--fs-3); font-weight: var(--fw-semi); white-space: nowrap; cursor: pointer; transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.ed-ctl > .ed-sb { background: var(--c-surface-sub); }
@media (hover: hover) { .ed-sb:not([aria-pressed="true"]):not(:disabled):hover { background: var(--c-line); color: var(--c-ink); } }
.ed-sb[aria-pressed="true"] { background: var(--c-accent-bg); color: var(--c-accent); font-weight: var(--fw-bold); }
.ed-seg .ed-sb[aria-pressed="true"] { background: var(--c-surface); box-shadow: inset 0 0 0 1px var(--c-accent-line); }
.ed-sb:disabled { color: var(--c-ink-faint); cursor: default; }
.ed-app.is3d .only2d { display: none; }
.ed-views { position: absolute; left: 0; bottom: calc(100% + var(--sp-1)); z-index: 4; width: 168px; pointer-events: auto; padding: var(--sp-1); border: 1px solid var(--c-line); border-radius: var(--r-1); background: var(--c-surface); }
.ed-views .ed-row { margin: 0; }   /* 목록은 조절줄 윗끝에 붙는다(폰은 왼쪽 줄 윗끝) — 터치로 줄이 높아져도 단추를 덮지 않는다 */
.ed-app.locked .ed-hint strong::after { content: " · 잠금"; color: var(--c-up); }

/* 오른쪽 패널 — 선택한 것의 속성(ed-props)은 미니맵 위 따로 칸이라 고른 바로 그 자리에서 보인다 */
.ed-props { grid-area: props; min-width: 0; max-height: 60dvh; border-left: 1px solid var(--c-line); background: var(--c-surface); overflow: hidden auto; overscroll-behavior: contain; }
.ed-side { grid-area: side; min-width: 0; border-left: 1px solid var(--c-line); background: var(--c-surface); overflow: hidden auto; overscroll-behavior: contain; }
.ed-sec { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--c-line); }
.ed-sec-h { display: flex; align-items: center; justify-content: space-between; margin: 0 0 var(--sp-2); }
.ed-sec-h h2 { margin: 0; }
.ed-sec h2 { margin: 0 0 var(--sp-2); font-size: var(--fs-2); font-weight: var(--fw-bold); }
#plMini { display: block; width: 100%; height: 132px; border: 1px solid var(--c-line); border-radius: var(--r-1); background: var(--c-surface-sub); cursor: crosshair; touch-action: none; }
.ed-f { display: grid; gap: var(--sp-1); margin: 0 0 var(--sp-2); }
.ed-f > span:first-child, .ed-f > label:first-child { font-size: var(--fs-4); line-height: var(--lh-4); font-weight: var(--fw-semi); color: var(--c-ink-sub); }
.ed-f select, .ed-f input[type="text"], .ed-f input[type="number"] { width: 100%; min-height: 36px; padding: 0 var(--sp-2); border: 1px solid var(--c-control); border-radius: var(--r-1); background: var(--c-surface); font-size: var(--fs-3); }
.ed-f .in { display: flex; align-items: center; gap: var(--sp-2); border: 1px solid var(--c-control); border-radius: var(--r-1); background: var(--c-surface); padding-right: var(--sp-2); }
.ed-f .in:focus-within { border-color: var(--c-accent); }
.ed-f .in input { min-width: 0; border: 0 !important; background: transparent !important; text-align: right; }
.ed-f .in input[type="text"] { text-align: left; }
.ed-f .in input:focus-visible { outline: none; }
.ed-f .in em { flex: none; font-style: normal; font-size: var(--fs-4); color: var(--c-ink-faint); }
.ed-f .in input[readonly], .ed-out { color: var(--c-ink); }
.ed-out { display: block; padding: var(--sp-2) var(--sp-3); border: 1px solid var(--c-line); border-radius: var(--r-1); background: var(--c-surface-sub); text-align: right; font-weight: var(--fw-semi); font-variant-numeric: tabular-nums; }
.ed-rg { display: grid; grid-template-columns: minmax(0, 1fr) 92px; align-items: center; gap: var(--sp-3); }
.ed-rg input[type="range"] { width: 100%; accent-color: var(--c-accent); }
.ed-sec .ed-b.wide { margin-bottom: var(--sp-2); }
.ed-sec .ed-btns { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

/* 분석 보기(포셰·존·동선) — 속성 칸(ed-props) 안의 표. 존 견본은 캔버스와 같은 토큰·같은 진하기 */
.ed-ana { display: grid; gap: var(--sp-2); }
.ed-props > .ed-seg { margin-bottom: var(--sp-2); }
.ed-ana .ed-note, .ed-ana .ed-f { margin: 0; }
.ed-tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ed-tbl th, .ed-tbl td { padding: var(--sp-1); border-bottom: 1px solid var(--c-line); font-size: var(--fs-3); font-weight: var(--fw-semi); text-align: left; vertical-align: top; }
.ed-tbl thead th { border-bottom-color: var(--c-line-strong); color: var(--c-ink-sub); font-size: var(--fs-4); line-height: var(--lh-4); }
.ed-tbl .num { text-align: right; white-space: nowrap; }
.ed-tbl tfoot th, .ed-tbl tfoot td { border-bottom: 0; font-weight: var(--fw-bold); }
.ed-tbl small { display: block; color: var(--c-ink-sub); font-size: var(--fs-4); line-height: var(--lh-4); font-weight: var(--fw-reg); }
.ed-tbl .ed-b { min-height: 28px; padding: 0 var(--sp-2); }
.ed-zsw { display: inline-block; width: var(--sp-3); height: var(--sp-3); margin-right: var(--sp-1); border: 1px solid var(--c-accent); border-radius: var(--r-1); background: color-mix(in srgb, var(--c-accent) 20%, transparent); vertical-align: -1px; }
.ed-zsw[data-z="private"] { border-color: var(--c-up); background: color-mix(in srgb, var(--c-up) 20%, transparent); }
.ed-zsw[data-z="service"] { border-color: var(--c-control); background: color-mix(in srgb, var(--c-control) 20%, transparent); }
.ed-ana-add { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; gap: var(--sp-2); }
/* 일조·단면·그림자 — 종류 단추 7개는 네 칸 두 줄(폰은 한 줄). 조작(ed-ana-ctl)은 표 밖 고정 묶음, 단면은 작은 캔버스 */
.ed-props > .ed-seg.wide { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ed-props > .ed-seg.wide .ed-sb { min-width: 0; padding: 0; }
.ed-ana-ctl { display: grid; gap: var(--sp-2); }
.ed-props > .ed-ana-ctl { margin-bottom: var(--sp-3); }
.ed-ana-ctl .ed-f, .ed-ana-ctl .ed-note { margin: 0; }
.ed-ana-ctl .ed-note { font-size: var(--fs-4); line-height: var(--lh-4); text-align: right; font-variant-numeric: tabular-nums; }
.ed-ana-ctl .ed-b[aria-pressed="true"] { border-color: var(--c-accent); background: var(--c-accent-bg); color: var(--c-accent); }
.ed-ana-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
.ed-ana-set summary { min-height: 32px; padding: var(--sp-1) 0; color: var(--c-ink-sub); font-size: var(--fs-4); line-height: var(--lh-2); font-weight: var(--fw-semi); cursor: pointer; }
.ed-ana-set > .ed-f { margin: var(--sp-1) 0 var(--sp-2); }
.ed-tbl .val { text-align: right; }
.ed-sec-cv { display: block; width: 100%; height: 96px; border: 1px solid var(--c-line); border-radius: var(--r-1); background: var(--c-surface-sub); }

/* 알림·창 */
.ed-toasts { position: fixed; left: 50%; bottom: calc(var(--sp-8) + var(--sp-8)); z-index: 50; display: grid; gap: var(--sp-2); justify-items: center; translate: -50% 0; pointer-events: none; max-width: calc(100vw - var(--sp-6)); }
.ed-toast { padding: var(--sp-2) var(--sp-4); border-radius: var(--r-1); background: var(--c-ink); color: var(--c-surface); font-size: var(--fs-3); animation: ed-in var(--t-base) var(--ease) backwards; }
.ed-toast.err { background: var(--c-up); }
@keyframes ed-in { from { opacity: 0; translate: 0 var(--sp-2); } }
dialog.ed-dlg { width: min(640px, calc(100vw - var(--sp-6))); max-height: calc(100dvh - var(--sp-6)); padding: 0; border: 1px solid var(--c-line); border-radius: var(--r-3); background: var(--c-surface); color: var(--c-ink); box-shadow: var(--sh-2); overflow: hidden auto; }
dialog.ed-dlg.sm { width: min(440px, calc(100vw - var(--sp-6))); }
dialog.ed-dlg::backdrop { background: color-mix(in srgb, var(--c-ink) 40%, transparent); }
.ed-dlg-h { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-3) var(--sp-3) 0 var(--sp-5); }
.ed-dlg-h h2 { margin: 0; font-size: var(--fs-1); line-height: var(--lh-1); font-weight: var(--fw-bold); letter-spacing: -0.02em; }
.ed-dlg-b { padding: var(--sp-3) var(--sp-5) var(--sp-5); }
.ed-dlg-b p { margin: 0 0 var(--sp-3); color: var(--c-ink-sub); }
.ed-dlg-b ul { margin: 0 0 var(--sp-3); padding-left: var(--sp-5); color: var(--c-ink-sub); }
.ed-dlg-b .ed-f { margin-bottom: var(--sp-4); }
.ed-dlg-b .row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-4); }
.ed-dlg-b .row .ed-b { min-height: 44px; }
.ed-dlg-b .row .ed-b.danger { border-color: var(--c-up); color: var(--c-up); }

/* 카드·목록이 패널 안에 들어올 때 기본 */
.ed-pb img { max-width: 100%; }

@media (pointer: coarse) {
  :root { --ed-edge: 44px; }
  .ed-b, .ed-tbl .ed-b, .ed-sb, .ed-row, .ed-title, .ed-f select, .ed-f input[type="text"], .ed-f input[type="number"], .ed-rg input[type="range"], .ed-ana-set summary { min-height: 44px; }
  .ed-sb { min-width: 44px; }
  .ed-x { width: 44px; height: 44px; }
}

/* 중간 폭(~1365px: 아이패드·브라우저 확대·1280 노트북): 위 바의 가로줄(렌더샷·갤러리·견적·시방서·내보내기·불러오기·새로 만들기)은 1320px 부터 들어가므로, 제목 칸 여유를 두고 1365px 까지는 메뉴 항목을 [메뉴] 로 접는다(폰과 같은 규칙). 저장·나가기는 항상 화면 안 */
@media (max-width: 1365px) {
  .ed-more { display: inline-flex; }
  .ed-menu { position: absolute; top: calc(var(--ed-top) - 1px); right: var(--sp-2); z-index: 30; display: none; flex-direction: column; align-items: stretch; gap: var(--sp-1); min-width: 200px; margin: 0; padding: var(--sp-2); border: 1px solid var(--c-line); border-radius: var(--r-2); background: var(--c-surface); box-shadow: var(--sh-2); }
  .ed-menu.open { display: flex; }
  .ed-menu .ed-b { justify-content: flex-start; min-height: 44px; }
}
@media (min-width: 769px) and (max-width: 1279px) {   /* 작은 노트북·아이패드 가로(1024)까지 양쪽 패널을 좁혀 캔버스를 넓힌다(1024px 에서 404 → 504px) */
  :root { --ed-panel: 240px; --ed-side: 224px; }
}
@media (min-width: 769px) and (max-width: 1023px) {
  .ed-top { padding-right: var(--sp-2); }
  .ed-hist .ed-b { padding: 0 var(--sp-2); }
  .ed-title { flex-basis: 160px; }
}

/* 폰: 도구 패널 = 아래 시트, 오른쪽 패널 = 밀어 여는 서랍(처음엔 접힘) */
@media (max-width: 768px) {
  .ed-app { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--ed-top) minmax(0, 1fr) 56px; grid-template-areas: "top" "stage" "rail"; transition: none; }
  .ed-app.no-panel, .ed-app.no-side { --ed-panel: 280px; --ed-side: 268px; }
  .ed-small-only { display: inline-flex !important; }
  .ed-big-only, .ed-ss, .ed-title, .ed-edge.l { display: none; }
  .ed-top { padding: 0 var(--sp-2) 0 0; }
  .ed-logo { width: 56px; }
  .ed-hist { margin-left: var(--sp-1); }
  .ed-hist .ed-b { padding: 0 var(--sp-2); }
  .ed-rail { flex-direction: row; border-right: 0; border-top: 1px solid var(--c-line); overflow: hidden; }
  .ed-rb { flex: 1 1 0; min-width: 0; width: auto; height: 100%; padding: 0 2px; border-left: 0; border-top: 2px solid transparent; }
  .ed-rb:nth-last-child(2) { margin: 0; border-top: 2px solid transparent; }
  .ed-rb.on { border-top-color: var(--c-accent); }
  .ed-panel { position: fixed; z-index: 20; left: 0; right: 0; bottom: 56px; max-height: 60dvh; border-right: 0; border-top: 1px solid var(--c-line); border-radius: var(--r-3) var(--r-3) 0 0; transition: translate var(--t-base) var(--ease), visibility var(--t-base); }
  .ed-panel[data-own] { height: 60dvh; }   /* panels.js 의 판은 높이 100% 로 부모를 채운다 — 높이가 정해져 있어야 안쪽 목록만 스크롤된다(max-height 만 있으면 목록이 내용 높이까지 늘어나 잘린다) */
  .ed-app.no-panel .ed-panel { translate: 0 100%; visibility: hidden; }
  .ed-side { position: fixed; z-index: 20; top: var(--ed-top); right: 0; bottom: 56px; width: min(var(--ed-side), 88vw); box-shadow: var(--sh-2); transition: translate var(--t-base) var(--ease), visibility var(--t-base); }
  .ed-app.no-side .ed-side { translate: 100% 0; visibility: hidden; }
  .ed-ctls { display: contents; }
  .ed-ctl { position: absolute; bottom: var(--sp-3); z-index: 3; }
  .ed-ctl.l { left: var(--sp-2); }
  .ed-ctl.r { right: var(--sp-2); bottom: auto; top: 50%; flex-direction: column; flex-wrap: nowrap; margin: 0; translate: 0 -50%; }
  .ed-edge.r { top: auto; bottom: calc(var(--sp-3) + 112px); margin: 0; }
  .ed-props { grid-area: auto; position: fixed; z-index: 19; left: 0; right: 0; bottom: 56px; max-height: 45dvh; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; column-gap: var(--sp-3); border-left: 0; border-top: 1px solid var(--c-line); border-radius: var(--r-3) var(--r-3) 0 0; box-shadow: var(--sh-2); }   /* 선택 속성 = 닫힌 서랍 밖의 아래 시트 */
  .ed-props > h2 { grid-column: 1; align-self: center; margin: 0 0 var(--sp-2); }
  .ed-props > .ed-note { grid-column: 2; align-self: center; margin: 0 0 var(--sp-2); text-align: right; }
  .ed-props > .ed-btns, .ed-props > .ed-sec-h, .ed-props > .ed-seg, .ed-props > .ed-ana { grid-column: 1 / -1; }
  .ed-props > .ed-ana-ctl { grid-column: 1 / -1; }
  .ed-props > .ed-seg.wide { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .ed-app.no-side .ed-props { visibility: visible; }
  .ed-app.ana .ed-stage { margin-bottom: 40dvh; }   /* 분석 보기: 시트가 계속 떠 있으므로 캔버스를 시트 위로 줄인다 — 도면과 캔버스 단추가 시트에 가리지 않는다 */
  .ed-app.ana .ed-props { height: 40dvh; max-height: none; }
  .ed-hide-small { display: none; }
  .ed-hint { max-width: calc(100% - var(--sp-4)); }
  .ed-hint { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0 var(--sp-2); padding: var(--sp-1) var(--sp-2); }   /* 폰: 이름 · 글(두 줄까지) · [끝내기] 를 한 줄 막대로 — 화면의 5분의 1 을 먹던 카드를 줄인다 */
  .ed-hint span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  .ed-panel[data-own] .ed-ph { display: flex; }   /* 시트에는 닫기 단추가 필요하다 */
  .ed-panel[data-own] .pl-head { display: none; }   /* 시트 머리와 겹치는 판의 제목 줄은 감춘다 */
  .ed-toasts { bottom: calc(var(--sp-9) + var(--sp-9)); }
}
@media (max-width: 359px) {   /* 320px 폰: 위 바 가로줄이 341px 이라 단추 안쪽 여백과 칸 사이를 한 단계씩 줄여 저장 단추가 화면 안에 든다 */
  .ed-top { gap: var(--sp-1); }
  .ed-hist .ed-b { padding: 0 var(--sp-1); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
/* 도면판 — 미리보기 창과 A3 가로 인쇄(인쇄할 때는 도면판 캔버스만 남긴다) */
dialog.ed-dlg.ed-sheet { width: min(1120px, calc(100vw - var(--sp-6))); }
.ed-sheet-cv { display: block; max-width: 100%; max-height: calc(100dvh - var(--sp-6) - 10rem); margin-inline: auto; border: 1px solid var(--c-line); }   /* 낮은 화면에서도 단추 줄이 창 안에 남게 높이로도 줄인다(비율은 캔버스 크기 그대로) */
@page { size: A3 landscape; margin: 0; }
@media print {
  body.printing > :not(.ed-sheet) { display: none !important; }
  body.printing dialog.ed-sheet { position: absolute; inset: 0; width: 420mm; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; box-shadow: none; overflow: visible; }
  body.printing dialog.ed-sheet::backdrop { display: none; }
  body.printing .ed-sheet .ed-dlg-h, body.printing .ed-sheet-act { display: none; }
  body.printing .ed-sheet .ed-dlg-b { padding: 0; }
  body.printing .ed-sheet-cv { width: 420mm; height: 297mm; max-width: none; max-height: none; border: 0; }
}

/* 갤러리 — 렌더샷 카드 격자 */
.ed-gal { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: var(--sp-3); margin: 0; padding: 0; list-style: none; }
.ed-gal-i { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-2); border: 1px solid var(--c-line); border-radius: var(--r-2); background: var(--c-surface); }
.ed-gal-i.cur { border-color: var(--c-accent); }
.ed-gal-im { display: block; border-radius: var(--r-1); overflow: hidden; background: var(--c-surface-sub); }
.ed-gal-im img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; }
.ed-gal-t { display: flex; flex-direction: column; min-width: 0; }
.ed-gal-t strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--fw-semi); }
.ed-gal-t span { font-size: var(--fs-4); line-height: var(--lh-4); color: var(--c-ink-sub); font-variant-numeric: tabular-nums; }
.ed-gal-a { display: flex; gap: var(--sp-1); }
.ed-gal-a .ed-b { flex: 1; justify-content: center; }
/* 시방서 — 창과 A4 세로 인쇄(인쇄할 때는 시방서만 남긴다 · A4 는 spec.js 가 인쇄하는 동안만 @page 를 덧붙인다 — 도면판의 A3 가로를 이긴다) */
dialog.ed-dlg.ed-spec { width: min(880px, calc(100vw - var(--sp-6))); }
@media print {
  body.printing-spec > :not(.ed-spec) { display: none !important; }
  body.printing-spec dialog.ed-spec { position: static; width: auto; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; box-shadow: none; overflow: visible; }
  body.printing-spec dialog.ed-spec::backdrop { display: none; }
  body.printing-spec .ed-spec .ed-dlg-h .ed-x { display: none; }
}

/* 아이콘 — Phosphor(MIT) 원본 SVG 를 글자색으로 칠한다(icons/README.md) */
.ico { flex: none; display: inline-block; width: 18px; height: 18px; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.ed-b .ico, .ed-sb .ico { width: 16px; height: 16px; }
.ed-b:has(.ico), .ed-sb:has(.ico) { gap: 6px; }
.ed-sb:has(.ico) { display: inline-flex; align-items: center; justify-content: center; }
.ed-rb { gap: 2px; align-content: center; height: auto; min-height: 56px; padding-block: 6px; }
.ed-rb .ico { width: 22px; height: 22px; }
.ed-row .ed-lab { display: flex; align-items: center; gap: var(--sp-2); }
.ed-row .ico { color: var(--c-ink-sub); }
.ed-row[aria-pressed="true"] .ico { color: var(--c-accent); }
.i-arrow-clockwise { --i: url("icons/arrow-clockwise.svg"); }
.i-arrow-counter-clockwise { --i: url("icons/arrow-counter-clockwise.svg"); }
.i-bezier-curve { --i: url("icons/bezier-curve.svg"); }
.i-blueprint { --i: url("icons/blueprint.svg"); }
.i-book-open { --i: url("icons/book-open.svg"); }
.i-camera { --i: url("icons/camera.svg"); }
.i-chart-pie-slice { --i: url("icons/chart-pie-slice.svg"); }
.i-circle { --i: url("icons/circle.svg"); }
.i-corners-out { --i: url("icons/corners-out.svg"); }
.i-cube { --i: url("icons/cube.svg"); }
.i-cube-transparent { --i: url("icons/cube-transparent.svg"); }
.i-cursor { --i: url("icons/cursor.svg"); }
.i-door { --i: url("icons/door.svg"); }
.i-eraser { --i: url("icons/eraser.svg"); }
.i-export { --i: url("icons/export.svg"); }
.i-file-plus { --i: url("icons/file-plus.svg"); }
.i-flip-horizontal { --i: url("icons/flip-horizontal.svg"); }
.i-flip-vertical { --i: url("icons/flip-vertical.svg"); }
.i-folder-open { --i: url("icons/folder-open.svg"); }
.i-grid-four { --i: url("icons/grid-four.svg"); }
.i-image { --i: url("icons/image.svg"); }
.i-images { --i: url("icons/images.svg"); }
.i-clipboard-text { --i: url("icons/clipboard-text.svg"); }
.i-download-simple { --i: url("icons/download-simple.svg"); }
.i-trash { --i: url("icons/trash.svg"); }
.i-line-segment { --i: url("icons/line-segment.svg"); }
.i-lock { --i: url("icons/lock.svg"); }
.i-magnifying-glass { --i: url("icons/magnifying-glass.svg"); }
.i-minus { --i: url("icons/minus.svg"); }
.i-plus { --i: url("icons/plus.svg"); }
.i-polygon { --i: url("icons/polygon.svg"); }
.i-receipt { --i: url("icons/receipt.svg"); }
.i-ruler { --i: url("icons/ruler.svg"); }
.i-selection-plus { --i: url("icons/selection-plus.svg"); }
.i-sign-out { --i: url("icons/sign-out.svg"); }
.i-square { --i: url("icons/square.svg"); }
.i-stack { --i: url("icons/stack.svg"); }
.i-swatches { --i: url("icons/swatches.svg"); }
.i-text-t { --i: url("icons/text-t.svg"); }
.i-wall { --i: url("icons/wall.svg"); }
.i-wrench { --i: url("icons/wrench.svg"); }
@media (min-width: 769px) and (max-width: 1279px) { .ed-top .ed-b .ico { display: none; } }   /* 좁은 화면은 위 줄 글자만 — 나가기가 밀려나지 않게 */
@media (max-width: 768px) { .ed-rb { height: 100%; min-height: 0; padding-block: 0; gap: 0; } .ed-rb .ico { width: 18px; height: 18px; } }   /* 폰 아래 탭 줄: 줄 높이 안에 아이콘 + 이름 */
/* 글자 무게 한 단계 가볍게(11-16 대표: archisketch 수준) — 단추·도구 줄은 보통, 고른 것만 한 단계 굵게 */
.ed-b, .ed-sb, .ed-row, .ed-rb { font-weight: var(--fw-reg); }
.ed-b.primary, .ed-rb.on, .ed-row[aria-pressed="true"], .ed-sb[aria-pressed="true"] { font-weight: var(--fw-semi); }
/* 시작 방법 창 — 새 도면을 열 때 고르는 다섯 길 */
.ed-start { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: var(--sp-2); }
.ed-start-o { display: flex; align-items: center; gap: var(--sp-3); min-height: 64px; padding: var(--sp-3); border: 1px solid var(--c-line); border-radius: var(--r-2); background: var(--c-surface); color: var(--c-ink); text-align: left; cursor: pointer; transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.ed-start-o .ico { width: 26px; height: 26px; color: var(--c-accent); }
.ed-start-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ed-start-t strong { font-size: var(--fs-3); font-weight: var(--fw-semi); }
.ed-start-t span { font-size: var(--fs-4); color: var(--c-ink-sub); }
@media (hover: hover) { .ed-start-o:hover { border-color: var(--c-control); background: var(--c-surface-sub); } }
@media (max-width: 768px) { .ed-top .ed-b .ico { display: none; } }   /* 폰 위 줄도 글자만 — 저장 단추가 화면 밖으로 밀리지 않게 */
