:root {
  color-scheme: light;
  /* โทนน้ำเงิน-ทอง: ใช้สีคนละโทนกับ P1Chat (น้ำตาล) จะได้รู้ทันทีว่าอยู่ในแชทภายใน ไม่ใช่แชทลูกค้า */
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --border: #d9e1ec;
  --text: #1a1a1a;
  --text-muted: #5f6b7a;
  --brand: #1f4e79;
  --brand-strong: #163a5c;
  --brand-soft: #e8f1fb;
  --brand-text: #ffffff;
  --accent: #d4a23a;
  --accent-strong: #b88828;
  --accent-ring: rgba(212, 162, 58, 0.22);
  --header-bg: linear-gradient(135deg, #1f4e79 0%, #2d6aa3 100%);
  --danger: #d92d20;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bubble-in: #ffffff;
  --bubble-out: #1f4e79;
  --bubble-out-text: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Thai", "Sarabun", "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1419;
  --surface: #171d25;
  --surface-2: #1e2630;
  --border: #2b3542;
  --text: #e8eaed;
  --text-muted: #a9b4c2;
  --brand: #7fb3e6;
  --brand-strong: #a6cdf2;
  --brand-soft: #1a2a3c;
  --brand-text: #0b1620;
  --accent-ring: rgba(212, 162, 58, 0.3);
  --header-bg: linear-gradient(135deg, #142f49 0%, #1f4e79 100%);
  --bubble-out: #2d6aa3;
  --warn: #f0a640;
  --warn-soft: #3a2c08;
  --bubble-in: #222b36;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
html:has(> body > #app:not([hidden])), body:has(> #app:not([hidden])) { height: 100%; min-height: 0; overflow: hidden; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
input[type="checkbox"] { accent-color: var(--brand); }

/* ---------- generic controls ---------- */
.button { border: 1px solid transparent; border-radius: 10px; padding: 8px 14px; cursor: pointer; background: transparent; transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease; white-space: nowrap; }
.button:disabled { opacity: 0.55; cursor: not-allowed; }
.button--primary { background: var(--brand); color: var(--brand-text); font-weight: 600; }
.button--primary:hover:not(:disabled) { background: var(--brand-strong); }
.button--ghost { border-color: var(--border); background: var(--surface); }
.button--ghost:hover:not(:disabled) { background: var(--surface-2); }
.button--block { width: 100%; }
.button--sm { padding: 4px 10px; font-size: 13px; }
.button--google { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--surface); color: var(--text); border: 1px solid var(--border); font-weight: 600; text-decoration: none; margin-bottom: 12px; }
.button--google:hover { background: var(--surface-2); }
.button__icon { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #4285f4; color: #fff; font-size: 13px; font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field__label { font-size: 13px; color: var(--text-muted); }
.field__input { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; outline: none; width: 100%; }
.field__input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.pill { border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; }
.pill--muted { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.pill--ok { background: var(--brand-soft); color: var(--brand-strong); box-shadow: inset 0 0 0 1px rgba(212, 162, 58, 0.45); }
.pill--down { background: #fee4e2; color: var(--danger); }
.connection-chip { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.connection-chip__online { font-weight: 700; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.badge--muted { background: var(--text-muted); }
.empty { color: var(--text-muted); text-align: center; padding: 24px 12px; font-size: 14px; }
.stage-meta { font-size: 12px; color: var(--text-muted); }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.setup-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.app-version { font-size: 11px; font-weight: 500; color: var(--text-muted); letter-spacing: 0; white-space: nowrap; }
.msg__link { color: inherit; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.msg__link:hover { text-decoration-thickness: 2px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login__card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--accent); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.login__brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 0.2px; }
.login__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block; }
.login__title { margin: 14px 0 4px; font-size: 22px; }
.login__hint { margin: 0 0 20px; color: var(--text-muted); font-size: 14px; }
.login__error { color: var(--danger); font-size: 13px; margin: 0 0 12px; }
.login__legal { margin: 12px 0 0; font-size: 12px; color: var(--text-muted); }
/* 💻 แอป Windows: ชวนติดตั้ง (เบราว์เซอร์บน Windows) · บอกให้ไปล็อกอินในเบราว์เซอร์ (ในแอป) */
.login__app-link { display: block; margin-top: 10px; font-size: 13px; color: var(--brand); text-align: center; }
.login__hint--desktop { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--brand-soft, rgba(31, 78, 121, .08)); }

/* ---------- shell ---------- */
.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.topbar { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; padding: 10px 18px; background: var(--header-bg); color: #ffffff; border-bottom: 3px solid var(--accent); }
.topbar .app-version { color: rgba(255, 255, 255, 0.75); }
.topbar .pill { white-space: nowrap; }
.topbar .button--ghost { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.28); color: #ffffff; }
.topbar .button--ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); border-color: var(--accent); }
.topbar .pill--muted { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.25); color: #ffffff; }
.topbar .pill--ok { background: rgba(212, 162, 58, 0.22); color: #ffd58a; }
.topbar .pill--down { background: rgba(217, 45, 32, 0.35); color: #ffd3cf; }
.topbar__brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.topbar__status { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar__agent { font: inherit; color: #ffd58a; font-size: 14px; background: none; border: 1px dashed transparent; border-radius: 8px; padding: 4px 8px; cursor: pointer; white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.topbar__agent:hover, .topbar__agent:focus-visible { border-color: rgba(255, 213, 138, 0.6); }
.topbar__agent::after { content: ' ✎'; opacity: 0.7; }
.topbar__menu, .topbar__menu-version, .team__back { display: none; }
.theme-toggle__label, .topbar__label { display: none; }
#open-push.is-on { border-color: var(--accent); }
.update-banner { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-size: 14px; max-width: calc(100vw - 32px); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1c2024; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); z-index: 40; max-width: calc(100vw - 32px); text-align: center; }

/* ---------- modal ---------- */
.modal { width: min(680px, 94vw); border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); padding: 20px; box-shadow: var(--shadow); }
.modal--narrow { width: min(440px, 94vw); }
.modal::backdrop { background: rgba(12, 16, 20, 0.45); }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.modal__head h2, .modal h2 { margin: 0; font-size: 18px; }
.modal__hint { color: var(--text-muted); font-size: 13px; }
.presence-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-muted); margin-left: 4px; }
.push-status { margin: 4px 0 8px; padding: 8px 10px; border-radius: 8px; font-size: 14px; background: var(--bg); border: 1px solid var(--border); }
.push-status[data-tone='ok'] { background: var(--brand-soft); color: var(--brand-strong); }
.push-status[data-tone='warn'] { background: var(--warn-soft); color: var(--warn); }
.push-options { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 12px; }
.push-options .checkbox { align-items: flex-start; }
.push-help { font-size: 13px; margin: 0 0 12px; }
.push-help summary { cursor: pointer; font-weight: 600; }
.push-help ul { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.push-devices h3 { font-size: 14px; margin: 12px 0 6px; }
.push-devices ul { margin: 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }

/* ---------- action menu (⋯ ข้อความ · ⋮ ห้อง) ---------- */
.action-menu { position: fixed; z-index: 70; min-width: 190px; padding: 6px; display: grid; gap: 2px; max-height: calc(100dvh - 16px); overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18); }
.action-menu__item { font: inherit; font-size: 14px; text-align: left; padding: 9px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; }
.action-menu__item:hover, .action-menu__item:focus-visible { background: var(--surface-2); outline: none; }
.action-menu__item--danger { color: var(--danger); }
.action-menu__item:disabled { color: var(--text-muted); cursor: not-allowed; background: transparent; }
.action-menu__heading { font-size: 12px; font-weight: 700; color: var(--text-muted); padding: 8px 12px 2px; }
.action-menu__separator { height: 1px; margin: 4px 6px; background: var(--border); }

/* ---------- lightbox ---------- */
.lightbox { width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh; margin: 0; padding: 0; border: 0; background: transparent; color: #fff; overflow: hidden; }
.lightbox[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.lightbox::backdrop { background: rgba(8, 10, 12, 0.88); }
.lightbox__stage { position: relative; flex: none; max-width: 100vw; }
.lightbox__img { position: absolute; left: 50%; top: 50%; max-width: none; max-height: none; transform: translate(-50%, -50%); border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); transition: transform 0.15s ease; }
.lightbox__img:not([src]) { visibility: hidden; }
.lightbox__bar { display: flex; align-items: center; gap: 10px; }
.lightbox__count { font-size: 13px; opacity: 0.8; min-width: 3em; text-align: center; }
.lightbox__button { border: 1px solid rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.08); color: #fff; border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 13px; text-decoration: none; cursor: pointer; }
.lightbox__button:hover { background: rgba(255, 255, 255, 0.18); }
.lightbox__nav { position: fixed; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.14); color: #fff; font-size: 28px; line-height: 1; cursor: pointer; }
.lightbox__nav:hover { background: rgba(255, 255, 255, 0.26); }
.lightbox__nav--prev { left: 16px; }
.lightbox__nav--next { right: 16px; }

/* ---------- layout ---------- */
.team { flex: 1; display: grid; grid-template-columns: clamp(280px, 26vw, 380px) minmax(0, 1fr); min-height: 0; }
.team__side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); background: var(--surface); }
.team__side-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 6px; }
.team__tabs { flex: 1; display: flex; gap: 4px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.team__tab { flex: 1; font: inherit; font-size: 13px; font-weight: 600; padding: 5px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--text-muted); cursor: pointer; }
.team__tab.is-active { background: var(--surface); color: var(--brand-strong); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08); }
.team__search { padding: 0 12px 8px; }
.team__search .field__input { font-size: 15px; }
.team-list { list-style: none; margin: 0; padding: 0 8px 8px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.team__note { margin: 0; padding: 8px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); font-size: 11px; color: var(--text-muted); }
.team-room { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 9px 10px; border-radius: var(--radius); cursor: pointer; }
.team-room:hover { background: var(--surface-2); }
.team-room.is-active { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--accent); }
.team-room__main { min-width: 0; }
.team-room__name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-room__count { font-weight: 500; color: var(--text-muted); }
.team-room__flag { font-size: 12px; }
.team-room__preview { color: var(--text-muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-room.has-unread .team-room__preview { color: var(--text); font-weight: 600; }
.team-room__who { color: var(--brand); font-weight: 600; }
.team-room__meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.team-room__time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.team-search__hint { margin: 4px 6px 6px; color: var(--text-muted); font-size: 13px; }
.team-avatar { position: relative; width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 18px; flex-shrink: 0; }
.team-avatar--group { background: var(--surface-2); border: 1px solid var(--border); font-size: 20px; }
.team-avatar__dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: #16a34a; border: 2px solid var(--surface); }
.team-pick .team-avatar, .team-member .team-avatar { width: 30px; height: 30px; font-size: 13px; }
.team-pick .team-avatar__dot, .team-member .team-avatar__dot { width: 10px; height: 10px; }

/* ---------- thread ---------- */
.team__thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.thread__placeholder { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--text-muted); padding: 24px; }
.thread__placeholder h2 { color: var(--text); font-size: 18px; margin-bottom: 6px; }
.team__body { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.team__body.is-dropping { outline: 3px dashed var(--accent); outline-offset: -8px; background: var(--brand-soft); }
.team__header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.team__header-avatar { display: inline-flex; }
.team__identity { min-width: 0; flex: 1; }
.team__title { margin: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team__subtitle { margin: 0; font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team__menu { font-size: 18px; line-height: 1; padding: 4px 10px; }
.team__messages { flex: 1; overflow-y: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 4px; }
.team__older { align-self: center; margin-bottom: 8px; }
.team__message-list { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.day { align-self: center; font-size: 12px; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 2px 12px; margin: 8px 0; }
.tmsg { display: flex; flex-direction: column; max-width: min(72%, 560px); gap: 3px; position: relative; }
.tmsg--other { align-self: flex-start; }
.tmsg--mine { align-self: flex-end; align-items: flex-end; }
.tmsg--system { align-self: center; max-width: 86%; }
.tmsg--continued { margin-top: -4px; }
.tmsg__author { font-size: 12px; font-weight: 700; padding-left: 4px; }
.tmsg__bubble { position: relative; background: var(--bubble-in); border: 1px solid var(--border); border-radius: 16px; padding: 8px 12px 6px; word-break: break-word; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; }
.tmsg--mine .tmsg__bubble { background: var(--bubble-out); color: var(--bubble-out-text); border-color: transparent; }
.tmsg__text { white-space: pre-wrap; }
.tmsg__time { font-size: 10px; opacity: 0.7; align-self: flex-end; white-space: nowrap; }
.tmsg__system { font-size: 12px; color: var(--text-muted); text-align: center; padding: 2px 10px; }
.tmsg__deleted { font-style: italic; opacity: 0.7; font-size: 13px; }
.tmsg__quote { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; font: inherit; font-size: 12px; padding: 4px 8px; border: 0; border-left: 3px solid var(--accent); border-radius: 6px; background: rgba(0, 0, 0, 0.06); color: inherit; cursor: pointer; }
.tmsg--mine .tmsg__quote { background: rgba(255, 255, 255, 0.14); }
.tmsg__quote-author { font-weight: 700; }
.tmsg__quote-text { opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tmsg.is-flash .tmsg__bubble { box-shadow: 0 0 0 3px var(--accent-ring); }
.tmsg__image-link { display: block; cursor: zoom-in; }
.tmsg__image { max-width: 260px; max-height: 320px; border-radius: 12px; display: block; }
.tmsg__file { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; padding: 2px 0; }
.tmsg__file-icon { font-size: 22px; }
.tmsg__file-info { display: flex; flex-direction: column; min-width: 0; }
.tmsg__file-name { font-weight: 600; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.tmsg__file-size { opacity: 0.75; }
.tmsg__more { position: absolute; top: 4px; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); font-size: 14px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity 120ms ease; }
.tmsg--other .tmsg__more { right: -32px; }
.tmsg--mine .tmsg__more { left: -32px; }
.tmsg:hover .tmsg__more, .tmsg__more:focus-visible, .tmsg__more[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .tmsg__more { opacity: 0.7; } }
.tmsg__read { font-size: 11px; color: var(--text-muted); padding-right: 4px; }
/* 📨 ข้อความจากสะพาน P1Chat (เรื่องประสานงาน) — กรอบทองให้เห็นชัดว่ามาจากอีกระบบ */
.tmsg--bridge .tmsg__bubble { border-color: var(--accent); background: var(--brand-soft); color: var(--text); }
.tmsg--bridge .tmsg__author { color: var(--accent-strong); }
.tmsg__bridge { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; padding-top: 6px; border-top: 1px dashed var(--accent); font-size: 12px; }
.tmsg__bridge-link { color: var(--brand-strong); font-weight: 600; text-decoration: none; }
.tmsg__bridge-link:hover { text-decoration: underline; }
.tmsg__bridge-hint { color: var(--text-muted); }
.team__typing { margin: 0; padding: 2px 18px 4px; font-size: 12px; color: var(--text-muted); font-style: italic; }
.team__reply { display: flex; align-items: center; gap: 8px; margin: 0 18px; padding: 6px 10px; border-left: 3px solid var(--accent); border-radius: 8px; background: var(--surface-2); font-size: 13px; }
.team__reply-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.team__reply-body span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-muted); }
.team__reply-cancel { border: 0; background: transparent; cursor: pointer; font-size: 16px; color: var(--text-muted); padding: 2px 6px; }
.team__pending { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 18px 0; }
.team-pending__item { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-size: 13px; max-width: 260px; }
.team-pending__item img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.team-pending__file { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-pending__remove { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 12px; cursor: pointer; }
.team__composer { display: flex; gap: 8px; padding: 10px 18px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--surface); align-items: flex-end; }
.composer__input { flex: 1; resize: none; max-height: 160px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; outline: none; }
.composer__input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.team__attach { padding: 8px 10px; font-size: 18px; line-height: 1; }
.team-picks { display: flex; flex-direction: column; gap: 2px; max-height: 40vh; overflow-y: auto; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 10px; padding: 4px; }
.team-pick { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.team-pick:hover { background: var(--surface-2); }
.team-pick__name { font-weight: 600; }
.team-pick__email { color: var(--text-muted); grid-column: 3; justify-self: end; font-size: 11px; }
.team-members { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.team-member { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 10px; }
.team-member__name { flex: 1; font-weight: 600; }
.team-member__name small { font-weight: 500; color: var(--text-muted); }

/* ---------- มือถือ ---------- */
@media (max-width: 860px) {
  .topbar { position: relative; flex-wrap: wrap; gap: 6px 8px; padding: 6px 10px; padding-top: max(6px, env(safe-area-inset-top)); }
  .topbar__brand { order: 0; flex-wrap: nowrap; font-size: 15px; }
  .topbar__brand .app-version { display: none; }
  .topbar__menu { order: 2; margin-left: auto; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 36px; border-radius: 10px; font-size: 20px; line-height: 1; cursor: pointer; color: #ffffff; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.3); }
  .topbar.is-menu-open .topbar__menu { background: #fff8e1; color: #163a5c; }
  .topbar__status { order: 1; flex: 1; flex-wrap: nowrap; overflow-x: auto; gap: 6px; scrollbar-width: none; }
  .topbar__status::-webkit-scrollbar { display: none; }
  .topbar__actions { display: none; }
  .topbar.is-menu-open .topbar__actions { display: flex; flex-direction: column; align-items: stretch; gap: 8px; position: absolute; top: calc(100% + 4px); right: 8px; z-index: 50; margin: 0; width: min(300px, calc(100vw - 16px)); max-height: calc(100dvh - 80px); overflow-y: auto; padding: 12px; border-radius: 14px; border: 1px solid var(--accent); background: var(--header-bg); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45); }
  .topbar__actions .button--ghost { padding: 10px 14px; text-align: left; font-size: 15px; }
  .topbar__actions .theme-toggle__label, .topbar__actions .topbar__label { display: inline; margin-left: 6px; }
  .topbar__actions #alerts-toggle { text-align: center; }
  .topbar__agent { max-width: none; text-align: left; padding: 8px 10px; border-color: rgba(255, 213, 138, 0.35); }
  .topbar__menu-version { display: block; margin: 0 0 2px; color: rgba(255, 255, 255, 0.75); white-space: normal; }
  .action-menu { left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); top: auto; min-width: 0; box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.3); }
  .action-menu__item { padding: 13px 14px; font-size: 16px; }
  .lightbox__nav--prev { left: 6px; }
  .lightbox__nav--next { right: 6px; }
  .team { grid-template-columns: 1fr; }
  .team__side { border-right: 0; }
  .team.is-room-open .team__side { display: none; }
  .team:not(.is-room-open) .team__thread { display: none; }
  .app.is-room-open .topbar { display: none; }
  .team__back { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 18px; cursor: pointer; }
  .team__header { padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); }
  .team__messages { padding: 10px 10px; }
  .tmsg { max-width: 86%; }
  .tmsg--other .tmsg__more { right: -30px; }
  .tmsg--mine .tmsg__more { left: -30px; }
  .team__composer { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .team__composer .composer__input { font-size: 16px; }
  .team__search .field__input { font-size: 16px; }
  .team__reply { margin: 0 10px; }
  .team__pending { padding: 8px 10px 0; }
}
