:root {
  --bg: #14161c; --panel: #1d2029; --panel2: #252a36; --line: #353b4b; --text: #eef1f6; --muted: #9aa3b5;
  --lucas: #1fbf8f; --lucas-soft: #d9fff2; --claude: #e8793a; --claude-soft: #fff1dc;
  --warn: #f6c343; --err: #ef4444; --ok: #48bb78;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif; overflow: hidden; -webkit-text-size-adjust: 100%; }
button { white-space: nowrap; flex-shrink: 0; font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
button:hover { border-color: #56607a; }
a.btnlink { white-space: nowrap; flex-shrink: 0; color: var(--text); background: rgba(56,105,238,.25); border: 1px solid #3869EE; border-radius: 8px; padding: 6px 10px; text-decoration: none; font-size: inherit; }
a.btnlink:hover { background: rgba(56,105,238,.4); }
button.primary { background: var(--lucas); border-color: var(--lucas); color: #062a20; font-weight: 700; }
button.on { background: var(--warn); color: #222; border-color: var(--warn); }

#topbar { position: fixed; inset: 0 0 auto 0; height: 52px; display: flex; align-items: center; gap: 8px; padding: 0 12px; padding-top: env(safe-area-inset-top); background: rgba(20,22,28,.92); border-bottom: 1px solid var(--line); z-index: 30; }
.brand { font-weight: 800; letter-spacing: .06em; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dot.lucas { background: var(--lucas); } .dot.claude { background: var(--claude); margin-right: 6px; }
.pill { font-size: 12px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pill.ok::before { content: '●'; color: var(--ok); margin-right: 6px; }
.pill.bad::before { content: '●'; color: var(--err); margin-right: 6px; }
.pill.demo::before { content: '●'; color: var(--warn); margin-right: 6px; }
.spacer { flex: 1; }
.zoom { display: flex; gap: 4px; }
#demoBanner { position: fixed; top: 52px; left: 0; right: 0; z-index: 29; background: var(--warn); color: #222; font-weight: 700; text-align: center; font-size: 13px; padding: 5px 8px; }

#stage { position: fixed; inset: 52px 0 0 0; }
#game, #game canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.fatal { padding: 40px; text-align: center; color: var(--muted); }

/* 캐릭터 이름표·말풍선 */
.agent-ui { position: absolute; transform: translate(-50%, -100%); display: flex; flex-direction: column; align-items: center; gap: 3px; pointer-events: none; }
.bubble { pointer-events: auto; cursor: pointer; font-size: 11px; line-height: 1.3; max-width: 190px; padding: 4px 8px; border-radius: 10px; background: #fff; color: #1b1d24; box-shadow: 0 2px 0 rgba(0,0,0,.35); position: relative; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -5px; transform: translateX(-50%); border: 5px solid transparent; border-top-color: #fff; border-bottom: 0; }
.bubble.approval { background: var(--warn); } .bubble.approval::after { border-top-color: var(--warn); }
.bubble.unknown { background: #c9ced8; } .bubble.unknown::after { border-top-color: #c9ced8; }
.bubble.script { background: #e7e3ff; } .bubble.script::after { border-top-color: #e7e3ff; }
.tag { pointer-events: auto; cursor: pointer; font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 6px; white-space: nowrap; }
.tag.lucas { background: var(--lucas); color: #052a1f; } .tag.claude { background: var(--claude); color: #2b1306; }
.alert { pointer-events: auto; width: 20px; height: 20px; border-radius: 50%; background: var(--err); color: #fff; font-weight: 900; font-size: 14px; display: grid; place-items: center; box-shadow: 0 0 0 2px #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.18); } }
.room-label { position: absolute; pointer-events: auto; cursor: pointer; font-size: 11px; font-weight: 700; color: #fff; background: rgba(0,0,0,.45); padding: 2px 7px; border-radius: 6px; white-space: nowrap; transform: translate(4px, 2px); }
.room-label:hover { background: rgba(0,0,0,.7); }

/* 패널 */
#panel { position: fixed; top: 52px; right: 0; bottom: 0; width: min(420px, 100vw); background: var(--panel); border-left: 1px solid var(--line); z-index: 40; display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(0,0,0,.4); }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 17px; flex: 1; }
#panelBody { flex: 1; overflow-y: auto; padding: 12px 14px 20px; -webkit-overflow-scrolling: touch; }
#panelChat:empty { display: none; }
#panelChat { border-top: 1px solid var(--line); padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); background: var(--panel2); }
#panelChat textarea { width: 100%; min-height: 64px; resize: vertical; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: inherit; font-size: 14px; }
#panelChat .row { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
#panelChat select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px; font: inherit; }
#panelChat .hint { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.4; }
.sec { margin: 14px 0 6px; font-size: 12px; font-weight: 800; color: var(--muted); letter-spacing: .04em; }
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font-size: 13px; line-height: 1.5; }
.card .t { font-weight: 700; }
.card .m { color: var(--muted); font-size: 12px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 3px 8px; font-size: 12.5px; }
.kv div:nth-child(odd) { color: var(--muted); }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: #3a4257; margin-right: 4px; }
.badge.s-개발중, .badge.s-기획중 { background: #2b6cb0; } .badge.s-사용자승인대기 { background: var(--warn); color: #222; }
.badge.s-수정필요 { background: var(--err); } .badge.s-완료 { background: var(--ok); color: #062a20; } .badge.s-검토요청 { background: #805ad5; }
.badge.unk { background: #6b7280; }
.profile { display: flex; gap: 12px; align-items: center; }
.avatar { width: 48px; height: 60px; image-rendering: pixelated; background: var(--bg); border-radius: 8px; border: 1px solid var(--line); }
.empty { color: var(--muted); font-size: 12.5px; padding: 6px 0; }
pre.md { white-space: pre-wrap; word-break: break-word; font-size: 12px; line-height: 1.5; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 50vh; overflow: auto; }
.file { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.file:hover { border-color: #56607a; }
.preview img { max-width: 100%; border-radius: 8px; }
.warn-note { background: rgba(246,195,67,.12); border: 1px solid rgba(246,195,67,.4); color: #f8dc8a; border-radius: 8px; padding: 8px 10px; font-size: 12px; line-height: 1.5; margin: 8px 0; }
.tag.small { font-size: 9px; padding: 1px 4px; }
.room-label.small { font-size: 9px; padding: 1px 5px; }
.note { background: var(--panel2); border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 8px 10px; font-size: 12px; line-height: 1.5; margin: 8px 0; }
.prog { height: 6px; background: #3a4257; border-radius: 999px; overflow: hidden; margin: 6px 0 2px; }
.prog > div { height: 100%; background: linear-gradient(90deg, var(--lucas), #7fc8f8); }
.row.btns { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 2px; }
button.ok { background: var(--ok); border-color: var(--ok); color: #062a20; font-weight: 700; }
button.warn { background: var(--warn); border-color: var(--warn); color: #222; font-weight: 700; }
button.bad { background: var(--err); border-color: var(--err); color: #fff; font-weight: 700; }
.avatar.sm { width: 32px; height: 40px; flex-shrink: 0; }
.card.org .row { display: flex; gap: 8px; align-items: center; }
.card.org input, .card.org select, .card.org textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font: inherit; font-size: 12.5px; width: 100%; }
.card.org input[type=color] { padding: 0; height: 28px; }
.card.org .row input { flex: 1; font-weight: 700; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.grid2 label, label.full { font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
label.full { margin-top: 6px; }
#panelChat label { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
/* 일정 시계 */
#clock { position: absolute; left: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 20; background: rgba(20,22,28,.88); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; min-width: 190px; max-width: 280px; cursor: pointer; box-shadow: 0 6px 18px rgba(0,0,0,.35); }
#clock:hover { border-color: #56607a; }
.ck-time { font-size: 24px; font-weight: 800; letter-spacing: .04em; display: flex; gap: 6px; align-items: center; font-variant-numeric: tabular-nums; }
.ck-date { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.ck-list { font-size: 12px; line-height: 1.5; }
.ck-list .now { color: var(--warn); font-weight: 700; }
.ck-list .due { color: #ff8a8a; }
.ck-list .m { font-size: 11px; }
/* 비상벨 */
#alarm { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 70; background: #b91c1c; color: #fff; font-weight: 800; padding: 10px 14px; border-radius: 10px; display: flex; gap: 10px; align-items: center; box-shadow: 0 8px 24px rgba(185,28,28,.5); max-width: calc(100vw - 32px); animation: alarmPulse .6s infinite alternate; }
#alarm button { background: #fff; color: #b91c1c; border: 0; font-weight: 800; }
@keyframes alarmPulse { from { background: #b91c1c; } to { background: #ef4444; } }
body.alarming #stage::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 25; box-shadow: inset 0 0 0 4px rgba(239,68,68,.9), inset 0 0 60px rgba(239,68,68,.45); animation: alarmEdge .5s infinite alternate; }
@keyframes alarmEdge { from { opacity: .35; } to { opacity: 1; } }
/* 소리·조명 메뉴 */
#soundMenu { position: fixed; top: 56px; right: 12px; z-index: 65; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 260px; box-shadow: 0 8px 24px rgba(0,0,0,.45); font-size: 13px; }
#soundMenu label { display: flex; align-items: center; gap: 6px; margin: 5px 0; }
#soundMenu .vol input { flex: 1; }
#soundMenu .row { display: flex; gap: 6px; margin: 6px 0; }
#soundMenu select { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px; font: inherit; }
.sm-title { font-weight: 800; color: var(--muted); font-size: 12px; margin-top: 4px; }
/* 오른쪽: 업무 지시·진행 현황 */
body.dock-open #stage { right: 360px; }
#dock { position: fixed; top: 52px; right: 0; bottom: 0; width: 360px; background: var(--panel); border-left: 1px solid var(--line); z-index: 35; overflow-y: auto; overflow-x: hidden; padding: 0 0 20px; display: none; }
#dock .dk-row.btns2 { flex-direction: column; align-items: stretch; }
#dock .dk-row.btns2 button { width: 100%; }
body.dock-open #dock { display: block; }
.dk-sec { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.dk-title { font-weight: 800; font-size: 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
#dock select, #dock textarea { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px; font: inherit; font-size: 13.5px; }
#dock textarea { min-height: 84px; resize: vertical; margin-top: 6px; }
.dk-row { display: flex; gap: 6px; align-items: center; justify-content: space-between; margin-top: 6px; }
.dk-row button { flex: 1; }
#dock .hint { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.4; }
.job { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; font-size: 12.5px; }
.job.running { border-color: #7fc8f8; }
.job.done { border-color: rgba(72,187,120,.6); }
.job.failed { border-color: var(--err); }
.job .rep { white-space: pre-wrap; max-height: 120px; overflow: auto; color: var(--muted); font-size: 12px; margin-top: 4px; }
.spin { display: inline-block; width: 10px; height: 10px; border: 2px solid #7fc8f8; border-top-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.mini { font-size: 11px; padding: 3px 8px; }
/* 왼쪽: 완료 알림 센터 */
#notify { position: absolute; left: 12px; top: 12px; z-index: 21; width: 300px; max-width: calc(100% - 24px); background: rgba(20,22,28,.9); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.nf-head { display: flex; align-items: center; gap: 6px; padding: 7px 10px; font-size: 13px; }
.nf-head b { flex: 1; }
.nf-head button { padding: 1px 7px; font-size: 12px; }
.nf-count { background: var(--err); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 800; padding: 0 7px; }
.nf-count:empty { display: none; }
#nfList { max-height: 36vh; overflow-y: auto; padding: 0 8px 8px; }
#notify.collapsed #nfList { display: none; }
.nf { display: flex; gap: 8px; padding: 7px 8px; border-radius: 8px; background: var(--panel2); margin-top: 5px; font-size: 12.5px; line-height: 1.4; cursor: pointer; border-left: 3px solid #56607a; }
.nf.unread { border-left-color: var(--ok); }
.nf.k-error.unread { border-left-color: var(--err); } .nf.k-approval.unread { border-left-color: var(--warn); }
.nf .ic { font-size: 15px; }
.nf .tm { color: var(--muted); font-size: 11px; }
.nf-pop { animation: nfPop .5s ease; }
@keyframes nfPop { from { transform: translateX(-12px); opacity: 0; } to { transform: none; opacity: 1; } }
/* 중앙 기억 */
.memf input, .memf select { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px; font: inherit; font-size: 13px; margin-top: 6px; }
.card.mem .badge { margin-right: 6px; }
.card.mem.del { opacity: .55; }
#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #fff; color: #1b1d24; padding: 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 600; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.4); max-width: calc(100vw - 32px); }

@media (max-width: 720px) {
  #topbar { gap: 5px; padding: 0 8px; } .brand { font-size: 12px; letter-spacing: 0; } .dot.claude { margin-right: 3px; }
  .pill { display: none; } .lbl { display: none; } #btnBoss { padding: 6px 8px; }
  #btnDemo { padding: 6px 8px; font-size: 12px; } .zoom button { padding: 6px 8px; }
  #panel { top: auto; left: 0; width: 100%; height: 72vh; border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; }
  .bubble { font-size: 10px; max-width: 140px; }
  #panelChat textarea { min-height: 42px; } #panelChat .hint { display: none; }
  #clock { min-width: 0; padding: 6px 9px; } .ck-time { font-size: 18px; } .ck-list { display: none; }
  body.dock-open #stage { right: 0; } #dock { width: 100%; z-index: 38; }
  #notify { width: 220px; } #nfList { max-height: 22vh; }
}
