:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --line: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Pretendard', 'Malgun Gothic', 'Apple SD Gothic Neo', system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  font-size: 13px;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: transparent; border: 1px solid transparent; border-radius: 7px; padding: 6px 10px; cursor: pointer; }
button:disabled { opacity: .35; cursor: default; }

/* 상단 바 */
.topbar { height: 52px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; }
.brand { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; margin-right: 6px; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.logo svg { width: 18px; height: 18px; }
.group { display: flex; gap: 2px; padding-left: 10px; border-left: 1px solid var(--line); }
.topbar .group button:hover:not(:disabled) { background: #f3f4f6; }
.seg { display: flex; background: #f1f3f5; border-radius: 9px; padding: 3px; }
.seg button { padding: 5px 14px; border-radius: 7px; }
.seg button.on { background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); color: var(--accent); font-weight: 600; }
.spacer { flex: 1; }
.topbar button, .brand { white-space: nowrap; }

/* 도면 이름 (목록 열기) */
.plan-name { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: #f9fafb; font-weight: 600; max-width: 240px; }
.plan-name:hover { border-color: #93c5fd; background: var(--accent-soft); }
.plan-name svg { width: 15px; height: 15px; flex: none; color: var(--muted); }
.plan-name .nm { overflow: hidden; text-overflow: ellipsis; }
.plan-name .caret { color: var(--muted); font-size: 10px; }

/* 도면 목록 창 */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(17, 24, 39, .45); display: grid; place-items: center; padding: 24px; }
.dialog { background: var(--panel); border-radius: 14px; width: min(940px, 100%); max-height: 100%; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); overflow: hidden; }
.dialog header { display: flex; align-items: center; gap: 6px; padding: 16px 18px 6px; flex-wrap: wrap; }
.dialog header h2 { margin: 0; font-size: 17px; }
.dialog header h2 small { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 4px; }
.dialog header button { border: 1px solid var(--line); background: #fff; }
.dialog header button:hover { background: #f9fafb; }
.dialog header button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.dialog header button.primary:hover { background: #1d4ed8; }
.dialog header button.close { border-color: transparent; font-size: 15px; color: var(--muted); }
.dialog .note { margin: 0; padding: 0 18px 12px; color: var(--muted); font-size: 12px; }
/* 지붕 */
.roof-types { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 4px 0 12px; }
.roof-types button { border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 8px 4px 7px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.roof-types button:hover { border-color: var(--accent); }
.roof-types button.on { border: 2px solid var(--accent); padding: 7px 3px 6px; background: var(--accent-soft); }
.roof-types svg { width: 26px; height: 26px; color: #78350f; }
.roof-types b { font-size: 12px; }
.roof-types span { font-size: 10.5px; color: var(--muted); text-align: center; }
.roof-toggle { display: flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: #fff; color: var(--muted); padding: 5px 9px; border-radius: 8px; font-size: 13px; }
.roof-toggle svg { width: 16px; height: 16px; }
.roof-toggle.on { color: #78350f; border-color: #d6a77a; background: #fdf3e7; }
/* 시작 화면 (홈) */
button.brand { border: 0; background: none; padding: 0; color: inherit; cursor: pointer; }
button.brand:hover .logo { filter: brightness(1.1); }
.home { position: fixed; inset: 0; z-index: 60; background: #eef1f6; display: flex; justify-content: center; align-items: safe center; padding: 24px; overflow-y: auto; overflow-x: hidden; animation: home-in .35s ease-out; }
.home[hidden] { display: none; }
.home-card { width: 100%; max-width: 880px; min-width: 0; margin: auto 0; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 24px 28px 20px; box-shadow: 0 20px 50px rgba(15, 23, 42, .08); }
.home-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.home-logo { width: 52px; height: 52px; border-radius: 14px; animation: home-logo .6s ease-out; }
.home-logo svg { width: 30px; height: 30px; }
.home-title { flex: 1; min-width: 0; }
.home-title h1 { margin: 0; font-size: 24px; letter-spacing: -.01em; }
.home-title p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.home-close { border: 0; background: none; color: var(--muted); font-size: 16px; padding: 6px 8px; align-self: flex-start; }
.home-card h3 { margin: 16px 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.home-recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.home-recent button { padding: 0; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: #fff; text-align: left; display: flex; flex-direction: column; }
.home-recent button:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.home-recent img, .home-recent .noimg { width: 100%; aspect-ratio: 32 / 20; object-fit: cover; background: #f3f4f6; display: grid; place-items: center; color: #9ca3af; font-size: 12px; }
.home-recent .meta { padding: 7px 10px 9px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.home-recent .meta b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-recent .meta span { font-size: 12px; color: var(--muted); }
.home-recent .all { border-style: dashed; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 13px; min-height: 120px; }
.home-uses { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.home-uses button { border: 1px solid var(--line); border-radius: 11px; background: #fff; padding: 14px 10px 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.home-uses button:hover { border-color: var(--accent); background: var(--accent-soft); }
.home-uses button.on { border: 2px solid var(--accent); padding: 13px 9px 11px; }
.home-uses svg { width: 26px; height: 26px; color: var(--accent); }
.home-uses b { font-size: 14px; }
.home-uses span { font-size: 11.5px; color: var(--muted); }
.home-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.home-acts button { border: 1px solid var(--line); background: #fff; padding: 8px 14px; }
.home-acts button:hover, .home-acts button.on { border-color: var(--accent); color: var(--accent); }
.home-guide { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-top: 12px; }
.home-guide div { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.home-guide span { color: var(--muted); line-height: 1.5; }
.home-skip { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 18px; font-size: 12.5px; color: var(--muted); }
.home-skip small { color: #9ca3af; }
@keyframes home-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes home-logo { from { opacity: 0; transform: scale(.7) rotate(-8deg); } to { opacity: 1; transform: none; } }
@media (max-width: 640px) {
  .home { padding: 12px; }
  .home-title h1 { font-size: 20px; }
  .home-uses span { font-size: 11px; text-align: center; }
  .home-card { padding: 18px 16px; }
  .home-uses { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-recent { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.home .home-logo { display: grid; } /* 좁은 화면에서 위쪽 막대 로고를 숨겨도 시작 화면 로고는 보이게 */
/* 건물 용도 고르기 */
.use-sel { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 5px 6px; font-size: 13px; font-weight: 600; color: var(--accent); }
.use-tabs { display: flex; gap: 6px; padding: 0 18px 10px; flex-wrap: wrap; }
.use-tabs button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 14px; }
.use-tabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.plan-card.blank .thumb { font-size: 34px; color: #9ca3af; }
/* 배치 추천 */
.advise #adviseBody { padding: 4px 18px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.adv-rooms { width: 100%; border-collapse: collapse; font-size: 13px; }
.adv-rooms th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.adv-rooms td { padding: 5px 6px; border-bottom: 1px solid #f1f2f4; vertical-align: middle; }
.adv-rooms td em { color: var(--muted); font-style: normal; font-size: 12px; }
.adv-rooms select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.code-sum { display: flex; gap: 8px; margin-bottom: 10px; font-size: 13px; font-weight: 600; }
.code-sum span { padding: 3px 10px; border-radius: 999px; }
.code-sum .fail { background: #fde8e8; color: #b42318; }
.code-sum .warn { background: #fff4db; color: #9a6700; }
.code-sum .ok { background: #e6f6ec; color: #1a7f37; }
.code-law h4 { margin: 12px 0 6px; font-size: 14px; }
.code-law ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.code-law li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; background: #f7f8fa; font-size: 13px; }
.code-law li p { margin: 2px 0 0; color: #4b5563; line-height: 1.45; }
.code-law li .grow { flex: 1; min-width: 0; }
.code-law li > button { flex: none; align-self: center; font-size: 12px; padding: 4px 10px; }
.code-sum .primary { margin-left: auto; font-size: 12px; padding: 3px 12px; }
.code-law .mark { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; color: #fff; background: #9aa3ab; }
.code-law li.ok .mark { background: #1a7f37; }
.code-law li.warn .mark { background: #d4a106; }
.code-law li.fail .mark { background: #d1242f; }
.code-law li.fail { background: #fff5f5; }
.adv-style {border: 1px solid var(--line, #e2e5ea); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px; background: #fbfaf7; }
.adv-style select { margin-left: 6px; font: inherit; padding: 3px 6px; }
.adv-style-short { margin: 8px 0 4px; font-weight: 600; }
.adv-style ol { margin: 4px 0 6px 18px; padding: 0; line-height: 1.55; }
.adv-opts { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; }
.adv-opts label { display: flex; align-items: center; gap: 5px; }
.adv-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.adv-acts button { border: 1px solid var(--line); background: #fff; padding: 8px 14px; }
.adv-acts button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.adv-result { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.adv-result h4 { margin: 8px 0 3px; font-size: 13px; }
.adv-result h4:first-child { margin-top: 0; }
.adv-result ul { margin: 0; padding-left: 18px; color: #374151; }
.adv-result .skip { color: var(--muted); }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; padding: 4px 18px 20px; overflow-y: auto; }
.plan-card { border: 1px solid var(--line); border-radius: 11px; overflow: hidden; display: flex; flex-direction: column; background: #fff; }
.plan-card.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plan-card .thumb { padding: 0; border: 0; border-radius: 0; position: relative; aspect-ratio: 32 / 22; background: #f3f4f6; display: grid; place-items: center; }
.plan-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.plan-card .thumb:hover img { opacity: .85; }
.plan-card .noimg { color: #9ca3af; font-size: 12px; }
.plan-card .badge { position: absolute; top: 8px; left: 8px; background: var(--accent); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 99px; }
.plan-card .meta { padding: 9px 11px 4px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.plan-card .meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-card .meta span { color: var(--muted); font-size: 12px; }
.plan-card .acts { display: flex; gap: 2px; padding: 4px 6px 8px; }
.plan-card .acts button { padding: 4px 7px; font-size: 12px; color: var(--muted); }
.plan-card .acts button:hover { background: #f3f4f6; color: var(--text); }
.plan-card .acts button.danger:hover { color: #dc2626; background: #fef2f2; }

/* 브랜드 도면 창 */
.brand-dialog { width: min(1320px, 100%); height: min(860px, 100%); }
.brand-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 400px 1fr; border-top: 1px solid var(--line); }
.brand-form { overflow-y: auto; padding: 14px 18px 24px; border-right: 1px solid var(--line); }
.brand-form h3 { margin: 16px 0 10px; color: var(--text); font-size: 13px; }
.brand-form h3:first-child { margin-top: 2px; }
.ff { display: flex; flex-direction: column; gap: 4px; margin-bottom: 9px; min-width: 0; }
.ff > span { font-size: 12px; color: var(--muted); }
.ff input, .ff select, .ff textarea { font: inherit; border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; background: #fff; color: var(--text); min-width: 0; width: 100%; }
.ff textarea { resize: vertical; }
.ff input:focus, .ff select:focus, .ff textarea:focus { outline: 0; border-color: var(--accent); }
.ff input[type=color] { padding: 2px; height: 36px; cursor: pointer; }
.ff2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checks { display: flex; gap: 16px; }
.checks label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.logo-row { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.logo-box { width: 130px; height: 76px; flex: none; border: 1px dashed #cbd5e1; border-radius: 9px; display: grid; place-items: center; color: #9ca3af; font-size: 12px; background: #fafafa; overflow: hidden; }
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.filebtn { display: inline-block; border: 1px solid var(--line); border-radius: 7px; padding: 6px 12px; cursor: pointer; background: #fff; }
.filebtn:hover { border-color: var(--accent); color: var(--accent); }
.brand-preview { background: #eef0f3; padding: 22px; overflow: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; }
.brand-preview canvas { width: 100%; max-width: 1100px; height: auto; background: #fff; box-shadow: 0 6px 24px rgba(0, 0, 0, .14); border-radius: 4px; }

/* 확인/입력 창 */
.ask-modal { z-index: 60; }
.ask-dialog { width: min(420px, 100%); padding: 22px 22px 18px; gap: 0; }
.ask-dialog h2 { margin: 0 0 8px; font-size: 16px; }
.ask-dialog p { margin: 0 0 16px; color: #4b5563; line-height: 1.6; white-space: pre-line; }
.ask-dialog p:empty { display: none; }
.ask-dialog input { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 16px; }
.ask-dialog input:focus { outline: 0; border-color: var(--accent); }
.ask-btns { display: flex; justify-content: flex-end; gap: 8px; }
.ask-btns button { border: 1px solid var(--line); background: #fff; padding: 7px 16px; }
.ask-btns button:hover { background: #f9fafb; }
.ask-btns .primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.ask-btns .primary:hover { background: #1d4ed8; }
.ask-btns .primary.danger { background: #dc2626; border-color: #dc2626; }

/* 3D 평면도 창 */
.segs { display: flex; background: #f1f3f5; border-radius: 9px; padding: 3px; gap: 2px; }
.segs button { flex: 1; padding: 6px 8px; border-radius: 7px; font-size: 12.5px; }
.segs button.on { background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); color: var(--accent); font-weight: 600; }
.checks.col { flex-direction: column; gap: 8px; }
.render-status { color: var(--accent); font-size: 12px; margin-left: 8px; }
/* CAD 불러오기 */
.cad-layer { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid #f1f3f5; }
.cad-layer i { width: 12px; height: 12px; border-radius: 3px; }
.cad-layer span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.cad-layer span em { color: var(--muted); font-style: normal; font-size: 11px; margin-left: 4px; }
.cad-layer select { font: inherit; font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 3px 4px; background: #fff; }
.cad-stats { margin-top: 14px; padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); color: #1e3a8a; font-size: 12.5px; line-height: 1.6; }
.cad-stats.bad { background: #fef2f2; color: #991b1b; }
.cad-ul { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12.5px; cursor: pointer; }
#cadRasterBtn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.cad-stats .btns button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
#cadPreview { width: 100%; height: auto; background: #fff; box-shadow: 0 6px 24px rgba(0, 0, 0, .14); border-radius: 4px; }

/* AI 렌더링 */
.ai-styles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.ai-styles button { border: 1px solid var(--line); padding: 7px 4px; font-size: 12px; background: #fff; }
.ai-styles button:hover { border-color: #93c5fd; }
.ai-styles button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
#aiForm textarea { min-height: 84px; }
#aiForm .btns button.primary { flex: 1; padding: 9px; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; font-size: 14px; }
#aiForm .btns button.primary:disabled { opacity: .6; }
.ai-keys { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 10px; }
.ai-keys summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.ai-keyrow { margin-top: 10px; }
.ai-keyrow .linkrow input { background: #fff; color: var(--text); }
.ai-preview { align-items: stretch; }
.ai-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; }
.ai-pair figure { margin: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ai-pair img { width: 100%; height: auto; border-radius: 6px; box-shadow: 0 4px 16px rgba(0, 0, 0, .12); background: #fff; }
.ai-pair figcaption { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ai-res-btns { margin-left: auto; display: flex; gap: 4px; }
.ai-res-btns button { border: 1px solid var(--line); background: #fff; font-size: 12px; padding: 4px 8px; }
.ai-result { position: relative; min-height: 160px; border-radius: 6px; background: #fff; display: grid; place-items: center; }
.ai-result p { color: var(--muted); font-size: 13px; padding: 20px; text-align: center; margin: 0; }
.ai-result.busy::after { content: ''; position: absolute; inset: 0; border-radius: 6px; background: linear-gradient(100deg, rgba(255,255,255,0) 30%, rgba(255,255,255,.6) 50%, rgba(255,255,255,0) 70%) -100% 0 / 200% 100%; animation: aishine 1.4s linear infinite; }
@keyframes aishine { to { background-position: 100% 0; } }
.ai-history { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; }
.ai-history button { padding: 0; border: 2px solid transparent; border-radius: 6px; overflow: hidden; width: 104px; }
.ai-history button.on { border-color: var(--accent); }
.ai-history img { display: block; width: 100%; height: auto; }
@media (max-width: 900px) { .ai-pair { grid-template-columns: 1fr; } }

/* 공유하기 */
.share-dialog { width: min(640px, 100%); }
.share-body { padding: 4px 18px 18px; overflow-y: auto; }
.share-body section { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 10px; }
.share-body section:first-child { border-top: 0; margin-top: 0; }
.share-body h3 { margin: 0 0 6px; font-size: 14px; }
.share-body h3 small { font-weight: 400; color: var(--accent); font-size: 12px; margin-left: 6px; }
.share-body .btns { align-items: center; }
.share-body .btns button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.linkrow { display: flex; gap: 6px; }
.linkrow input { flex: 1; min-width: 0; font: inherit; font-size: 12px; border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; background: #f9fafb; color: var(--muted); }
.linkrow button.primary { border: 1px solid var(--accent); background: var(--accent); color: #fff; font-weight: 600; }
.sharewarn { margin: 8px 0 0; padding: 8px 10px; border-radius: 8px; background: #fffbeb; color: #92400e; font-size: 12px; line-height: 1.5; }
/* 보기 전용 (공유 링크로 연 도면): 고치는 도구는 숨긴다 */
.viewonly-bar { display: flex; align-items: center; gap: 8px; padding-left: 10px; border-left: 1px solid var(--line); }
.viewonly-bar span { font-size: 12px; font-weight: 600; color: #92400e; background: #fef3c7; border-radius: 99px; padding: 3px 10px; white-space: nowrap; }
.viewonly-bar button { border: 1px solid var(--accent); color: var(--accent); background: #fff; font-weight: 600; }
body.viewonly #fileGroup, body.viewonly #moreBtn, body.viewonly .catalog, body.viewonly #catalogBtn,
body.viewonly .tools button:not([data-tool=select]):not([data-tool=pano]), body.viewonly [data-act=undo], body.viewonly [data-act=redo],
body.viewonly .levels .add { display: none !important; }
body.viewonly .plan-name { pointer-events: none; }

/* 360° 보기 */
.pano-dialog { width: min(1200px, 100%); height: min(760px, 100%); }
.pano-view { position: relative; flex: 1; min-height: 0; margin: 8px 12px 12px; border-radius: 10px; overflow: hidden; background: #1f2227; }
.pano-view canvas { display: block; width: 100%; height: 100%; }
.render-img { width: 100%; max-width: 1100px; height: auto; min-height: 200px; border-radius: 6px; box-shadow: 0 6px 24px rgba(0, 0, 0, .14);
  background: repeating-conic-gradient(#e5e7eb 0 25%, #fff 0 50%) 0 0 / 20px 20px; }

/* 레이아웃 */
.layout { flex: 1; display: grid; grid-template-columns: 236px 1fr 272px; min-height: 0; }
.left, .right { background: var(--panel); overflow-y: auto; }
.left { border-right: 1px solid var(--line); }
.right { border-left: 1px solid var(--line); }
section { padding: 14px; border-bottom: 1px solid var(--line); }
h3 { margin: 0 0 10px; font-size: 12px; color: var(--muted); font-weight: 600; }
h3 small { font-weight: 400; color: #9ca3af; margin-left: 4px; }
h2 { margin: 0 0 12px; font-size: 15px; }

/* 도구 */
.tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tools button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 4px 7px; border: 1px solid var(--line); position: relative; font-size: 12px; }
.tools button svg { width: 20px; height: 20px; }
.tools button kbd { position: absolute; top: 3px; right: 5px; font-size: 9px; color: #9ca3af; font-family: inherit; }
.tools button:hover { background: #f9fafb; }
.tools button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* 가구 */
.search { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; margin-bottom: 10px; background: #fff; color: #9ca3af; }
.search:focus-within { border-color: var(--accent); color: var(--accent); }
.search svg { width: 15px; height: 15px; flex: none; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; font: inherit; padding: 7px 0; background: transparent; color: var(--text); }
.search kbd { font-family: inherit; font-size: 10px; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; color: #9ca3af; }
.search:focus-within kbd { display: none; }
.empty { grid-column: 1 / -1; color: var(--muted); text-align: center; padding: 18px 0; line-height: 1.6; }
.cats { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.cats button { padding: 4px 11px; border-radius: 99px; background: #f3f4f6; font-size: 12px; }
.cats button.on { background: var(--text); color: #fff; }
.items { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.item { display: flex; flex-direction: column; align-items: center; gap: 3px; border: 1px solid var(--line); padding: 8px 4px 6px; font-size: 11.5px; }
.item canvas { width: 60px; height: 48px; }
.item:hover { border-color: #93c5fd; }
.item.on { border-color: var(--accent); background: var(--accent-soft); }

/* 작업 영역 */
.stage { position: relative; min-width: 0; min-height: 0; }
#planWrap, #view3d { position: absolute; inset: 0; overflow: hidden; }
.stage.split #planWrap { right: 50%; }
.stage.split #view3d { left: 50%; border-left: 1px solid var(--line); }
.stage.split .focused::after { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 0 2px rgba(37, 99, 235, .45); pointer-events: none; }
#plan { display: block; touch-action: none; }
#view3d canvas { display: block; touch-action: none; }
/* 층 버튼 (도면 왼쪽 아래, 위층이 위에) */
.levels { position: absolute; left: 12px; bottom: 12px; z-index: 5; display: flex; flex-direction: column; gap: 3px; padding: 4px; background: rgba(255, 255, 255, .94); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 2px 8px rgba(0, 0, 0, .08); max-height: calc(100% - 24px); overflow-y: auto; }
.levels button { min-width: 64px; padding: 6px 10px; border-radius: 7px; font-size: 13px; white-space: nowrap; }
.levels button:hover { background: #f1f3f5; }
.levels button.on { background: var(--accent); color: #fff; font-weight: 600; }
.levels button.add { color: var(--accent); font-size: 16px; line-height: 1; padding: 4px 10px; }
.hint3d { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); background: rgba(17, 24, 39, .75); color: #fff; padding: 7px 14px; border-radius: 99px; font-size: 12px; pointer-events: none; white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; }

.status { height: 28px; flex: none; display: flex; align-items: center; gap: 16px; padding: 0 14px; background: var(--panel); border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

.status .warn { color: #dc2626; font-weight: 600; padding: 2px 8px; font-size: 12px; background: #fef2f2; border-radius: 99px; }
.status .warn:hover { background: #fee2e2; }

/* 경고 목록 */
.warnlist h3 { color: #dc2626; }
.warnlist button { width: 100%; text-align: left; display: flex; gap: 8px; align-items: flex-start; padding: 7px 8px; color: #991b1b; line-height: 1.4; }
.warnlist button:hover { background: #fef2f2; }
.warnlist button::before { content: '⚠'; color: #dc2626; }
.okline { color: #15803d; margin: 0; font-size: 12px; }
.warnbox { background: #fef2f2; color: #991b1b; border-radius: 8px; padding: 8px 10px; margin: 0 0 12px; line-height: 1.5; font-size: 12px; }

/* 속성 패널 */
.field { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.field > span { color: var(--muted); }
.inp { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 7px; padding: 0 8px; width: 140px; background: #fff; }
.inp:focus-within { border-color: var(--accent); }
.inp input, .inp select { border: 0; outline: 0; font: inherit; width: 100%; padding: 6px 0; background: transparent; color: inherit; min-width: 0; }
.inp input[type=color] { padding: 2px 0; height: 30px; cursor: pointer; }
.inp em { font-style: normal; color: #9ca3af; font-size: 11px; margin-left: 4px; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.btns button { border: 1px solid var(--line); background: #fff; }
.btns button:hover { background: #f9fafb; }
.btns button.danger { color: #dc2626; }
.btns button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
/* 글자 메모 내용 (여러 줄) */
.field-ta { flex-direction: column; align-items: stretch; }
.field-ta textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; resize: vertical; min-height: 56px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: #f9fafb; border-radius: 9px; padding: 10px; }
.stat span { color: var(--muted); font-size: 11.5px; }
.stat b { display: block; font-size: 17px; margin-top: 2px; }
.roomlist button { width: 100%; display: flex; justify-content: space-between; padding: 7px 8px; }
.roomlist button:hover { background: #f3f4f6; }
.roomlist em { font-style: normal; color: var(--muted); }
.info { color: var(--muted); margin: 0 0 10px; line-height: 1.5; }
.keys { margin: 0; padding: 0; list-style: none; color: var(--muted); line-height: 2; font-size: 12px; }
.keys kbd { background: #f3f4f6; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-family: inherit; font-size: 11px; color: var(--text); }

/* 색/재료 고르기 */
.cpick { margin: 4px 0 12px; }
.cpick-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cpick-head > span { color: var(--muted); }
.cpick-head .chip { width: 18px; height: 18px; border-radius: 5px; border: 1px solid rgba(0, 0, 0, .15); }
.linkbtn { margin-left: auto; padding: 2px 6px; font-size: 11.5px; color: var(--accent); }
.linkbtn:hover { background: var(--accent-soft); }
.hintsm { font-style: normal; font-size: 11px; color: #9ca3af; }
.sws { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.sws em { flex-basis: 100%; font-style: normal; font-size: 11px; color: #9ca3af; }
.sw { width: 22px; height: 22px; padding: 0; border-radius: 6px; border: 1px solid rgba(0, 0, 0, .14); position: relative; }
.sw:hover { transform: scale(1.1); }
.sw.on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }
.sw.custom { overflow: hidden; cursor: pointer; background: conic-gradient(#f87171, #fbbf24, #34d399, #60a5fa, #a78bfa, #f87171); }
.sw.custom input { opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.floors { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.floor { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); padding: 5px 7px; font-size: 12px; text-align: left; }
.floor i { width: 18px; height: 18px; border-radius: 4px; flex: none; border: 1px solid rgba(0, 0, 0, .12); }
.floor:hover { border-color: #93c5fd; }
.floor.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.floor i.pat { background-size: cover; }
/* 벽 마감: 어느 쪽 벽면인지 고르기 */
.sideseg { margin-bottom: 10px; }
.sideseg button { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.themes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.theme { border: 1px solid var(--line); display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 7px 8px; font-size: 12px; }
.theme:hover { border-color: #93c5fd; }
.theme.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.theme .strip { display: flex; width: 100%; height: 12px; border-radius: 4px; overflow: hidden; border: 1px solid rgba(0, 0, 0, .08); }
.theme .strip i { flex: 1; }
.paledit { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pal-item { position: relative; }
.pal-item input { width: 28px; height: 28px; padding: 0; border: 1px solid rgba(0, 0, 0, .15); border-radius: 7px; cursor: pointer; background: none; }
.pal-item input::-webkit-color-swatch-wrapper { padding: 0; }
.pal-item input::-webkit-color-swatch { border: 0; border-radius: 6px; }
.pal-item .x { position: absolute; top: -6px; right: -6px; width: 16px; height: 16px; padding: 0; border-radius: 50%; background: #fff; border: 1px solid var(--line); font-size: 11px; line-height: 13px; color: var(--muted); display: none; }
.pal-item:hover .x { display: block; }
.pal-add { width: 28px; height: 28px; padding: 0; border: 1px dashed #cbd5e1; color: var(--muted); font-size: 16px; }
.pal-add:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 좁은 화면용 버튼 (기본은 숨김) ---------- */
.only-narrow, .only-narrow-s, .drawer-close { display: none !important; }
.icon-btn { border: 1px solid var(--line); background: #fff; padding: 5px 8px; line-height: 1; position: relative; }
.icon-btn svg { width: 17px; height: 17px; display: block; }
.icon-btn.dot::after { content: ''; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.drawer-close { margin-left: auto; padding: 2px 8px; color: var(--muted); font-size: 14px; }
#hint { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg .short { display: none; }
.status .spacer { min-width: 8px; }
.status > * { white-space: nowrap; flex: none; }
.status > #hint { flex: 0 1 auto; }

/* 상단 바가 넘칠 때 (main.js fitTopbar): 파일 메뉴는 ⋯ 버튼으로, 보기 버튼은 짧은 이름으로 */
body.tb-compact .only-narrow-s { display: block !important; }
body.tb-compact #fileGroup {
  display: none; position: fixed; top: 50px; left: 8px; z-index: 40; flex-direction: column; align-items: stretch;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; box-shadow: 0 10px 30px rgba(0, 0, 0, .15);
}
body.tb-compact #fileGroup button { text-align: left; padding: 8px 14px; }
body.tb-compact.more-open #fileGroup { display: flex; }
body.tb-compact .seg .long { display: none; }
body.tb-compact .seg .short { display: inline; }
body.tb-compact .plan-name { max-width: 160px; }
/* 그래도 넘치면 (휴대폰): 도면 이름은 아이콘만, 둘러보기/걸어보기는 바꿀 쪽 버튼 하나만 */
body.tb-tight .topbar { gap: 4px; padding: 0 6px; }
body.tb-tight .topbar .icon-btn, body.tb-tight .topbar .group button { padding: 5px 6px; }
body.tb-tight .plan-name .nm, body.tb-tight .plan-name .caret { display: none; }
body.tb-tight #walkSeg button.on { display: none; }
body.tb-tight .seg button { padding: 5px 6px; }

/* 분할 화면이 좁으면 (main.js) 2D 위, 3D 아래로 */
.stage.split.split-v #planWrap { right: 0; bottom: 50%; }
.stage.split.split-v #view3d { left: 0; top: 50%; border-left: 0; border-top: 1px solid var(--line); }

/* ========== 반응형 (기본 규칙보다 뒤에 있어야 적용된다) ========== */
@media (max-width: 1100px) {
  .brand { font-size: 0; gap: 0; margin-right: 0; }
  .topbar { gap: 6px; padding: 0 8px; }
  .group button, .seg button { padding: 5px 7px; }
  .layout { grid-template-columns: 200px 1fr 230px; }
}

/* 900px 이하: 왼쪽은 아이콘 도구 막대, 가구 목록과 속성 패널은 서랍처럼 열고 닫기 */
@media (max-width: 900px) {
  .only-narrow { display: flex !important; }
  .drawer-close { display: inline-block !important; }
  .layout { grid-template-columns: 62px 1fr; }
  .left { overflow-y: auto; overflow-x: hidden; }
  .left > section:first-child { padding: 8px 6px; border-bottom: 0; }
  .left > section:first-child h3 { display: none; }
  .tools { grid-template-columns: 1fr; gap: 4px; }
  .tools button { font-size: 10.5px; padding: 7px 2px 5px; gap: 2px; }
  .tools button kbd { display: none; }
  .catalog, .right {
    position: fixed; top: 52px; bottom: 28px; z-index: 30; background: var(--panel); overflow-y: auto;
    transition: transform .2s ease;
  }
  .catalog { left: 62px; width: min(290px, calc(100vw - 80px)); border-right: 1px solid var(--line); box-shadow: 8px 0 24px rgba(0, 0, 0, .12); transform: translateX(-130%); }
  .catalog h3 { display: flex; align-items: center; gap: 4px; }
  body.catalog-open .catalog { transform: none; }
  .right { right: 0; width: min(300px, calc(100vw - 70px)); border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(0, 0, 0, .12); transform: translateX(110%); }
  .right > .drawer-close { position: absolute; top: 10px; right: 8px; z-index: 1; }
  body.props-open .right { transform: none; }
  body.props-open #propsBtn, body.catalog-open #catalogBtn { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
}

/* 760px 이하: 파일 메뉴는 ⋯ 버튼으로, 분할 화면은 위아래로 */
@media (max-width: 760px) {
  .only-narrow-s { display: block !important; }
  #fileGroup {
    display: none; position: fixed; top: 50px; left: 8px; z-index: 40; flex-direction: column; align-items: stretch;
    background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; box-shadow: 0 10px 30px rgba(0, 0, 0, .15);
  }
  #fileGroup button { text-align: left; padding: 8px 14px; }
  body.more-open #fileGroup { display: flex; }
  .plan-name { max-width: 110px; }
  .logo { display: none; }
  .topbar .group { padding-left: 4px; }
  .seg .long { display: none; }
  .seg .short { display: inline; }
  .seg button { padding: 5px 8px; }
  #coords { display: none; }
  .modal { padding: 8px; }
  .brand-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow-y: auto; }
  .brand-preview { order: -1; padding: 12px; }
  .brand-form { border-right: 0; overflow: visible; }
}
