/* ===== บีบี้ — ธีมมือถือ QWERTY ยุค 2011 (ออกแบบใหม่ ไม่อิงเครื่องรุ่นใด) ===== */
:root {
  --blue1: #4a9cf0; --blue2: #1a5fb4; --blue-txt: #1b64c2;
  --ink: #15181c; --muted: #6b737d; --line: #dde2e8; --bg: #fff;
  --hdr1: #f3f5f8; --hdr2: #dbe0e7;
  --green: #35c04a; --red: #e3342f; --ping: #e0201b;
  --font: system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: 14px; color: var(--ink);
  background: #0c0e12; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--ink); }
[hidden] { display: none !important; }
a { color: var(--blue-txt); }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .tiny { font-size: 11px; }
.red { color: var(--ping); } .red-txt { color: var(--red) !important; } .mono { font-family: ui-monospace, Consolas, monospace; letter-spacing: .08em; }
.center-txt { text-align: center; } .grow { flex: 1; min-height: 0; } .wrap { white-space: normal !important; }
.err { color: var(--red); font-size: 12.5px; min-height: 1em; margin: 4px 0; }

/* ---------------------------------------------------------------- device frame */
#device { position: relative; display: flex; flex-direction: column; height: 100dvh; background: #000; }
.dev-top, .dev-nav, .kbd, .dev-brand { display: none; }
.disclaimer { display: none; }
#screen { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }

@media (min-width: 720px) and (min-height: 760px) {
  body {
    display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100dvh;
    background: radial-gradient(ellipse at 50% 30%, #2b3443 0%, #121720 60%, #07090c 100%);
  }
  #device {
    width: 452px; height: auto; padding: 0 22px 18px; border-radius: 44px 44px 60px 60px;
    background: linear-gradient(160deg, #3a3d43 0%, #16171a 18%, #08090a 55%, #1d1f23 100%);
    box-shadow: 0 0 0 2px #50545b, 0 0 0 5px #111, 0 30px 70px rgba(0,0,0,.65), inset 0 2px 1px rgba(255,255,255,.18);
  }
  .dev-top { display: flex; align-items: center; justify-content: center; height: 46px; position: relative; }
  .dev-speaker { width: 74px; height: 6px; border-radius: 6px; background: repeating-linear-gradient(90deg, #000 0 3px, #2b2e33 3px 5px); box-shadow: inset 0 1px 2px #000; }
  .dev-led { position: absolute; right: 26px; top: 18px; width: 9px; height: 9px; border-radius: 50%; background: #3a0f0f; box-shadow: inset 0 1px 2px #000; }
  #screen {
    flex: none; width: 408px; height: 452px; border-radius: 6px;
    box-shadow: 0 0 0 3px #000, 0 0 0 4px #3c4047, inset 0 0 0 1px rgba(0,0,0,.4);
  }
  .dev-nav { display: flex; align-items: center; justify-content: space-between; gap: 6px; height: 64px; margin-top: 14px; padding: 0 4px; }
  .kbd { display: flex; flex-direction: column; gap: 6px; padding: 8px 6px 0; }
  .dev-brand { display: block; text-align: center; color: #8d939c; font: italic 700 13px/1 var(--font); letter-spacing: .3em; margin-top: 12px; text-shadow: 0 1px 0 #000; }
  .disclaimer { display: block; color: #6f7886; font-size: 11px; margin: 14px 0 0; text-align: center; }
}
@media (min-width: 720px) and (min-height: 980px) { #screen { height: 520px; } }

/* LED แจ้งเตือน */
.dev-led.on { animation: led 2.4s infinite; }
.dev-led.flash { animation: ledflash .9s 3; }
@keyframes led { 0%, 70%, 100% { background: #3a0f0f; box-shadow: inset 0 1px 2px #000; } 78%, 88% { background: #ff2a2a; box-shadow: 0 0 10px 3px rgba(255,40,40,.75); } }
@keyframes ledflash { 0%, 100% { background: #3a0f0f; } 50% { background: #ff4040; box-shadow: 0 0 14px 5px rgba(255,50,50,.85); } }

/* ปุ่มนำทาง */
.nk { width: 64px; height: 40px; border: 0; border-radius: 12px 12px 18px 18px; background: linear-gradient(#2a2c31, #111215); box-shadow: inset 0 1px 0 rgba(255,255,255,.15), 0 2px 3px #000; display: grid; place-items: center; }
.nk:active { transform: translateY(1px); filter: brightness(1.3); }
.nk span { width: 22px; height: 22px; background: currentColor; -webkit-mask: var(--ic) center/contain no-repeat; mask: var(--ic) center/contain no-repeat; }
.nk.call { color: #42d158; --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.6 10.8a15 15 0 0 0 6.6 6.6l2.2-2.2c.3-.3.7-.4 1-.2 1.1.4 2.3.6 3.6.6.6 0 1 .4 1 1V20c0 .6-.4 1-1 1A17 17 0 0 1 3 4c0-.6.4-1 1-1h3.5c.6 0 1 .4 1 1 0 1.3.2 2.5.6 3.6.1.3 0 .7-.2 1z'/%3E%3C/svg%3E"); }
.nk.end { color: #ff4d4d; --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath transform='rotate(135 12 12)' d='M6.6 10.8a15 15 0 0 0 6.6 6.6l2.2-2.2c.3-.3.7-.4 1-.2 1.1.4 2.3.6 3.6.6.6 0 1 .4 1 1V20c0 .6-.4 1-1 1A17 17 0 0 1 3 4c0-.6.4-1 1-1h3.5c.6 0 1 .4 1 1 0 1.3.2 2.5.6 3.6.1.3 0 .7-.2 1z'/%3E%3C/svg%3E"); }
.nk.menu { color: #d6dbe2; --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='5' width='18' height='2.6' rx='1.3'/%3E%3Crect x='3' y='10.7' width='18' height='2.6' rx='1.3'/%3E%3Crect x='3' y='16.4' width='18' height='2.6' rx='1.3'/%3E%3C/svg%3E"); }
.nk.back { color: #d6dbe2; --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6L4 11l5 5'/%3E%3Cpath d='M4 11h10a6 6 0 0 1 0 12h-2'/%3E%3C/svg%3E"); }
.trackpad { width: 62px; height: 46px; border-radius: 12px; border: 0; background: radial-gradient(ellipse at 40% 30%, #6c727c, #2d3138 70%); box-shadow: 0 0 0 3px #0b0c0e, 0 0 0 4px #4a4e55, inset 0 2px 3px rgba(255,255,255,.25); }
.trackpad:active { filter: brightness(1.25); }

/* คีย์บอร์ด */
.krow { display: flex; gap: 5px; justify-content: center; }
.key { position: relative; flex: 1; height: 33px; border: 0; border-radius: 9px 9px 12px 12px; padding: 0;
  background: linear-gradient(#34373d, #141518 70%); box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 2px 2px #000;
  color: #f3f5f8; font-weight: 700; font-size: 13px; line-height: 1; touch-action: manipulation; }
.key .ka { position: absolute; top: 3px; right: 5px; font-size: 8.5px; font-weight: 600; color: #8fb4ff; }
.key .kl { position: relative; top: 2px; }
.key.down, .key:active { background: linear-gradient(#4a4e56, #24262b); transform: translateY(1px); }
.k-space { flex: 2.4; } .k-enter, .k-del { color: #cfd6df; }
.k-alt .kl, .k-sym .kl, .k-shift .kl, .k-shift2 .kl { font-size: 10.5px; color: #8fb4ff; }
.kbd.shift .k-shift, .kbd.shift .k-shift2, .kbd.alt .k-alt { background: linear-gradient(#2a5ea8, #123a73); }
.kbd.alt .ka { color: #fff; font-size: 10px; }

/* PING!!! เขย่าเครื่อง */
#device.shake { animation: shake .8s; }
@keyframes shake { 10%, 90% { transform: translate(-2px, 0) rotate(-.6deg); } 20%, 80% { transform: translate(5px, 0) rotate(.8deg); } 30%, 50%, 70% { transform: translate(-7px, 1px) rotate(-1deg); } 40%, 60% { transform: translate(7px, -1px) rotate(1deg); } }

/* ---------------------------------------------------------------- status bar */
.statusbar { flex: none; height: 22px; display: flex; justify-content: space-between; align-items: center; padding: 0 8px; background: #050607; color: #e9edf2; font-size: 11px; font-weight: 600; padding-top: env(safe-area-inset-top); box-sizing: content-box; }
.sb-left, .sb-right { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sb-left span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.sb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 4px var(--green); }
.sb-dot.busy { background: var(--red); box-shadow: 0 0 4px var(--red); }
.sb-net { font-size: 9px; color: #8fd0ff; }
.sb-signal { display: flex; align-items: flex-end; gap: 1px; height: 11px; }
.sb-signal i { width: 3px; background: #e9edf2; }
.sb-signal i:nth-child(1) { height: 3px; } .sb-signal i:nth-child(2) { height: 5px; } .sb-signal i:nth-child(3) { height: 8px; } .sb-signal i:nth-child(4) { height: 11px; }
.sb-batt { width: 20px; height: 10px; border: 1.5px solid #e9edf2; border-radius: 2px; padding: 1px; position: relative; }
.sb-batt::after { content: ""; position: absolute; right: -4px; top: 2px; width: 2px; height: 4px; background: #e9edf2; }
.sb-batt i { display: block; height: 100%; background: #7be36b; }
body.has-unread .statusbar::before { content: ""; position: absolute; left: 50%; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: #ff3030; animation: led 2.4s infinite; }
@media (min-width: 720px) and (min-height: 760px) { body.has-unread .statusbar::before { display: none; } }

/* ---------------------------------------------------------------- views */
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.view.center { align-items: center; justify-content: safe center; text-align: center; gap: 10px; overflow-y: auto; }
.view.center > * { flex-shrink: 0; }
.view.pad { padding: 18px; }
.col { display: flex; flex-direction: column; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* logo: สี่เหลี่ยมมน "bb" + จุด LED */
.logo { width: 64px; height: 64px; border-radius: 16px; position: relative; background: linear-gradient(150deg, #3a3f47, #0d0f12 60%); box-shadow: 0 6px 16px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.25); }
.logo::before { content: "bb"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font: 800 34px/1 "Arial Rounded MT Bold", var(--font); letter-spacing: -2px; padding-bottom: 6px; }
.logo::after { content: ""; position: absolute; right: 10px; top: 10px; width: 9px; height: 9px; border-radius: 50%; background: #ff3a3a; box-shadow: 0 0 8px #ff3a3a; }
.logo.big { width: 96px; height: 96px; border-radius: 24px; }
.logo.big::before { font-size: 52px; }
.logo.big::after { width: 12px; height: 12px; right: 14px; top: 14px; }

#v-boot { background: #000; color: #9aa3ad; }
.boot-bar { width: 160px; height: 6px; border-radius: 3px; background: #1d2026; overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 40%; background: linear-gradient(90deg, var(--blue1), #9fd0ff); animation: boot 1s ease-in-out infinite; }
@keyframes boot { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }

.login { background: radial-gradient(circle at 50% 0%, #2e3540, #0b0d10 70%); color: #eef2f6; }
.brand { margin: 0; font-size: 34px; letter-spacing: .02em; }
.tagline { margin: 0; color: #b9c3cf; font-size: 13px; }
.feat { list-style: none; padding: 0; margin: 4px 0 6px; text-align: left; color: #d5dce5; display: grid; gap: 4px; }
.feat li::before { content: "▸ "; color: var(--blue1); }
.feat .red { color: #ff6b6b; }
.login .muted { color: #8892a0; } .login a { color: #8fc2ff; }

/* ---------------------------------------------------------------- buttons / fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 14px; border-radius: 6px;
  border: 1px solid #b9c1cb; background: linear-gradient(#fff, #e6eaef); color: var(--ink); font-weight: 600; text-decoration: none; }
.btn:hover { filter: brightness(1.03); } .btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.blue { background: linear-gradient(var(--blue1), var(--blue2)); border-color: #164f96; color: #fff; text-shadow: 0 -1px 0 rgba(0,0,0,.25); }
.btn.red { background: linear-gradient(#f05a55, #c21f1a); border-color: #9c1712; color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 28px; padding: 3px 10px; font-size: 12.5px; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn.google { background: #fff; color: #222; border-color: #fff; min-height: 44px; padding: 8px 18px; font-size: 15px; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.g-ic { width: 18px; height: 18px; background: conic-gradient(from -45deg, #ea4335 0 25%, #fbbc05 0 50%, #34a853 0 75%, #4285f4 0); border-radius: 50%; -webkit-mask: radial-gradient(circle, transparent 4px, #000 4.5px); mask: radial-gradient(circle, transparent 4px, #000 4.5px); }
.ping-wide { background: linear-gradient(#fff3f2, #ffd9d6); border-color: #f0a19c; color: var(--ping); font-weight: 900; letter-spacing: .05em; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-size: 12.5px; font-weight: 600; color: #3b434c; }
.field input, .field textarea, .field select, .modal input, .page-body input, .page-body textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #b8c0ca; border-radius: 5px; background: #fff; font-weight: 400; font-size: 14px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.08); }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--blue1); outline-offset: 0; border-color: var(--blue2); }
.title-bar { margin: -18px -18px 12px; padding: 10px 14px; background: linear-gradient(#3b4048, #1d2126); color: #fff; font-size: 15px; }
#v-setup { background: #f4f6f9; }
.color-pick { display: flex; flex-wrap: wrap; gap: 7px; }
.cp { width: 28px; height: 28px; border-radius: 6px; border: 2px solid #fff; background: var(--c); box-shadow: 0 0 0 1px #c3cad3; }
.cp.on { box-shadow: 0 0 0 2px var(--blue2); transform: scale(1.1); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin: -4px 0 8px; }
.chip { border: 1px solid #c9d0d8; background: #f5f7fa; border-radius: 12px; padding: 3px 9px; font-size: 12px; }
.chip:hover { background: #e7f1fd; border-color: var(--blue1); }
.seg { display: flex; border: 1px solid #b9c1cb; border-radius: 6px; overflow: hidden; }
.seg-b { flex: 1; border: 0; padding: 7px; background: linear-gradient(#fff, #eceff3); font-weight: 600; font-size: 13px; }
.seg-b.on { background: linear-gradient(var(--blue1), var(--blue2)); color: #fff; }
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 10px 2px; border-bottom: 1px solid var(--line); position: relative; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; }
.toggle i { width: 42px; height: 24px; border-radius: 12px; background: #c5ccd5; position: relative; transition: .2s; }
.toggle i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: .2s; }
.toggle input:checked + i { background: var(--green); }
.toggle input:checked + i::after { left: 20px; }
.toggle input:focus-visible + i { outline: 2px solid var(--blue1); }

/* ---------------------------------------------------------------- main */
.me-bar { flex: none; display: flex; align-items: center; gap: 9px; padding: 7px 9px; background: linear-gradient(#454b54, #23272d); color: #fff; cursor: pointer; border-bottom: 1px solid #000; }
.me-bar:focus-visible { outline: 2px solid var(--blue1); outline-offset: -2px; }
.me-txt { flex: 1; min-width: 0; }
.me-name { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-status { font-size: 12px; color: #c4ccd6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-pin { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.me-pin b { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; color: #a9d4ff; letter-spacing: .06em; }
.me-pin .muted { color: #9aa4b0; }
.np { color: #7fc4ff; font-weight: 700; }
.tabs { flex: none; display: flex; background: linear-gradient(#2d3137, #121417); border-bottom: 1px solid #000; }
.tab { flex: 1; position: relative; border: 0; background: none; color: #b8c1cc; font-size: 11.5px; padding: 6px 2px 5px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tab.on { color: #fff; background: linear-gradient(#3e8ee0, #1b5daf); box-shadow: inset 0 1px 0 rgba(255,255,255,.3); }
.t-ic { width: 20px; height: 20px; background: currentColor; -webkit-mask: var(--ic) center/contain no-repeat; mask: var(--ic) center/contain no-repeat; }
.ic-contacts { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='8' r='4.2'/%3E%3Cpath d='M3.5 21a8.5 8.5 0 0 1 17 0z'/%3E%3C/svg%3E"); }
.ic-chats { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 3h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H10l-5 4v-4H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z'/%3E%3C/svg%3E"); }
.ic-updates { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l2.9 6.3 6.9.7-5.2 4.6 1.5 6.8L12 16.9l-6.1 3.5 1.5-6.8L2.2 9l6.9-.7z'/%3E%3C/svg%3E"); }
.ic-groups { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='8' cy='8' r='3.4'/%3E%3Ccircle cx='16.5' cy='9' r='3'/%3E%3Cpath d='M1.5 20a6.5 6.5 0 0 1 13 0zM13.5 20a5 5 0 0 1 9 0v0z'/%3E%3C/svg%3E"); }
.badge { position: absolute; top: 2px; right: calc(50% - 26px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; box-shadow: 0 0 0 1.5px #121417; }
.badge.dot { min-width: 9px; width: 9px; height: 9px; padding: 0; top: 5px; right: calc(50% - 16px); }
.search-row { flex: none; display: flex; align-items: center; gap: 6px; padding: 5px 8px; background: #eef1f4; border-bottom: 1px solid var(--line); }
.search-row input { flex: 1; border: 1px solid #c3cad3; border-radius: 4px; padding: 3px 7px; font-size: 13px; background: #fff; min-width: 0; }

.list { background: #fff; }
.hdr { display: flex; align-items: center; gap: 4px; padding: 4px 9px; font-size: 12px; font-weight: 700; color: #39424c; background: linear-gradient(var(--hdr1), var(--hdr2)); border-bottom: 1px solid #c6cdd6; border-top: 1px solid #fff; position: sticky; top: 0; z-index: 1; }
.hdr.tog { cursor: pointer; }
.hdr:focus-visible { outline: 2px solid var(--blue1); outline-offset: -2px; }
.caret { width: 12px; color: #6b7480; }
.row { display: flex; align-items: center; gap: 9px; padding: 6px 9px; min-height: 52px; border-bottom: 1px solid var(--line); cursor: pointer; outline: none; }
.row.static { cursor: default; }
.row:hover { background: #f2f7fd; }
.row:focus-visible, .row:focus { background: linear-gradient(#4fa0f2, #1d62b8); color: #fff; }
.row:focus .row-sub, .row:focus .time { color: #e1eeff; }
.row:focus .tag { background: rgba(255,255,255,.25); color: #fff; }
.row-txt { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.row-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.row.unread .row-title { font-weight: 800; }
.row.unread .row-sub { color: var(--ink); font-weight: 600; }
.row.action .row-title { color: var(--blue-txt); }
.time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.cnt { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--blue2); color: #fff; font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; }
.tag { display: inline-block; margin-left: 5px; padding: 0 5px; border-radius: 3px; background: #e9edf2; color: #56606b; font-size: 10.5px; font-weight: 600; vertical-align: 1px; }
.tag.busy { background: #fde5e4; color: #c3201b; }
.acts-inline { display: flex; gap: 4px; }
.row.invite { background: #fffbea; }
.row.pending { opacity: .8; }
.empty { padding: 26px 18px; text-align: center; color: var(--muted); }
.empty p { margin: 4px 0; }

/* avatar */
.av { flex: none; position: relative; width: 40px; height: 40px; border-radius: 7px; background: var(--c, #6d7b8d) center/cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.2); display: grid; place-items: center; }
.av-i { color: #fff; font-weight: 800; font-size: 18px; text-shadow: 0 1px 1px rgba(0,0,0,.3); }
.av.has-photo .av-i { display: none; }
.av.sm { width: 32px; height: 32px; border-radius: 6px; } .av.sm .av-i { font-size: 14px; }
.av.xl { width: 84px; height: 84px; border-radius: 12px; } .av.xl .av-i { font-size: 38px; }
.av.group::before { content: ""; width: 62%; height: 62%; background: #fff; -webkit-mask: var(--g) center/contain no-repeat; mask: var(--g) center/contain no-repeat;
  --g: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='8' cy='8' r='3.4'/%3E%3Ccircle cx='16.5' cy='9' r='3'/%3E%3Cpath d='M1.5 20a6.5 6.5 0 0 1 13 0zM13.5 20a5 5 0 0 1 9 0v0z'/%3E%3C/svg%3E"); }
.av.group .av-i { display: none; }
.av.plus { background: #f0f4f8; box-shadow: inset 0 0 0 1.5px #9db8d6; }
.av.plus .av-i { color: var(--blue-txt); text-shadow: none; font-size: 24px; font-weight: 400; }
.pres { position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; }
.pres.on { background: var(--green); } .pres.busy { background: var(--red); }
.me-bar .pres { border-color: #2c3036; }

/* ---------------------------------------------------------------- chat */
.chat-head, .page-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: linear-gradient(#454b54, #23272d); color: #fff; border-bottom: 1px solid #000; min-height: 50px; }
.ib { border: 0; background: none; color: inherit; min-width: 32px; height: 32px; border-radius: 6px; font-size: 16px; }
.ib:hover { background: rgba(255,255,255,.1); }
.chat-title { flex: 1; min-width: 0; cursor: pointer; }
.chat-name { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub { font-size: 11.5px; color: #c4ccd6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .pres { border-color: #2c3036; }
.page-title { font-weight: 700; font-size: 15px; }
.msgs { padding: 8px 9px 12px; background: #e9eef3 linear-gradient(rgba(255,255,255,.55), rgba(255,255,255,.55)); display: flex; flex-direction: column; gap: 6px; }
.day { align-self: center; font-size: 11px; color: #5f6873; background: rgba(255,255,255,.85); border: 1px solid #d3d9e0; border-radius: 9px; padding: 1px 9px; margin: 6px 0 2px; }
.sys { align-self: center; text-align: center; font-size: 11.5px; color: #66707b; font-style: italic; max-width: 90%; }
.m { display: flex; flex-direction: column; max-width: 82%; }
.m.me { align-self: flex-end; align-items: flex-end; }
.m.them { align-self: flex-start; align-items: flex-start; }
.who { font-size: 11px; font-weight: 700; margin: 0 0 1px 4px; }
.bub { padding: 6px 10px; border-radius: 10px; background: #fff; border: 1px solid #ccd3db; box-shadow: 0 1px 1px rgba(0,0,0,.06); white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.m.me .bub { background: linear-gradient(#e5f2ff, #cfe5fd); border-color: #a9c9ec; border-bottom-right-radius: 3px; }
.m.them .bub { border-bottom-left-radius: 3px; }
.m.ping .bub { background: linear-gradient(#fffbe6, #ffeeb0); border-color: #f0c64a; }
.ping-txt { color: var(--ping); font-weight: 900; font-size: 18px; letter-spacing: .04em; text-shadow: 0 1px 0 #fff; }
.ping-txt::before { content: "⚡ "; }
.m.broadcast .bub { background: #fff; border: 1px dashed #c08a1e; }
.m.me.broadcast .bub { background: #f5fbff; }
.bc-tag { font-size: 10.5px; font-weight: 700; color: #a06a00; margin-bottom: 2px; }
.meta { font-size: 10.5px; color: #75808b; margin: 1px 4px 0; display: flex; align-items: center; gap: 2px; }
.mk { display: inline-grid; place-items: center; min-width: 14px; height: 14px; padding: 0 2px; border-radius: 3px; font-size: 9.5px; font-weight: 800; line-height: 1; }
.mk-S { color: #7c8792; }
.mk-D { color: #57616c; border: 1px solid #9aa4ae; }
.mk-R { color: #fff; background: var(--blue2); border: 1px solid var(--blue2); }
.row:focus .mk-D { color: #fff; border-color: #fff; }
.typing { flex: none; padding: 3px 10px; font-size: 11.5px; color: #4e5965; background: #f3f5f7; border-top: 1px solid var(--line); }
.pencil { display: inline-block; animation: write 1s infinite; }
@keyframes write { 50% { transform: translate(3px, -1px) rotate(-12deg); } }
.composer { flex: none; display: flex; align-items: flex-end; gap: 4px; padding: 6px; background: linear-gradient(#f7f8fa, #e2e6eb); border-top: 1px solid #c3cad3; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
.composer textarea { flex: 1; resize: none; min-height: 34px; max-height: 96px; padding: 7px 9px; border: 1px solid #b8c0ca; border-radius: 6px; font-size: 14.5px; line-height: 1.35; background: #fff; }
.composer .ib { color: #3c4550; width: 34px; height: 34px; }
.emo-btn { padding: 4px !important; }
.emo-btn .emo-svg { width: 24px; height: 24px; display: block; }
.ping-btn { color: var(--ping) !important; font-weight: 900; font-size: 13px !important; border: 1.5px solid #f0a19c !important; background: #fff4f3 !important; }
.send-btn { background: linear-gradient(var(--blue1), var(--blue2)) !important; color: #fff !important; }
.chat-locked { flex: none; padding: 10px; text-align: center; background: #fff4e5; color: #8a5300; border-top: 1px solid #f0d2a0; }
.emo-panel { flex: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 2px; padding: 6px; background: #fff; border-top: 1px solid var(--line); max-height: 132px; overflow-y: auto; }
.emo-pick { border: 0; background: none; padding: 5px; border-radius: 6px; }
.emo-pick:hover, .emo-pick:focus { background: #e6f0fc; }
.emo-pick .emo-svg { width: 26px; height: 26px; display: block; margin: auto; }
.emo { display: inline-block; width: 1.35em; height: 1.35em; vertical-align: -.32em; margin: 0 1px; }
.emo .emo-svg { width: 100%; height: 100%; display: block; }

/* ---------------------------------------------------------------- page */
.page-body { padding: 12px 14px 20px; background: #f6f7f9; }
.prof-top { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.prof-top.center { flex-direction: column; text-align: center; gap: 6px; }
.prof-top h3 { margin: 0; }
.gap-s { gap: 6px; }
.big-status { text-align: center; font-size: 14px; padding: 8px 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; margin: 6px 0; }
.np-line { text-align: center; color: var(--blue-txt); font-weight: 600; font-size: 13px; margin: 4px 0; }
.kv, .pin-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.pin-row { justify-content: flex-start; }
.pin-row .btn { margin-left: auto; }
.sec { margin: 22px 0 4px; font-size: 13px; color: #4d5660; border-bottom: 2px solid #d5dbe2; padding-bottom: 3px; }
.acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.acts.col { flex-direction: column; gap: 0; }
.row-inline { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.row-inline.between { flex-wrap: wrap; }
.row-inline > input { flex: 1; min-width: 0; }
.checklist { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 6px; background: #fff; max-height: 220px; overflow-y: auto; margin: 6px 0; }
.ck { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-bottom: 1px solid #edf0f3; cursor: pointer; font-size: 13.5px; }
.ck input { width: 18px; height: 18px; accent-color: var(--blue2); }
.page-body .row { background: #fff; }

/* ---------------------------------------------------------------- BB menu / modal / toast */
.bbmenu-wrap { position: absolute; inset: 0; z-index: 20; background: rgba(0,0,0,.25); display: flex; align-items: flex-end; }
.bbmenu { min-width: 62%; max-width: 86%; margin: 0 0 8px 8px; background: rgba(28,31,36,.96); border: 1px solid #4b515a; border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.5); padding: 4px 0; animation: pop .14s ease-out; max-height: 85%; overflow-y: auto; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.mi { display: block; width: 100%; text-align: left; border: 0; background: none; color: #eef2f6; padding: 8px 14px; font-size: 14px; }
.mi:hover, .mi:focus { outline: none; background: linear-gradient(#4fa0f2, #1d62b8); color: #fff; }
.mi.ping { color: #ff6b66; font-weight: 900; letter-spacing: .04em; }
.mi.ping:focus, .mi.ping:hover { color: #fff; }
.mi.danger { color: #ff8a85; }
.bbmenu .sep { height: 1px; background: #4b515a; margin: 4px 0; }
.modal-wrap { position: absolute; inset: 0; z-index: 30; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 14px; }
.modal { width: 100%; max-width: 380px; max-height: 92%; overflow-y: auto; background: #fff; border-radius: 8px; padding: 0 14px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.45); animation: pop .15s ease-out; }
.modal h3 { margin: 0 -14px 10px; padding: 9px 14px; background: linear-gradient(#454b54, #23272d); color: #fff; font-size: 14.5px; border-radius: 8px 8px 0 0; }
.modal > input { margin: 6px 0; }
.pin-input { font-family: ui-monospace, Consolas, monospace; font-size: 18px !important; letter-spacing: .14em; text-transform: uppercase; }
.pin-big { text-align: center; font: 800 30px/1.2 ui-monospace, Consolas, monospace; letter-spacing: .14em; color: var(--blue2); margin: 6px 0; }
.qr { display: block; width: 190px; height: 190px; margin: 6px auto; border: 1px solid var(--line); border-radius: 6px; }
.find-res { margin-top: 6px; }
.find-card { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #f7fafd; }
.help { padding-left: 18px; line-height: 1.6; }
.toast { position: absolute; left: 50%; top: 34px; transform: translateX(-50%); z-index: 40; max-width: 90%; padding: 7px 14px; border-radius: 16px;
  background: rgba(20,22,26,.93); color: #fff; font-size: 13px; box-shadow: 0 6px 16px rgba(0,0,0,.35); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; animation: pop .15s; }
.toast.msg { background: rgba(23,74,140,.95); }
.toast.ping { background: var(--ping); font-weight: 800; font-size: 14.5px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }

.login .hub-link { color: #8fc2ff; }

/* ---------------------------------------------------------------- มือถือ: คีย์บอร์ดบีบี้ใต้จอ (เหมือนเครื่องจริง) */
@media not all and (min-width: 720px) and (min-height: 760px) {
  /* ตัวเครื่องมีขอบ (bezel) เหมือนบนคอม: ขอบเงามน + ลำโพง + LED + กรอบจอ */
  body.bbkb {
    height: 100dvh; overflow: hidden;
    padding: calc(env(safe-area-inset-top) + 6px) calc(env(safe-area-inset-right) + 6px) calc(env(safe-area-inset-bottom) + 6px) calc(env(safe-area-inset-left) + 6px);
    background: radial-gradient(ellipse at 50% 25%, #2b3443 0%, #121720 60%, #07090c 100%);
  }
  body.bbkb #device {
    height: 100%; padding: 0 7px 4px; border-radius: 30px 30px 42px 42px;
    background: linear-gradient(160deg, #3a3d43 0%, #16171a 18%, #08090a 55%, #1d1f23 100%);
    box-shadow: 0 0 0 1.5px #50545b, 0 0 0 3.5px #111, 0 12px 30px rgba(0,0,0,.6), inset 0 2px 1px rgba(255,255,255,.18);
  }
  body.bbkb .dev-top { display: flex; align-items: center; justify-content: center; flex: none; height: 24px; position: relative; }
  body.bbkb .dev-speaker { width: 56px; height: 5px; border-radius: 5px; background: repeating-linear-gradient(90deg, #000 0 3px, #2b2e33 3px 5px); box-shadow: inset 0 1px 2px #000; }
  body.bbkb .dev-led { position: absolute; right: 22px; top: 8px; width: 8px; height: 8px; border-radius: 50%; background: #3a0f0f; box-shadow: inset 0 1px 2px #000; }
  body.bbkb #screen {
    flex: 1 1 auto; min-height: 0; margin: 0 3px; border-radius: 6px;
    box-shadow: 0 0 0 2px #000, 0 0 0 3px #3c4047, inset 0 0 0 1px rgba(0,0,0,.4);
  }
  body.bbkb .statusbar { padding-top: 0; }
  body.bbkb.has-unread .statusbar::before { display: none; }
  body.bbkb .dev-brand { display: block; flex: none; text-align: center; color: #8d939c; font: italic 700 9px/1 var(--font); letter-spacing: .3em; margin: 3px 0 1px; text-shadow: 0 1px 0 #000; }
  body.bbkb.native-kb .dev-brand { display: none; }
  body.bbkb .dev-nav { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex: none; height: 46px; padding: 7px 4px 3px; }
  body.bbkb .nk { flex: 1; max-width: 64px; height: 34px; border-radius: 10px 10px 16px 16px; }
  body.bbkb .nk span { width: 20px; height: 20px; }
  body.bbkb .trackpad { flex: none; width: 54px; height: 36px; border-radius: 10px; }
  body.bbkb .kbd { display: flex; flex-direction: column; flex: none; gap: 5px; padding: 3px 0 2px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
  body.bbkb .krow { gap: 4px; }
  body.bbkb .key { height: clamp(38px, 5.4dvh, 48px); font-size: 16px; border-radius: 8px 8px 12px 12px; }
  body.bbkb .key .ka { font-size: 9.5px; top: 2px; right: 4px; }
  body.bbkb .k-alt .kl, body.bbkb .k-sym .kl, body.bbkb .k-shift .kl { font-size: 12px; }
  body.bbkb .k-lang .kl { font-size: 13px; color: #ffd27a; }
  /* กำลังใช้คีย์บอร์ดของเครื่อง (ปุ่ม ไทย) → ซ่อนคีย์บอร์ดบีบี้ให้มีที่ */
  body.bbkb.native-kb .kbd, body.bbkb.native-kb .dev-nav { display: none; }
  body.bbkb .composer { padding-bottom: 6px; }
}
.key.down, .key:active { transition: none; }
.k-lang .kl { color: #ffd27a; }

/* จอสัมผัส: ตัวอักษรช่องพิมพ์ ≥ 16px กัน iPhone ซูมเข้าเวลาแตะ */
@media (pointer: coarse) {
  input, textarea, select, .composer textarea, .search-row input, .pin-input { font-size: 16px !important; }
}

/* แถบชวนติดตั้งลงหน้าจอ */
.install-bar { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 10px; background: linear-gradient(#fff8dc, #ffefb0); border-bottom: 1px solid #e7cf7a; font-size: 12.5px; }
.ib-t { flex: 1; min-width: 0; line-height: 1.3; }
.ib-x { border: 0; background: none; font-size: 20px; line-height: 1; padding: 2px 4px; color: #7a6a2a; }
