:root {
  --bg: #0a160f;
  --panel: #11271d;
  --card: #163325;
  --line: #2c5a47;
  --accent: #25d366;
  --accent2: #7cf5c0;
  --text: #e8fff5;
  --muted: #8fb3a3;
  --danger: #e53935;
  --warn: #ef6c00;
  --sidebar-w: 200px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg); color: var(--text); overflow: hidden;
}

#app { display: flex; height: 100vh; height: 100dvh; width: 100%; }

#sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: #0a160f; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 40;
  transition: transform .25s ease;
}
.sidebar-brand {
  display: flex; flex-direction: row; align-items: center; gap: 8px;
  padding: 12px; font-weight: 700;
  border-bottom: 1px solid var(--line);
  writing-mode: horizontal-tb;
}
.sidebar-brand .logo-img { border-radius: 6px; object-fit: cover; flex-shrink: 0; width: 28px; height: 28px; }
.sidebar-brand .brand-text {
  writing-mode: horizontal-tb;
  letter-spacing: 0.02em;
  line-height: 1.2;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#nav { flex: 1; padding: 8px 6px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav-item {
  display: flex; flex-direction: row; align-items: center; gap: 10px;
  width: 100%; padding: 11px 12px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); font-size: 14px; font-weight: 600;
  cursor: pointer; text-align: left; transition: background .15s, color .15s;
  writing-mode: horizontal-tb;
}
.nav-item:hover { background: #0d2519; color: var(--text); }
.nav-item.active { background: #1a4d35; color: var(--accent2); }
.nav-item.nav-settings { margin-top: auto; border-top: 1px solid var(--line); border-radius: 0; padding-top: 14px; }
.nav-icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }

#bottomNav {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 90;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  grid-template-columns: repeat(5, 1fr);
}
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 8px 4px 6px; border: 0; background: transparent;
  color: var(--muted); font: inherit; cursor: pointer; min-height: 52px;
}
.bottom-nav-item .nav-label { font-size: 10px; line-height: 1.1; }
.bottom-nav-item.active { color: var(--accent2); background: #1a4d35; }
.nav-label {
  writing-mode: horizontal-tb;
  white-space: nowrap;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.sidebar-foot { padding: 10px 12px; border-top: 1px solid var(--line); }

.menu-btn {
  display: none; position: fixed; z-index: 50;
  top: env(safe-area-inset-top, 0px);
  left: env(safe-area-inset-left, 0px);
  width: 44px; height: 44px; margin: 0; padding: 0;
  border-radius: 0 0 10px 0; border: 1px solid var(--line); border-top: 0; border-left: 0;
  background: #0a160f; color: var(--text); font-size: 22px; cursor: pointer;
  line-height: 44px; text-align: center;
  transition: opacity .2s ease, visibility .2s ease;
}

#workspace { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#topbar {
  display: flex; flex-direction: row; align-items: center; gap: 10px; flex-shrink: 0;
  padding: 10px 14px 10px 12px; background: #0a160f; border-bottom: 1px solid var(--line);
  min-height: 48px;
}
#pageTitle {
  margin: 0; font-size: 20px; font-weight: 600; flex: 1; min-width: 0;
  writing-mode: horizontal-tb;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--accent2);
}
#topbar .status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); flex: 0 0 auto; justify-content: flex-end; min-width: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #888; }
.dot.on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.code-badge {
  font-family: monospace; font-weight: 800; font-size: 13px; letter-spacing: 1px;
  color: var(--accent2); background: rgba(129,199,132,.12); padding: 2px 8px; border-radius: 6px;
}
.health-badge { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: #0d2519; border: 1px solid var(--line); white-space: nowrap; }
.health-badge.ok { color: #81c784; border-color: #2e7d32; }
.health-badge.warn { color: #ef9a9a; border-color: #c62828; }
.degrade-banner {
  flex-shrink: 0; padding: 8px 14px; font-size: 13px; background: #3e2723; color: #ffccbc;
  border-bottom: 1px solid #bf360c; text-align: center;
}
.degrade-banner .link-btn { background: none; border: 0; color: var(--accent2); font-weight: 700; cursor: pointer; text-decoration: underline; }
.voice-rx-status { min-height: 1.2em; margin: 4px 0 8px; padding: 6px 8px; border-radius: 8px; background: rgba(255,255,255,.04); }
.voice-rx-status.ok { color: #81c784; }
.voice-rx-status.err { color: #ef9a9a; }
.quick-msgs { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0; flex-shrink: 0; }
.quick-msg-btn {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 16px; border: 1px solid var(--line);
  background: #0d2519; color: var(--accent2); font-size: 13px; cursor: pointer;
}
.bubble .ack { margin-left: 4px; color: var(--muted); font-size: 10px; }
body.large-ui { font-size: 17px; }
body.large-ui .btn { font-size: 16px; padding: 12px 16px; }
body.large-ui .bubble { font-size: 16px; }
body.glove-mode .btn, body.glove-mode .ptt, body.glove-mode .icon-btn, body.glove-mode .quick-msg-btn { min-height: 52px; min-width: 52px; font-size: 16px; }
body.glove-mode .ptt { font-size: 20px; padding: 20px; }
body.glove-mode .im-here-btn { font-size: 22px; padding: 22px; }
.onboard-card h3 { margin-top: 0; }
.btn.holding { opacity: 0.85; transform: scale(0.98); }
.connect-card { border: 1px solid rgba(129,199,132,.35); }
.connect-card .my-code { font-size: 28px; }
.card-install .install-map-block {
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line);
}
.card-install .card-title.sub { font-size: 15px; margin: 0 0 8px; }
.connect-card .my-code { font-size: 28px; }
.align-center { align-items: center; }

#body { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
#body.split-view .map-area {
  flex: 0 0 var(--map-split, 45%);
  min-height: 28vh; max-height: 85%;
}
#body.split-view #pages {
  flex: 1 1 auto; min-height: 100px; max-height: none; overflow-y: auto;
}
.map-split-handle {
  flex: 0 0 16px; background: #0d2519; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  cursor: row-resize; touch-action: none; display: flex; align-items: center; justify-content: center; z-index: 20;
}
.map-split-handle::after {
  content: ''; width: 48px; height: 5px; border-radius: 3px; background: var(--accent); opacity: .85;
}
.map-split-handle.hidden { display: none !important; }

.map-area {
  position: relative; flex: 1; min-height: 0;
  border-bottom: 2px solid var(--accent);
  background: #0a1f16;
}
.map-area.hidden { display: none; }
#map { position: absolute; inset: 0; }
.map-hint {
  position: absolute; bottom: 10px; left: 10px; right: 10px; z-index: 15;
  background: rgba(10,22,15,.92); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; font-size: 12px; color: var(--muted);
}
.connect-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  background: #b71c1c; color: #fff; padding: 10px 14px; font-size: 13px; line-height: 1.5;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.update-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 199;
  background: #1565c0; color: #fff; padding: 10px 14px; font-size: 13px; line-height: 1.45;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.update-banner.hidden { display: none !important; }
body.has-update-banner #workspace { margin-top: 52px; }

body.no-browser-net .net-only { display: none !important; }
body:not(.needs-offline-pair):not(.conn-mode-hotspot) .offline-only { display: none !important; }
body.conn-mode-hotspot .offline-only.web-near-pair,
body.conn-mode-hotspot .offline-only { display: block !important; }
body.conn-mode-apk .web-near-pair { display: none !important; }
body.conn-mode-apk .apk-mode-panel { display: block !important; }
.conn-mode-seg { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.conn-mode-btn.active { background: var(--accent); color: #05291c; font-weight: 700; }
.conn-mode-hint { margin: 4px 0 8px; line-height: 1.45; }
.portable-router-panel { margin-top: 8px; }
.portable-router-panel summary { cursor: pointer; color: var(--accent); }
.matrix-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.matrix-table th, .matrix-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.matrix-table th { background: var(--card2); }
.matrix-table td.ok { color: #2e7d32; }
.matrix-table td.warn { color: #ef6c00; }
.apk-mode-panel { margin-top: 8px; }
.install-details { margin-top: 8px; }
.install-details summary { cursor: pointer; padding: 6px 0; }
.chat-dispose-banner {
  margin: 8px 12px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(46, 125, 50, .15);
  border: 1px solid rgba(129, 199, 132, .35);
}
.chat-dispose-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.chat-contact-actions {
  display: flex;
  gap: 8px;
  padding: 6px 12px 0;
  flex-wrap: wrap;
}
.chat-contact-actions.hidden,
.chat-dispose-banner.hidden { display: none; }
.chat-contact-actions .btn.active,
.chat-dispose-actions .btn.active { background: rgba(46, 125, 50, .35); border-color: #81c784; }

.offline-mode-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 198;
  background: #1b5e20; color: #fff; padding: 8px 14px; font-size: 13px;
  text-align: center; box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.offline-mode-banner.hidden { display: none !important; }
body.offline-mode.has-offline-banner #workspace { margin-top: 36px; }
body.offline-mode.has-offline-banner #topbar { margin-top: 36px; }

body.has-banner #workspace { margin-top: 56px; }

#pages {
  flex: 0 0 auto; max-height: 38vh; overflow-y: auto;
  background: var(--panel); padding: 12px;
}
#pages.pages-full { max-height: none; flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
#pages.pages-full .page:not(.hidden):not(.page-chat) { flex: 0 0 auto; width: 100%; }
#pages.pages-full .page-chat:not(.hidden) { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.page.hidden { display: none !important; }
.page-chat { display: flex; flex-direction: column; min-height: 280px; padding: 0 !important; background: transparent !important; height: 100%; }
.chat-home, .chat-room { flex: 1; display: flex; flex-direction: column; min-height: 0; height: 100%; }
.chat-room.hidden { display: none !important; }
.chat-home-header {
  font-size: 18px; font-weight: 800; padding: 4px 4px 10px; color: var(--accent2);
  writing-mode: horizontal-tb; white-space: nowrap;
}
.chat-home-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.chat-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 8px;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.chat-row:active { background: #0d2519; }
.chat-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: #05291c; font-weight: 800; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.chat-row-body { flex: 1; min-width: 0; }
.chat-row-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.chat-row-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row-time { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.chat-row-preview { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.chat-row-unread {
  background: var(--danger); color: #fff; border-radius: 10px; font-size: 11px;
  min-width: 18px; height: 18px; padding: 0 5px; display: flex; align-items: center; justify-content: center;
}
.chat-room-header {
  display: flex; align-items: center; gap: 10px; padding-bottom: 8px; margin-bottom: 4px;
  border-bottom: 1px solid var(--line); font-weight: 700;
}
.chat-room .chat-list { flex: 1; padding: 4px 0; min-height: 0; overflow-y: auto; }
.chat-room .chat-input {
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 30;
  margin: 0 -12px -12px;
  padding: 10px 12px calc(14px + var(--safe-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.35);
}
.page-chat .chat-list { flex: 1; min-height: 120px; }
.icon-btn.recording { background: var(--danger) !important; color: #fff; }
.hidden { display: none !important; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.card-title,
.chat-home-header,
.chat-room-header,
.modal-card h3,
.modal-card h4,
details.card > summary,
details.card > summary.card-title {
  writing-mode: horizontal-tb;
  text-orientation: mixed;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}
.card-title { font-weight: 700; margin-bottom: 6px; }
details.card > summary.card-title {
  display: flex;
  flex-direction: row;
  align-items: center;
  margin-bottom: 0;
}
details.card summary { cursor: pointer; list-style: none; }
details.card summary::-webkit-details-marker { display: none; }
.sep-line { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }

.row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.row.spread { justify-content: space-between; }
.row.gap { gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.small.warn { color: #ffb74d; }
.small.ok { color: #81c784; }
.radio-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 14px; }

input[type=text], input[type=tel], input[type=number], select {
  width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line);
  background: #0d2519; color: var(--text); font-size: 14px; margin: 4px 0;
}
select { width: auto; min-width: 120px; }
input[type=color] { width: 48px; height: 36px; padding: 2px; border-radius: 8px; cursor: pointer; }
input[type=range] { width: 100%; accent-color: var(--accent); }

.btn {
  background: var(--accent); color: #05291c; border: 0; border-radius: 9px;
  padding: 10px 14px; font-weight: 700; cursor: pointer; font-size: 14px;
}
.btn.ghost { background: transparent; color: var(--accent2); border: 1px solid var(--accent2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.full { width: 100%; margin-top: 6px; }
.icon-btn { background: transparent; border: 0; font-size: 22px; cursor: pointer; color: var(--text); padding: 6px; }
.icon-btn.send { color: var(--accent2); }

.floor-cal { font-size: 13px; display: flex; align-items: center; gap: 4px; }
.floor-input { width: 64px; padding: 6px 8px; margin: 0; border-radius: 8px; border: 1px solid var(--line); background: #0d2519; color: var(--text); font-size: 14px; text-align: center; }

.ptt {
  width: 100%; height: 80px; border-radius: 16px; border: 0; cursor: pointer;
  background: var(--accent); color: #05291c; font-size: 17px; font-weight: 800; margin: 6px 0;
  user-select: none; touch-action: none;
}
.ptt.active { background: var(--danger); color: #fff; }

.peer-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.dial-status { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,.05); min-height: 1.2em; }
.dial-status.ok { color: #81c784; }
.dial-status.err { color: #ef9a9a; }
.dial-status.busy { color: #ffd54f; }
.peer-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; background: #0d2519; border-radius: 8px; }

.skill-list { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.65; }
.skill-list li { margin-bottom: 6px; }
.page-section { font-size: 15px; font-weight: 700; color: var(--accent2); margin: 16px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.page-section:first-child { margin-top: 0; }
.card-danger { border-color: var(--danger); }
.med-preview { margin-top: 8px; padding: 10px; background: #0d2519; border-radius: 8px; border: 1px solid var(--line); white-space: pre-wrap; }

.sos-flash {
  position: fixed; inset: 0; z-index: 100; background: #000;
  display: flex; align-items: center; justify-content: center;
}
.sos-flash.on { background: #fff; }
.sos-flash-inner { text-align: center; color: #fff; }
.sos-flash.on .sos-flash-inner { color: #000; }
.sos-flash-text { font-size: 48px; font-weight: 900; letter-spacing: 8px; }
.sos-flash-inner p { opacity: .8; font-size: 14px; }
.peer-stale { opacity: .65; border: 1px dashed var(--muted); }
.peer-stale-tag { color: var(--warn); font-size: 11px; }

.chat-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; min-height: 120px; padding: 4px 0; }
.chat-date-sep { text-align: center; font-size: 11px; color: var(--muted); margin: 10px 0 6px; }
.chat-row-wrap { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; }
.chat-row-wrap.me { flex-direction: row-reverse; align-self: flex-end; }
.chat-row-wrap.them { align-self: flex-start; }
.chat-mini-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: #1a4d35; color: var(--accent2); font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.bubble { max-width: 78%; padding: 9px 12px; border-radius: 16px; font-size: 14px; word-break: break-word; position: relative; }
.bubble.me { background: #1f6f4a; border-bottom-right-radius: 4px; }
.bubble.them { background: #16382a; border-bottom-left-radius: 4px; }
.bubble .who { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.bubble img { max-width: 200px; border-radius: 8px; }
.bubble .voice { cursor: pointer; }
.bubble .voice-audio { display: block; max-width: 240px; min-width: 180px; height: 40px; margin: 4px 0; }
.chat-input { display: flex; align-items: center; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line); flex-shrink: 0; }
.chat-input .icon-btn { min-width: 44px; min-height: 44px; }
.chat-input input[type=text] { margin: 0; flex: 1; }
.icon-btn.recording { color: var(--danger); }

.switch { position: relative; display: inline-block; width: 52px; height: 30px; flex-shrink: 0; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider { position: absolute; inset: 0; background: #3a4d44; border-radius: 30px; transition: .2s; }
.slider:before { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(22px); }

.banner {
  position: absolute; top: 10px; left: 10px; right: 10px; z-index: 20;
  background: var(--warn); color: #fff; padding: 10px 12px; border-radius: 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.banner.danger { background: var(--danger); }
.emergency-links { display: flex; gap: 6px; }
.emergency-links .btn { background: #fff; color: var(--danger); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.75); z-index: 300; display: flex; align-items: center; justify-content: center; padding: 12px; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: 88%; max-width: 360px; }
.modal-card h3 { margin: 0 0 8px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }

.my-code { font-size: 24px; font-weight: 800; letter-spacing: 3px; color: var(--accent2); font-family: monospace; }
.code-area { width: 100%; min-height: 56px; resize: vertical; margin: 6px 0; padding: 8px; border-radius: 9px; border: 1px solid var(--line); background: #0d2519; color: var(--text); font-family: monospace; font-size: 11px; word-break: break-all; }
.qr-img {
  display: flex; align-items: center; justify-content: center;
  width: min(320px, 88vw); aspect-ratio: 1;
  margin: 12px auto; padding: 14px;
  background: #fff; border-radius: 12px; box-sizing: border-box;
}
.qr-img canvas.qr-canvas,
.qr-img img, .qr-img svg {
  display: block; width: 100% !important; height: 100% !important;
  max-width: 100%; max-height: 100%;
  aspect-ratio: 1; object-fit: contain;
  image-rendering: pixelated; image-rendering: crisp-edges;
}
.region-map-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.region-map-btn { flex: 1 1 auto; min-width: 42%; }
.nested-details { margin-top: 8px; padding: 8px; background: rgba(0,0,0,.15); border-radius: 8px; }
.map-download-status.ok { color: var(--accent2); }
.map-download-status.warn { color: #ffb74d; }
.map-download-status.bad { color: var(--danger); }
.map-download-status.busy { color: var(--muted); }
.card-install .link-btn-block { display: block; text-align: center; text-decoration: none; margin-top: 6px; }
.card-install #installIosBtn { margin-bottom: 6px; }
.geofence-status.bad { color: var(--danger); font-weight: 600; }

.voice-path-guide { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 8px; line-height: 1.4; }
.voice-path-guide.ok { color: #81c784; border-color: #2e7d32; }
.voice-path-guide.warn { color: #ffb74d; border-color: #ef6c00; }
.voice-path-guide.bad { color: #ef9a9a; border-color: #c62828; }
.mix-scenario-panel { margin-top: 8px; }
.mix-scenario-table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.mix-scenario-table th, .mix-scenario-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.mix-scenario-table th { color: var(--accent); font-weight: 600; }
.mix-scenario-table td:first-child { white-space: nowrap; }
.team-status-banner { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); margin: 8px 0; background: rgba(46,125,50,.12); }
.sos-queue-status.warn { color: #ffb74d; }
.qr-code-text { max-height: 120px; font-size: 10px; }
.qr-modal-card { max-width: 400px; }
.qr-no-img { color: var(--muted); font-size: 13px; text-align: center; padding: 24px 8px; }
.qr-loading { font-size: 42px; line-height: 1; padding: 40px 0; text-align: center; }
.scan-video-wrap {
  position: relative; width: 100%; background: #000; border-radius: 10px; overflow: hidden;
  min-height: min(62vh, 520px); aspect-ratio: 4 / 3;
}
.scan-video {
  width: 100%; height: 100%; min-height: min(58vh, 480px);
  display: block; object-fit: contain; background: #000;
}
.scan-viewfinder {
  position: absolute; inset: 12% 10%; border: 2px solid rgba(124, 245, 192, 0.85);
  border-radius: 12px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.scan-status { margin: 0 0 8px; text-align: center; line-height: 1.4; }
.scan-zoom-row { display: flex; gap: 8px; justify-content: center; margin: 0 0 6px; }
.scan-zoom-btn.active { background: var(--accent); color: #05291c; font-weight: 700; }
.scan-tip { text-align: center; margin: 0 0 8px; font-size: 11px; }
.scan-modal-card { max-width: min(520px, 98vw); }
code { background: #0d2519; padding: 1px 5px; border-radius: 5px; font-size: 12px; }

.conv-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; flex-shrink: 0; }
.conv-chip { flex: 0 0 auto; padding: 6px 12px; border-radius: 16px; background: #0d2519; border: 1px solid var(--line); color: var(--text); cursor: pointer; font-size: 13px; position: relative; }
.conv-chip.active { background: var(--accent); color: #05291c; font-weight: 700; }
.conv-chip .unread { position: absolute; top: -4px; right: -4px; background: var(--danger); color: #fff; border-radius: 10px; font-size: 10px; padding: 0 5px; }
.sep { align-self: center; background: #0d2519; border: 1px solid var(--line); color: var(--muted); font-size: 11px; padding: 3px 12px; border-radius: 12px; margin: 8px 0; }
.bubble .meta { font-size: 10px; color: var(--muted); margin-top: 2px; text-align: right; }
.lora-tag {
  display: inline-block; font-size: 10px; font-weight: 600;
  background: #5d4037; color: #ffcc80; padding: 2px 7px; border-radius: 4px; margin-top: 4px;
}
.rally-all-btn { background: #1565C0; color: #fff; margin-bottom: 10px; }
.rally-flash-marker {
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(21, 101, 192, 0.45); border: 3px solid #fff;
  box-shadow: 0 0 20px rgba(21, 101, 192, 0.85);
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.rally-flash-marker.pulse { transform: scale(1.35); opacity: 1; }
#mapArea.map-rally-flash { animation: mapRallyFlash 0.55s ease 3; }
@keyframes mapRallyFlash {
  0%, 100% { box-shadow: inset 0 0 0 0 rgba(21, 101, 192, 0); }
  50% { box-shadow: inset 0 0 70px 10px rgba(21, 101, 192, 0.5); }
}
.health-badge { cursor: pointer; }
.quality-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 13px; }
.quality-body { max-height: 60vh; overflow-y: auto; }
.mesh-hint-card { border-color: #2c5a47; }
.vq-lights { display: flex; align-items: center; gap: 8px; padding: 8px 0; flex-wrap: wrap; }
.vq-dot { width: 14px; height: 14px; border-radius: 50%; background: #444; border: 2px solid #222; }
.vq-dot.ok { background: #25d366; box-shadow: 0 0 6px #25d366; }
.vq-dot.warn { background: #ffb74d; }
.vq-dot.off { background: #555; }
.vq-label { font-size: 12px; color: var(--muted); }
.vq-tip { flex: 1; min-width: 120px; }
.geo-accuracy { font-size: 12px; margin: 6px 0; color: var(--muted); }
.geo-accuracy.good { color: #81c784; }
.geo-accuracy.warn { color: #ffb74d; }
.geo-accuracy.bad { color: #ef5350; }
.rally-nav-tag { font-size: 10px; background: #1565C0; color: #fff; padding: 1px 6px; border-radius: 4px; }
.code-area {
  width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: #0d2519; color: var(--text); font-size: 13px;
}
.chat-row-name { font-weight: 600; }
.maplibregl-popup-content { color: #111; }

@media (min-width: 900px) {
  #body { flex-direction: row; }
  .map-area { flex: 1; min-height: 0; border-bottom: 0; border-right: 1px solid var(--line); }
  #pages { flex: 0 0 400px; max-height: none; overflow-y: auto; }
  #pages.pages-full { flex: 1; max-width: 520px; }
}

@media (max-width: 899px) {
  #pages { max-height: 42vh; padding-bottom: var(--safe-bottom); }
  #pages.pages-full { max-height: none; flex: 1; min-height: 0; padding-bottom: 0; }
  #pages.pages-full .page-chat:not(.hidden) { min-height: 0; }
  .map-area.hidden + #pages { max-height: none; flex: 1; }
  .chat-room .chat-input { margin: 0; padding-left: 8px; padding-right: 8px; }
}

/* v82: 全平台對齊 APK 原生 — 僅底部五分頁，無側欄／頂欄 */
body.apk-shell #sidebar,
body.apk-shell #menuBtn,
body.apk-shell #topbar { display: none !important; }
body.apk-shell #bottomNav { display: grid !important; }
body.apk-shell #app { flex-direction: column; }
body.apk-shell #workspace {
  padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  padding-top: env(safe-area-inset-top, 0px);
}
body.apk-shell #pages.pages-full { max-height: none; flex: 1; min-height: 0; }
body.apk-shell #pages { flex: 1; min-height: 0; overflow-y: auto; }
.walkie-status-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.walkie-device-name { margin-top: 4px; padding-left: 20px; font-size: 13px; color: #a5d6a7; }
.walkie-status-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; background: #616161; }
#walkieStatusText { font-weight: 700; font-size: 17px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.apk-shell #walkieRelayLine { display: none !important; }
.relay-chip { font-size: 12px; color: #00897B; white-space: nowrap; }
.audio-route-btn.active { background: #1a4d35; color: var(--accent2); font-weight: 700; }

/* v107: APK layout parity */
body.apk-shell #page-walkie,
body.apk-shell #page-map,
body.apk-shell #page-safety,
body.apk-shell #page-settings {
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}
body.apk-shell .card {
  background: #163325;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 8px;
}
body.apk-shell .card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}
body.apk-shell .card-title.sub {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 8px;
  margin-bottom: 6px;
}
body.apk-shell .walkie-status-card {
  background: #11271d;
}
body.apk-shell .ptt-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 16px 0 8px;
}
body.apk-shell #pttBtn.ptt,
body.apk-shell .ptt {
  width: min(88vw, 280px);
  height: 88px;
  border-radius: 44px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 16px rgba(37, 211, 102, 0.35);
  margin: 0;
}
body.apk-shell .ptt.active {
  box-shadow: 0 4px 18px rgba(229, 57, 53, 0.45);
}
body.apk-shell .ptt-hint {
  text-align: center;
  margin: 8px 0 0;
}
body.apk-shell .walkie-adv-fold {
  margin-top: 8px;
}
body.apk-shell .walkie-adv-fold > summary {
  cursor: pointer;
  list-style: none;
}
body.apk-shell .map-drag-hint {
  margin: 0 0 8px;
  text-align: center;
}
body.apk-shell .audio-route-row .btn {
  flex: 1;
  min-width: 0;
}
body.mixed-team-apk #audioRouteCard {
  opacity: 0.55;
  pointer-events: none;
}
