/* ============================================================
   AI 웹 사옥 — 4가지 스킨 (dashboard / chat / retro / 3d)
   외부 CDN 없이 단일 CSS. 모바일 우선 + safe-area 대응.
   ============================================================ */

:root {
  --bg: #0b1020;
  --bg-2: #0e1630;
  --panel: rgba(20, 29, 54, 0.82);
  --panel-solid: #141d36;
  --panel-2: rgba(30, 41, 70, 0.72);
  --text: #e8edf7;
  --muted: #94a2c0;
  --line: rgba(140, 160, 210, 0.18);
  --accent: #6ea8fe;
  --accent-2: #8b5cf6;
  --accent-ink: #08101f;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.38);
  --font: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'Cascadia Code', 'Courier New', monospace;
  --topbar-h: 58px;
  --tabbar-h: 64px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  overflow-x: hidden;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(110, 168, 254, 0.18), transparent 60%),
    radial-gradient(700px 500px at 100% 0%, rgba(139, 92, 246, 0.16), transparent 60%);
  z-index: 0;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3, h4, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------- 잠금 화면 ---------------- */
.lock {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
  background:
    radial-gradient(700px 420px at 50% -10%, rgba(110, 168, 254, 0.22), transparent 65%),
    linear-gradient(180deg, #080d19 0%, #0b1226 60%, #070b14 100%);
}
.lock::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(110, 168, 254, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110, 168, 254, 0.06) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 78%);
}
.lock-card {
  position: relative;
  z-index: 1;
  width: min(360px, 100%);
  padding: 26px 22px 20px;
  border-radius: 24px;
  background: rgba(15, 23, 42, 0.86);
  border: 1px solid rgba(140, 160, 210, 0.22);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  text-align: center;
  backdrop-filter: blur(10px);
}
.lock-logo {
  width: 64px; height: 64px;
  margin: 0 auto 12px;
  display: grid; place-items: center;
  font-size: 32px;
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(110, 168, 254, 0.22), rgba(139, 92, 246, 0.22));
  border: 1px solid rgba(160, 180, 230, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.lock-card h1 { font-size: 20px; letter-spacing: -0.02em; }
.lock-sub { margin-top: 4px; font-size: 12px; color: var(--muted); }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 22px 0 18px; }
.pin-dots span {
  width: 13px; height: 13px; border-radius: 50%;
  border: 1.5px solid rgba(160, 180, 230, 0.5);
  transition: transform 0.12s ease, background 0.12s ease;
}
.pin-dots span.on {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.12);
  box-shadow: 0 0 12px rgba(110, 168, 254, 0.7);
}
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 auto;
  max-width: 280px;
}
.pin-pad button {
  height: 56px;
  border-radius: 16px;
  border: 1px solid rgba(140, 160, 210, 0.18);
  background: rgba(30, 41, 70, 0.6);
  font-size: 20px;
  font-weight: 600;
  transition: transform 0.08s ease, background 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.pin-pad button:active { transform: scale(0.95); background: rgba(110, 168, 254, 0.28); }
.pin-pad .pin-blank { font-size: 15px; color: var(--muted); background: transparent; border-color: transparent; }
.lock-msg { min-height: 18px; margin-top: 14px; font-size: 12.5px; color: var(--bad); }
.lock-msg.info { color: var(--muted); }
.lock-foot { margin-top: 10px; font-size: 11px; color: var(--muted); }
.linkbtn { border: 0; background: none; color: var(--accent); padding: 0; font-size: inherit; text-decoration: underline; }
.lock.shake .lock-card { animation: shake 0.36s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(4px); }
}

/* ---------------- 기본 레이아웃 ---------------- */
.shell { position: relative; z-index: 1; min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1 1 auto; overflow: hidden; }
.brand-logo {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(110, 168, 254, 0.25), rgba(139, 92, 246, 0.25));
  border: 1px solid var(--line);
  font-size: 17px;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.brand-text strong { font-size: 14px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.iconbtn {
  width: 36px; height: 36px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--panel);
  display: grid; place-items: center;
  font-size: 15px;
}
.killswitch {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.ks-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 8px var(--good); }
.killswitch.paused { color: var(--bad); border-color: rgba(248, 113, 113, 0.45); }
.killswitch.paused .ks-dot { background: var(--bad); box-shadow: 0 0 10px var(--bad); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.skin-picker {
  display: inline-flex; align-items: center; gap: 2px;
  height: 32px; padding: 0 4px 0 9px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 13px;
}
.skin-picker select {
  border: 0; background: transparent; font-size: 11.5px; font-weight: 600;
  padding: 0 2px; max-width: 82px;
  appearance: none; -webkit-appearance: none;
}
.skin-picker select option { background: #111a2e; color: #e8edf7; }

.banner-host { position: relative; z-index: 2; }
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 10px 12px 0;
  padding: 11px 13px;
  border-radius: 13px;
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.1);
  font-size: 12.5px;
  color: #ffe9b0;
}
.banner.danger { border-color: rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.1); color: #ffd0d0; }
.banner button { flex: none; }

.main {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 12px calc(var(--tabbar-h) + 26px + env(safe-area-inset-bottom));
  outline: none;
}
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.tabbar button {
  position: relative;
  border: 0;
  background: transparent;
  border-radius: 12px;
  padding: 6px 2px 5px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted);
  font-size: 10.5px;
}
.tabbar button[aria-current='true'] { color: var(--text); background: rgba(110, 168, 254, 0.12); }
.tab-ico { font-size: 19px; line-height: 1; }
.tab-badge {
  position: absolute; top: 2px; right: calc(50% - 22px);
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px;
  background: var(--bad); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 16px;
}

/* ---------------- 공통 컴포넌트 ---------------- */
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin: 4px 2px 12px; }
.view-head h2 { font-size: 19px; letter-spacing: -0.03em; }
.view-head p { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.view-head .head-actions { display: flex; gap: 6px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.grid { display: grid; gap: 10px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 8px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.muted { color: var(--muted); }
.tiny { font-size: 11px; }
.small { font-size: 12.5px; }
.strong { font-weight: 700; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { margin-left: auto; }
.center { text-align: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  transition: filter 0.15s ease, transform 0.08s ease;
}
.btn:active { transform: scale(0.98); }
.btn:hover { filter: brightness(1.12); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
}
.btn.good { background: rgba(52, 211, 153, 0.16); border-color: rgba(52, 211, 153, 0.4); color: var(--good); }
.btn.danger { background: rgba(248, 113, 113, 0.14); border-color: rgba(248, 113, 113, 0.4); color: #ffb4b4; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 12px; border-radius: 9px; }
.btn.xs { min-height: 27px; padding: 0 8px; font-size: 11px; border-radius: 8px; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn-icon { width: 38px; padding: 0; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.input, .select, .textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(8, 14, 28, 0.55);
  font-size: 13.5px;
}
.textarea { min-height: 84px; resize: vertical; }
.select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(110, 168, 254, 0.15); }
.hint { font-size: 11px; color: var(--muted); }
.error-text { font-size: 11.5px; color: var(--bad); }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  font-size: 10.5px; font-weight: 700;
  white-space: nowrap;
}
.pill.good { color: var(--good); border-color: rgba(52, 211, 153, 0.35); background: rgba(52, 211, 153, 0.1); }
.pill.warn { color: var(--warn); border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.1); }
.pill.bad { color: var(--bad); border-color: rgba(248, 113, 113, 0.35); background: rgba(248, 113, 113, 0.1); }
.pill.accent { color: var(--accent); border-color: rgba(110, 168, 254, 0.35); background: rgba(110, 168, 254, 0.1); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.on { background: var(--good); box-shadow: 0 0 8px var(--good); }
.dot.busy { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.dot.off { background: #64748b; }

/* 대시보드 */
.hero {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background:
    radial-gradient(420px 220px at 90% -30%, rgba(139, 92, 246, 0.28), transparent 70%),
    linear-gradient(135deg, rgba(110, 168, 254, 0.16), rgba(20, 29, 54, 0.6));
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.hero h2 { font-size: 21px; letter-spacing: -0.03em; }
.hero p { font-size: 12px; color: var(--muted); margin-top: 3px; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.stat {
  padding: 13px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.stat .stat-label { font-size: 10.5px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.stat .stat-value { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; margin-top: 4px; }
.stat .stat-sub { font-size: 10.5px; color: var(--muted); }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 18px 2px 8px; }
.section-title h3 { font-size: 14px; letter-spacing: -0.01em; }
.section-title .tiny { color: var(--muted); }

.room-card {
  padding: 13px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: var(--panel);
  text-align: left;
  display: flex; flex-direction: column; gap: 8px;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.room-card:hover { transform: translateY(-2px); border-color: rgba(110, 168, 254, 0.45); }
.room-card .rc-top { display: flex; align-items: center; gap: 8px; }
.room-card .rc-icon { font-size: 21px; }
.room-card .rc-name { font-weight: 700; font-size: 13.5px; }
.room-card .rc-latest { font-size: 11.5px; color: var(--muted); line-height: 1.45; min-height: 32px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.room-card .rc-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.agent-row { display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); }
.avatar {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 11px;
  font-size: 17px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 1px solid var(--line);
}
.agent-meta { min-width: 0; flex: 1; }
.agent-meta .nm { font-size: 12.5px; font-weight: 700; }
.agent-meta .rl { font-size: 10.5px; color: var(--muted); }
.gauge { height: 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.gauge > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.gauge.warn > i { background: linear-gradient(90deg, var(--warn), #f97316); }
.gauge.bad > i { background: linear-gradient(90deg, #f87171, #ef4444); }

.deadline-row {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 11px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.dday {
  flex: none; min-width: 50px; text-align: center;
  padding: 4px 6px; border-radius: 9px;
  background: rgba(110, 168, 254, 0.12);
  border: 1px solid rgba(110, 168, 254, 0.28);
  font-size: 10.5px; font-weight: 800;
}
.dday.soon { background: rgba(251, 191, 36, 0.14); border-color: rgba(251, 191, 36, 0.4); color: var(--warn); }
.dday.today { background: rgba(248, 113, 113, 0.16); border-color: rgba(248, 113, 113, 0.45); color: var(--bad); }
.dday.done { background: rgba(52, 211, 153, 0.12); border-color: rgba(52, 211, 153, 0.35); color: var(--good); }

/* ---------------- 채팅 ---------------- */
.chat-wrap { display: flex; flex-direction: column; min-height: 55vh; }
.room-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.room-tabs::-webkit-scrollbar { display: none; }
.room-tab {
  flex: none;
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 34px; padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 12px; font-weight: 600;
  color: var(--muted);
}
.room-tab[aria-pressed='true'] { color: var(--text); border-color: rgba(110, 168, 254, 0.5); background: rgba(110, 168, 254, 0.16); }
.room-tab .cnt { font-size: 10px; color: var(--muted); }
.chat-card { display: flex; flex-direction: column; overflow: hidden; min-height: 62vh; max-height: calc(100vh - var(--topbar-h) - var(--tabbar-h) - 128px); }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 11px 13px; border-bottom: 1px solid var(--line); }
.chat-head .ch-icon { font-size: 20px; }
.chat-head h3 { font-size: 14px; }
.chat-head p { font-size: 10.5px; color: var(--muted); }
.feed { flex: 1; overflow-y: auto; padding: 13px 12px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.feed-empty { margin: auto; text-align: center; color: var(--muted); font-size: 12px; padding: 30px 10px; }
.feed-empty .big { font-size: 34px; margin-bottom: 8px; }
.msg { display: flex; gap: 8px; align-items: flex-start; }
.msg .avatar { width: 30px; height: 30px; font-size: 15px; border-radius: 9px; }
.msg-main { min-width: 0; max-width: min(88%, 560px); }
.msg-meta { display: flex; align-items: baseline; gap: 6px; margin-bottom: 3px; font-size: 10.5px; color: var(--muted); }
.msg-meta .nm { font-weight: 700; color: var(--text); font-size: 11.5px; }
.bubble {
  padding: 9px 12px;
  border-radius: 4px 13px 13px 13px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 13.5px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.msg-boss { flex-direction: row-reverse; }
.msg-boss .msg-main { display: flex; flex-direction: column; align-items: flex-end; }
.msg-boss .msg-meta { flex-direction: row-reverse; }
.msg-boss .bubble {
  background: linear-gradient(135deg, rgba(110, 168, 254, 0.26), rgba(139, 92, 246, 0.22));
  border-color: rgba(110, 168, 254, 0.4);
  border-radius: 13px 4px 13px 13px;
}
.msg-agent .bubble { background: var(--panel-2); }
.msg-system { justify-content: center; }
.msg-system .bubble {
  background: rgba(251, 191, 36, 0.08);
  border: 1px dashed rgba(251, 191, 36, 0.35);
  color: #fcd77f;
  border-radius: 999px;
  font-size: 11.5px;
  padding: 5px 12px;
  text-align: center;
  white-space: normal;
}
.mention { color: var(--accent); font-weight: 700; }
.chain-chip { font-size: 9.5px; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.chain-chip.hot { color: var(--warn); border-color: rgba(251, 191, 36, 0.4); }
.msg-att { margin-top: 6px; }
.att-thumb { border: 0; padding: 0; background: none; display: block; max-width: 240px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.att-thumb img { display: block; width: 100%; max-height: 220px; object-fit: cover; }
.filecard {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(8, 14, 28, 0.4);
  font-size: 11.5px;
  text-decoration: none; color: var(--text);
  max-width: 260px;
}
.filecard .fc-ico { font-size: 17px; }
.filecard .fc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer { border-top: 1px solid var(--line); padding: 9px 10px calc(9px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 80%, transparent); }
.mention-bar { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 7px; scrollbar-width: none; }
.mention-bar::-webkit-scrollbar { display: none; }
.mention-chip {
  flex: none;
  border: 1px solid var(--line);
  background: rgba(110, 168, 254, 0.08);
  color: var(--accent);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
}
.mention-chip.all { color: var(--warn); border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.08); }
.composer-row { display: flex; align-items: flex-end; gap: 6px; }
.attach-btn {
  flex: none; width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); font-size: 17px;
}
.composer textarea {
  flex: 1;
  min-height: 40px; max-height: 130px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(8, 14, 28, 0.55);
  font-size: 13.5px;
  resize: none;
}
.send-btn { flex: none; height: 40px; padding: 0 15px; border-radius: 12px; border: 0; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 13px; font-weight: 700; }
.attach-preview { display: flex; align-items: center; gap: 8px; padding: 6px 2px 0; font-size: 11.5px; color: var(--accent); }
.attach-preview button { border: 0; background: rgba(248, 113, 113, 0.15); color: #ffb4b4; border-radius: 8px; padding: 2px 7px; font-size: 11px; }
.composer-hint { font-size: 10px; color: var(--muted); text-align: right; padding-top: 4px; }

/* ---------------- 할일 · 마감 ---------------- */
.panel { padding: 13px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.panel h3 { font-size: 14px; margin-bottom: 9px; }
.task-form { display: grid; grid-template-columns: 1fr; gap: 7px; margin-bottom: 10px; }
.task-form .row { gap: 6px; }
.task-form .row .input { flex: 1 1 auto; width: auto; min-width: 0; }
.task-form .row .btn { flex: none; white-space: nowrap; }
.del-form .btn { white-space: nowrap; }
.task-list { display: flex; flex-direction: column; gap: 6px; }
.task-item { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 11px; border: 1px solid var(--line); background: rgba(8, 14, 28, 0.28); }
.task-item.done .task-title { text-decoration: line-through; color: var(--muted); }
.check {
  width: 22px; height: 22px; flex: none;
  border-radius: 7px; border: 1.5px solid var(--line);
  background: transparent;
  display: grid; place-items: center;
  font-size: 12px; color: transparent;
}
.check.on { background: var(--good); border-color: var(--good); color: #06251a; }
.task-title { font-size: 12.5px; flex: 1; min-width: 0; word-break: break-word; }
.task-meta { font-size: 10px; color: var(--muted); display: flex; gap: 5px; flex-wrap: wrap; }
.prio { font-size: 9.5px; font-weight: 800; padding: 1px 5px; border-radius: 5px; }
.prio.high { color: var(--bad); background: rgba(248, 113, 113, 0.14); }
.prio.medium { color: var(--warn); background: rgba(251, 191, 36, 0.12); }
.prio.low { color: var(--muted); background: rgba(255, 255, 255, 0.06); }
.del-form { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 10px; }

/* ---------------- 설정 ---------------- */
.settings-block { margin-bottom: 12px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.block-head > div { min-width: 0; }
.block-head .btn { flex: none; }
.block-head h3 { font-size: 14px; }
.block-head p { font-size: 11px; color: var(--muted); margin-top: 2px; }
.agent-card { padding: 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; gap: 9px; }
.agent-card .ac-head { display: flex; align-items: center; gap: 9px; }
.agent-card .ac-body { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.keyrow { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(8, 14, 28, 0.3); font-size: 11.5px; }
.keycode { font-family: var(--mono); font-size: 11px; background: rgba(255, 255, 255, 0.05); border: 1px dashed var(--line); border-radius: 7px; padding: 3px 6px; word-break: break-all; }
.guide-box { width: 100%; min-height: 240px; font-family: var(--mono); font-size: 11px; line-height: 1.55; background: rgba(2, 6, 14, 0.65); border: 1px solid var(--line); border-radius: 11px; padding: 11px; color: #cfe1ff; resize: vertical; }
.tabs-line { display: flex; gap: 5px; overflow-x: auto; margin-bottom: 8px; scrollbar-width: none; }
.tabs-line::-webkit-scrollbar { display: none; }
.tabbtn { flex: none; border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 5px 10px; font-size: 11.5px; color: var(--muted); }
.tabbtn[aria-pressed='true'] { color: var(--text); border-color: rgba(110, 168, 254, 0.5); background: rgba(110, 168, 254, 0.14); }
.danger-zone { border-color: rgba(248, 113, 113, 0.3); }
.danger-zone h3 { color: #ffb4b4; }

/* ---------------- 3D 오피스 ---------------- */
.office-scene {
  perspective: 1400px;
  display: grid;
  place-items: center;
  padding: 30px 0 18px;
  min-height: 340px;
  overflow: visible;
}
.office-floor {
  width: min(400px, 62vw);
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 18px;
  border-radius: 26px;
  background:
    linear-gradient(135deg, rgba(139, 92, 246, 0.18), rgba(30, 20, 60, 0.5)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 28px);
  border: 1px solid rgba(167, 139, 250, 0.35);
  box-shadow: 24px 34px 70px rgba(0, 0, 0, 0.55), inset 0 0 60px rgba(139, 92, 246, 0.12);
  transform: rotateX(52deg) rotateZ(-38deg);
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
}
.office-floor:hover { transform: rotateX(48deg) rotateZ(-34deg); }
.zone {
  position: relative;
  border-radius: 16px;
  border: 1px solid rgba(167, 139, 250, 0.3);
  background: linear-gradient(160deg, rgba(76, 44, 130, 0.6), rgba(34, 20, 60, 0.7));
  box-shadow: 0 18px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform-style: preserve-3d;
  padding: 8px;
  display: grid; place-items: center;
  border: 0;
  color: #f5f3ff;
  text-align: center;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.zone:hover, .zone:focus-visible { transform: translateZ(26px); box-shadow: 0 30px 40px rgba(0, 0, 0, 0.45); }
.zone-inner {
  transform: rotateZ(38deg) rotateX(-52deg) translateZ(20px);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 100%;
}
.zone-inner .z-icon { font-size: 27px; line-height: 1; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5)); }
.zone-inner .z-name { font-size: 12px; font-weight: 800; letter-spacing: -0.01em; }
.zone-inner .z-agents { font-size: 12px; letter-spacing: 1px; opacity: 0.95; }
.zone-inner .z-sub { font-size: 9.5px; opacity: 0.75; }
.zone-bubble {
  position: absolute; left: 50%; bottom: calc(100% - 6px);
  transform: translateX(-50%);
  max-width: 150px;
  padding: 5px 8px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.95);
  color: #21123f;
  font-size: 9.5px;
  line-height: 1.35;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  pointer-events: none;
}
.zone .desk {
  position: absolute; right: 10px; bottom: 10px;
  width: 42px; height: 18px;
  border-radius: 4px;
  background: rgba(245, 243, 255, 0.16);
  border: 1px solid rgba(245, 243, 255, 0.26);
  transform: translateZ(6px);
}
.zone .agent-dot { position: absolute; left: 10px; top: 8px; font-size: 11px; }
.office-legend { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--muted); margin-top: 4px; }
.office-3d-head { text-align: center; margin: 6px 0 0; }
.office-3d-head h2 { font-size: 20px; letter-spacing: -0.03em; }
.office-3d-head p { font-size: 11.5px; color: var(--muted); }

/* ---------------- 모달 / 토스트 ---------------- */
.modal-root { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3, 7, 17, 0.7); backdrop-filter: blur(4px); }
.modal {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: min(86vh, 760px);
  overflow-y: auto;
  padding: 18px;
  border-radius: 18px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
}
.modal h3 { font-size: 16px; margin-bottom: 6px; letter-spacing: -0.02em; }
.modal p { font-size: 12.5px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 16px; flex-wrap: wrap; }
.modal .close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); }
.modal-img { max-width: 100%; max-height: 70vh; border-radius: 12px; display: block; margin: 10px auto; }
.toast-root { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 7px; width: min(420px, calc(100vw - 24px)); pointer-events: none; }
.toast { padding: 10px 13px; border-radius: 12px; background: rgba(15, 23, 42, 0.95); border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45); font-size: 12.5px; animation: toastIn 0.2s ease; }
.toast.good { border-color: rgba(52, 211, 153, 0.45); }
.toast.bad { border-color: rgba(248, 113, 113, 0.5); color: #ffc3c3; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------------- 스킨 1: 대시보드 (기본값 명시) ---------------- */
body.skin-dashboard {
  --bg: #0b1020;
  --bg-2: #0e1630;
  --panel: rgba(20, 29, 54, 0.82);
  --panel-solid: #141d36;
  --panel-2: rgba(30, 41, 70, 0.72);
  --text: #e8edf7;
  --muted: #94a2c0;
  --line: rgba(140, 160, 210, 0.18);
  --accent: #6ea8fe;
  --accent-2: #8b5cf6;
  --radius: 16px;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.38);
}

/* ---------------- 스킨 2: 모던 채팅 (Slack/Discord) ---------------- */
body.skin-chat {
  --bg: #313338;
  --bg-2: #2b2d31;
  --panel: #2b2d31;
  --panel-solid: #313338;
  --panel-2: #383a40;
  --text: #dbdee1;
  --muted: #949ba4;
  --line: rgba(255, 255, 255, 0.07);
  --accent: #5865f2;
  --accent-2: #4752c4;
  --radius: 10px;
  --shadow: none;
}
body.skin-chat::before { background: none; }
body.skin-chat .topbar { background: #2b2d31; backdrop-filter: none; }
body.skin-chat .brand-logo { background: #5865f2; border: 0; }
body.skin-chat .card, body.skin-chat .panel, body.skin-chat .stat, body.skin-chat .agent-card, body.skin-chat .room-card { border: 0; background: #2b2d31; }
body.skin-chat .bubble { border: 0; background: #383a40; }
body.skin-chat .msg-boss .bubble { background: #5865f2; color: #fff; }
body.skin-chat .chat-card { background: #313338; }
body.skin-chat .chat-head { background: #2b2d31; border-bottom-color: #1f2023; }
body.skin-chat .composer { background: #313338; border-top-color: #26272b; }
body.skin-chat .composer textarea, body.skin-chat .input, body.skin-chat .select, body.skin-chat .textarea { background: #383a40; border-color: #1f2023; }
body.skin-chat .tabbar { background: #2b2d31; }
body.skin-chat .hero { background: linear-gradient(135deg, #5865f2, #4752c4); border: 0; }
body.skin-chat .hero p { color: rgba(255, 255, 255, 0.8); }
body.skin-chat .hero .pill { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.35); color: #fff; }

/* ---------------- 스킨 3: 레트로 CRT ---------------- */
body.skin-retro {
  --bg: #000;
  --bg-2: #02100a;
  --panel: #02170c;
  --panel-solid: #02170c;
  --panel-2: #042012;
  --text: #4dff88;
  --muted: #2f9c5a;
  --line: #126b32;
  --accent: #39ff14;
  --accent-2: #0f9d3f;
  --good: #39ff14;
  --warn: #ffe066;
  --bad: #ff5f5f;
  --radius: 2px;
  --radius-sm: 2px;
  --shadow: none;
  --font: var(--mono);
}
body.skin-retro::before { background: repeating-linear-gradient(0deg, rgba(0, 255, 90, 0.03) 0 1px, transparent 1px 3px); }
body.skin-retro .crt-overlay { display: block; }
body.skin-retro .topbar { background: #000; border-bottom: 1px solid #1f8a45; }
body.skin-retro .brand-logo { background: transparent; border: 1px solid #2f9c5a; border-radius: 0; filter: grayscale(1) sepia(1) hue-rotate(60deg) saturate(4); }
body.skin-retro .card, body.skin-retro .panel, body.skin-retro .stat, body.skin-retro .agent-card, body.skin-retro .room-card, body.skin-retro .bubble, body.skin-retro .chat-card {
  border: 1px solid #1f8a45; background: #01140a; box-shadow: none; border-radius: 2px;
}
body.skin-retro .bubble { text-shadow: 0 0 6px rgba(57, 255, 20, 0.55); }
body.skin-retro .hero { background: #01140a; border: 1px solid #1f8a45; }
body.skin-retro .hero h2::before { content: '> '; }
body.skin-retro .btn, body.skin-retro .input, body.skin-retro .select, body.skin-retro .textarea, body.skin-retro .tabbtn { border-radius: 0; border: 1px solid #1f8a45; background: #01140a; }
body.skin-retro .btn.primary, body.skin-retro .send-btn { background: #39ff14; color: #001a08; border: 1px solid #39ff14; }
body.skin-retro .tabbar { background: #000; border-top: 1px solid #1f8a45; }
body.skin-retro .tabbar button[aria-current='true'] { color: #39ff14; background: rgba(57, 255, 20, 0.08); }
body.skin-retro .msg-system .bubble { border-style: dashed; }
body.skin-retro .brand-text strong::after { content: ' ▮'; animation: blink 1.1s steps(2) infinite; }
body.skin-retro .pill, body.skin-retro .dday, body.skin-retro .mention-chip, body.skin-retro .room-tab { border-radius: 0; }
.crt-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 70; pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}

/* ---------------- 스킨 4: 3D 오피스 ---------------- */
body.skin-3d {
  --bg: #160a2b;
  --bg-2: #1f0f3a;
  --panel: rgba(52, 28, 92, 0.55);
  --panel-solid: #24103f;
  --panel-2: rgba(72, 40, 122, 0.55);
  --text: #f5f3ff;
  --muted: #b9a8e0;
  --line: rgba(167, 139, 250, 0.27);
  --accent: #a78bfa;
  --accent-2: #7c3aed;
}
body.skin-3d::before { background: radial-gradient(900px 600px at 50% 0%, rgba(124, 58, 237, 0.35), transparent 65%), radial-gradient(700px 500px at 100% 80%, rgba(45, 212, 191, 0.12), transparent 60%); }
body.skin-3d .card, body.skin-3d .panel, body.skin-3d .stat, body.skin-3d .agent-card, body.skin-3d .room-card { backdrop-filter: blur(12px); }
body.skin-3d .hero { background: radial-gradient(420px 220px at 85% -20%, rgba(45, 212, 191, 0.25), transparent 70%), linear-gradient(135deg, rgba(124, 58, 237, 0.35), rgba(30, 15, 55, 0.7)); }

/* ---------------- 데스크톱 ---------------- */
@media (min-width: 900px) {
  .main { padding: 20px 26px 40px 108px; }
  .topbar { padding-left: calc(84px + 14px); }
  .tabbar {
    left: 0; top: 0; bottom: 0; right: auto;
    width: 84px;
    grid-template-columns: 1fr;
    grid-auto-rows: 70px;
    align-content: center;
    gap: 8px;
    padding: 12px 8px;
    border-top: 0;
    border-right: 1px solid var(--line);
  }
  .tabbar button { border-radius: 14px; font-size: 10px; }
  .tab-badge { right: 12px; top: 8px; }
  .toast-root { bottom: 24px; }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .chat-card { min-height: 66vh; }
}
@media (max-width: 420px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .skin-picker { padding: 0 2px 0 4px; }
  .skin-picker > span { display: none; }
  .skin-picker select { max-width: 74px; font-size: 10.5px; }
  .killswitch .ks-label { display: none; }
  .killswitch { padding: 0 8px; }
  .top-actions { gap: 4px; }
  .iconbtn { width: 34px; }
  .block-head h3 { font-size: 13px; }
  .block-head p { font-size: 10.5px; }
  .topbar { padding-left: 10px; padding-right: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .office-floor, .office-floor:hover { transform: rotateX(52deg) rotateZ(-38deg); }
}
