/* DXF 도면 작업 웹 — 화면 스타일
 *
 * 원칙
 *  1) 클래스·id 이름은 app.js 가 쓰는 그대로 둔다. 모양만 손본다.
 *  2) 바깥 폰트·아이콘을 부르지 않는다 (인터넷 없는 곳에서 돈다).
 *  3) 손가락으로 눌러야 하니 누르는 것은 44px 이상.
 */

/* ── 색·치수 ───────────────────────────────────────────── */
:root {
  --bg:        #0d1015;   /* 가장 어두운 바탕 */
  --panel:     #151a22;   /* 사이드바·카드 */
  --panel2:    #1d232d;   /* 입력칸·보조 단추 */
  --panel3:    #252d39;   /* 눌린 것·강조 */
  --line:      #262e3a;
  --line2:     #333d4d;

  --fg:        #e7ecf3;
  --fg2:       #c5cedb;
  --dim:       #97a3b6;   /* 도움말 */
  --dim2:      #6e7b8e;   /* 더 여린 글씨 */

  --accent:    #5aa8ff;
  --accent2:   #82c1ff;
  --accent-ink:#05101d;
  --accent-bg: rgba(90,168,255,.12);
  --accent-ln: rgba(90,168,255,.42);

  --ok:        #42d39a;
  --warn:      #ffb54a;
  --bad:       #ff6f6f;
  --bad-bg:    rgba(255,111,111,.12);
  --warn-bg:   rgba(255,181,74,.12);

  --radius:    10px;
  --radius-lg: 14px;
  --radius-sm: 8px;
  --touch:     44px;

  --shadow:    0 10px 30px -12px rgba(0,0,0,.75);
  --shadow-lg: 0 24px 60px -20px rgba(0,0,0,.85);

  --mono: Consolas, "D2Coding", "Cascadia Mono", "Courier New", monospace;

  /* 레이어 표의 칸 너비 — 머리글과 각 줄이 같은 값을 써야 세로줄이 맞는다
     (줄마다 grid 가 따로라 너비를 못 박지 않으면 어긋난다) */
  --lnum-w: 78px;
  --lcol-w: 112px;
  --lmrg-w: 190px;
  --ldel-w: 46px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI",
               "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo",
               "Noto Sans KR", sans-serif;
  font-size: 15px; line-height: 1.62; letter-spacing: -0.01em;
  word-break: keep-all;                 /* 한글은 낱말 단위로 줄바꿈 */
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; }
h1, h2, h3 { letter-spacing: -0.02em; }
::selection { background: rgba(90,168,255,.32); }

/* 키보드 초점은 또렷하게, 마우스 클릭에는 테두리가 남지 않게 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* 스크롤 막대 */
* { scrollbar-width: thin; scrollbar-color: #38424f transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #333c4a; border-radius: 9px;
  border: 3px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: #4a5668; background-clip: padding-box; }

/* ── 레이아웃 ───────────────────────────────────────────── */
#app { display: flex; height: 100%; }

#side {
  width: 284px; flex: 0 0 284px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
#side header {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.035), transparent);
}
#side h1 {
  margin: 0; font-size: 15.5px; font-weight: 700; color: var(--fg);
  display: flex; align-items: center; gap: 9px;
}
#side h1::before {                      /* 작은 표식 — 그림 파일 없이 */
  content: ''; width: 4px; height: 17px; border-radius: 3px; flex: none;
  background: linear-gradient(180deg, var(--accent2), var(--accent));
}
#side .sub {
  color: var(--dim); font-size: 11.5px; line-height: 1.5;
  margin-top: 7px; word-break: break-all;
}

/* ── 프로젝트 고르개 ───────────────────────────────────── */
.projBox { display: flex; gap: 7px; margin: 12px 0 2px; }
.projBox select {
  flex: 1; min-width: 0;
  background: var(--panel2); border: 1px solid var(--line2);
  border-radius: var(--radius-sm); padding: 9px 32px 9px 11px;
  min-height: var(--touch); font-size: 13.5px; font-weight: 600; color: var(--fg);
}
.projBox button {
  width: var(--touch); flex: none;
  background: var(--panel2); border: 1px solid var(--line2);
  border-radius: var(--radius-sm); font-size: 18px; line-height: 1; color: var(--dim);
  min-height: var(--touch);
  transition: border-color .15s, color .15s, background .15s;
}
.projBox button:hover { border-color: var(--accent-ln); color: var(--accent); background: var(--accent-bg); }

.projTag {
  font-size: 12px; font-weight: 600; color: var(--accent2);
  background: var(--accent-bg); border: 1px solid var(--accent-ln);
  border-radius: 999px; padding: 3px 11px; white-space: nowrap;
}

/* ── 도구 목록 (여기가 핵심) ───────────────────────────── */
#toolList { overflow-y: auto; overflow-x: hidden; flex: 1; padding: 2px 0 24px; }

/* 분류 머리글 — 스크롤해도 위에 붙어 있어 지금 어느 묶음인지 늘 보인다 */
.grp {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 8px;
  margin: 0; padding: 16px 16px 8px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  color: #aab6c8; font-size: 11.5px; font-weight: 700;
  letter-spacing: .07em; line-height: 1.3;
}
.grp::before {
  content: ''; width: 6px; height: 6px; border-radius: 2px; flex: none;
  background: var(--accent); opacity: .65;
}
.grp:first-child { padding-top: 12px; }

/* 도구 한 칸 */
.tool {
  position: relative; display: block; width: calc(100% - 16px);
  margin: 5px 8px 0; padding: 10px 30px 11px 13px;
  text-align: left; border-radius: var(--radius);
  min-height: var(--touch); color: var(--fg2);
  transition: background .14s, color .14s;
}
.tool::before {                          /* 고른 표시 막대 */
  content: ''; position: absolute; left: -5px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 0; border-radius: 3px;
  background: var(--accent); transition: height .16s ease;
}
.tool b {
  display: block; font-weight: 600; font-size: 14.5px; line-height: 1.4;
  color: inherit;
}
.tool span {                             /* 설명은 두 줄까지만 — 목록이 흐트러지지 않게 */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--dim2); font-size: 12px; line-height: 1.45; margin-top: 2px;
}
.tool:hover { background: rgba(255,255,255,.05); color: var(--fg); }
.tool:hover span { color: var(--dim); }
.tool:active { background: rgba(255,255,255,.08); }

.tool.on {
  background: var(--accent-bg);
  box-shadow: inset 0 0 0 1px var(--accent-ln);
  color: #dceaff;
}
.tool.on::before { height: 56%; }
.tool.on b { font-weight: 700; }
.tool.on span { color: #93b6dc; }
.tool.on::after {                        /* 오른쪽 꺾쇠 */
  content: ''; position: absolute; right: 14px; top: 50%;
  width: 7px; height: 7px;
  border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent);
  transform: translateY(-50%) rotate(-45deg);
}

#side footer {
  border-top: 1px solid var(--line); padding: 10px 12px;
  display: flex; gap: 8px;
  background: linear-gradient(0deg, rgba(0,0,0,.25), transparent);
}
#side footer button {
  flex: 1; background: var(--panel2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 6px; font-size: 12.5px;
  color: var(--dim); min-height: 42px;
  transition: color .15s, border-color .15s, background .15s;
}
#side footer button:hover { color: var(--fg); border-color: var(--line2); background: var(--panel3); }
#side footer #logoutBtn:hover { color: var(--bad); border-color: rgba(255,111,111,.45); background: var(--bad-bg); }

/* ── 오른쪽 본문 ───────────────────────────────────────── */
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }

#head {
  padding: 13px 22px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: linear-gradient(180deg, rgba(255,255,255,.03), transparent);
}
#head h2 {
  margin: 0; font-size: 18px; font-weight: 700; color: var(--fg);
  margin-right: 2px;
}
#head .est {
  color: var(--dim); font-size: 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
#head .est:empty { display: none; }
#head .danger {
  color: var(--warn); font-size: 12px; font-weight: 600;
  background: var(--warn-bg); border: 1px solid rgba(255,181,74,.45);
  border-radius: 999px; padding: 3px 11px; white-space: nowrap;
}
#menuBtn { display: none; }

/* 화면 위쪽 오른쪽 끝에 붙는 단추 (로그아웃 등) */
.topbtn {
  margin-left: auto; flex: none;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 15px; font-size: 12.5px;
  color: var(--dim); min-height: 38px;
  transition: color .15s, border-color .15s, background .15s;
}
.topbtn:hover { border-color: rgba(255,111,111,.45); color: var(--bad); background: var(--bad-bg); }

#body { flex: 1; overflow-y: auto; }
#pad { padding: 22px 22px 56px; max-width: 920px; }

.desc {
  color: var(--dim); font-size: 13.5px; line-height: 1.72;
  margin: 0 0 20px; white-space: pre-line;
  border-left: 2px solid var(--line2); padding-left: 14px;
}
.desc:empty { display: none; }

/* ── 옵션 폼 ───────────────────────────────────────────── */
#opts {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 6px 18px 18px;
}
#opts:empty { display: none; }

.opt {
  padding: 14px 0 0; margin: 0;
  border-top: 1px solid var(--line);
}
.opt:first-child { border-top: 0; padding-top: 16px; }

.opt > label {
  display: block; font-size: 13.5px; font-weight: 700; color: var(--fg);
  margin-bottom: 7px; letter-spacing: -0.005em;
}
.help {
  color: var(--dim); font-size: 12.5px; line-height: 1.6; margin-top: 7px;
}
.opt .help { margin-top: 7px; }

/* 입력칸 공통 */
.opt input[type=text], .opt input[type=number], .opt select, .opt textarea {
  width: 100%; background: var(--bg);
  border: 1px solid var(--line2); border-radius: var(--radius);
  padding: 11px 13px; min-height: var(--touch); color: var(--fg);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.opt input::placeholder, .opt textarea::placeholder { color: var(--dim2); }
.opt textarea {
  min-height: 104px; resize: vertical;
  font-family: var(--mono); font-size: 13px; line-height: 1.6; letter-spacing: 0;
}
.opt input:hover, .opt select:hover, .opt textarea:hover { border-color: #3e4a5c; }
.opt input:focus, .opt select:focus, .opt textarea:focus,
.projBox select:focus, .mcard input:focus, #loginCard input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(90,168,255,.18);
}

/* 고르개 — 화살표를 직접 그린다 (바깥 아이콘 없이) */
.opt select, .projBox select {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image:
    url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2397a3b6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.6 6 6.4 11 1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
  padding-right: 34px;
}
.opt select[multiple] {
  background-image: none; padding: 6px; min-height: 150px;
  line-height: 1.7;
}
.opt select[multiple] option { padding: 7px 9px; border-radius: 6px; }
option { background: var(--panel2); color: var(--fg); }

/* 예·아니오 */
.check {
  display: flex; align-items: center; gap: 11px;
  min-height: var(--touch); padding: 8px 13px;
  background: var(--bg); border: 1px solid var(--line2); border-radius: var(--radius);
  transition: border-color .15s, background .15s;
}
.check:hover { border-color: #3e4a5c; }
.check input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); cursor: pointer; }
.check label { font-size: 14px; font-weight: 600; margin: 0; cursor: pointer; flex: 1; }

/* 여러 개 고르기 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line2); background: var(--panel2); border-radius: 999px;
  padding: 9px 15px; min-height: 42px; font-size: 13px; color: var(--fg2);
  transition: border-color .14s, background .14s, color .14s;
}
.chip:hover { border-color: var(--accent-ln); color: var(--fg); }
.chip.on {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  font-weight: 700;
}

/* 색 고르기 */
.colorRow { display: flex; align-items: center; gap: 11px; margin-top: 2px; }
.sw {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--line2); flex: none;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.35);
}
.colorRow input[type=number] { width: 96px; flex: none; }
.colorRow .cname { color: var(--dim); font-size: 12.5px; }

.palette { margin-bottom: 9px; }
.palette .row { display: flex; flex-wrap: wrap; gap: 6px; }
.palette .p {
  width: 32px; height: 32px; border-radius: 7px; padding: 0;
  border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.4);
  transition: transform .1s;
}
.palette .p:hover { transform: scale(1.1); }
.palette .p.on { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.2); }

/* ── 레이어 표 ─────────────────────────────────────────── */
.lmbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 2px 0 10px;
}
.lmbar .help { margin: 0; }
.lmbar .chip { min-height: 38px; padding: 7px 14px; font-size: 12.5px; }

.lmap {
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: var(--bg);
}
.lrow {
  display: grid; grid-template-columns: 1fr 72px auto auto auto;
  align-items: center; gap: 10px; padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}
.lrow:last-child { border-bottom: 0; }
.lrow:nth-child(even) { background: rgba(255,255,255,.022); }
.lrow:hover:not(.lhead) { background: rgba(90,168,255,.07); }
.lhead {
  background: var(--panel2); font-size: 11.5px; color: var(--dim);
  font-weight: 700; letter-spacing: .04em;
  position: sticky; top: 0; z-index: 1;
}
.lname { min-width: 0; }
.lname b { display: block; font-size: 13.5px; font-weight: 600; word-break: break-all; }
.lname i { display: block; font-style: normal; color: var(--dim2); font-size: 11.5px; line-height: 1.45; }
.lcnt { text-align: right; color: var(--dim); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.lcol { display: flex; align-items: center; gap: 8px; width: var(--lcol-w); }
.lhead .lmrg { width: var(--lmrg-w); }
/* 표 안의 칸은 좁아야 한다 — 위쪽 '.opt input' 규칙보다 세게 잡는다 */
.opt .lcol input[type=number], .opt .lrow input.lmrg, .lcol input, input.lmrg {
  background: var(--panel2); border: 1px solid var(--line2);
  border-radius: 7px; padding: 7px 9px; min-height: 38px; color: var(--fg);
}
.opt .lcol input[type=number], .lcol input { width: var(--lnum-w); text-align: center; }
.opt .lrow input.lmrg, input.lmrg { width: var(--lmrg-w); }
.lcol input:focus, input.lmrg:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(90,168,255,.18);
}
.sw.sm { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line2); flex: none; }
input.lmrg::placeholder { color: #5a6675; }
.ldel { text-align: center; width: var(--ldel-w); }
.ldel input { width: 20px; height: 20px; accent-color: var(--bad); cursor: pointer; }

/* ── 실행 줄 ───────────────────────────────────────────── */
#runBar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin: 22px 0 4px; padding: 14px 16px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.btn {
  background: linear-gradient(180deg, var(--accent2), var(--accent));
  color: var(--accent-ink); border: 0; border-radius: var(--radius);
  padding: 0 28px; min-height: var(--touch);
  font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 8px 18px -10px rgba(90,168,255,.9);
  transition: filter .15s, transform .06s, box-shadow .15s, background .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.07); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .38; box-shadow: none; cursor: not-allowed; }
.btn.ghost {
  background: var(--panel2); color: var(--fg2); border: 1px solid var(--line2);
  font-weight: 600; box-shadow: none; padding: 0 20px;
}
.btn.ghost:hover:not(:disabled) { background: var(--panel3); color: var(--fg); filter: none; }
.btn.stop {
  background: var(--bad); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 8px 18px -10px rgba(255,111,111,.9);
}

#status {
  font-size: 13px; color: var(--dim); margin-left: auto;
  display: inline-flex; align-items: center; gap: 8px;
  font-variant-numeric: tabular-nums;
}
#status:empty { display: none; }
#status::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: currentColor; opacity: .8;
}
#status.run { color: var(--accent); }
#status.run::before { animation: blip 1.1s ease-in-out infinite; }
#status.ok { color: var(--ok); }
#status.err { color: var(--bad); }
@keyframes blip { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .3; transform: scale(.75); } }

/* ── 실행 기록(로그) ───────────────────────────────────── */
#logBox { margin-top: 18px; display: none; }
#logBox.show { display: block; }
#logBox::before {
  content: '실행 기록';
  display: block; font-size: 12px; font-weight: 700; letter-spacing: .06em;
  color: var(--dim); margin: 0 0 8px 3px;
}
#log {
  background: #080a0e; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 15px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.62; letter-spacing: 0;
  white-space: pre-wrap; word-break: break-all;
  max-height: 46vh; overflow-y: auto; color: #b9c4d3;
}
#log div { padding: 0 0 0 10px; border-left: 2px solid transparent; }
#log .e { color: var(--bad); border-left-color: var(--bad); background: rgba(255,111,111,.07); }
#log .w { color: var(--warn); border-left-color: rgba(255,181,74,.6); }
#log .g { color: var(--ok); border-left-color: rgba(66,211,154,.5); }

/* ── 결과 파일 ─────────────────────────────────────────── */
#files { margin-top: 18px; display: none; }
#files.show { display: block; }
#files::before {
  content: '결과';
  display: block; font-size: 12px; font-weight: 700; letter-spacing: .06em;
  color: var(--dim); margin: 0 0 8px 3px;
}
.file {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--accent-ln);
  border-radius: var(--radius); padding: 11px 13px; margin-bottom: 8px;
}
.file .nm {
  flex: 1; min-width: 170px; font-size: 13.5px; line-height: 1.55;
  word-break: break-all; color: var(--fg2);
}
.file .sz { color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.file a, .file button {
  background: var(--panel2); border: 1px solid var(--line2); border-radius: var(--radius-sm);
  padding: 0 15px; font-size: 12.5px; font-weight: 600; text-decoration: none;
  color: var(--fg2); min-height: 40px; display: inline-flex; align-items: center;
  transition: border-color .15s, color .15s, background .15s;
}
.file a:hover, .file button:hover {
  border-color: var(--accent-ln); color: var(--accent2); background: var(--accent-bg);
}

/* ── 기록 · 저장한 설정 ────────────────────────────────── */
.hist { margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line); }
.hist h3 {
  font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--dim);
  margin: 0 0 10px 3px;
}
.hrow {
  display: flex; align-items: center; gap: 11px; padding: 10px 13px;
  border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 7px;
  background: var(--panel); font-size: 13.5px; width: 100%; text-align: left;
  color: var(--fg2);
  transition: border-color .15s, background .15s, color .15s;
}
button.hrow:hover { border-color: var(--line2); background: var(--panel2); color: var(--fg); }
.hrow .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.hrow .t { color: var(--dim2); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dot.done     { background: var(--ok);     box-shadow: 0 0 0 3px rgba(66,211,154,.16); }
.dot.error    { background: var(--bad);    box-shadow: 0 0 0 3px rgba(255,111,111,.16); }
.dot.canceled { background: var(--dim2); }
.dot.running  { background: var(--accent); box-shadow: 0 0 0 3px rgba(90,168,255,.18); animation: blip 1.1s ease-in-out infinite; }
.dot.queued   { background: var(--warn);   box-shadow: 0 0 0 3px rgba(255,181,74,.16); }

.rname {
  flex: 1; text-align: left; background: none; border: 0; padding: 0; min-width: 0;
  color: inherit;
}
.rname b { display: block; font-size: 13.5px; font-weight: 600; color: var(--fg); }
.rname i { display: block; font-style: normal; color: var(--dim2); font-size: 11.5px; line-height: 1.5; }
.rdel {
  background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0 13px; min-height: 38px; font-size: 12px; color: var(--dim); flex: none;
  transition: border-color .15s, color .15s, background .15s;
}
.rdel:hover { border-color: rgba(255,111,111,.45); color: var(--bad); background: var(--bad-bg); }

/* ── 새 프로젝트 창 ────────────────────────────────────── */
.modal {
  display: none; position: fixed; inset: 0; z-index: 60;
  background: rgba(4,6,10,.72); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  align-items: center; justify-content: center; padding: 18px;
}
.modal.on { display: flex; animation: fade .16s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.mcard {
  background: var(--panel); border: 1px solid var(--line2); border-radius: var(--radius-lg);
  padding: 24px 24px 20px; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.mcard h3 { margin: 0 0 8px; font-size: 17px; font-weight: 700; }
.mcard .help { margin: 0 0 6px; }
.mcard label {
  display: block; font-size: 13px; font-weight: 700; color: var(--fg);
  margin: 16px 0 6px;
}
.mcard input {
  width: 100%; background: var(--bg); border: 1px solid var(--line2);
  border-radius: var(--radius); padding: 11px 13px; min-height: var(--touch);
  transition: border-color .15s, box-shadow .15s;
}
.mcard input::placeholder { color: var(--dim2); }
.mbtns { display: flex; gap: 9px; margin-top: 20px; }
.mbtns .btn { flex: 1; }
.err { color: var(--bad); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ── 로그인 ───────────────────────────────────────────── */
#loginWrap {
  height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(700px 380px at 50% -10%, rgba(90,168,255,.10), transparent 70%),
    var(--bg);
}
#loginCard {
  background: var(--panel); border: 1px solid var(--line2); border-radius: var(--radius-lg);
  padding: 30px 28px; width: 100%; max-width: 360px; box-shadow: var(--shadow);
}
#loginCard h1 { font-size: 18px; font-weight: 700; margin: 0 0 6px; }
#loginCard p { color: var(--dim); font-size: 12.5px; margin: 0 0 20px; }
#loginCard input {
  width: 100%; background: var(--bg); border: 1px solid var(--line2);
  border-radius: var(--radius); padding: 12px 14px; min-height: var(--touch); margin-bottom: 12px;
  transition: border-color .15s, box-shadow .15s;
}
#loginCard button { width: 100%; }
#loginErr { color: var(--bad); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ── 알림 쪽지 ─────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--line2); border-radius: var(--radius);
  padding: 12px 20px; font-size: 13.5px; z-index: 70; max-width: min(90vw, 520px);
  box-shadow: var(--shadow); color: var(--fg);
  animation: toastIn .2s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ── 태블릿·휴대폰 ───────────────────────────────────── */
@media (max-width: 860px) {
  #app { flex-direction: column; }
  #side {
    position: fixed; inset: 0 auto 0 0; z-index: 40;
    width: 86vw; max-width: 330px; flex-basis: auto;
    transform: translateX(-102%); transition: transform .2s ease;
    box-shadow: 0 0 60px rgba(0,0,0,.65);
  }
  #side.open { transform: none; }
  #menuBtn {
    display: inline-flex; align-items: center; justify-content: center;
    width: var(--touch); height: var(--touch); flex: none;
    background: var(--panel2); border: 1px solid var(--line2);
    border-radius: var(--radius); font-size: 17px; color: var(--fg2);
  }
  #scrim {
    position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 39; display: none;
  }
  #scrim.on { display: block; }

  #head { padding: 10px 14px; gap: 9px; }
  #head h2 { font-size: 16.5px; }
  #pad { padding: 16px 14px 72px; }
  #opts { padding: 4px 14px 16px; border-radius: var(--radius); }
  #runBar { padding: 12px; border-radius: var(--radius); }
  #runBar .btn { flex: 1 1 132px; padding: 0 14px; }
  #status { width: 100%; margin-left: 0; }
  #log { max-height: 40vh; font-size: 12px; }

  /* 도구 목록은 손가락에 맞게 조금 더 넉넉하게 */
  .tool { padding-top: 12px; padding-bottom: 13px; }
  .grp { padding-top: 18px; }

  /* 레이어 표는 좁은 화면에서 칸을 줄인다 */
  :root { --lnum-w: 64px; --lcol-w: 98px; --lmrg-w: 124px; --ldel-w: 40px; }
  /* 좁은 화면에서 표를 억지로 구겨넣지 않고 옆으로 밀어 본다 */
  .lmap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .lrow { gap: 8px; padding: 8px 10px; min-width: 470px; }
  .file a, .file button { min-height: var(--touch); flex: 1 1 auto; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ══════════════════════════════════════════════════════════
   묶음 접기 · 도면 미리보기
   (기존 색·치수 변수를 그대로 쓴다)
   ══════════════════════════════════════════════════════════ */

/* ── 분류 머리글을 누르면 접힌다 ─────────────────────────── */
.grp {
  width: 100%; cursor: pointer;
  justify-content: flex-start;
  transition: color .15s;
}
.grp:hover { color: var(--fg); }
.grp .grpname { flex: 1; text-align: left; }
.grp .grpcnt {
  flex: none; font-size: 10.5px; font-weight: 700; color: var(--dim2);
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 7px; letter-spacing: 0;
}
.grp::after {                       /* 접힘 표시 꺾쇠 */
  content: ''; flex: none; width: 6px; height: 6px; margin-left: 2px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .18s ease; opacity: .55;
}
.grp.off::after { transform: rotate(-45deg) translate(-1px, 1px); }
.grp.off .grpcnt { color: var(--accent2); border-color: var(--accent-ln); background: var(--accent-bg); }
.grpbody { overflow: hidden; }
.grpbody.off { display: none; }

/* ── 미리보기 (도면 고르개 아래) ─────────────────────────── */
.pv { display: none; margin-top: 10px; }
.pv.on { display: block; }
.pvimg {
  /* 도면은 가로로 넓기도 하고(계통도) 세로로 길기도 하다(주차장 3개 층).
     상자 크기를 고정하고 그 안에 맞춰 넣는다 — 어느 쪽이든 전체가 보인다. */
  display: block; width: 100%; height: 340px; object-fit: contain;
  background: #000; border: 1px solid var(--line2);
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: zoom-in;
}
.pvbar {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 11px; font-size: 12px; color: var(--dim);
  background: var(--panel2);
  border: 1px solid var(--line2); border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
}
.pvbar span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pvbtn {
  flex: none; background: var(--panel3); border: 1px solid var(--line2);
  border-radius: var(--radius-sm); padding: 6px 12px; font-size: 12px; color: var(--fg2);
  min-height: 34px;
}
.pvbtn:hover { border-color: var(--accent-ln); color: var(--accent2); background: var(--accent-bg); }
.pvmsg {
  padding: 22px 14px; text-align: center; font-size: 12.5px; color: var(--dim);
  background: var(--panel2); border: 1px dashed var(--line2); border-radius: var(--radius);
}
.pvmsg.warn { color: var(--warn); border-color: rgba(255,181,74,.4); background: var(--warn-bg); }

/* ── 크게 보기 ──────────────────────────────────────────── */
.pvfull {
  position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column;
  background: rgba(3,6,10,.94);
}
.pvfullbar {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; border-bottom: 1px solid var(--line);
  background: var(--panel); flex: none;
}
.pvfullbar b { font-size: 14px; }
.pvnote { flex: 1; font-size: 12px; color: var(--dim2); }
.pvstage {
  flex: 1; min-height: 0; overflow: hidden; display: flex;
  align-items: center; justify-content: center; touch-action: none; cursor: grab;
}
.pvstage:active { cursor: grabbing; }
.pvstage img {
  max-width: 100%; max-height: 100%;
  transform-origin: center center; will-change: transform;
  user-select: none; -webkit-user-drag: none;
}

@media (max-width: 860px) {
  .pvimg { height: 240px; }
  .pvnote { display: none; }
}
