/* AI Cloud Agent 공통 스타일. 색은 로고 주황(#D3643F)을 기준으로 한다. */
:root {
  --brand: #D3643F;
  --brand-600: #B9532F;
  --brand-700: #9A4426;
  --brand-50: #FCF1EC;
  --brand-100: #F8E0D6;
  --bg: #FBFAF8;
  --surface: #FFFFFF;
  --surface-2: #F6F3F0;
  --rail: #F3EFEB;
  --text: #1E1B18;
  --text-2: #4A4540;
  --muted: #7A736C;
  --border: #E9E3DD;
  --border-2: #DCD4CC;
  --ok: #1F9D6B;
  --warn: #D99A1E;
  --danger: #D2403A;
  --info: #3B7BE8;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow: 0 1px 2px rgba(30, 20, 10, .04), 0 4px 16px rgba(30, 20, 10, .06);
  --shadow-lg: 0 10px 40px rgba(30, 20, 10, .14);
  --rail-w: 76px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "D2Coding", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161412; --surface: #1F1C19; --surface-2: #27231F; --rail: #1A1715;
    --text: #F2EEEA; --text-2: #D3CCC5; --muted: #9C948C; --border: #332E29; --border-2: #423B35;
    --brand-50: #2E1F19; --brand-100: #46291E;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161412; --surface: #1F1C19; --surface-2: #27231F; --rail: #1A1715;
  --text: #F2EEEA; --text-2: #D3CCC5; --muted: #9C948C; --border: #332E29; --border-2: #423B35;
  --brand-50: #2E1F19; --brand-100: #46291E; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 15px; line-height: 1.6; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.inline-icon { width: 14px; height: 14px; vertical-align: -2px; color: var(--brand); }
svg.lucide { width: 18px; height: 18px; stroke-width: 1.9; flex: none; }

/* ---------- 틀 ---------- */
.app { display: flex; min-height: 100vh; }
.rail { position: fixed; inset: 0 auto 0 0; width: var(--rail-w); background: var(--rail); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding: 14px 0; z-index: 30; }
.rail-logo { display: block; margin-bottom: 18px; border-radius: 10px; overflow: hidden; transition: transform .15s; }
.rail-logo:hover { transform: rotate(-8deg) scale(1.05); }
.rail-logo img { display: block; }
.rail-items { display: flex; flex-direction: column; gap: 4px; flex: 1; width: 100%; align-items: center; }
.rail-item { width: 62px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; border-radius: 12px; color: var(--text-2); font-size: 11px; background: none; border: 0; cursor: pointer; }
.rail-item svg.lucide { width: 21px; height: 21px; }
.rail-item:hover { background: var(--surface-2); color: var(--text); }
.rail-item.is-active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
.rail-bottom { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.rail-more { position: relative; }
.rail-avatar { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--surface); background: var(--brand); color: #fff; font-weight: 700; cursor: pointer; overflow: hidden; padding: 0; box-shadow: var(--shadow); }
.rail-avatar img { width: 100%; height: 100%; object-fit: cover; }
.main { flex: 1; margin-left: var(--rail-w); min-width: 0; }
.tabbar { display: none; }

.popover { position: absolute; z-index: 50; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; min-width: 200px; }
.rail-popover { left: calc(100% + 8px); top: 0; }
.rail-popover-up { top: auto; bottom: 0; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 9px; border: 0; background: none; text-align: left; cursor: pointer; color: var(--text); font-size: 14px; white-space: nowrap; }
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--danger); }
.menu-item small { color: var(--muted); margin-left: auto; font-size: 12px; }
.menu-head { padding: 8px 12px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: flex; flex-direction: column; }
.menu-head small { color: var(--muted); }
.menu-credit { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px; color: var(--text-2); }
.menu-credit b { margin-left: auto; color: var(--brand); }
.flash { margin: 16px auto 0; max-width: 760px; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--brand-50); color: var(--brand-700); border: 1px solid var(--brand-100); }

/* ---------- 공통 부품 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 16px; border-radius: 11px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer; transition: background .15s, border-color .15s, transform .05s; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-dark { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.is-on { color: var(--brand); background: var(--brand-50); }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 13px; color: var(--text-2); }
.chip-btn:hover { border-color: var(--border-2); color: var(--text); }
.chip-btn svg.lucide { width: 15px; height: 15px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 12px; white-space: nowrap; }
.badge.brand { background: var(--brand-50); color: var(--brand-700); }
.badge.ok { background: #E6F6EF; color: #137a52; }
.badge.warn { background: #FFF5DF; color: #94650a; }
.badge.danger { background: #FDECEA; color: #b4261f; }
.tool-icon { --c: var(--brand); display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px; background: color-mix(in srgb, var(--c) 13%, var(--surface)); color: var(--c); flex: none; }
.tool-icon.sm { width: 30px; height: 30px; border-radius: 9px; }
.tool-icon.sm svg.lucide { width: 16px; height: 16px; }
.tool-icon.lg { width: 48px; height: 48px; border-radius: 14px; }
.tool-icon.lg svg.lucide { width: 24px; height: 24px; }
.tool-icon.xl { width: 64px; height: 64px; border-radius: 18px; }
.tool-icon.xl svg.lucide { width: 32px; height: 32px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=url], input[type=date], input[type=datetime-local], input[type=time], select, textarea.input {
  height: 42px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--border-2); background: var(--surface); outline: none; width: 100%; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 90px; line-height: 1.55; }
input:focus, select:focus, textarea.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span, .field > label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field small { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 14px; }
.card h3 { margin: 0 0 10px; font-size: 16px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table-wrap .table tr:last-child td { border-bottom: 0; }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty > svg.lucide { width: 40px; height: 40px; color: var(--border-2); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a, .tabs button { padding: 10px 14px; border: 0; background: none; color: var(--muted); font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs .is-active { color: var(--text); border-bottom-color: var(--brand); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat small { color: var(--muted); display: block; font-size: 12px; }
.stat b { font-size: 24px; letter-spacing: -.02em; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }

/* ---------- 페이지 ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 36px 28px 80px; }
.page.narrow { max-width: 760px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 28px; letter-spacing: -.02em; margin: 0 0 6px; }
.page-head p { margin: 0 0 14px; }
.section-title { font-size: 15px; color: var(--text-2); margin: 28px 0 12px; font-weight: 700; }
.search-box { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; border: 1px solid var(--border-2); border-radius: 12px; background: var(--surface); max-width: 420px; }
.search-box input { border: 0; box-shadow: none !important; height: 38px; padding: 0; background: transparent; }
.search-box svg.lucide { color: var(--muted); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.agent-card { display: flex; gap: 14px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); transition: border-color .15s, box-shadow .15s, transform .15s; }
.agent-card:hover { border-color: var(--brand-100); box-shadow: var(--shadow); transform: translateY(-1px); }
.agent-card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.agent-card-body .muted { font-size: 13px; line-height: 1.45; }
.list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-2); }
.list-row > a.grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 홈 ---------- */
.home { max-width: 820px; margin: 0 auto; padding: 9vh 24px 80px; }
.home-hero { text-align: center; margin-bottom: 26px; display: flex; flex-direction: column; align-items: center; }
.home-logo { border-radius: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.home-hero h1 { font-size: 34px; letter-spacing: -.03em; margin: 10px 0 6px; }
.home-hero p { margin: 0; }
.home-groups { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 0; margin-top: 30px; }
.home-group { display: flex; flex-direction: column; align-items: center; padding: 0 14px; border-right: 1px solid var(--border); }
.home-group:last-child { border-right: 0; }
.home-group-label { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.home-group-items { display: flex; gap: 6px; }
.tool-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 74px; padding: 6px 2px; border-radius: 12px; font-size: 12px; color: var(--text-2); text-align: center; }
.tool-tile:hover { background: var(--surface-2); color: var(--text); }
.tool-name { line-height: 1.25; }
.home-examples { display: flex; flex-direction: column; gap: 4px; margin-top: 26px; align-items: flex-start; }
.example { display: inline-flex; align-items: center; gap: 10px; border: 0; background: none; color: var(--text-2); padding: 8px 12px; border-radius: 10px; cursor: pointer; text-align: left; }
.example:hover { background: var(--surface-2); color: var(--text); }
.example svg.lucide { width: 16px; height: 16px; color: var(--muted); }
.recent { margin-top: 36px; }

/* ---------- 입력창 ---------- */
.prompt { background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 14px 14px 10px; transition: border-color .15s, box-shadow .15s; position: relative; }
.prompt:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-50), var(--shadow); }
.prompt textarea { width: 100%; border: 0; outline: none; resize: none; background: transparent; padding: 4px 6px; min-height: 52px; max-height: 260px; line-height: 1.55; font-size: 16px; }
.prompt-compact textarea { min-height: 26px; }
.prompt-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.prompt-left, .prompt-right { display: flex; align-items: center; gap: 6px; }
.prompt .icon-btn { border: 1px solid var(--border); border-radius: 999px; width: 34px; height: 34px; }
.send-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: background .15s, opacity .15s; }
.send-btn:hover { background: var(--brand-600); }
.send-btn:disabled { opacity: .35; cursor: default; }
.send-btn.stop { background: var(--text); }
.prompt.is-dragover { border-style: dashed; background: var(--brand-50); }
.prompt-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 240px; padding: 5px 8px 5px 6px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; }
.file-chip img { width: 28px; height: 28px; object-fit: cover; border-radius: 6px; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0; display: inline-flex; }
.file-chip.is-loading { opacity: .6; }
.prompt-options { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 2px; }
.opt { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); background: var(--surface-2); border-radius: 999px; padding: 3px 4px 3px 12px; }
.opt select, .opt input[type=text], .opt input[type=number] { height: 28px; border-radius: 999px; font-size: 12px; padding: 0 8px; width: auto; min-width: 70px; border-color: var(--border); }
.opt-toggle { padding-right: 10px; }
.opt input[type=checkbox] { accent-color: var(--brand); }
.tier { position: relative; }
.tier-popover { bottom: calc(100% + 8px); left: 0; min-width: 240px; }
.tier-popover .menu-item { flex-direction: column; align-items: flex-start; gap: 0; }
.tier-popover .menu-item small { margin-left: 0; }
.tier-popover .menu-item.is-active { background: var(--brand-50); }
.prompt.is-listening [data-mic] { color: #fff; background: var(--danger); border-color: var(--danger); }
.fineprint { text-align: center; font-size: 11px; color: var(--muted); margin: 6px 0 0; }

/* ---------- 작업 화면 ---------- */
body.is-workspace .main { height: 100vh; overflow: hidden; }
.ws { display: flex; flex-direction: column; height: 100vh; }
.ws-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface); flex: none; }
.ws-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ws-title small { font-size: 12px; }
.ws-name { border: 0 !important; box-shadow: none !important; padding: 0 !important; height: 24px !important; font-weight: 700; font-size: 15px; background: transparent !important; }
.ws-actions { display: flex; align-items: center; gap: 6px; }
.ws-popover { right: 0; top: calc(100% + 6px); }
.ws-body { flex: 1; display: flex; min-height: 0; }
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ws.has-canvas .chat { flex: 0 0 min(460px, 40%); border-right: 1px solid var(--border); }
.chat-scroll { flex: 1; overflow-y: auto; padding: 20px 0 10px; scroll-behavior: auto; }
.messages, .plan, .status-line, .chat-empty { max-width: 800px; margin: 0 auto; padding: 0 22px; }
.chat-input { padding: 8px 22px 12px; max-width: 844px; width: 100%; margin: 0 auto; flex: none; }
.ws.has-canvas .chat-input { max-width: none; }
.chat-empty { text-align: center; padding-top: 8vh; display: flex; flex-direction: column; align-items: center; }
.chat-empty h2 { margin: 12px 0 4px; }
.chat-empty .home-examples { align-items: center; }
.canvas { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface-2); position: relative; overflow: hidden; }
.canvas-empty { margin: auto; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.canvas-empty svg.lucide { width: 44px; height: 44px; color: var(--border-2); }
.canvas-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface); flex: none; flex-wrap: wrap; }
.canvas-head .grow { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.canvas-body { flex: 1; overflow: auto; padding: 18px; }

/* 메시지 */
.msg { margin: 0 0 22px; display: flex; flex-direction: column; }
.msg-user { align-items: flex-end; }
.msg-user .bubble { background: var(--brand-50); border: 1px solid var(--brand-100); border-radius: 18px 18px 4px 18px; padding: 10px 14px; max-width: 85%; white-space: pre-wrap; word-break: break-word; }
.msg-user .msg-files { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-bottom: 6px; }
.msg-assistant .msg-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.msg-assistant .msg-meta img { width: 20px; height: 20px; border-radius: 6px; }
.msg-actions { display: flex; gap: 2px; margin-top: 6px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions, .msg:last-child .msg-actions { opacity: 1; }
.msg-actions .icon-btn { width: 30px; height: 30px; }
.msg-actions svg.lucide { width: 15px; height: 15px; }
.msg-error { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: #FDECEA; color: #9b231d; font-size: 14px; display: flex; gap: 8px; align-items: flex-start; }
.msg-error a { text-decoration: underline; font-weight: 600; }
.msg.is-compare { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); }
.cursor::after { content: ""; display: inline-block; width: 8px; height: 16px; margin-left: 2px; background: var(--brand); vertical-align: -3px; animation: blink 1s steps(1) infinite; border-radius: 2px; }
@keyframes blink { 50% { opacity: 0; } }

/* 도구 카드 */
.tool-card { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); margin: 0 0 12px; font-size: 14px; overflow: hidden; }
.tool-card summary { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; list-style: none; color: var(--text-2); }
.tool-card summary::-webkit-details-marker { display: none; }
.tool-card summary .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-card .tool-body { padding: 4px 12px 12px; border-top: 1px solid var(--border); }
.tool-card .spin { animation: spin 1s linear infinite; color: var(--brand); }
.tool-card.is-error summary { color: var(--danger); }
.tool-card pre { max-height: 260px; overflow: auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.result-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 8px; }
.result-list a { color: var(--info); font-weight: 600; }
.result-list small { display: block; color: var(--muted); font-size: 12px; }
.result-list p { margin: 2px 0 0; font-size: 13px; color: var(--text-2); }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 8px; }
.image-grid img, .image-grid video { width: 100%; border-radius: 10px; display: block; background: var(--surface-2); aspect-ratio: 1; object-fit: cover; cursor: zoom-in; }
.project-link { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; margin-top: 8px; background: var(--surface-2); }
.project-link:hover { border-color: var(--brand-100); }

/* 계획 */
.plan { margin-bottom: 18px; }
.plan-box { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 12px 14px; }
.plan-box h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.plan-step { display: flex; align-items: flex-start; gap: 8px; padding: 4px 0; font-size: 14px; }
.plan-step .st { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-2); flex: none; margin-top: 2px; display: inline-flex; align-items: center; justify-content: center; }
.plan-step.is-running .st { border-color: var(--brand); border-top-color: transparent; animation: spin .9s linear infinite; }
.plan-step.is-done .st { border-color: var(--ok); background: var(--ok); }
.plan-step.is-done .st::after { content: "✓"; color: #fff; font-size: 11px; font-weight: 800; }
.plan-step.is-error .st { border-color: var(--danger); background: var(--danger); }
.plan-step.is-done .t { color: var(--muted); }
.plan-step small { display: block; color: var(--muted); font-size: 12px; }
.status-line { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.dot-pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(.7); opacity: .5; } 50% { transform: scale(1.1); opacity: 1; } }
.shimmer { background: linear-gradient(90deg, var(--muted) 0%, var(--text) 50%, var(--muted) 100%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* 마크다운 */
.md { word-break: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.35; margin: 1.3em 0 .5em; letter-spacing: -.01em; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.25em; } .md h3 { font-size: 1.1em; }
.md p { margin: .6em 0; }
.md ul, .md ol { padding-left: 1.4em; margin: .5em 0; }
.md li { margin: .2em 0; }
.md a { color: var(--info); text-decoration: underline; text-underline-offset: 2px; }
.md blockquote { margin: .8em 0; padding: .2em 1em; border-left: 3px solid var(--brand-100); color: var(--text-2); }
.md code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: .12em .38em; border-radius: 6px; }
.md pre { background: #1E1B18; color: #F2EEEA; padding: 14px 16px; border-radius: 12px; overflow-x: auto; position: relative; font-size: 13px; line-height: 1.55; }
.md pre code { background: none; padding: 0; color: inherit; }
.md pre .copy-code { position: absolute; top: 8px; right: 8px; background: rgba(255,255,255,.1); color: #fff; border: 0; border-radius: 6px; font-size: 11px; padding: 3px 8px; cursor: pointer; }
.md table { border-collapse: collapse; margin: .8em 0; font-size: 14px; display: block; overflow-x: auto; max-width: 100%; }
.md th, .md td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; }
.md th { background: var(--surface-2); }
.md img { border-radius: 10px; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1.4em 0; }

/* 토스트·모달 */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14px; max-width: 360px; animation: toastIn .2s ease-out; }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }
.modal-back { position: fixed; inset: 0; background: rgba(20, 14, 10, .45); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .15s; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 480px; max-height: 90vh; overflow: auto; }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; flex: 1; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; }
.lightbox img, .lightbox video { max-width: 92vw; max-height: 88vh; border-radius: 12px; box-shadow: var(--shadow-lg); }
@keyframes fade { from { opacity: 0; } }

/* 로그인 등 가운데 카드 */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 30px 18px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 32px 28px; }
.auth-card .auth-logo { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 22px; text-align: center; }
.auth-card .auth-logo img { border-radius: 14px; }
.auth-card h1 { font-size: 22px; margin: 0; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.social-btn { width: 100%; margin-bottom: 8px; }

.error-page .empty img { opacity: .9; }
.error-page h1 { font-size: 48px; margin: 0; color: var(--text); }
.error-detail { text-align: left; max-width: 100%; overflow: auto; font-size: 12px; background: var(--surface-2); padding: 12px; border-radius: 10px; max-height: 50vh; }
.mobile-only { display: none !important; }

/* ---------- 모바일 ---------- */
@media (max-width: 860px) {
  .rail { display: none; }
  .main { margin-left: 0; padding-bottom: 64px; }
  body.is-workspace .main { padding-bottom: 0; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: calc(58px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border); z-index: 40; }
  body.is-workspace .tabbar { display: none; }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); gap: 2px; }
  .tabbar a.is-active { color: var(--brand); }
  .home { padding: 6vh 16px 40px; }
  .home-hero h1 { font-size: 26px; }
  .home-group { border-right: 0; padding: 0 6px; max-width: 100%; }
  .home-group-items { flex-wrap: wrap; justify-content: center; }
  .page { padding: 24px 16px 60px; }
  .page-head h1 { font-size: 23px; }
  .ws.has-canvas .chat { flex: 1; border-right: 0; }
  .ws.has-canvas .canvas { position: fixed; inset: 56px 0 0 0; z-index: 20; display: none; }
  .ws.has-canvas.show-canvas .canvas { display: flex; }
  .mobile-only { display: inline-flex !important; }
  .messages, .plan, .status-line, .chat-empty { padding: 0 14px; }
  .chat-input { padding: 6px 10px 10px; }
  .ws-actions .btn span { display: none; }
  .msg-actions { opacity: 1; }
  .toasts { left: 12px; right: 12px; bottom: 74px; }
}

/* 모바일 앱(웹뷰) 안: docs/MOBILE_APP.md */
.is-app .web-only { display: none !important; }
.app-only { display: none !important; }
.is-app .app-only { display: revert !important; }
.is-app { -webkit-tap-highlight-color: transparent; }