/* ===== AI 客服控制台 ===== */
:root {
  --bg: #f3f5f8; --surface: #ffffff; --surface-2: #f7f8fa; --line: #e6e9ef; --line-2: #eff1f5;
  --text: #17202b; --muted: #6a7686; --faint: #9aa4b2;
  --primary: #06c755; --primary-d: #04a948; --primary-soft: #e6f9ee;
  --accent: #3b6cf6; --accent-soft: #eaf0ff;
  --warn: #f59e0b; --warn-soft: #fff4dc; --danger: #ef4444; --danger-soft: #fdecec;
  --nav: #0f1720; --nav-2: #1a2430; --nav-text: #b7c2cf;
  --chat-bg: #eef1f5; --b-in: #ffffff; --b-out: #d8f5e3; --b-staff: #dde7ff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --r: 14px; --r-sm: 10px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117; --surface: #151b23; --surface-2: #1b222c; --line: #262f3b; --line-2: #1f2731;
    --text: #e6ebf1; --muted: #93a0b0; --faint: #6b7787;
    --primary-soft: #0f2e1d; --accent-soft: #18233d; --warn-soft: #33270d; --danger-soft: #3a1717;
    --nav: #0a0e13; --nav-2: #161d26;
    --chat-bg: #0f141a; --b-in: #1d252f; --b-out: #143a25; --b-staff: #1b2a4a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 12px; background: var(--surface);
  width: 100%; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(6, 199, 85, .15); }
textarea { resize: vertical; }
textarea.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; line-height: 1.6; }
code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font-size: 12px; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 18px; }
.sm { display: none; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-sm); padding: 8px 14px;
  cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-weight: 500; transition: background .15s, transform .05s, border-color .15s; text-decoration: none; color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; box-shadow: 0 1px 2px rgba(6, 199, 85, .3); }
.btn.primary:hover { background: var(--primary-d); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled, .send-btn:disabled { opacity: .5; cursor: wait; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; cursor: pointer;
  display: inline-grid; place-items: center; font-size: 20px; color: var(--muted); flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.chip-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.chip-btn:hover { border-color: var(--primary); color: var(--primary-d); }

/* ---------- layout ---------- */
.app { display: flex; height: 100vh; height: 100dvh; }
.nav { width: 220px; background: var(--nav); color: var(--nav-text); display: flex; flex-direction: column; padding: 16px 12px; flex-shrink: 0; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #fff; font-size: 16px; padding: 4px 8px 20px; letter-spacing: .3px; }
.brand-icon { background: linear-gradient(135deg, #06c755, #00a3ff); border-radius: 10px; width: 34px; height: 34px; display: grid; place-items: center; font-size: 18px; box-shadow: 0 4px 12px rgba(6, 199, 85, .35); }
.nav-item {
  display: flex; align-items: center; gap: 12px; background: none; border: 0; color: inherit; padding: 10px 12px;
  border-radius: 10px; cursor: pointer; text-align: left; position: relative; transition: background .15s, color .15s;
}
.nav-item .ni { font-size: 17px; width: 22px; text-align: center; }
.nav-item b { font-weight: 500; flex: 1; }
.nav-item b em { font-style: normal; }
.nav-item:hover { background: var(--nav-2); color: #fff; }
.nav-item.active { background: rgba(6, 199, 85, .14); color: #fff; }
.nav-item.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.badge { font-style: normal; background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 6px; min-width: 18px; height: 18px; line-height: 18px; text-align: center; }
.badge:empty { display: none; }
.nav-foot { margin-top: auto; padding: 12px 8px 0; font-size: 12px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--nav-2); }
.nav-foot a { color: var(--nav-text); opacity: .7; }
.ai-chip { color: var(--nav-text); opacity: .7; word-break: break-all; }

main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; background: var(--surface);
  border-bottom: 1px solid var(--line); gap: 12px; min-height: 60px;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }
.switches { display: flex; gap: 8px; }
.switch {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; padding: 5px 12px 5px 6px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; font-weight: 500;
}
.switch input { display: none; }
.switch em { font-style: normal; }
.slider { width: 36px; height: 20px; border-radius: 10px; background: #c5ccd6; position: relative; transition: .2s; flex-shrink: 0; }
.slider::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::after { left: 18px; }

#banner:empty { display: none; }
#banner { padding: 10px 24px 0; display: flex; flex-direction: column; gap: 8px; }
#banner .alert { margin: 0; }

.page { display: none; flex: 1; overflow: auto; padding: 20px 24px; min-height: 0; -webkit-overflow-scrolling: touch; }
.page.active { display: block; animation: fade .18s ease; }
#page-chats.active { display: flex; padding: 0; overflow: hidden; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.narrow { max-width: 780px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head b { font-size: 15px; }
.alert { background: var(--danger-soft); color: var(--danger); padding: 10px 14px; border-radius: var(--r-sm); margin-bottom: 12px; white-space: pre-line; font-size: 13.5px; }
.alert.warn { background: var(--warn-soft); color: #9a6200; }
.alert.info { background: var(--accent-soft); color: var(--accent); }
.alert.urgent { display: flex; align-items: center; gap: 10px; background: var(--danger); color: #fff; font-weight: 600; animation: pulse 1.5s infinite; white-space: normal; }
.alert.urgent span { flex: 1; }
.alert.urgent .btn { background: #fff; color: var(--danger); border: 0; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, .2); } }
@media (prefers-color-scheme: dark) { .alert.warn { color: #f5c26b; } }
.empty { color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; height: 100%; min-height: 200px; text-align: center; }
.empty-ico { font-size: 44px; opacity: .5; }

/* ---------- chats ---------- */
.chats { display: flex; flex: 1; min-height: 0; min-width: 0; position: relative; overflow: hidden; }
.ulist { min-width: 0; width: 320px; border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; flex-shrink: 0; }
.ulist-tools { padding: 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.ulist-tools input { background: var(--surface-2); border-color: transparent; border-radius: 999px; padding-left: 16px; }
.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 6px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; color: var(--text); }
.ulist-items { overflow-y: auto; flex: 1; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.uitem { display: flex; gap: 12px; padding: 12px 14px; cursor: pointer; border-bottom: 1px solid var(--line-2); transition: background .12s; position: relative; }
.uitem:hover { background: var(--surface-2); }
.uitem:active { background: var(--line-2); }
.uitem.active { background: var(--primary-soft); }
.uitem.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--primary); }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex-shrink: 0; display: grid; place-items: center;
  font-weight: 700; color: #fff; font-size: 17px; background: hsl(var(--h, 210) 55% 55%);
}
.uitem-main { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 3px; }
.uitem-top { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.uitem-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.uitem-top .muted { flex-shrink: 0; font-size: 12px; }
.uitem-last { color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; min-width: 0; }
.uitem-last span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.uitem.unread .uitem-top b, .uitem.unread .uitem-last span { color: var(--text); font-weight: 600; }
.tag { font-style: normal; font-size: 11px; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); white-space: nowrap; font-weight: 600; flex-shrink: 0; }
.tag.human { background: var(--warn-soft); color: #b77400; }
.tag.flow { background: var(--accent-soft); color: var(--accent); }
.tag.off { background: var(--danger-soft); color: var(--danger); }

.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--chat-bg); }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); min-height: 60px; }
.chat-title { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-title b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.chat-title .muted { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .back { display: none; font-size: 30px; line-height: 1; margin-left: -8px; }
#btnInfo { display: none; }
.mode-toggle { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; flex-shrink: 0; }
.mode-toggle button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 500; transition: .15s; }
.mode-toggle button.on[data-mode=ai] { background: var(--primary); color: #fff; }
.mode-toggle button.on[data-mode=human] { background: var(--warn); color: #fff; }
.msgs { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.day { align-self: center; font-size: 12px; color: var(--muted); background: var(--surface); padding: 2px 12px; border-radius: 999px; margin: 10px 0 4px; box-shadow: var(--shadow); }
.msg { display: flex; flex-direction: column; max-width: 72%; animation: pop .15s ease; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg .bubble { padding: 9px 13px; border-radius: 18px; background: var(--b-in); white-space: pre-wrap; word-break: break-word; box-shadow: var(--shadow); line-height: 1.55; }
.msg.in .bubble { border-bottom-left-radius: 6px; }
.msg.out .bubble { background: var(--b-out); border-bottom-right-radius: 6px; }
.msg.out.staff .bubble { background: var(--b-staff); }
.msg .bubble.media { padding: 4px; background: transparent; box-shadow: none; }
.msg .bubble img { max-width: 240px; max-height: 280px; border-radius: 14px; display: block; cursor: zoom-in; box-shadow: var(--shadow); }
.msg .meta { font-size: 11px; color: var(--faint); margin: 3px 6px 2px; }
.msg.sys { align-self: center; max-width: 92%; align-items: center; }
.msg.sys span { background: var(--line-2); color: var(--muted); font-size: 12px; padding: 4px 12px; border-radius: 999px; text-align: center; }
.composer { background: var(--surface); border-top: 1px solid var(--line); padding: 10px 14px calc(10px + var(--safe-b)); }
.composer-tools { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; overflow-x: auto; scrollbar-width: none; }
.composer-tools::-webkit-scrollbar { display: none; }
.composer-tools select { width: auto; max-width: 180px; padding: 5px 10px; border-radius: 999px; font-size: 13px; flex-shrink: 0; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer-row textarea, .composer-row input { border-radius: 20px; padding: 10px 16px; background: var(--surface-2); border-color: transparent; resize: none; max-height: 160px; line-height: 1.45; }
.send-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; font-size: 17px;
  cursor: pointer; flex-shrink: 0; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(6, 199, 85, .35); transition: transform .05s;
}
.send-btn:active { transform: scale(.92); }

.info { width: 300px; background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto; padding: 20px; flex-shrink: 0; }
.info h3 { font-size: 12px; color: var(--muted); margin: 22px 0 8px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.info-head { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding-bottom: 6px; }
.info-head .avatar { width: 72px; height: 72px; font-size: 28px; }
.info-head b { font-size: 16px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.row { display: flex; gap: 8px; align-items: center; }
#drawerMask { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40; }
#drawerMask.on { opacity: 1; pointer-events: auto; }
#lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .88); display: none; place-items: center; z-index: 100; cursor: zoom-out; padding: 16px; }
#lightbox.on { display: grid; animation: fade .15s; }
#lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* ---------- SOP ---------- */
.sop-layout { display: grid; grid-template-columns: 290px 1fr; gap: 16px; align-items: start; }
.sop-list { position: sticky; top: 0; }
.flow-item { padding: 11px 12px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; margin-bottom: 4px; transition: background .12s; }
.flow-item:hover { background: var(--surface-2); }
.flow-item.active { border-color: var(--primary); background: var(--primary-soft); }
.flow-item small { display: block; color: var(--muted); margin-top: 2px; }
.help { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.help b { color: var(--text); }
.help p { margin: 6px 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > span { font-weight: 600; font-size: 13px; }
.field small { color: var(--muted); font-size: 12px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.step { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: var(--surface-2); border-left: 4px solid var(--accent); }
.step.t-input { border-left-color: var(--warn); }
.step.t-message { border-left-color: var(--faint); }
.step.t-id { border-left-color: #a855f7; }
.step.t-id .step-no { background: #a855f7; }
.step-extra .hint { color: var(--faint); font-size: 12px; padding-top: 10px; }
.chip.act { border-color: #a855f7; color: #a855f7; }
.action-help { width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: var(--r-sm); }
.action-help summary { cursor: pointer; }
.fu { padding: 4px 0; border-bottom: 1px dashed var(--line-2); }
.step-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.step-no { background: var(--accent); color: #fff; border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.step.t-input .step-no { background: var(--warn); }
.step.t-message .step-no { background: var(--faint); }
.step-head .s-id { width: 170px; font-family: ui-monospace, monospace; }
.step-head .s-type { width: 130px; }
.step-head .sp { flex: 1; }
.step textarea, .step input, .step select { background: var(--surface); }
.opt { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.opt .o-label, .opt .o-target { flex: 1; min-width: 0; }
.opt .o-target { font-family: ui-monospace, monospace; }
.arrow { color: var(--faint); }
.step-extra { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.step-extra label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.editor-actions { display: flex; gap: 8px; justify-content: space-between; margin: 16px -18px -18px; position: sticky; bottom: -20px; background: var(--surface); padding: 12px 18px; border-top: 1px solid var(--line); border-radius: 0 0 var(--r) var(--r); }

/* ---------- prompt ---------- */
.prompt-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; align-items: center; }
.chip { font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.chip:hover { border-color: var(--primary); }
.sandbox { position: sticky; top: 0; display: flex; flex-direction: column; height: calc(100dvh - 140px); }
.sandbox-msgs { background: var(--chat-bg); border-radius: var(--r-sm); margin-bottom: 10px; }

/* ---------- templates / settings ---------- */
.tpl { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; margin-bottom: 10px; display: grid; grid-template-columns: 170px 1fr auto; gap: 10px; align-items: start; background: var(--surface-2); }
.settings-wrap { max-width: 880px; }
.set-field { display: grid; grid-template-columns: 240px 1fr; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line-2); align-items: start; }
.card-head + .set-field { border-top: 0; }
.set-field .lbl b { font-weight: 600; display: block; }
.set-field .lbl small { color: var(--muted); font-size: 12px; line-height: 1.5; display: block; margin-top: 2px; }
.pw-wrap { display: flex; gap: 6px; }
.set-field .switch { padding: 0; background: none; border: 0; }
.save-bar { position: sticky; bottom: -20px; background: linear-gradient(transparent, var(--bg) 35%); padding: 18px 0 20px; text-align: right; margin-bottom: 8px; z-index: 2; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row code { flex: 1; padding: 9px 12px; font-size: 13px; word-break: break-all; }
.inline-form { display: flex; gap: 8px; }
.test-result { margin-top: 10px; font-size: 13px; white-space: pre-wrap; color: var(--muted); }
.test-result:empty { display: none; }
.tg-help { background: var(--surface-2); padding: 14px; border-radius: var(--r-sm); font-size: 13px; line-height: 1.8; overflow-x: auto; margin: 0; }

#toast { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; pointer-events: none; }
.toast { background: #17202b; color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); max-width: 420px; white-space: pre-line; animation: pop .2s; font-size: 13.5px; }
.toast.err { background: var(--danger); }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; background: radial-gradient(circle at 20% 20%, #1b3a2b, #0f1720 60%); padding: 16px; }
.login-card { background: var(--surface); padding: 36px 32px; border-radius: 20px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; text-align: center; box-shadow: var(--shadow-lg); }
.login-card h1 { margin: 0; font-size: 21px; }
.login-card p { margin: 0; }
.login-card input { font-size: 16px; padding: 12px 14px; }
.login-card .btn { padding: 12px; font-size: 15px; }
.login-logo { font-size: 30px; background: linear-gradient(135deg, #06c755, #00a3ff); width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center; margin: 0 auto 4px; box-shadow: 0 8px 20px rgba(6, 199, 85, .35); }

/* ---------- tablet：客人資訊改成右側抽屜 ---------- */
@media (max-width: 1180px) {
  #btnInfo { display: inline-grid; }
  .info { position: fixed; right: 0; top: 0; bottom: 0; z-index: 50; box-shadow: var(--shadow-lg); transform: translateX(105%); transition: transform .25s ease; width: min(340px, 88vw); padding-bottom: calc(20px + var(--safe-b)); }
  .info.open { transform: none; }
  .prompt-grid { grid-template-columns: 1fr; }
  .sandbox { height: 540px; position: static; }
}

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  body { font-size: 15px; }
  input, select, textarea { font-size: 16px; } /* iOS 不會自動放大 */
  .lg { display: none; }
  .sm { display: inline; }
  .app { flex-direction: column-reverse; }
  .nav {
    width: 100%; flex-direction: row; padding: 4px 4px calc(4px + var(--safe-b)); gap: 0; justify-content: space-around;
    border-top: 1px solid var(--nav-2); z-index: 30;
  }
  .brand, .nav-foot { display: none; }
  .nav-item { flex: 1; flex-direction: column; gap: 1px; padding: 6px 2px; font-size: 11px; align-items: center; border-radius: 10px; }
  .nav-item .ni { font-size: 20px; width: auto; }
  .nav-item b { flex: none; white-space: nowrap; }
  .nav-item.active { background: transparent; color: var(--primary); }
  .nav-item.active::before { display: none; }
  .nav-item .badge { position: absolute; top: 2px; left: 50%; margin-left: 6px; }
  .topbar { padding: 8px 14px; min-height: 52px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
  .topbar h1 { font-size: 17px; }
  .switch { padding: 4px 10px 4px 4px; font-size: 12px; gap: 6px; }
  #banner { padding: 8px 12px 0; }
  .page { padding: 14px 12px 24px; }

  /* 聊天：列表與對話切換（滑入） */
  .ulist { width: 100%; border-right: 0; }
  .chat { position: absolute; inset: 0; z-index: 20; transform: translateX(100%); transition: transform .25s cubic-bezier(.2, .8, .2, 1); visibility: hidden; }
  .chats.open .chat { transform: none; visibility: visible; }
  .chat-head { padding: 6px 8px; gap: 6px; min-height: 54px; }
  .chat-head .back { display: inline-grid; }
  .mode-toggle button { padding: 7px 10px; font-size: 15px; }
  .msgs { padding: 12px; }
  .msg { max-width: 84%; }
  .msg .bubble img { max-width: 200px; }
  .composer { padding: 8px 10px calc(8px + var(--safe-b)); }
  .kbd-hint { display: none; }
  body.chat-open .nav, body.chat-open .topbar, body.chat-open #banner { display: none; }
  .uitem { padding: 12px; }

  .sop-layout, .form-grid, .step-extra { grid-template-columns: 1fr; }
  .sop-list { position: static; }
  .set-field { grid-template-columns: 1fr; gap: 8px; }
  .tpl { grid-template-columns: 1fr; }
  .step-head { flex-wrap: wrap; }
  .step-head .s-id, .step-head .s-type { width: calc(50% - 22px); }
  .opt { flex-wrap: wrap; }
  .opt .o-label { flex-basis: 100%; }
  .inline-form { flex-direction: column; }
  .card { padding: 14px; border-radius: 12px; }
  .editor-actions { margin: 16px -14px -14px; padding: 10px 14px; bottom: -24px; }
  .save-bar { bottom: -24px; }
  #toast { left: 12px; right: 12px; top: calc(12px + env(safe-area-inset-top, 0px)); bottom: auto; align-items: center; }
}

.ocr-check { margin-top: 6px; padding: 4px 8px; border-radius: 6px; }
.ocr-check.ok { background: var(--primary-soft); color: var(--primary-d); }
.ocr-check.bad { background: var(--warn-soft); color: #9a6200; }
