/* ==========================================================================
   ตรีจักร 191 — Sunny design system v3 (dark-first, Gen Z)
   ========================================================================== */
:root {
  --bg0: #05080f;
  --bg1: #0b1120;
  --bg2: #121b30;
  --bg3: #1a2540;
  --line: rgba(148, 163, 196, .14);
  --line-soft: rgba(148, 163, 196, .08);
  --txt: #f3f6fc;
  --mut: #8d99b5;
  --dim: #5b6578;
  --red: #ff4545;
  --red-deep: #e02626;
  --red-glow: rgba(255, 69, 69, .45);
  --red-soft: rgba(255, 69, 69, .12);
  --green: #3ddc97;
  --green-soft: rgba(61, 220, 151, .12);
  --amber: #ffc24b;
  --amber-soft: rgba(255, 194, 75, .12);
  --blue: #5ea9ff;
  --blue-soft: rgba(94, 169, 255, .12);
  --grad-red: linear-gradient(135deg, #ff5a5a, #e02626 60%, #a31212);
  --grad-card: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,0));
  --shadow: 0 8px 28px rgba(0, 0, 0, .45);
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --appbar-h: 60px;
  --tabbar-h: 72px;
  --font: "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  --spring: cubic-bezier(.32, .72, .28, 1);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg0: #eef1f7;
    --bg1: #ffffff;
    --bg2: #f2f5fb;
    --bg3: #e7ecf6;
    --line: rgba(20, 30, 60, .1);
    --line-soft: rgba(20, 30, 60, .05);
    --txt: #131a2c;
    --mut: #5d6b89;
    --dim: #8b96ad;
    --red-soft: rgba(224, 38, 38, .08);
    --green-soft: rgba(18, 140, 90, .1);
    --amber-soft: rgba(180, 120, 10, .12);
    --blue-soft: rgba(30, 110, 220, .1);
    --grad-card: linear-gradient(180deg, rgba(255,255,255,.7), rgba(255,255,255,0));
    --shadow: 0 8px 26px rgba(25, 40, 80, .1);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg0);
  color: var(--txt);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0 0 .45em; line-height: 1.32; letter-spacing: -.01em; }
p { margin: 0 0 .7em; }
.hidden { display: none !important; }
.mut { color: var(--mut); }
.small { font-size: .84rem; }
.num { font-variant-numeric: tabular-nums; }

.view { min-height: 100dvh; }
.wrap {
  max-width: 620px;
  margin: 0 auto;
  padding: 14px 16px calc(var(--tabbar-h) + 30px);
  animation: fadeUp .32s var(--spring);
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ============ Splash ============ */
.splash {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px;
  background: radial-gradient(120% 60% at 50% 0%, rgba(255,69,69,.14), transparent 60%), var(--bg0);
}
.splash-t { font-size: 1.5rem; font-weight: 800; letter-spacing: .02em; }
.pulse { animation: pulseMark 1.4s ease-in-out infinite; }
@keyframes pulseMark {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(255,69,69,0)); }
  50% { transform: scale(1.07); filter: drop-shadow(0 0 22px var(--red-glow)); }
}

/* ============ Gate ============ */
.gate {
  display: flex; flex-direction: column;
  background:
    radial-gradient(110% 46% at 50% -6%, rgba(255,69,69,.16), transparent 62%),
    var(--bg0);
}
.gate-inner {
  max-width: 480px; width: 100%; margin: 0 auto;
  padding: 54px 22px 34px; flex: 1;
  display: flex; flex-direction: column; justify-content: center;
}
.gate-mark {
  width: 76px; height: 76px; border-radius: 24px;
  background: var(--grad-red);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 12px 34px var(--red-glow);
  margin-bottom: 22px;
}
.gate-mark svg { width: 38px; height: 38px; }
.gate-kicker {
  font-size: .8rem; font-weight: 700; letter-spacing: .14em;
  color: var(--mut); text-transform: uppercase; margin-bottom: 6px;
}
.gate h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: 8px; }
.gate h1 .num { color: var(--red); }
.gate-sub { color: var(--mut); font-size: 1.02rem; margin-bottom: 26px; }
.role-cards { display: grid; gap: 12px; }
.role-card {
  display: flex; gap: 15px; align-items: center; text-align: left;
  background: var(--grad-card), var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  cursor: pointer; width: 100%;
  transition: transform .16s var(--spring), border-color .16s, box-shadow .16s;
}
.role-card:active { transform: scale(.97); }
.role-card:hover { border-color: rgba(255,69,69,.5); box-shadow: var(--shadow); }
.rc-ic {
  width: 52px; height: 52px; border-radius: 16px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--blue-soft); color: var(--blue);
}
.rc-ic svg { width: 26px; height: 26px; }
.role-card.admin .rc-ic { background: var(--red-soft); color: var(--red); }
.role-card b { display: block; font-size: 1.12rem; margin-bottom: 2px; }
.role-card p { margin: 0; font-size: .87rem; color: var(--mut); }
.role-card .go { margin-left: auto; color: var(--dim); flex: none; }
.role-card .go svg { width: 20px; height: 20px; display: block; }
.gate-note {
  margin-top: 22px; font-size: .82rem; color: var(--mut);
  background: var(--bg1); border: 1px dashed var(--line);
  border-radius: var(--r-sm); padding: 11px 14px;
}

/* ============ Appbar ============ */
.appbar {
  position: sticky; top: 0; z-index: 40;
  min-height: var(--appbar-h);
  display: flex; align-items: center; gap: 10px;
  max-width: 620px; margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg0) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px; flex: none;
  background: var(--grad-red); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px var(--red-glow);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-t { line-height: 1.25; min-width: 0; }
.brand-t b { display: block; font-size: .98rem; }
.brand-t span { font-size: .74rem; color: var(--mut); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  background: var(--green);
  box-shadow: 0 0 10px rgba(61,220,151,.7);
}
.status-dot.on {
  background: var(--red);
  box-shadow: 0 0 12px var(--red-glow);
  animation: blink 1.1s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: .45; } }
.spacer { flex: 1; }
.iconbtn {
  width: 42px; height: 42px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 13px; border: 1px solid var(--line);
  background: var(--bg1); color: var(--mut); cursor: pointer;
  transition: transform .14s var(--spring);
  position: relative;
}
.iconbtn:active { transform: scale(.9); }
.iconbtn svg { width: 20px; height: 20px; }
.iconbtn.lit { color: var(--amber); border-color: rgba(255,194,75,.4); }
.iconbtn .ping {
  position: absolute; top: 9px; right: 10px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); box-shadow: 0 0 8px var(--red-glow);
}

/* ============ Tabbar ============ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg1) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line-soft);
}
.tabbar-inner {
  max-width: 620px; margin: 0 auto; display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbtn {
  flex: 1; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px 9px; min-height: var(--tabbar-h); justify-content: center;
  font-size: .72rem; font-weight: 700; color: var(--dim);
  position: relative; transition: color .18s;
}
.tabbtn svg { width: 23px; height: 23px; transition: transform .2s var(--spring); }
.tabbtn[aria-current="page"] { color: var(--red); }
.tabbtn[aria-current="page"] svg { transform: translateY(-1px) scale(1.08); filter: drop-shadow(0 0 8px var(--red-glow)); }
.tbadge {
  position: absolute; top: 7px; margin-left: 28px;
  min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 999px; background: var(--red); color: #fff;
  font-size: .68rem; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ============ Cards & hero ============ */
.card {
  background: var(--grad-card), var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.sec-t {
  font-size: .78rem; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--mut);
  margin: 20px 2px 10px;
  display: flex; align-items: center; gap: 8px;
}
.sec-t:first-child { margin-top: 2px; }

.hero { position: relative; overflow: hidden; }
.hero-calm { border-color: rgba(61,220,151,.3); }
.hero-calm .hero-glow {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(90% 130% at 50% 0%, rgba(61,220,151,.1), transparent 65%);
}
.hero-alert {
  border-color: rgba(255,69,69,.55);
  animation: alertPulse 2s ease-in-out infinite;
}
@keyframes alertPulse {
  0%, 100% { box-shadow: var(--shadow), 0 0 0 0 var(--red-glow); }
  50% { box-shadow: var(--shadow), 0 0 34px 2px var(--red-glow); }
}
.hero-alert .hero-glow {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(90% 130% at 50% 0%, rgba(255,69,69,.16), transparent 65%);
}
.hero-kicker {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .76rem; font-weight: 800; letter-spacing: .06em;
  padding: 5px 12px; border-radius: 999px; margin-bottom: 10px;
  background: var(--green-soft); color: var(--green);
}
.hero-alert .hero-kicker { background: var(--red-soft); color: var(--red); }
.hero-title { font-size: 1.42rem; font-weight: 800; margin-bottom: 4px; position: relative; }
.hero-sub { color: var(--mut); font-size: .94rem; margin: 0; position: relative; }
.hero-row { display: flex; gap: 10px; margin-top: 14px; position: relative; }

/* ============ Panic button ============ */
.panic-wrap {
  display: flex; flex-direction: column; align-items: center;
  padding: 26px 0 8px;
}
.panic {
  position: relative; border: 0; cursor: pointer;
  width: 148px; height: 148px; border-radius: 50%;
  background: var(--grad-red); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-weight: 800; font-size: 1.06rem;
  box-shadow: 0 16px 44px var(--red-glow), inset 0 2px 6px rgba(255,255,255,.3);
  transition: transform .16s var(--spring);
}
.panic svg { width: 40px; height: 40px; }
.panic:active { transform: scale(.93); }
.panic::before, .panic::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(255,69,69,.55);
  animation: ring 2.2s ease-out infinite; pointer-events: none;
}
.panic::after { animation-delay: 1.1s; }
@keyframes ring {
  from { transform: scale(1); opacity: .9; }
  to { transform: scale(1.55); opacity: 0; }
}
.panic-cap { margin-top: 14px; color: var(--mut); font-size: .86rem; text-align: center; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 14px; border: 1px solid transparent;
  padding: 12px 20px; font-weight: 700; font-size: .97rem;
  cursor: pointer; text-decoration: none; color: var(--txt);
  transition: transform .14s var(--spring), filter .14s, background .14s;
  background: var(--bg3);
}
.btn svg { width: 19px; height: 19px; flex: none; }
.btn:active { transform: scale(.96); }
.btn-block { width: 100%; }
.btn-lg { padding: 15px 22px; font-size: 1.05rem; border-radius: 16px; }
.btn-sm { padding: 8px 14px; font-size: .85rem; border-radius: 11px; }
.btn-danger { background: var(--grad-red); color: #fff; box-shadow: 0 8px 22px var(--red-glow); }
.btn-green { background: linear-gradient(135deg, #3ddc97, #1d9e66); color: #04120b; }
.btn-soft { background: var(--red-soft); color: var(--red); border-color: rgba(255,69,69,.25); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--txt); }
.btn-quiet { background: transparent; color: var(--mut); }
.btn[disabled] { opacity: .5; transform: none; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ============ Segmented (สถานะของฉัน) ============ */
.seg {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.seg-btn {
  border: 1.5px solid var(--line); background: var(--bg2);
  border-radius: var(--r-md); padding: 13px 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: .82rem; font-weight: 700; color: var(--mut);
  transition: all .18s var(--spring);
}
.seg-btn svg { width: 24px; height: 24px; }
.seg-btn:active { transform: scale(.95); }
.seg-btn.sel[data-v="safe"] { border-color: var(--green); background: var(--green-soft); color: var(--green); box-shadow: 0 0 18px rgba(61,220,151,.25); }
.seg-btn.sel[data-v="help"] { border-color: var(--red); background: var(--red-soft); color: var(--red); box-shadow: 0 0 18px var(--red-glow); }
.seg-btn.sel[data-v="away"] { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }

/* ============ Chips ============ */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line); background: var(--bg2); color: var(--mut);
  border-radius: 999px; padding: 9px 16px; font-size: .87rem; font-weight: 700;
  cursor: pointer; transition: all .16s var(--spring);
}
.chip:active { transform: scale(.94); }
.chip.sel { border-color: var(--red); background: var(--red-soft); color: var(--red); }

/* ============ Sheet ============ */
#sheet-root:empty { display: none; }
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(2, 4, 10, .62);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fadeIn .22s ease;
  display: flex; align-items: flex-end; justify-content: center;
}
@keyframes fadeIn { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 620px;
  max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg1);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: 26px 26px 0 0;
  padding: 10px 20px calc(22px + env(safe-area-inset-bottom));
  animation: sheetUp .34s var(--spring);
}
@keyframes sheetUp {
  from { transform: translateY(60px); opacity: .4; }
}
.sheet-handle {
  width: 44px; height: 5px; border-radius: 99px;
  background: var(--line); margin: 4px auto 14px;
}
.sheet-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
.sheet-head h3 { font-size: 1.2rem; margin: 0; flex: 1; }
.sheet-x {
  width: 36px; height: 36px; flex: none; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg2); color: var(--mut);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.sheet-x svg { width: 17px; height: 17px; }
.sheet-sub { color: var(--mut); font-size: .9rem; margin-bottom: 14px; }
.sheet-foot { display: flex; gap: 10px; margin-top: 18px; }
.sheet-foot .btn { flex: 1; }
.steps { display: flex; gap: 6px; margin-bottom: 16px; }
.steps i { flex: 1; height: 4px; border-radius: 99px; background: var(--bg3); }
.steps i.on { background: var(--red); }

/* ============ Toast ============ */
#toast-root {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + 18px);
  z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; padding: 0 20px;
}
.toast {
  background: rgba(14, 20, 36, .94); color: #fff;
  border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 18px;
  font-size: .9rem; font-weight: 600;
  box-shadow: var(--shadow);
  animation: toastIn .3s var(--spring);
  max-width: 480px; text-align: center;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.toast.ok { border-color: rgba(61,220,151,.5); }
.toast.err { border-color: rgba(255,69,69,.55); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
}
.toast.out { opacity: 0; transform: translateY(8px); transition: all .25s; }

/* ============ Map ============ */
.mapbox {
  border-radius: var(--r-lg); overflow: hidden;
  border: 1px solid var(--line);
  background: #0a1224;
  position: relative;
}
.mapbox svg { display: block; width: 100%; height: auto; touch-action: manipulation; }
.map-cap {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; font-size: .82rem; color: var(--mut);
  border-top: 1px solid var(--line-soft); background: var(--bg1);
}
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: .8rem; color: var(--mut); }
.legend i { display: inline-flex; align-items: center; gap: 6px; font-style: normal; }
.sw { width: 13px; height: 13px; border-radius: 4px; display: inline-block; }
.zone-pick { border: 2px solid transparent; border-radius: var(--r-md); transition: border-color .15s; }
.zone-pick.sel { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }

/* ============ Queue (admin) ============ */
.q-card { border-left: 4px solid var(--amber); }
.q-card.mine { border-left-color: var(--red); border-color: rgba(255,69,69,.4); }
.q-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.q-ava {
  width: 46px; height: 46px; border-radius: 14px; flex: none;
  background: var(--bg3); color: var(--mut);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.05rem;
}
.q-card.mine .q-ava { background: var(--red-soft); color: var(--red); }
.q-who b { display: block; font-size: 1.02rem; }
.q-who span { font-size: .8rem; color: var(--mut); }
.q-count { margin-left: auto; position: relative; width: 64px; height: 64px; flex: none; }
.q-count svg { transform: rotate(-90deg); }
.q-count b {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; font-variant-numeric: tabular-nums;
}
.q-log { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.q-log .li { padding: 10px 13px; }
.li {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--bg2); border: 1px solid var(--line-soft);
  border-radius: var(--r-md); padding: 13px 14px;
}
.li-ic {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg3); color: var(--mut);
}
.li-ic svg { width: 19px; height: 19px; }
.li-ic.red { background: var(--red-soft); color: var(--red); }
.li-ic.green { background: var(--green-soft); color: var(--green); }
.li-ic.amber { background: var(--amber-soft); color: var(--amber); }
.li-ic.blue { background: var(--blue-soft); color: var(--blue); }
.li-body { flex: 1; min-width: 0; }
.li-body b { display: block; font-size: .94rem; }
.li-body p { margin: 2px 0 0; font-size: .83rem; color: var(--mut); }
.li-time { font-size: .74rem; color: var(--dim); flex: none; }

/* ============ Banner ============ */
.banner {
  display: flex; gap: 12px; align-items: flex-start;
  border-radius: var(--r-md); padding: 14px 15px; margin-bottom: 14px;
  font-size: .9rem; border: 1px solid;
}
.banner svg { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.banner.red { background: var(--red-soft); border-color: rgba(255,69,69,.35); color: var(--txt); }
.banner.green { background: var(--green-soft); border-color: rgba(61,220,151,.35); }
.banner.amber { background: var(--amber-soft); border-color: rgba(255,194,75,.35); }
.banner b { display: block; margin-bottom: 1px; }
.banner p { margin: 0; font-size: .84rem; color: var(--mut); }

/* ============ Forms ============ */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .84rem; font-weight: 700; color: var(--mut); margin-bottom: 7px; }
.inp, .ta, .sel-inp {
  width: 100%; background: var(--bg2);
  border: 1.5px solid var(--line); border-radius: var(--r-sm);
  padding: 12px 14px; font-size: .95rem; color: var(--txt);
  transition: border-color .15s;
}
.inp:focus, .ta:focus, .sel-inp:focus { outline: none; border-color: var(--red); }
.ta { min-height: 96px; resize: vertical; }
.preset-list { display: grid; gap: 8px; margin-bottom: 12px; }
.preset {
  text-align: left; background: var(--bg2); border: 1.5px solid var(--line);
  border-radius: var(--r-sm); padding: 11px 14px; cursor: pointer;
  font-size: .88rem; font-weight: 600; transition: all .15s var(--spring);
  display: flex; gap: 10px; align-items: center;
}
.preset:active { transform: scale(.98); }
.preset.sel { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.preset svg { width: 17px; height: 17px; flex: none; }

/* ============ Tool row (redzone) ============ */
.tool-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.tool-btn {
  border: 1.5px solid var(--line); background: var(--bg2); color: var(--mut);
  border-radius: var(--r-md); padding: 12px 8px; cursor: pointer;
  font-size: .85rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all .16s var(--spring);
}
.tool-btn svg { width: 19px; height: 19px; }
.tool-btn.active { border-color: var(--red); background: var(--red-soft); color: var(--red); }

/* ============ Presence ============ */
.p-row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line-soft); }
.p-row:last-child { border-bottom: 0; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: var(--bg3); color: var(--mut);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
}
.p-row b { display: block; font-size: .93rem; }
.p-row span { font-size: .78rem; color: var(--mut); }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-left: auto; flex: none; box-shadow: 0 0 8px rgba(61,220,151,.7); }

/* ============ Empty / misc ============ */
.empty {
  text-align: center; padding: 38px 20px; color: var(--mut);
  border: 1.5px dashed var(--line); border-radius: var(--r-lg);
  margin-bottom: 14px;
}
.empty svg { width: 44px; height: 44px; margin-bottom: 10px; opacity: .5; }
.empty b { display: block; color: var(--txt); font-size: 1rem; margin-bottom: 4px; }
.empty p { margin: 0; font-size: .86rem; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  background: var(--bg2); border: 1px solid var(--line-soft);
  border-radius: var(--r-md); padding: 13px 8px; text-align: center;
}
.stat b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .76rem; color: var(--mut); font-weight: 700; }
.stat.g b { color: var(--green); }
.stat.r b { color: var(--red); }
.stat.b b { color: var(--blue); }
.hint { font-size: .8rem; color: var(--dim); text-align: center; margin-top: 14px; }
.divider { height: 1px; background: var(--line-soft); margin: 16px 0; }
kbd.key {
  background: var(--bg3); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 6px; padding: 1px 7px; font-size: .78rem; font-family: inherit;
}
@media (min-width: 560px) {
  .gate h1 { font-size: 3rem; }
  .panic { width: 164px; height: 164px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* นับถอยหลัง 3 วินาทีก่อนเปิดฟอร์มแจ้งเหตุ (กันกดพลาด) */
.cd-wrap { text-align: center; padding: 20px 0 8px; }
.cd-num {
  font-size: 4.4rem; font-weight: 800; line-height: 1;
  color: var(--red); font-variant-numeric: tabular-nums;
  text-shadow: 0 0 28px var(--red-glow);
  animation: cd-pulse 1s ease-in-out infinite;
}
.cd-cap { color: var(--mut); margin: 10px 0 0; font-size: .95rem; }
@keyframes cd-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
