:root {
  --bg: #0e1014; --panel: #161920; --panel2: #1c2029; --line: #272c38; --text: #e7eaf0; --muted: #8a93a6;
  --accent: #5b8cff; --accent2: #7aa2ff; --ok: #3fb97f; --warn: #ffb454; --err: #ff6b6b;
  --radius: 8px; font-size: 13px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  display: flex; flex-direction: column; overflow: hidden; -webkit-font-smoothing: antialiased; }
button, select, input, textarea { font: inherit; color: inherit; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 11px; cursor: pointer; white-space: nowrap; }
button:hover { border-color: #3a4152; background: #222733; }
button:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent2); border-color: var(--accent2); }
button.ghost { background: transparent; }
button.mini { padding: 2px 8px; font-size: 12px; margin-left: auto; }
button:disabled { opacity: .5; cursor: default; }
select { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; max-width: 260px; }
.spacer { flex: 1; }
.muted { color: var(--muted); font-weight: 400; }

.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.brand { font-size: 16px; font-weight: 700; letter-spacing: -.2px; display: flex; align-items: baseline; gap: 8px; margin-right: 8px; }
.brand .logo { color: var(--accent); font-size: 18px; }
.brand small { color: var(--muted); font-weight: 400; font-size: 12px; }
.stat { color: var(--muted); font-variant-numeric: tabular-nums; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius);
  min-width: 270px; padding: 6px; z-index: 30; box-shadow: 0 12px 32px rgba(0,0,0,.45); }
.menu-pop a { display: flex; flex-direction: column; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.menu-pop a:hover { background: #262c3a; }
.menu-pop a span { color: var(--muted); font-size: 12px; }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

.layout { flex: 1; display: grid; grid-template-columns: 270px minmax(0, 1fr) 380px; min-height: 0; }
aside { background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
aside.left { border-right: 1px solid var(--line); }
aside.right { border-left: 1px solid var(--line); }
aside section { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
aside section.grow { flex: 1; }
h3 { margin: 0 0 8px; font-size: 12px; text-transform: none; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 8px; letter-spacing: .2px; }
aside.right > h3 { padding: 12px 12px 0; }

.list { list-style: none; margin: 0; padding: 0; overflow: auto; max-height: 232px; }
.list li { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.list li:hover { background: var(--panel2); }
.list li.active { background: #20283a; }
.badge { font-size: 10.5px; padding: 1px 6px; border-radius: 10px; background: #2a3040; color: #b9c2d6; flex: none; }
.badge.plan { background: #1d3557; color: #a8c7ff; } .badge.section { background: #3b2a55; color: #d2b6ff; } .badge.elevation { background: #204036; color: #9fe0c0; }
.list .sid { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; width: 46px; }
.list .ttl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.warn-dot { color: var(--warn); margin-left: auto; }
.job { margin-top: 8px; font-size: 12px; color: var(--muted); background: var(--panel2); border-radius: 6px; padding: 8px; max-height: 110px; overflow: auto; white-space: pre-wrap; }

.tree { overflow: auto; flex: 1; min-height: 0; }
.tag-row { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; user-select: none; }
.tag-row:hover { background: var(--panel2); }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; border: 1px solid rgba(255,255,255,.2); }
.tag-row .name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-row .cnt { color: var(--muted); font-size: 12px; }
.el-row { padding: 3px 6px 3px 34px; color: #c4cbda; border-radius: 6px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; }
.el-row:hover { background: var(--panel2); } .el-row.sel { background: #26324a; color: #fff; }
.tag-off .name, .tag-off + .els { opacity: .4; }
.gridbox { font-size: 11.5px; color: var(--muted); line-height: 1.6; max-height: 120px; overflow: auto; }
.gridbox b { color: #b9c2d6; font-weight: 600; }

.center { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tabs { display: flex; align-items: center; gap: 4px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; flex-wrap: wrap; }
.tabs > button[data-tab] { background: transparent; border-color: transparent; padding: 6px 12px; color: var(--muted); font-weight: 600; }
.tabs > button[data-tab].active { color: var(--text); background: var(--panel2); border-color: var(--line); }
.toolrow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.toolrow button { padding: 4px 9px; font-size: 12px; }
.chk, .clip { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; margin-left: 6px; }
.clip select, .clip input[type=number] { padding: 3px 6px; font-size: 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 5px; }
.clip input[type=range] { width: 130px; accent-color: var(--accent); }
.view { position: relative; flex: 1; min-height: 0; overflow: hidden; background: radial-gradient(ellipse at 50% 35%, #1b2029 0%, #0c0e12 75%); }
#canvas { width: 100%; height: 100%; display: block; }
.hud { position: absolute; left: 12px; bottom: 10px; color: var(--muted); font-size: 12px; pointer-events: none; font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px #000; }
.inspector { position: absolute; right: 12px; top: 12px; width: 300px; max-height: 70%; overflow: auto; background: rgba(22,25,32,.94); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; font-size: 12.5px; backdrop-filter: blur(6px); }
.inspector h4 { margin: 0 0 6px; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.inspector .note { color: #c9d1e0; margin: 6px 0; line-height: 1.5; }
.inspector table { width: 100%; border-collapse: collapse; }
.inspector td { padding: 2px 0; vertical-align: top; } .inspector td:first-child { color: var(--muted); width: 74px; }
.inspector pre { background: #0f1218; border-radius: 6px; padding: 8px; overflow: auto; max-height: 180px; font-size: 11px; margin: 8px 0 0; }
.empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.empty-card { text-align: center; max-width: 420px; color: var(--muted); line-height: 1.6; }
.empty-card h2 { color: var(--text); font-size: 18px; margin: 0 0 8px; }
.sheetview { background: #fff; cursor: grab; display: flex; align-items: center; justify-content: center; }
.sheetview:active { cursor: grabbing; }
.sheetview img { max-width: 100%; max-height: 100%; user-select: none; transform-origin: 0 0; }
.sheetview .hud { color: #333; text-shadow: none; background: rgba(255,255,255,.85); padding: 2px 8px; border-radius: 4px; }
.loading { position: absolute; top: 10px; right: 12px; background: rgba(0,0,0,.7); color: #fff; padding: 4px 10px; border-radius: 12px; font-size: 12px; }

.pill { font-size: 11px; padding: 1px 8px; border-radius: 10px; background: #2a3040; color: #b9c2d6; font-weight: 500; }
.pill.run { background: #1d3557; color: #a8c7ff; } .pill.ok { background: #1f3d30; color: #9fe0c0; } .pill.err { background: #4a2326; color: #ffb3b3; }
.chat { flex: 1; overflow: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.chat > * { flex-shrink: 0; }
.msg { line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: #24304a; border-radius: 10px 10px 2px 10px; padding: 7px 11px; max-width: 92%; }
.msg.ai { color: #dfe4ee; }
.msg.err { color: #ffb3b3; background: #2d1b1d; border: 1px solid #55292d; border-radius: 8px; padding: 8px 10px; }
.msg.done { color: var(--muted); font-size: 12px; border-top: 1px dashed var(--line); padding-top: 6px; }
.step { border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); font-size: 12.5px; overflow: hidden; }
.step summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 6px 9px; cursor: pointer; }
.step summary::-webkit-details-marker { display: none; }
.step .ico { width: 16px; text-align: center; color: var(--accent2); flex: none; }
.step .lbl { font-weight: 600; flex: none; } .step .arg { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.step .st { flex: none; color: var(--muted); } .step.ok .st { color: var(--ok); } .step.bad .st { color: var(--err); }
.step .body { border-top: 1px solid var(--line); padding: 8px 9px; color: #c4cbda; white-space: pre-wrap; font-size: 11.5px; max-height: 220px; overflow: auto;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.step img { display: block; width: 100%; border-top: 1px solid var(--line); background: #fff; cursor: zoom-in; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
.quick button { font-size: 12px; padding: 4px 9px; border-radius: 14px; }
.quick button.cta { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; padding: 8px 14px; width: 100%; border-radius: 8px; font-size: 13px; }
#chatForm { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: none; }
#chatInput { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; resize: none; line-height: 1.5; }
#chatForm .row { display: flex; gap: 6px; justify-content: flex-end; }
.typing { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.typing i { width: 6px; height: 6px; background: var(--accent2); border-radius: 50%; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .typing i { animation: none; } }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px 24px; width: min(680px, 92vw); max-height: 86vh; overflow: auto; position: relative; line-height: 1.6; }
.modal-card h2 { margin: 0 0 12px; font-size: 17px; }
.modal-card .x { position: absolute; right: 12px; top: 10px; background: transparent; border: 0; font-size: 20px; color: var(--muted); }
.modal-card input[type=text], .modal-card input[type=password] { width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; color: var(--text); }
.modal.login { background: var(--bg, #0d1016); z-index: 70; }
.modal.login .modal-card { width: min(380px, 92vw); }
.modal.login .msg.err { margin-top: 10px; }
.modal-card code, .modal-card pre { background: #0f1218; border-radius: 6px; padding: 2px 6px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.modal-card pre { padding: 10px; overflow: auto; white-space: pre-wrap; }
.modal-card table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.modal-card th, .modal-card td { text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--line); }
.modal-card th:first-child, .modal-card td:first-child { text-align: left; }
.modal-card th { color: var(--muted); font-weight: 600; font-size: 12px; }
.modal-card .flag { color: var(--warn); }
.modal-card .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.drop { border: 1.5px dashed #3a4152; border-radius: 10px; padding: 22px; text-align: center; color: var(--muted); margin-top: 10px; cursor: pointer; }
.drop.over { border-color: var(--accent); color: var(--text); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 60; display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 94vh; background: #fff; border-radius: 6px; }
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: #2c3240; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
@media (max-width: 1180px) { .layout { grid-template-columns: 220px minmax(0, 1fr) 300px; } .brand small { display: none; } }
@media (max-width: 860px) { .layout { grid-template-columns: 190px minmax(0, 1fr) 250px; } .stat { display: none; } }

/* 사람별 프로젝트 · 읽기 전용 예시 · 데이터 안내 */
.proj-meta { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #2a3040; color: #b9c2d6; white-space: nowrap; }
.proj-meta.ro { background: #3d3420; color: #ffd591; }
.ro-banner { flex: none; padding: 6px 14px; background: #2b2618; color: #ffd591; border-bottom: 1px solid #4a4026; font-size: 12.5px; }
button.danger:hover:not(:disabled) { border-color: var(--err); color: #ffb3b3; }
a.btn { display: inline-block; text-decoration: none; border-radius: 6px; padding: 8px 14px; border: 1px solid var(--line); background: var(--panel2); color: inherit; }
a.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
a.btn.primary:hover { background: var(--accent2); border-color: var(--accent2); }
#whoami { white-space: nowrap; }
a.charge { font-size: 12px; color: var(--accent); text-decoration: none; padding: 2px 6px; border: 1px solid var(--line); border-radius: 10px; white-space: nowrap; }
a.charge:hover { border-color: var(--accent); }
.bill-note { margin: 0 0 6px; padding: 6px 8px; font-size: 12px; line-height: 1.5; color: var(--muted); border: 1px dashed var(--line); border-radius: 6px; }
.bill-note.warn { color: #ffd591; border-color: #4a4026; }
.bill-note a { color: var(--accent); }
.modal.login .notice { margin: 14px 0 0; padding-left: 18px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.datainfo li { margin-bottom: 6px; line-height: 1.55; }
