:root {
  --canvas: #EEF1F0;
  --surface: #FFFFFF;
  --surface-2: #F6F8F7;
  --ink: #17201F;
  --ink-2: #3A4644;
  --muted: #66716F;
  --faint: #98A3A0;
  --line: #DFE5E3;
  --line-2: #EAEFED;
  --brand: #0F6E6A;
  --brand-ink: #0B5552;
  --brand-soft: #E1F0EE;
  --rail: #12302E;
  --rail-ink: #A9C9C4;
  --amber: #B97508;
  --amber-bg: #FCF1DC;
  --red: #C8402F;
  --red-bg: #FBE7E3;
  --green: #1E9A5C;
  --note: #FFF6D2;
  --note-line: #EAD98E;
  --shadow: 0 1px 2px rgba(18, 48, 46, .06), 0 4px 16px -6px rgba(18, 48, 46, .14);
  --shadow-pop: 0 18px 50px -12px rgba(18, 48, 46, .35), 0 2px 8px rgba(18, 48, 46, .08);
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--canvas);
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--brand); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
svg { flex: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 10px; font-weight: 600; font-size: 13.5px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); border-color: #CDD6D3; }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn-amber { background: var(--amber); border-color: var(--amber); color: #fff; }
.btn-amber:hover { background: #9E6406; border-color: #9E6406; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-bg); border-color: #F0C6BE; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; display: inline-grid; place-items: center; color: var(--muted);
  transition: background .12s, color .12s; position: relative;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.active { background: var(--brand-soft); color: var(--brand); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label, .field > .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .help { font-size: 12.5px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 110, 106, .14); }
.row { display: flex; gap: 10px; align-items: center; }
.row > .field { flex: 1; }
.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; word-break: break-all; white-space: pre-wrap; color: var(--ink-2);
}

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 40px; height: 24px; border-radius: 12px; background: #C9D2CF; position: relative; transition: background .18s; flex: none; }
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .2s cubic-bezier(.3, 1.3, .5, 1);
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 6px;
  font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; border: 1px solid var(--line-2);
}
.chip-member { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.chip-guest { background: #EFF1F0; color: var(--muted); border-color: transparent; }
.chip-amber { background: var(--amber-bg); color: var(--amber); border-color: transparent; }
.chip-red { background: var(--red-bg); color: var(--red); border-color: transparent; }
.chip-lang { background: transparent; color: var(--ink-2); border-color: var(--line); }
.chip svg { width: 12px; height: 12px; }

.avatar {
  width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: 14px;
  flex: none; position: relative; color: #fff;
}
.avatar .presence {
  position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--surface);
  background: #B9C3C0;
}
.avatar .presence.on { background: var(--green); }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 13.5px; }
.empty b { display: block; color: var(--ink-2); font-size: 15px; margin-bottom: 4px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; background: var(--rail); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 18px; padding: 32px 28px 28px; box-shadow: var(--shadow-pop); }
.login-mark { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.login-mark img { width: 40px; height: 40px; }
.login-mark h1 { font-size: 20px; margin: 0; letter-spacing: -.02em; }
.login-mark p { margin: 0; color: var(--muted); font-size: 13px; }
.login .btn-primary { width: 100%; height: 44px; font-size: 15px; margin-top: 6px; }
.form-error { color: var(--red); font-size: 13px; min-height: 20px; margin: -4px 0 8px; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 64px 340px 1fr; height: 100%; height: 100dvh; }
.rail {
  background: var(--rail); color: var(--rail-ink); display: flex; flex-direction: column; align-items: center;
  padding: 14px 0 12px; gap: 4px;
}
.rail-logo { width: 38px; height: 38px; margin-bottom: 14px; }
.rail-btn {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: var(--rail-ink); position: relative;
  transition: background .12s, color .12s;
}
.rail-btn svg { width: 22px; height: 22px; }
.rail-btn:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.rail-btn.active { background: rgba(95, 208, 193, .16); color: #fff; }
.rail-btn .count {
  position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; border-radius: 9px; background: #E9A23B; color: #2A1C02;
  font-size: 11px; font-weight: 800; display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--rail);
}
.rail-spacer { flex: 1; }
.rail-me { width: 40px; height: 40px; border-radius: 12px; font-size: 14px; }
.rail-me .presence { border-color: var(--rail); }
.rail-service {
  width: 44px; padding: 6px 0 8px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 700; color: var(--rail-ink); margin-bottom: 6px;
}
.rail-service .light { width: 10px; height: 10px; border-radius: 50%; background: #E06B5B; box-shadow: 0 0 0 4px rgba(224, 107, 91, .18); }
.rail-service.on .light { background: #4FD38E; box-shadow: 0 0 0 4px rgba(79, 211, 142, .18); }
.rail-service:hover { background: rgba(255, 255, 255, .07); }

/* ---------- Conversation list ---------- */
.list-col { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.list-head { padding: 16px 16px 10px; display: flex; flex-direction: column; gap: 12px; border-bottom: 1px solid var(--line-2); }
.list-title { display: flex; align-items: center; justify-content: space-between; }
.list-title h2 { font-size: 19px; margin: 0; letter-spacing: -.02em; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); }
.search input { padding-left: 34px; height: 36px; background: var(--surface-2); border-color: transparent; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.tab {
  height: 32px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px;
}
.tab .n { font-size: 11.5px; font-weight: 700; color: var(--faint); }
.tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(18, 48, 46, .12); }
.tab.waiting.has .n { color: #fff; background: var(--amber); border-radius: 9px; padding: 0 6px; min-width: 18px; line-height: 18px; text-align: center; }
.subtabs { display: flex; gap: 6px; }
.subtab { height: 26px; padding: 0 10px; border-radius: 13px; font-size: 12.5px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); }
.subtab.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.list { flex: 1; overflow-y: auto; padding: 6px 8px 12px; min-height: 0; }
.conv-item {
  display: flex; gap: 11px; padding: 11px 10px; border-radius: 12px; cursor: pointer; position: relative; width: 100%; text-align: left;
  transition: background .1s;
}
.conv-item:hover { background: var(--surface-2); }
.conv-item.selected { background: var(--brand-soft); }
.conv-item.open::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 2px; background: var(--brand); }
.conv-main { flex: 1; min-width: 0; }
.conv-line1 { display: flex; align-items: center; gap: 6px; }
.conv-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.conv-time { margin-left: auto; font-size: 11.5px; color: var(--faint); white-space: nowrap; flex: none; }
.conv-time.wait { color: var(--amber); font-weight: 700; }
.conv-preview {
  font-size: 13px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; gap: 6px; align-items: center;
}
.conv-preview .txt { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.conv-item.unread .conv-preview { color: var(--ink); font-weight: 600; }
.conv-line3 { display: flex; gap: 4px; margin-top: 6px; align-items: center; flex-wrap: wrap; }
.conv-unread {
  min-width: 20px; height: 20px; border-radius: 10px; background: var(--red); color: #fff; font-size: 11.5px; font-weight: 800;
  display: grid; place-items: center; padding: 0 6px; margin-left: auto; flex: none;
}
.typing-mini { color: var(--brand); font-weight: 600; font-style: normal; }
.list-more { display: flex; justify-content: center; padding: 10px; }

/* ---------- Workspace ---------- */
.work { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.work-bar {
  height: 52px; display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--canvas); flex: none;
}
.open-tabs { display: flex; gap: 6px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; padding: 4px 0; }
.open-tabs::-webkit-scrollbar { display: none; }
.otab {
  display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 6px 0 10px; border-radius: 10px; background: rgba(255, 255, 255, .55);
  border: 1px solid transparent; font-size: 13px; font-weight: 600; white-space: nowrap; flex: none; color: var(--ink-2);
}
.otab:hover { background: var(--surface); }
.otab.visible { background: var(--surface); border-color: var(--line); color: var(--ink); box-shadow: 0 1px 2px rgba(18, 48, 46, .06); }
.otab .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.otab .dot.waiting { background: var(--amber); }
.otab .dot.active { background: var(--green); }
.otab .x { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; color: var(--faint); }
.otab .x:hover { background: var(--surface-2); color: var(--ink); }
.otab .x svg { width: 14px; height: 14px; }
.otab .badge { background: var(--red); color: #fff; font-size: 10.5px; font-weight: 800; border-radius: 8px; padding: 0 5px; line-height: 16px; }
.layout-switch { display: flex; background: rgba(255, 255, 255, .6); border-radius: 10px; padding: 3px; gap: 2px; flex: none; }
.layout-switch button { width: 32px; height: 28px; border-radius: 7px; display: grid; place-items: center; color: var(--muted); }
.layout-switch button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(18, 48, 46, .1); }
.layout-switch svg { width: 17px; height: 17px; }

.panes { flex: 1; display: grid; gap: 10px; padding: 0 12px 12px; min-height: 0; }
.panes.l1 { grid-template-columns: 1fr; }
.panes.l2 { grid-template-columns: 1fr 1fr; }
.panes.l3 { grid-template-columns: 1fr 1fr 1fr; }
.panes.l4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.work-empty { flex: 1; display: grid; place-items: center; padding: 20px; }
.work-empty-inner { text-align: center; max-width: 360px; color: var(--muted); }
.work-empty-inner h3 { color: var(--ink); font-size: 17px; margin: 14px 0 6px; }
.work-empty-inner svg { width: 46px; height: 46px; color: #B5C4C0; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 22px; }
.kpi { background: var(--surface); border-radius: 12px; padding: 12px; text-align: left; border: 1px solid var(--line-2); }
.kpi b { display: block; font-size: 22px; color: var(--ink); letter-spacing: -.02em; }
.kpi span { font-size: 12px; }

/* ---------- Chat pane ---------- */
.pane {
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); display: flex; min-width: 0; min-height: 0; overflow: hidden;
  position: relative; outline: 2px solid transparent; transition: outline-color .15s;
}
.pane.focused { outline-color: rgba(15, 110, 106, .35); }
.pane-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pane-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--line-2); min-height: 60px; }
.pane-back { display: none; }
.pane-who { flex: 1; min-width: 0; }
.pane-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 6px; min-width: 0; }
.pane-name span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane-sub { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; min-width: 0; white-space: nowrap; overflow: hidden; }
.pane-sub .live { color: var(--green); font-weight: 600; }
.pane-sub a { color: var(--muted); overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
.pane-sub a:hover { color: var(--brand); text-decoration: underline; }
.pane-actions { display: flex; gap: 4px; align-items: center; flex: none; }
.status-pill { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px; white-space: nowrap; flex: none; }
.pane-name .chip { flex: none; }
.status-pill.waiting { background: var(--amber-bg); color: var(--amber); }
.status-pill.active { background: #E2F4EA; color: #17784A; }
.status-pill.closed { background: #EEF0EF; color: var(--muted); }

.msgs { flex: 1; overflow-y: auto; padding: 16px 16px 8px; min-height: 0; background: var(--surface); }
.msgs-top { display: flex; justify-content: center; padding: 4px 0 12px; }
.m-row { display: flex; gap: 8px; margin-top: 3px; align-items: flex-end; }
.m-row.gap { margin-top: 14px; }
.m-row.mine { flex-direction: row-reverse; }
.m-col { display: flex; flex-direction: column; max-width: min(78%, 560px); min-width: 0; }
.m-row.mine .m-col { align-items: flex-end; }
.m-name { font-size: 12px; color: var(--muted); font-weight: 600; margin: 0 4px 3px; }
.m-bubble {
  border-radius: 14px; padding: 9px 13px; background: var(--surface-2); border: 1px solid var(--line-2);
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; font-size: 14px; color: var(--ink);
}
.m-row.them .m-bubble { border-bottom-left-radius: 4px; }
.m-row.mine .m-bubble { background: var(--brand); border-color: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.m-row.agent-other .m-bubble { background: #E7F1F0; border-color: #D3E5E2; }
.m-bubble a { color: inherit; }
/* Original + translation */
.m-dual {
  margin: 8px -13px -9px; padding: 7px 13px 8px; border-top: 1px dashed rgba(23, 32, 31, .16);
  background: rgba(23, 32, 31, .025); border-radius: 0 0 13px 13px; font-size: 13px; color: var(--ink-2);
}
.m-row.them .m-dual { border-bottom-left-radius: 3px; }
.m-row.mine .m-dual { border-top-color: rgba(255, 255, 255, .3); background: rgba(0, 0, 0, .1); color: rgba(255, 255, 255, .92); border-bottom-right-radius: 3px; }
.m-dual .lbl { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; margin-right: 6px; opacity: .75; vertical-align: 1px; }
.m-dual .lbl i { font-style: normal; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; line-height: 15px; }
.m-pending-tr { color: var(--faint); font-size: 12px; }
.m-meta { font-size: 11px; color: var(--faint); margin: 3px 4px 0; display: flex; gap: 8px; align-items: center; }
.m-meta .read { color: var(--brand); font-weight: 600; }
.m-meta .warn { color: var(--red); font-weight: 600; }
.m-meta button { color: var(--brand); font-weight: 700; font-size: 11px; }
.m-row.sending .m-bubble { opacity: .6; }
.m-row.failed .m-bubble { box-shadow: 0 0 0 1.5px var(--red); }
.m-att img { display: block; max-width: 240px; max-height: 260px; border-radius: 10px; object-fit: cover; background: var(--surface-2); margin-top: 2px; }
.m-file { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); text-decoration: none; max-width: 260px; margin-top: 2px; }
.m-file svg { width: 18px; height: 18px; }
.m-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.m-sys { text-align: center; margin: 14px 0 6px; font-size: 12px; color: var(--muted); }
.m-sys span { background: var(--surface-2); padding: 4px 10px; border-radius: 999px; display: inline-block; }
.m-event { text-align: center; margin: 10px 0 4px; font-size: 12px; color: var(--faint); }
.m-note { margin: 12px auto 4px; max-width: 86%; background: var(--note); border: 1px solid var(--note-line); border-radius: 10px; padding: 8px 12px; font-size: 13.5px; }
.m-note .h { font-size: 11.5px; font-weight: 700; color: #8A6D0A; margin-bottom: 2px; display: flex; gap: 6px; }
.m-note .b { white-space: pre-wrap; word-break: break-word; }
.m-note .m-dual { margin: 6px -12px -8px; border-radius: 0 0 9px 9px; }
.day-sep { text-align: center; margin: 18px 0 8px; font-size: 11.5px; color: var(--faint); font-weight: 600; }
.vtyping { padding: 4px 16px 8px; font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: baseline; min-height: 0; }
.vtyping em { font-style: normal; color: var(--ink-2); background: var(--surface-2); border: 1px dashed var(--line); padding: 2px 8px; border-radius: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 80%; }

.composer { border-top: 1px solid var(--line-2); padding: 8px 12px 12px; position: relative; }
.composer.note-mode { background: var(--note); border-top-color: var(--note-line); }
.comp-modes { display: flex; gap: 2px; margin-bottom: 6px; align-items: center; }
.comp-mode { height: 26px; padding: 0 10px; border-radius: 7px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.comp-mode.active { background: var(--surface-2); color: var(--ink); }
.note-mode .comp-mode.active { background: rgba(255, 255, 255, .7); color: #7A600A; }
.comp-hint { margin-left: auto; font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comp-box { display: flex; gap: 6px; align-items: flex-end; border: 1px solid var(--line); border-radius: 12px; padding: 4px 4px 4px 4px; background: var(--surface); }
.comp-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 110, 106, .12); }
.note-mode .comp-box:focus-within { border-color: #C9A622; box-shadow: 0 0 0 3px rgba(201, 166, 34, .15); }
.comp-box textarea { flex: 1; border: 0; outline: 0; resize: none; padding: 7px 6px; min-height: 36px; max-height: 160px; line-height: 1.45; background: transparent; }
.comp-send { width: 36px; height: 36px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; }
.comp-send:disabled { opacity: .35; cursor: default; }
.comp-send svg { width: 18px; height: 18px; }
.note-mode .comp-send { background: #A88A12; }
.comp-locked { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line-2); background: var(--surface-2); font-size: 13px; color: var(--muted); }
.canned-pop {
  position: absolute; left: 12px; right: 12px; bottom: calc(100% - 4px); background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-pop); max-height: 260px; overflow-y: auto; padding: 6px; z-index: 5;
}
.canned-item { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; }
.canned-item.active, .canned-item:hover { background: var(--brand-soft); }
.canned-item b { font-size: 13px; }
.canned-item code { font-size: 12px; color: var(--brand); margin-right: 6px; }
.canned-item p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Visitor info */
.info { width: 300px; border-left: 1px solid var(--line-2); overflow-y: auto; flex: none; background: var(--surface); }
.info-sec { padding: 16px; border-bottom: 1px solid var(--line-2); }
.info-sec h4 { margin: 0 0 10px; font-size: 13px; color: var(--ink-2); }
.info-head { display: flex; gap: 12px; align-items: center; }
.info-head .avatar { width: 44px; height: 44px; font-size: 17px; border-radius: 14px; }
.info-head b { display: block; font-size: 15px; }
.kv { display: grid; grid-template-columns: 82px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; color: var(--ink); min-width: 0; }
.pages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pages li { font-size: 12.5px; display: grid; grid-template-columns: 40px 1fr; gap: 8px; }
.pages li time { color: var(--faint); }
.pages li a { color: var(--ink-2); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.pages li a:hover { color: var(--brand); }
.hist { display: flex; flex-direction: column; gap: 6px; }
.hist button { text-align: left; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line-2); width: 100%; }
.hist button:hover { background: var(--surface-2); }
.hist .t { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.hist .p { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Pages (settings etc.) ---------- */
.page { grid-column: 2 / -1; overflow-y: auto; padding: 28px 32px 60px; min-height: 0; }
.page-inner { max-width: 880px; margin: 0 auto; }
.page h1 { font-size: 24px; letter-spacing: -.02em; margin: 0 0 4px; }
.page .lead { color: var(--muted); margin: 0 0 24px; }
.card { background: var(--surface); border-radius: 14px; padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card .sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line-2); }
.card-row:first-of-type { border-top: 0; }
.card-row .t b { display: block; font-size: 14px; }
.card-row .t span { font-size: 12.5px; color: var(--muted); }
.page-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.stat span { font-size: 12.5px; color: var(--muted); }
.stat b { display: block; font-size: 26px; letter-spacing: -.02em; margin-top: 2px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.bar i { display: block; width: 100%; max-width: 34px; background: var(--brand); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bar span { font-size: 11px; color: var(--faint); white-space: nowrap; }
.bar em { font-style: normal; font-size: 11.5px; color: var(--ink-2); font-weight: 600; }
.swatch-row { display: flex; gap: 8px; align-items: center; }
.swatch-row input[type=color] { width: 44px; height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--surface); }

/* ---------- Modal / menu / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(18, 48, 46, .4); display: grid; place-items: center; z-index: 50; padding: 20px; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 440px; box-shadow: var(--shadow-pop); padding: 22px; max-height: calc(100dvh - 40px); overflow-y: auto; animation: rise .2s cubic-bezier(.3, 1.2, .5, 1); }
.modal h3 { margin: 0 0 4px; font-size: 17px; }
.modal .sub { color: var(--muted); margin: 0 0 18px; font-size: 13px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.menu { position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-pop); padding: 6px; min-width: 200px; animation: fade .1s; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; font-size: 13.5px; text-align: left; }
.menu-item:hover { background: var(--surface-2); }
.menu-item svg { width: 16px; height: 16px; color: var(--muted); }
.menu-item .st { width: 9px; height: 9px; border-radius: 50%; }
.menu-sep { height: 1px; background: var(--line-2); margin: 6px 0; }
.menu-label { font-size: 11.5px; color: var(--faint); padding: 6px 10px 4px; font-weight: 600; }
.toasts { position: fixed; bottom: calc(20px + var(--safe-b)); left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 13.5px; box-shadow: var(--shadow-pop); animation: rise .2s; pointer-events: auto; display: flex; gap: 10px; align-items: center; max-width: calc(100vw - 32px); }
.toast.err { background: var(--red); }
.toast button { color: #8BE3D6; font-weight: 700; }
.alert-pop {
  position: fixed; top: 16px; right: 16px; z-index: 65; width: 320px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-pop);
  padding: 14px; display: flex; gap: 12px; animation: slidein .3s cubic-bezier(.3, 1.2, .5, 1); border-left: 4px solid var(--amber); cursor: pointer;
}
.alert-pop > svg { width: 22px; height: 22px; color: var(--amber); margin-top: 1px; }
.alert-pop b { display: block; font-size: 13.5px; }
.alert-pop p { margin: 2px 0 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.banner-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--amber-bg); color: #6B4A0B; font-size: 13px; }
.banner-bar .btn { margin-left: auto; }
.banner-bar > svg { width: 18px; height: 18px; flex: none; }
.m-note .h svg { width: 14px; height: 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes slidein { from { opacity: 0; transform: translateX(30px); } }

.mobile-nav { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .info { position: absolute; right: 0; top: 0; bottom: 0; box-shadow: var(--shadow-pop); z-index: 4; }
}
@media (max-width: 1100px) {
  .shell { grid-template-columns: 64px 300px 1fr; }
  .panes.l3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  body { font-size: 15px; }
  .shell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .rail { display: none; }
  .list-col { border-right: 0; }
  .shell.chat-open .list-col { display: none; }
  .shell:not(.chat-open) .work { display: none; }
  .work-bar { padding: 0 8px; height: auto; padding-top: calc(6px + var(--safe-t)); }
  .layout-switch { display: none; }
  .panes { padding: 0; gap: 0; grid-template-columns: 1fr !important; grid-template-rows: 1fr !important; }
  .panes .pane:not(.focused) { display: none; }
  .pane { border-radius: 0; box-shadow: none; outline: 0 !important; }
  .pane-back { display: inline-grid; }
  .pane-close, .pane-name .chip { display: none; }
  .pane-head { gap: 6px; padding-left: 6px; }
  .pane-actions { gap: 2px; }
  .shell.chat-open .mobile-nav { display: none; }
  .mobile-nav {
    display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: var(--safe-b);
  }
  .mobile-nav button { height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); position: relative; }
  .mobile-nav button svg { width: 22px; height: 22px; }
  .mobile-nav button.active { color: var(--brand); }
  .mobile-nav .count { position: absolute; top: 6px; left: calc(50% + 6px); background: var(--amber); color: #fff; font-size: 10.5px; font-weight: 800; border-radius: 8px; padding: 0 5px; line-height: 16px; }
  .list-head { padding-top: calc(14px + var(--safe-t)); }
  .page { grid-column: 1; padding: calc(20px + var(--safe-t)) 16px 40px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .info { position: fixed; inset: 0; width: 100%; z-index: 40; padding-top: var(--safe-t); }
  .composer { padding-bottom: calc(10px + var(--safe-b)); }
  .comp-box textarea { font-size: 16px; }
  .alert-pop { left: 12px; right: 12px; width: auto; top: calc(12px + var(--safe-t)); }
  .m-col { max-width: 86%; }
  .kpis { grid-template-columns: 1fr 1fr 1fr; }
  .row.wrap-m { flex-direction: column; align-items: stretch; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.popout .shell { grid-template-columns: 1fr; }
.popout .rail, .popout .list-col, .popout .work-bar, .popout .mobile-nav { display: none !important; }
.popout .panes { padding: 0; }
.popout .pane { border-radius: 0; box-shadow: none; outline: 0 !important; display: flex !important; }
.popout .shell { grid-template-rows: 1fr; }
.popout .work { display: flex !important; }
.popout .pane-back { display: none !important; }
