* { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --ink: #1C1C1E;
  --ink-2: #2C2C2E;
  --ink-3: #3C3C3E;
  --rail-bg: #8B1A1A;
  --rail-bg-2: #721515;
  --submenu-active: #ee4849;
  --text: #17181C;
  --text-muted: #6A6F7B;
  --text-faint: #9CA0AA;
  --line: #EAEBEF;
  --line-soft: #F1F2F5;
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #FAFAFB;
  --accent: #ee4849;
  --accent-hover: #d63c3d;
  --accent-soft: #FEE2E2;
  --warn: #C47A00;
  --warn-soft: #FFF5E0;
  --danger: #D0323C;
  --danger-soft: #FDECEE;
  --success: #0B8A4A;
  --success-soft: #E3F5EB;
  --rad-sm: 6px;
  --rad: 10px;
  --rad-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.07), 0 4px 12px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.11), 0 4px 10px rgba(0, 0, 0, 0.05);
  --rail-w: 64px;
  --top-h: 52px;
}

html, body {
  margin: 0; height: 100%;
  font-family: "Inter", "Pretendard", "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button, input, textarea, select { font-family: inherit; letter-spacing: inherit; color: inherit; }
button { cursor: pointer; }
input, textarea, select { background: var(--surface); color: var(--text); }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.022em; font-weight: 600; }

/* ===== Auth ===== */
.auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); padding: 24px; }
.auth-card { background: var(--surface); width: 360px; padding: 40px 36px 32px; border-radius: var(--rad-lg); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; border: 1px solid var(--line); }
.auth-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--ink); margin-bottom: 4px; }
.auth h1 { font-size: 23px; color: var(--text); }
.auth-sub { color: var(--text-muted); font-size: 14px; margin: 0 0 8px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.field input, .field textarea, .field select { padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--rad); font-size: 15px; outline: none; transition: border-color .12s, box-shadow .12s; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(238,72,73,0.10); }
.field-err { color: var(--danger); font-size: 14px; min-height: 18px; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: var(--rad); border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 500; color: var(--text); transition: background .1s, border-color .1s, transform .06s; white-space: nowrap; }
.btn:hover { background: var(--surface-2); border-color: #DEE0E5; }
.btn:active { transform: translateY(0.5px); }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--line-soft); color: var(--text); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: #F3C9CE; background: var(--surface); }
.btn-danger:hover { background: var(--danger-soft); border-color: #ECB1B7; }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; padding: 12px; }
.btn-send { padding: 0 18px; height: 44px; border-radius: var(--rad); }

.icon-btn { background: transparent; border: none; padding: 6px; border-radius: 8px; color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--line-soft); color: var(--text); }

/* ===== Shell: rail + topbar + content ===== */
.app { display: grid; grid-template-columns: var(--rail-w) 1fr; grid-template-rows: var(--top-h) 1fr; grid-template-areas: "rail topbar" "rail content"; height: 100vh; height: 100dvh; }
.rail { grid-area: rail; background: var(--rail-bg); display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 4px; border-right: 1px solid var(--rail-bg-2); }
.rail-brand { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #fff, #C8C9D0 90%); margin-bottom: 12px; }
.rail-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.rail-foot { display: flex; flex-direction: column; gap: 4px; margin-top: auto; }
.rail-btn { width: 40px; height: 40px; border-radius: 10px; background: transparent; border: none; color: rgba(255,255,255,0.75); display: inline-flex; align-items: center; justify-content: center; position: relative; transition: background .1s, color .1s; }
.rail-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.rail-btn.active { background: rgba(255,255,255,0.10); color: #fff; }
.rail-btn.active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #fff; }

.topbar { grid-area: topbar; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; }
.crumbs { font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -0.015em; }
.top-right { display: flex; align-items: center; gap: 12px; }
.muted-sm { font-size: 13px; color: var(--text-muted); }

.page { grid-area: content; min-height: 0; overflow: hidden; background: var(--bg); }

/* Generic pane */
.pane { background: var(--surface); border: 1px solid var(--line); border-radius: var(--rad-lg); min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.pane-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; min-height: 54px; flex-shrink: 0; }
.pane-title { font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -0.015em; }
.pane-note { margin: 12px; padding: 10px 12px; background: var(--line-soft); border-radius: var(--rad); font-size: 13px; color: var(--text-muted); line-height: 1.55; }

.select { padding: 8px 12px; border-radius: var(--rad); border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 500; outline: none; cursor: pointer; width: 100%; color: var(--text); }
.select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(238,72,73,0.10); }

/* ===== INBOX ===== */
.page-inbox { display: grid; grid-template-columns: 240px 340px 1fr; gap: 14px; padding: 14px; height: 100%; }
.pane-folders .folders { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.folders li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text); font-weight: 500; user-select: none; }
.folders li:hover { background: var(--line-soft); }
.folders li.active { background: var(--submenu-active); color: #fff; }
.folders li .folder-icon { width: 16px; height: 16px; color: inherit; opacity: 0.75; display: inline-flex; flex-shrink: 0; }
.folders li.active .folder-icon { opacity: 1; }
.folders li .count { margin-left: auto; font-size: 12px; background: var(--line-soft); color: var(--text-muted); padding: 1px 8px; border-radius: 999px; font-weight: 600; font-variant-numeric: tabular-nums; }
.folders li.active .count { background: rgba(255,255,255,0.16); color: #fff; }
.folders .sep { height: 1px; background: var(--line); margin: 6px 4px; padding: 0; cursor: default; pointer-events: none; }
.folders li.indent { padding-left: 28px; font-size: 13px; font-weight: 500; }
.folders li.indent .folder-icon { opacity: 0.6; }

.pane-conv-list .conv-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.conv-list li { padding: 12px 14px; border-radius: var(--rad); cursor: pointer; margin-bottom: 2px; position: relative; }
.conv-list li:hover { background: var(--line-soft); }
.conv-list li.active { background: var(--line-soft); border: 1px solid var(--line); padding: 11px 13px; }
.conv-list .row1 { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); font-weight: 500; }
.conv-list .row1 .vid { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 600; }
.conv-list .row1 .time { color: var(--text-faint); font-size: 12px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.conv-list .row2 { font-size: 14px; margin-top: 5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.4; }
.conv-list li.unread .row2 { color: var(--text); font-weight: 600; }
.conv-list .row3 { display: flex; gap: 6px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.conv-list .url { font-size: 12px; color: var(--text-faint); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.new      { background: var(--danger); }
.status-dot.open     { background: var(--accent); }
.status-dot.pending  { background: var(--warn); }
.status-dot.hold     { background: #8C7AE6; }
.status-dot.snoozed  { background: #A78BFA; }
.status-dot.closed   { background: #AFB3BD; }
.status-dot.bot      { background: var(--success); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--line-soft); color: var(--text-muted); border: 1px solid transparent; }
.chip.callback { background: var(--warn-soft); color: var(--warn); border-color: #F3DEA4; }
.chip.tag { color: #fff; }
.conv-list li.unread::after { content: ''; position: absolute; top: 14px; right: 14px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.pane-detail { display: flex; flex-direction: column; }
.detail-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; flex-wrap: wrap; flex-shrink: 0; }
.detail-title { flex: 1; min-width: 0; }
.detail-title #conv-title { font-weight: 600; font-size: 15px; color: var(--text); letter-spacing: -0.015em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail-title .sub { font-size: 13px; color: var(--text-faint); margin-top: 4px; word-break: break-all; }
.action-bar { display: flex; gap: 4px; flex-wrap: wrap; }

.callback-banner { margin: 12px 18px; padding: 10px 14px; background: var(--warn-soft); border: 1px solid #EFD89B; border-radius: var(--rad); color: #6B4100; font-size: 14px; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.callback-banner a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

.log { flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 22px 26px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }
.log-empty { margin: auto; color: var(--text-faint); font-size: 15px; }
.msg { display: flex; align-items: flex-end; gap: 6px; max-width: 100%; }
.msg .bubble { max-width: 62%; padding: 10px 14px; border-radius: 14px; font-size: 15px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.msg.admin { justify-content: flex-end; }
.msg.admin .bubble { background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.msg.admin.bot .bubble { background: var(--accent-soft); color: var(--accent-hover); border: 1px solid #DADFFC; }
.msg.visitor { justify-content: flex-start; }
.msg.visitor .bubble { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.system { justify-content: center; }
.msg.system .bubble { background: transparent; color: var(--text-faint); font-size: 12px; padding: 2px 8px; }
.msg .time { font-size: 12px; color: var(--text-faint); white-space: nowrap; font-variant-numeric: tabular-nums; }

.compose { position: relative; border-top: 1px solid var(--line); background: var(--surface); flex-shrink: 0; }
.reply-hint { padding: 6px 18px; background: var(--accent-soft); color: var(--accent-hover); font-size: 13px; border-bottom: 1px solid #DADFFC; }
.quick-replies { padding: 18px 14px 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.quick-replies .qr-btn { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--text); font-weight: 500; cursor: pointer; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; transition: background .1s, border-color .1s, color .1s; }
.quick-replies .qr-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-hover); }
.quick-replies .qr-btn .sh { color: var(--text-muted); font-family: ui-monospace, "SF Mono", monospace; font-size: 12px; margin-right: 4px; }
.quick-replies .qr-btn:hover .sh { color: var(--accent); }
.quick-replies .qr-more { background: transparent; border: 1px dashed var(--line); border-radius: 999px; padding: 6px 12px; font-size: 12px; color: var(--text-muted); cursor: pointer; }
.quick-replies .qr-more:hover { border-color: var(--accent); color: var(--accent); }
.quick-replies.empty { display: none; }
.compose-row { display: flex; gap: 8px; padding: 12px 14px; align-items: flex-end; }
.compose textarea { flex: 1; resize: none; min-height: 44px; max-height: 160px; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--rad); font-size: 15px; outline: none; line-height: 1.5; background: var(--surface); transition: border-color .12s, box-shadow .12s; }
.compose textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(238,72,73,0.10); }

.slash-menu { position: absolute; bottom: 70px; left: 14px; right: 14px; max-height: 260px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--rad); box-shadow: var(--shadow-lg); z-index: 10; padding: 6px; }
.slash-menu .item { padding: 9px 11px; border-radius: 8px; cursor: pointer; }
.slash-menu .item:hover, .slash-menu .item.focus { background: var(--line-soft); }
.slash-menu .item .sh { font-family: ui-monospace, "SF Mono", monospace; color: var(--accent); font-weight: 600; font-size: 13px; }
.slash-menu .item .tt { font-size: 14px; color: var(--text); margin-top: 2px; font-weight: 500; }
.slash-menu .item .bd { font-size: 13px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== Dropdown / toast ===== */
.dropdown { position: fixed; background: var(--surface); border: 1px solid var(--line); border-radius: var(--rad); box-shadow: var(--shadow-lg); padding: 4px; z-index: 100; min-width: 200px; }
.dropdown .item { padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--text); display: flex; gap: 8px; align-items: center; }
.dropdown .item:hover { background: var(--line-soft); }
.dropdown .item.danger { color: var(--danger); }
.dropdown .sep { height: 1px; background: var(--line); margin: 4px 0; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: var(--rad); font-size: 14px; box-shadow: var(--shadow-lg); z-index: 200; font-weight: 500; }

/* ===== SCENARIOS ===== */
.page-scenarios { display: grid; grid-template-columns: 300px 1fr; gap: 14px; padding: 14px; height: 100%; }
.pane-scen-list .scen-list { list-style: none; margin: 0; padding: 8px; flex: 1; overflow-y: auto; }
.scen-list li { padding: 12px 14px; border-radius: var(--rad); cursor: pointer; margin-bottom: 4px; border: 1px solid transparent; }
.scen-list li:hover { background: var(--line-soft); }
.scen-list li.active { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow-sm); }
.scen-list li .row1 { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; color: var(--text); }
.scen-list li .row1 > span:first-child { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scen-list li .badge { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--submenu-active); color: #fff; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; }
.scen-list li .badge.off { background: var(--text-faint); }
.scen-list li .tr { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.pane-scen-editor { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.detail-empty { margin: auto; color: var(--text-faint); font-size: 15px; }
.scen-editor-head { padding: 12px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; flex-shrink: 0; }
.scen-name-input { flex: 1; min-width: 220px; padding: 8px 12px; border: 1px solid transparent; border-radius: 8px; font-size: 16px; font-weight: 600; outline: none; background: transparent; transition: background .12s, border-color .12s; letter-spacing: -0.015em; }
.scen-name-input:hover { background: var(--line-soft); }
.scen-name-input:focus { background: var(--surface); border-color: var(--line); }
.scen-editor-head label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.scen-editor-head input[type="checkbox"] { accent-color: var(--ink); width: 14px; height: 14px; }

.scen-editor-body { flex: 1; min-height: 0; overflow: auto; background: var(--surface-2); position: relative; }
.flow-canvas { padding: 36px 20px 60px; display: flex; flex-direction: column; align-items: center; gap: 0; min-height: 100%; }

/* Starters section (customer-side chips) */
.flow-starters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--rad-lg); padding: 16px 20px; width: 100%; max-width: 520px; margin-bottom: 12px; box-shadow: var(--shadow-sm); }
.flow-starters h4 { font-size: 14px; color: var(--text); margin-bottom: 4px; font-weight: 600; }
.flow-starters .sub { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; line-height: 1.55; }
.flow-starters .starter-list { display: flex; flex-direction: column; gap: 8px; }
.flow-starters .starter-row { display: flex; gap: 8px; align-items: start; }
.flow-starters .starter-row input, .flow-starters .starter-row textarea { flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; outline: none; font-family: inherit; resize: none; line-height: 1.4; overflow-y: hidden; box-sizing: border-box; }
.flow-starters .starter-row input:focus, .flow-starters .starter-row textarea:focus { border-color: var(--accent); }
.flow-starters .starter-row button { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); }
.flow-starters .starter-row button:hover { background: var(--line-soft); color: var(--text); }
.flow-starters .starter-add { margin-top: 8px; background: transparent; border: 1px dashed var(--line); border-radius: 8px; padding: 8px 12px; width: 100%; color: var(--text-muted); font-size: 14px; }
.flow-starters .starter-add:hover { border-color: var(--accent); color: var(--text); border-style: solid; background: var(--line-soft); }

.flow-start, .flow-end-marker { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.flow-end-marker { opacity: 0.7; }
.flow-arrow { width: 2px; height: 24px; background: var(--line); position: relative; }
.flow-arrow::after { content: ''; position: absolute; bottom: -1px; left: 50%; transform: translateX(-50%); width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid var(--line); }
.flow-add { width: 28px; height: 28px; border-radius: 50%; border: 1px dashed #CDD0D7; background: var(--surface); color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; padding: 0; transition: border-color .1s, color .1s, background .1s; }
.flow-add:hover { border-color: var(--accent); color: var(--accent); background: var(--line-soft); border-style: solid; }
.flow-add-menu { display: flex; flex-direction: column; padding: 4px; }
.flow-add-menu button { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 6px; border: none; background: transparent; font-size: 14px; color: var(--text); text-align: left; }
.flow-add-menu button:hover { background: var(--line-soft); }
.flow-add-menu button svg { color: var(--text-muted); flex-shrink: 0; }

.flow-node { background: var(--surface); border: 1px solid var(--line); border-radius: var(--rad-lg); padding: 14px 18px; min-width: 320px; max-width: 520px; width: 100%; box-shadow: var(--shadow-sm); position: relative; transition: border-color .12s, box-shadow .12s; cursor: pointer; }
.flow-node:hover { border-color: #D7DAE0; box-shadow: var(--shadow); }
.flow-node.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(238,72,73,0.12); }
.flow-node .fn-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.flow-node .fn-icon { width: 26px; height: 26px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--line-soft); color: var(--text); }
.flow-node .fn-type { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
.flow-node .fn-body { font-size: 15px; color: var(--text); line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.flow-node .fn-hint { font-size: 13px; color: var(--text-muted); margin-top: 6px; font-family: ui-monospace, monospace; }
.flow-node .fn-ctrls { position: absolute; top: 10px; right: 10px; display: none; gap: 2px; }
.flow-node:hover .fn-ctrls { display: flex; }
.flow-node .fn-ctrls button { width: 26px; height: 26px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 0; color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; }
.flow-node .fn-ctrls button:hover { background: var(--line-soft); color: var(--text); }

.flow-node.message .fn-icon { background: var(--accent-soft); color: var(--accent); }
.flow-node.choice  .fn-icon { background: var(--success-soft); color: var(--success); }
.flow-node.input   .fn-icon { background: var(--warn-soft); color: var(--warn); }
.flow-node.handoff .fn-icon { background: var(--danger-soft); color: var(--danger); }
.flow-node.end     .fn-icon { background: #EEF0F4; color: var(--text-muted); }

.flow-branches { display: flex; gap: 20px; justify-content: center; margin-top: 0; position: relative; padding-top: 14px; }
.flow-branches::before { content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 2px; height: 14px; background: var(--line); }
.flow-branch { display: flex; flex-direction: column; align-items: center; gap: 0; }
.flow-branch .branch-connector-top { width: 2px; height: 10px; background: var(--line); }
.flow-branch .branch-label { background: var(--surface); color: var(--text); padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 500; border: 1px solid var(--line); max-width: 180px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.scen-editor-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; background: var(--surface); flex-shrink: 0; }

/* ===== Canvas editor ===== */
.scen-editor-body.canvas-mode { display: grid; grid-template-columns: 1fr 340px; gap: 0; overflow: hidden; }
.scen-canvas-wrap { display: flex; flex-direction: column; overflow: hidden; background: #F6F7F9; background-image: radial-gradient(circle, #D9DCE1 1px, transparent 1px); background-size: 18px 18px; background-position: 0 0; }
.scen-canvas-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface); flex-shrink: 0; }
.scen-canvas-hint { flex: 1; font-size: 12px; color: var(--text-muted); padding: 0 12px; line-height: 1.5; }
.zoom-group { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--surface); }
.zoom-group button { border: none; background: transparent; width: 28px; height: 26px; padding: 0; font-size: 14px; font-weight: 600; color: var(--text); border-radius: 6px; }
.zoom-group button:hover { background: var(--line-soft); }
.zoom-label { min-width: 42px; text-align: center; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.scen-tabs { display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); overflow-x: auto; flex-shrink: 0; }
.scen-tab { padding: 6px 12px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; font-size: 12px; color: var(--text-muted); white-space: nowrap; cursor: pointer; }
.scen-tab:hover { background: var(--line-soft); color: var(--text); }
.scen-tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.scen-canvas-viewport { position: relative; overflow: auto; flex: 1; }
.scen-canvas-inner { position: relative; transform-origin: 0 0; width: max-content; height: max-content; min-width: 100%; min-height: 100%; }
.scen-edges { position: absolute; top: 0; left: 0; pointer-events: none; display: block; overflow: visible; }
.scen-edge { fill: none; stroke: #6B0F0F; stroke-width: 1.8; opacity: 0.55; }
.scen-nodes { position: relative; min-width: 100%; min-height: 100%; }

.cnode { position: absolute; width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-sm); transition: box-shadow .12s, border-color .12s; user-select: none; }
.cnode.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(220,38,38,0.15); }
.cnode.entry { border-color: var(--ink); }
.cnode.entry::before { content: '시작'; position: absolute; top: -10px; left: 10px; background: var(--ink); color: #fff; padding: 1px 8px; border-radius: 4px; font-size: 10px; font-weight: 600; }
.cnode-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: grab; background: var(--line-soft); border-radius: 10px 10px 0 0; }
.cnode-head:active { cursor: grabbing; }
.cnode-ic { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); }
.cnode-type { font-size: 11px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.03em; text-transform: uppercase; }
.cnode-body { padding: 10px; font-size: 13px; color: var(--text); line-height: 1.4; min-height: 36px; white-space: pre-wrap; word-break: break-word; }
.cnode-in { position: absolute; left: -6px; top: 30px; width: 10px; height: 10px; background: var(--surface); border: 2px solid #9CA3AF; border-radius: 50%; }
.cnode-out { width: 16px; height: 16px; border: 2px solid #9CA3AF; background: var(--surface); border-radius: 50%; cursor: pointer; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; color: transparent; font-size: 12px; font-weight: 700; line-height: 1; transition: background .1s, border-color .1s, color .1s; }
.cnode-out::before { content: '+'; color: #9CA3AF; font-size: 14px; font-weight: 600; line-height: 1; }
.cnode-out:hover { border-color: var(--accent); background: var(--accent); }
.cnode-out:hover::before { color: #fff; }
.cnode:not(.cnode-choice) > .cnode-out { position: absolute; right: -8px; top: 28px; }
.cnode-btns { border-top: 1px solid var(--line); }
.cnode-btn-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-top: 1px solid var(--line-soft); position: relative; }
.cnode-btn-row:first-child { border-top: none; }
.cnode-btn-label { flex: 1; font-size: 12px; color: var(--text); white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.cnode-btn-row .cnode-out { position: absolute; right: -8px; top: 50%; transform: translateY(-50%); }
.cnode-btn-row.linked .cnode-out { background: var(--accent); border-color: var(--accent); }
.cnode-btn-row.linked .cnode-out::before { color: #fff; }

.cnode-message .cnode-ic { color: var(--accent); }
.cnode-choice .cnode-ic { color: #0EA5E9; }
.cnode-input .cnode-ic { color: #F59E0B; }
.cnode-handoff .cnode-ic { color: #DC2626; }
.cnode-end .cnode-ic { color: var(--text-muted); }

/* Sidebar */
.scen-sidebar { border-left: 1px solid var(--line); background: var(--surface); overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.scen-sidebar .flow-starters { max-width: none; margin-bottom: 0; }
.scen-sel-empty { font-size: 13px; color: var(--text-muted); text-align: center; padding: 28px 14px; border: 1px dashed var(--line); border-radius: 8px; line-height: 1.55; }
.scen-sel-empty-sub { margin-top: 6px; font-size: 12px; color: var(--text-faint); }
.scen-node-form { display: flex; flex-direction: column; gap: 12px; }
.scen-node-form-head { display: flex; align-items: center; justify-content: space-between; }
.scen-node-form-title { font-size: 14px; font-weight: 600; color: var(--text); }
.scen-node-form .field { display: flex; flex-direction: column; gap: 4px; }
.scen-node-form .field > span { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.scen-node-form textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; outline: none; resize: none; overflow-y: hidden; font-family: inherit; line-height: 1.5; box-sizing: border-box; }
.scen-node-form input[type="text"], .scen-node-form select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; outline: none; font-family: inherit; }
.scen-node-form textarea:focus, .scen-node-form input:focus, .scen-node-form select:focus { border-color: var(--accent); }
.scen-node-form .field-hint { font-size: 12px; color: var(--text-muted); }
.scen-btn-list { display: flex; flex-direction: column; gap: 10px; }
.scen-btn-row { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.scen-btn-row-top { display: grid; grid-template-columns: 1fr 30px; gap: 6px; align-items: start; }
.scen-btn-row-top textarea { line-height: 1.4; padding: 6px 10px; resize: none; overflow-y: hidden; box-sizing: border-box; background: var(--surface); }
.scen-btn-row-top .rmbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; width: 30px; height: 32px; padding: 0; color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.scen-btn-row-top .rmbtn:hover { background: var(--line-soft); color: var(--danger); border-color: var(--danger); }
.scen-btn-row-next { display: flex; flex-direction: column; gap: 4px; }
.scen-btn-arrow { font-size: 11px; color: var(--text-muted); padding-left: 4px; }
.scen-node-form .add-inline { margin-top: 4px; background: transparent; border: 1px dashed var(--line); border-radius: 8px; padding: 8px; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.scen-node-form .add-inline:hover { border-color: var(--accent); color: var(--text); background: var(--line-soft); }

.scen-var-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.scen-var-label { font-size: 11px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.02em; margin-right: 2px; }
.scen-var-chip { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; font-size: 13px; color: var(--text); font-weight: 500; cursor: pointer; transition: background .1s, border-color .1s, color .1s; touch-action: manipulation; -webkit-tap-highlight-color: rgba(238,72,73,0.15); }
.scen-var-chip:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-hover); }
.scen-var-chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.scen-var-chip::before { content: '+'; color: var(--text-faint); font-weight: 700; margin-right: 2px; font-size: 13px; }
.scen-var-chip.active::before { content: '✓'; color: #fff; }
.scen-var-chip:hover::before { color: var(--accent); }

/* Inline explainer box */
.scen-explain { background: var(--line-soft); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 12px; line-height: 1.55; color: var(--text); display: flex; flex-direction: column; gap: 2px; }
.scen-explain strong { font-size: 13px; color: var(--text); font-weight: 600; }
.scen-explain div { color: var(--text-muted); }

/* Variable-save preview */
.scen-var-preview { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; background: #F5F6F8; border: 1px dashed var(--line); border-radius: 8px; margin-top: 4px; font-size: 12px; }
.scen-var-preview-label { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); font-weight: 600; }
.scen-var-preview-row { display: flex; flex-wrap: wrap; gap: 2px; align-items: baseline; color: var(--text); }
.scen-var-preview-k { color: var(--text-muted); }
.scen-var-preview-v { color: var(--ink); font-weight: 600; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; }
.scen-var-preview-code { background: var(--accent-soft); color: var(--accent-hover); padding: 1px 6px; border-radius: 4px; font-family: ui-monospace, "SF Mono", monospace; font-size: 12px; border: 1px solid #F3C9CE; }

/* Variable-insert card */
.scen-var-box { background: #F5F6F8; border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.scen-var-title { font-size: 13px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 6px; }
.scen-var-title::before { content: '↳'; color: var(--accent); font-weight: 700; }
.scen-var-desc { font-size: 12px; color: var(--text-muted); line-height: 1.55; }
.scen-var-example { font-size: 12px; color: var(--text-muted); line-height: 1.7; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.scen-var-example .k { font-weight: 600; color: var(--text); margin-right: 4px; }
.scen-var-example code { background: var(--accent-soft); color: var(--accent-hover); padding: 1px 6px; border-radius: 4px; font-family: ui-monospace, "SF Mono", monospace; font-size: 11px; border: 1px solid #F3C9CE; }
.scen-var-example .v { color: var(--ink); font-weight: 600; }

/* Step picker (next-step chooser) */
.step-picker { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 13px; color: var(--text); cursor: pointer; text-align: left; transition: border-color .1s, background .1s; }
.step-picker:hover { border-color: var(--accent); background: var(--line-soft); }
.step-picker-ic { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--text-muted); }
.step-picker-ic.muted { color: var(--text-faint); }
.step-picker-ic.cnode-ic-message { color: var(--accent); }
.step-picker-ic.cnode-ic-choice  { color: #0EA5E9; }
.step-picker-ic.cnode-ic-input   { color: #F59E0B; }
.step-picker-ic.cnode-ic-handoff { color: #DC2626; }
.step-picker-ic.cnode-ic-end     { color: var(--text-muted); }
.step-picker-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.3; }
.step-picker-text.muted { color: var(--text-muted); }
.step-picker-chev { color: var(--text-faint); display: inline-flex; flex-shrink: 0; }

.dropdown:has(.step-picker-menu) { padding: 0; overflow: hidden; }
.step-picker-menu { display: flex; flex-direction: column; width: 360px; max-height: 420px; overflow: hidden; }
.step-picker-section { padding: 10px 12px 6px; font-size: 11px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.04em; text-transform: uppercase; border-top: 1px solid var(--line-soft); }
.step-picker-section:first-child { border-top: none; }
.step-picker-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px 10px 10px; }
.step-picker-new { display: grid; grid-template-columns: 28px 1fr; grid-template-rows: auto auto; grid-column-gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-align: left; cursor: pointer; transition: border-color .1s, background .1s, transform .05s; }
.step-picker-new:hover { border-color: var(--accent); background: var(--line-soft); }
.step-picker-new:active { transform: scale(0.98); }
.step-picker-new .ic { grid-row: 1 / span 2; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; background: var(--line-soft); color: var(--text-muted); }
.step-picker-new .lbl { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.2; }
.step-picker-new .sub { font-size: 11px; color: var(--text-muted); line-height: 1.2; margin-top: 1px; }
.step-picker-new.cnode-ic-message .ic { background: var(--accent-soft); color: var(--accent); }
.step-picker-new.cnode-ic-choice  .ic { background: #E0F2FE; color: #0369A1; }
.step-picker-new.cnode-ic-input   .ic { background: var(--warn-soft); color: var(--warn); }
.step-picker-new.cnode-ic-handoff .ic { background: var(--danger-soft, #FEE2E2); color: var(--danger); }
.step-picker-new.cnode-ic-end     .ic { background: #EEF0F4; color: var(--text-muted); }

.step-picker-list { flex: 1; overflow-y: auto; padding: 4px 6px 8px; }
.step-picker-item { display: flex; align-items: flex-start; gap: 8px; width: 100%; padding: 8px 10px; border: none; background: transparent; border-radius: 6px; font-size: 13px; color: var(--text); text-align: left; cursor: pointer; }
.step-picker-item:hover { background: var(--line-soft); }
.step-picker-item.selected { background: var(--accent-soft); color: var(--text); }
.step-picker-item .step-picker-ic { padding-top: 2px; }
.step-picker-item .step-picker-text { flex: 1; min-width: 0; white-space: normal; overflow: visible; text-overflow: clip; font-weight: 400; line-height: 1.4; }
.step-picker-item .step-picker-type { font-size: 11px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.step-picker-item .step-picker-preview { font-size: 13px; color: var(--text); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.step-picker-item .muted { color: var(--text-muted); font-weight: 400; }
.step-picker-empty { padding: 14px 12px; font-size: 12px; color: var(--text-muted); text-align: center; }

/* Edit modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(11,12,15,0.40); z-index: 250; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--rad-lg); width: 100%; max-width: 520px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); overflow: hidden; border: 1px solid var(--line); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 16px; color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-body .field > span { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.modal-body input[type="text"], .modal-body textarea, .modal-body select { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--rad); font-size: 15px; outline: none; }
.modal-body input:focus, .modal-body textarea:focus, .modal-body select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(238,72,73,0.10); }
.modal-body textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); }

.button-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.button-row input[type="text"] { flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; outline: none; }
.button-row .rmbtn { width: 32px; height: 34px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 0; color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; }
.button-row .rmbtn:hover { background: var(--line-soft); color: var(--text); }
.add-inline { background: transparent; border: 1px dashed var(--line); padding: 8px 12px; border-radius: 8px; font-size: 14px; color: var(--text-muted); width: 100%; }
.add-inline:hover { border-color: var(--accent); color: var(--text); border-style: solid; background: var(--line-soft); }

/* Simulator */
.sim-backdrop { position: fixed; inset: 0; background: rgba(11,12,15,0.50); z-index: 300; display: flex; align-items: center; justify-content: center; }
.sim-box { background: var(--surface); width: 380px; height: 620px; border-radius: 18px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0,0,0,0.35); }
.sim-head { background: var(--ink); color: #fff; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; }
.sim-head .t { font-weight: 600; font-size: 15px; }
.sim-head button { background: transparent; border: none; color: #fff; padding: 4px; border-radius: 6px; }
.sim-head button:hover { background: rgba(255,255,255,0.12); }
.sim-log { flex: 1; overflow-y: auto; padding: 16px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.sim-log .msg .bubble { max-width: 80%; }
.sim-log .btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.sim-log .btns button { background: var(--surface); border: 1px solid var(--accent); color: var(--accent); padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 500; }
.sim-log .btns button:hover { background: var(--accent); color: #fff; }
.sim-compose { padding: 10px 14px; border-top: 1px solid var(--line); display: flex; gap: 8px; background: var(--surface); }
.sim-compose input { flex: 1; padding: 9px 14px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; outline: none; }
.sim-compose button { padding: 0 18px; background: var(--ink); color: #fff; border: none; border-radius: 999px; font-size: 14px; font-weight: 600; }

/* ===== SETTINGS ===== */
.page-settings { display: grid; grid-template-columns: 240px 1fr; gap: 14px; padding: 14px; height: 100%; }
.pane-settings-side { padding: 10px; }
.set-tabs { list-style: none; margin: 0; padding: 0; }
.set-tabs li { padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text); margin-bottom: 2px; font-weight: 500; }
.set-tabs li:hover { background: var(--line-soft); }
.set-tabs li.active { background: var(--submenu-active); color: #fff; }
.pane-settings-main { padding: 32px 40px; overflow-y: auto; }
.pane-settings-main h2 { font-size: 21px; color: var(--text); margin-bottom: 6px; letter-spacing: -0.025em; }
.pane-settings-main .desc { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; line-height: 1.6; max-width: 620px; }
.pane-settings-main .desc code { background: var(--line-soft); padding: 1px 6px; border-radius: 4px; font-family: ui-monospace, monospace; font-size: 13px; }
.set-form { max-width: 660px; display: flex; flex-direction: column; gap: 16px; }
.set-form .field { gap: 6px; }
.set-form .checkbox { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; color: var(--text); cursor: pointer; }
.set-form .checkbox input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--ink); }
.set-form .actions { display: flex; gap: 10px; margin-top: 10px; }
.list-edit { display: flex; flex-direction: column; gap: 10px; max-width: 820px; }
.list-edit .row { background: var(--surface); border: 1px solid var(--line); border-radius: var(--rad); padding: 12px; display: grid; grid-template-columns: 150px 1fr 1fr 36px; gap: 10px; align-items: flex-start; }
.list-edit .row.faq { grid-template-columns: 1fr 2fr 36px; }
.list-edit .row.tag { grid-template-columns: 20px 1fr 36px; align-items: center; }
.list-edit .row.tag-add { grid-template-columns: 1fr 80px; gap: 10px; align-items: center; }
.list-edit .row.tag-add { display: grid; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--rad); padding: 12px; }
.list-edit .row.tag-add input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; outline: none; }
.tag-swatch { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.tag-name { font-size: 14px; color: var(--text); font-weight: 500; }
.list-edit input, .list-edit textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; outline: none; }
.list-edit input:focus, .list-edit textarea:focus { border-color: var(--accent); }
.list-edit textarea { min-height: 40px; resize: vertical; }
.list-edit .row .rm { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; height: 34px; color: var(--text-muted); padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.list-edit .row .rm:hover { background: var(--line-soft); color: var(--text); }
.hours-grid { display: grid; grid-template-columns: 60px 110px 110px 40px; gap: 10px; align-items: center; max-width: 420px; }
.hours-grid label { font-size: 14px; color: var(--text); font-weight: 500; }
.hours-grid input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--ink); }
.hours-grid input[type="text"] { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; outline: none; }

.install-code { background: var(--ink); color: #DDE0E6; padding: 18px; border-radius: var(--rad); font-family: ui-monospace, "SF Mono", monospace; font-size: 14px; line-height: 1.6; position: relative; word-break: break-all; }
.install-code button { position: absolute; top: 10px; right: 10px; background: var(--surface); color: var(--ink); border: none; padding: 5px 10px; border-radius: 6px; font-size: 13px; font-weight: 500; }
.install-code button:hover { background: #E5E6EB; }
.install-item { margin-bottom: 20px; }
.install-item-head { margin-bottom: 8px; }
.install-item-title { font-size: 15px; font-weight: 600; color: var(--text); }
.install-item-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.sites-list .site-row { grid-template-columns: 140px 1fr 1.4fr 36px; align-items: center; }
.sites-list .site-id { font-family: ui-monospace, "SF Mono", monospace; font-size: 12px; color: var(--text-muted); background: var(--line-soft); padding: 4px 8px; border-radius: 6px; display: inline-block; text-align: center; }
.site-add-form { margin-top: 18px; max-width: 820px; }
.site-add-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 10px; align-items: stretch; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--rad); padding: 12px; }
.site-add-row input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; outline: none; }
.site-add-row input:focus { border-color: var(--accent); }

.mobile-back { display: none; }
.folder-chips { display: none; }

@media (max-width: 960px) {
  :root { --rail-w: 56px; --top-h: 48px; }
  .rail { padding: 6px 0; gap: 2px; }
  .rail-brand { margin-bottom: 6px; }
  .rail-btn { width: 38px; height: 38px; }
  .topbar { padding: 0 12px; }

  .mobile-back { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

  /* ===== INBOX (mobile: one pane at a time) ===== */
  .page-inbox { display: flex; flex-direction: column; gap: 8px; padding: 8px; height: 100%; min-height: 0; }
  .page-inbox .pane-folders { display: none; }
  .page-inbox .pane-conv-list { flex: 1 1 auto; min-height: 0; }
  .page-inbox .pane-conv-list .pane-head { flex-wrap: wrap; gap: 6px; padding: 8px 10px; min-height: 0; }
  .pane-conv-list .conv-list li { touch-action: manipulation; -webkit-tap-highlight-color: rgba(238,72,73,0.15); }
  .folder-chips { display: flex; flex-direction: row; gap: 4px; overflow-x: auto; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--surface-2); flex-shrink: 0; -webkit-overflow-scrolling: touch; }
  .folder-chips .chip-f { flex-shrink: 0; padding: 6px 12px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; font-size: 12px; color: var(--text); white-space: nowrap; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
  .folder-chips .chip-f.active { background: var(--submenu-active); color: #fff; border-color: var(--submenu-active); }
  .folder-chips .chip-f .c { font-size: 11px; background: var(--line-soft); color: var(--text-muted); padding: 0 6px; border-radius: 999px; font-weight: 600; }
  .folder-chips .chip-f.active .c { background: rgba(255,255,255,0.22); color: #fff; }
  .page-inbox .pane-detail { display: none; }
  .page-inbox.detail-open .pane-conv-list,
  .page-inbox.detail-open .folder-chips { display: none; }
  .page-inbox.detail-open .pane-detail { display: flex; flex: 1 1 auto; min-height: 0; }

  .detail-head { padding: 10px 12px; gap: 8px; }
  .detail-title #conv-title { font-size: 14px; }
  .detail-title .sub { font-size: 12px; }
  .action-bar .btn { padding: 6px 10px; font-size: 13px; }
  .log { padding: 14px 14px; }
  .msg .bubble { max-width: 78%; font-size: 14px; padding: 9px 12px; }
  .compose-row { padding: 10px 10px; }
  .compose textarea { font-size: 14px; min-height: 40px; }
  .btn-send { height: 40px; padding: 0 14px; }

  /* ===== SCENARIOS (mobile) ===== */
  .page-scenarios { display: flex; flex-direction: column; gap: 8px; padding: 8px; }
  .page-scenarios .pane-scen-list { flex: 1; min-height: 0; }
  .page-scenarios .pane-scen-editor { display: none; }
  .page-scenarios.detail-open .pane-scen-list { display: none; }
  .page-scenarios.detail-open .pane-scen-editor { display: flex; flex: 1; min-height: 0; }

  .scen-editor-head { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .scen-name-input { font-size: 15px; min-width: 140px; flex: 1 1 140px; }
  .scen-editor-foot { padding: 10px 12px; }
  .scen-view-toggle { flex-shrink: 0; }

  /* Canvas mode on mobile: full-width, no sidebar */
  .scen-editor-body.canvas-mode { display: flex; flex-direction: column; }
  .scen-editor-body.canvas-mode .scen-sidebar { display: none; }
  .scen-editor-body.canvas-mode .scen-canvas-wrap { flex: 1 1 auto; min-height: 0; }
  .scen-canvas-viewport { -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; }
  .scen-canvas-toolbar { flex-wrap: wrap; padding: 8px 10px; gap: 6px; }
  .scen-canvas-hint { display: none; }
  .zoom-group { margin-left: auto; }

  /* Chat-flow mode (mobile default for scenarios) */
  .scen-editor-body.chat-mode { display: flex; flex-direction: column; overflow-y: auto; padding: 12px; background: #F5F6F8; gap: 10px; }
  .scen-editor-body.chat-mode .flow-starters { margin: 0; max-width: none; }
  .scen-chat-entries { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
  .scen-chat-entries[hidden] { display: none; }
  .scen-chat-entries-label { font-size: 11px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.04em; text-transform: uppercase; }
  .scen-chat-entries-chips { display: flex; flex-wrap: wrap; gap: 6px; }
  .scen-chat-entry { border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; border-radius: 999px; font-size: 12px; color: var(--text); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: rgba(238,72,73,0.15); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .scen-chat-entry:hover { background: var(--line-soft); }
  .scen-chat-entry.active { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }
  .scen-chat-crumb { font-size: 11px; color: var(--text-muted); padding: 2px 4px; letter-spacing: 0.01em; }
  .scen-chat-wrap { display: flex; flex-direction: column; gap: 8px; }
  .scen-chat-empty { padding: 30px 16px; text-align: center; color: var(--text-muted); font-size: 13px; background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; }
  .scen-chat-bubble { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-sm); max-width: 92%; align-self: flex-start; position: relative; }
  .scen-chat-bubble.entry { border-color: var(--ink); }
  .scen-chat-bubble.entry .scen-chat-bubble-head { background: var(--ink); color: #fff; }
  .scen-chat-bubble.entry .scen-chat-bubble-head .scen-chat-ic { color: #fff; }
  .scen-chat-bubble.entry .scen-chat-bubble-head .icon-btn { color: rgba(255,255,255,0.85); }
  .scen-chat-bubble.entry .scen-chat-bubble-head .icon-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
  .scen-chat-bubble-head { display: flex; align-items: center; gap: 6px; padding: 7px 10px; background: var(--line-soft); font-size: 11px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
  .scen-chat-ic { display: inline-flex; color: var(--text-muted); }
  .scen-chat-bubble-head .icon-btn { margin-left: auto; width: 26px; height: 26px; padding: 0; border-radius: 6px; }
  .scen-chat-bubble-body { padding: 10px 14px; font-size: 14px; color: var(--text); line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
  .scen-chat-bubble-body.muted { color: var(--text-faint); font-style: italic; }
  .scen-chat-buttons { display: flex; flex-direction: column; gap: 5px; padding: 6px 10px 10px; border-top: 1px solid var(--line-soft); }
  .scen-chat-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--line); background: var(--surface); padding: 10px 12px; border-radius: 8px; text-align: left; font-size: 14px; color: var(--text); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: rgba(238,72,73,0.15); }
  .scen-chat-btn .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .scen-chat-btn .arr { font-size: 11px; color: var(--text-faint); flex-shrink: 0; }
  .scen-chat-btn.linked .arr { color: var(--text-muted); }
  .scen-chat-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-hover); font-weight: 600; }
  .scen-chat-btn.active .arr { color: var(--accent); }
  .scen-chat-input-hint { padding: 8px 12px; border-top: 1px solid var(--line-soft); background: var(--warn-soft); font-size: 12px; color: var(--warn); }
  .scen-chat-form { padding: 12px; border-top: 1px solid var(--line-soft); background: var(--surface-2); }
  .scen-chat-add { width: 100%; padding: 12px; font-size: 14px; margin-top: 4px; align-self: stretch; }

  .scen-chat-message { border-left: 3px solid var(--accent); }
  .scen-chat-choice  { border-left: 3px solid #0EA5E9; }
  .scen-chat-input   { border-left: 3px solid #F59E0B; }
  .scen-chat-handoff { border-left: 3px solid var(--danger); align-self: center; }
  .scen-chat-end     { border-left: 3px solid var(--text-muted); align-self: center; background: var(--line-soft); }

  /* ===== SETTINGS (mobile) ===== */
  .page-settings { display: flex; flex-direction: column; gap: 8px; padding: 8px; }
  .pane-settings-side { flex-shrink: 0; }
  .pane-settings-side .set-tabs { display: flex; flex-direction: row; overflow-x: auto; padding: 6px; gap: 4px; }
  .pane-settings-side .set-tabs li { flex-shrink: 0; white-space: nowrap; padding: 8px 12px; font-size: 13px; }
  .pane-settings-main { padding: 16px; flex: 1; min-height: 0; overflow-y: auto; }
  .pane-settings-main .desc { margin-bottom: 16px; font-size: 13px; }
}
