:root {
  --blue: #3C50E0; --navy: #07167B; --teal: #0B4C7C; --alert: #C8322B;
  --bg: #1B1C1B; --card: #313231; --line: #484848; --muted: #C9C9CC; --quiet: #9C9C9E;
  --tint: #DADFFA; --white: #FFFFFF;
  --display: 'Manrope', system-ui, sans-serif; --body: 'Inter', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #0E0F0E; color: var(--white); font-family: var(--body); }
body { display: flex; justify-content: center; overscroll-behavior: none; }
#app { width: 100%; max-width: 480px; height: 100dvh; background: var(--bg); display: flex; flex-direction: column;
  position: relative; overflow: hidden; user-select: none; -webkit-user-select: none; }
button, a.btn { font: inherit; color: inherit; border: none; background: none; cursor: pointer; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.screen { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 10px 16px 16px; min-height: 0; }
.statusrow { display: flex; align-items: center; justify-content: space-between; min-height: 28px; font-size: 13px; color: var(--muted); }
.statusrow .left, .statusrow .right { display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--blue); display: inline-block; }
.dot.off { background: none; border: 2px solid var(--quiet); }
.card { background: var(--card); border-radius: 16px; padding: 12px 16px; }
.channel { display: flex; align-items: center; gap: 4px; padding: 14px 6px; }
.channel .mid { flex: 1; text-align: center; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
/* channel names wrap (up to 3 lines) instead of being cut short */
.chname { font-family: var(--display); font-weight: 700; font-size: 27px; line-height: 1.15; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.sub { font-size: 13px; color: var(--muted); }
.navbtn { width: 48px; height: 64px; display: flex; align-items: center; justify-content: center; border-radius: 12px; }
.navbtn:active { background: var(--line); }
.lastcall { display: flex; align-items: center; gap: 12px; }
.lastcall .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lastcall .name { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ghost { min-width: 96px; height: 48px; border-radius: 10px; border: 1px solid #7B7B7B !important; display: inline-flex; align-items: center;
  justify-content: center; gap: 6px; font-weight: 600; font-size: 15px; padding: 0 12px; }
.ghost:active { background: var(--line); }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tile { height: 64px; border-radius: 12px; background: var(--card); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; font-size: 13px; font-weight: 600; position: relative; }
.tile:active { background: var(--line); }
.tile .badge { position: absolute; top: 6px; right: 8px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--blue);
  font-size: 12px; display: flex; align-items: center; justify-content: center; padding: 0 6px; }
.tile.sos { background: var(--alert); }
.tile.sos .big { font-family: var(--display); font-size: 18px; font-weight: 800; letter-spacing: .06em; }
.tile.active { outline: 2px solid var(--blue); }
.spacer { flex: 1; min-height: 8px; }
.ptt { min-height: 170px; flex: 0 0 auto; border-radius: 24px; background: var(--card); border: 2px solid var(--blue);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; touch-action: none; }
.ptt .label { font-family: var(--display); font-size: 22px; font-weight: 700; }
.ptt.talking { background: var(--blue); }
.ptt.busy { border-color: var(--line); color: var(--muted); }
.ptt.offline { border: 2px dashed #7B7B7B; color: var(--muted); }
.ptt.call { border-color: var(--teal); }
.rxpanel { background: var(--navy); border: 2px solid var(--blue); border-radius: 16px; padding: 16px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px; }
.rxpanel .who { font-family: var(--display); font-weight: 800; font-size: 28px; line-height: 1.1; }
.rxpanel .tint { color: var(--tint); }
.bars { display: flex; gap: 4px; align-items: flex-end; height: 28px; }
.bars span { width: 6px; border-radius: 3px; background: #6474E7; transition: height .08s; }
.banner { background: var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.banner.call { background: var(--teal); flex-direction: row; align-items: center; justify-content: space-between; }
.banner.alarm { background: var(--alert); }
.banner.ticket { background: var(--teal); flex-direction: row; align-items: center; justify-content: space-between; }
.banner b { font-size: 16px; }
.header { display: flex; align-items: center; justify-content: space-between; min-height: 48px; }
.header h1 { font-family: var(--display); font-size: 22px; font-weight: 700; margin: 0; }
.iconbtn { width: 48px; height: 48px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; }
.iconbtn:active { background: var(--line); }
.list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 0; flex: 1; padding-bottom: 8px; }
.row { background: var(--card); border-radius: 12px; min-height: 64px; display: flex; align-items: center; gap: 12px; padding: 8px 12px; width: 100%; text-align: left; }
.row.sel { background: var(--navy); border: 2px solid var(--blue); }
.num { width: 36px; height: 36px; border-radius: 8px; background: var(--line); display: flex; align-items: center; justify-content: center; font-weight: 600; flex: none; }
.row.sel .num { background: var(--blue); }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.grow .t { font-size: 17px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch { width: 52px; height: 30px; border-radius: 999px; background: var(--line); position: relative; flex: none; }
.switch::after { content: ''; position: absolute; left: 4px; top: 4px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: .15s; }
.switch.on { background: var(--blue); }
.switch.on::after { left: 26px; background: var(--white); }
.note { font-size: 13px; color: var(--muted); line-height: 1.45; }
.smallbtn { height: 40px; padding: 0 12px; border-radius: 10px; background: var(--line); font-weight: 600; font-size: 14px; }
.smallbtn.blue { background: var(--blue); }
.msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.bubble { max-width: 85%; background: var(--card); border-radius: 14px; padding: 8px 12px; align-self: flex-start; }
.bubble.me { align-self: flex-end; background: var(--navy); }
.bubble .from { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.composer { display: flex; gap: 8px; }
.composer input, .field input { flex: 1; height: 48px; border-radius: 10px; border: 1px solid var(--line); background: #111; color: #fff;
  padding: 0 12px; font: inherit; font-size: 16px; }
.overlay { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; }
.sosscreen { background: var(--alert); align-items: center; text-align: center; gap: 16px; padding: 48px 24px 24px; }
.sosscreen h2 { font-family: var(--display); font-size: 28px; font-weight: 800; margin: 0; }
.ring { position: relative; width: 220px; height: 220px; }
.ring .val { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring .val b { font-family: var(--display); font-size: 56px; font-weight: 800; line-height: 1; }
.modal { position: absolute; inset: 0; background: rgba(0,0,0,.7); z-index: 30; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal .box { background: var(--card); border-radius: 16px; padding: 20px; width: 100%; display: flex; flex-direction: column; gap: 12px; }
.modal .box.alert { border: 3px solid var(--alert); }
.modal h3 { font-family: var(--display); margin: 0; font-size: 20px; }
.toast { position: absolute; left: 16px; right: 16px; bottom: 200px; background: #000; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; z-index: 40; font-size: 15px; text-align: center; pointer-events: none; }
/* with a dialog open, the toast moves to the top so it never covers the dialog's buttons */
.modal ~ .toast { top: 8px; bottom: auto; }
/* sign-in screens scroll on short screens; auto margins centre them when they fit */
.start { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: 24px; overflow-y: auto; min-height: 0; }
.start > :first-child { margin-top: auto; }
.start > :last-child { margin-bottom: auto; }
.start > * { flex: none; }
.signedout { text-align: left; }
.start h1 { font-family: var(--display); font-size: 26px; margin: 0; }
.bigbtn { height: 56px; border-radius: 12px; background: var(--blue); font-weight: 700; font-size: 17px; width: 100%; }
.bigbtn:disabled { opacity: .5; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); }
.err { color: #FF9C96; font-size: 14px; }
.chip { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 13px; font-size: 12px; font-weight: 600; }

.bubble img.pic { display: block; max-width: 100%; max-height: 240px; border-radius: 10px; margin-top: 6px; }
.composer .attach { height: 48px; width: 48px; display: inline-flex; align-items: center; justify-content: center; flex: none; cursor: pointer; }
/* sign-in and enrolment forms stack vertically: keep inputs at full height */
form.field { flex-direction: column; }
form.field input { flex: none; }

/* account button and Me screen */
.mebtn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 16px; background: var(--card); color: #fff; font-size: 13px; font-weight: 600; }
.mecard { text-align: center; padding: 18px; }
.mebig { font-family: var(--display); font-size: 26px; font-weight: 700; color: #fff; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { text-align: right; font-weight: 600; overflow-wrap: anywhere; }
.ghost.danger { color: var(--alert); border-color: var(--alert) !important; }
.bigbtn.danger { background: var(--alert); }

/* ---------- compact layout for small screens (eTera E980, 240 x 320) ---------- */
.compact .screen { gap: 6px; padding: 4px 8px 8px; }
.compact .statusrow { min-height: 26px; font-size: 12px; }
.compact .statusrow .left span:not(.dot) { display: none; }
.compact .mebtn { height: 26px; font-size: 12px; padding: 0 8px; }
.compact .mebtn svg { width: 14px; height: 14px; }
.compact .card { border-radius: 12px; padding: 8px 10px; }
.compact .channel { padding: 4px 2px; }
.compact .navbtn { width: 36px; height: 52px; }
.compact .chname { font-size: 20px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.compact .eyebrow { font-size: 11px; }
.cstrip { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 30px; padding: 4px 10px; border-radius: 8px;
  background: var(--line); font-size: 13px; font-weight: 600; text-align: left; width: 100%; }
.cstrip.alarm { background: var(--alert); }
.cstrip.call { background: var(--teal); }
.cstrip button { height: 26px; padding: 0 10px; border-radius: 6px; background: rgba(255,255,255,.18); font-size: 12px; font-weight: 700; }
.clast { display: flex; align-items: center; gap: 6px; padding: 0 4px; min-height: 40px; }
.clast .info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.clast .name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clast .iconbtn { width: 40px; height: 40px; background: var(--card); }
.crx { background: var(--navy); border: 2px solid var(--blue); border-radius: 12px; padding: 6px 10px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.crx .who { font-family: var(--display); font-weight: 800; font-size: 20px; line-height: 1.15; overflow-wrap: anywhere; }
.crx .tint { font-size: 12px; }
.crow { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.compact .tile { height: 44px; flex-direction: row; gap: 6px; font-size: 14px; border-radius: 10px; }
.compact .tile .badge { position: static; }
.compact .tile.sos .big { font-size: 16px; }
.compact .tile .hold { font-size: 10px; font-weight: 500; }
.compact .ptt { min-height: 64px; border-radius: 14px; gap: 0; }
.compact .ptt svg { display: none; }
.compact .ptt .label { font-size: 17px; }
.compact .ptt .sub { font-size: 11px; text-align: center; padding: 0 6px; }
.compact .header { min-height: 40px; }
.compact .header h1 { font-size: 18px; }
.compact .iconbtn { width: 40px; height: 40px; }
.compact .list { gap: 4px; }
.compact .row { min-height: 44px; border-radius: 10px; padding: 4px 10px; gap: 8px; }
.compact .grow .t { font-size: 15px; }
.compact .num { width: 28px; height: 28px; }
.compact .switch { width: 44px; height: 26px; }
.compact .switch::after { width: 18px; height: 18px; }
.compact .switch.on::after { left: 22px; }
.compact .toast { bottom: 80px; left: 8px; right: 8px; padding: 8px 10px; font-size: 13px; }
.compact .modal { padding: 8px; }
.compact .modal .box { padding: 12px; gap: 8px; }
.compact .modal h3 { font-size: 17px; }
.compact .bigbtn { height: 44px; font-size: 15px; }
.compact .ghost { height: 40px; font-size: 14px; min-width: 0; }
.compact .start { padding: 12px; gap: 8px; }
.compact .start h1 { font-size: 20px; }
.compact .composer input, .compact .field input { height: 40px; font-size: 15px; }
.compact .composer .attach { height: 40px; width: 40px; }
.compact .mecard { padding: 10px; }
.compact .mebig { font-size: 20px; }
.compact .kv { padding: 5px 0; font-size: 12px; }
.compact .banner { padding: 6px 10px; }
.compact .sosscreen { padding: 16px 12px 12px; gap: 8px; }
.compact .sosscreen h2 { font-size: 20px; }
.compact .ring { width: 150px; height: 150px; }
.compact .ring svg { width: 150px; height: 150px; }
.compact .ring .val b { font-size: 40px; }
.compact .lastcall { gap: 8px; }
.compact .bubble { padding: 6px 10px; font-size: 14px; }
.alarmscr { padding-top: 0 !important; }
.alarmhead { margin: 0 -16px; background: var(--alert); padding: 18px 16px 14px; }
.compact .alarmhead { margin: 0 -8px; padding: 8px 10px; }
.compact .alarmhead div:last-child { font-size: 19px !important; }
.compact .alarmscr .card.lastcall { padding: 6px 8px; }
.compact .alarmscr .card.lastcall svg { width: 18px; height: 18px; flex: none; }
.smallbtn .narrow { display: none; }
.compact .smallbtn { width: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.compact .smallbtn .wide { display: none; }
.compact .smallbtn .narrow { display: inline-flex; }
.compact .hide-compact { display: none; }
.ctalk { background: var(--blue); border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.ctalk .who { font-family: var(--display); font-weight: 800; font-size: 22px; }
.ctalk .eyebrow { color: #fff; }
.chint { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.35; padding: 0 4px; }
.compact .tile.cmenu { height: 44px; width: 100%; }
.composer input { min-width: 0; }
.compact .composer { gap: 4px; }
.compact .composer .smallbtn.blue { width: auto; padding: 0 10px; height: 40px !important; }
.startlogo { height: 120px; width: auto; display: block; margin: 0 auto 4px; }
.compact .startlogo { height: 72px; }

/* ---------- home and alarm: content scrolls, PTT (and SOS on short screens) stay pinned ---------- */
.screen.home, .screen.alarmscr { overflow: hidden; }
.scrollpart { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.scrollpart > * { flex-shrink: 0; }
.scrollpart > .rxpanel { flex: 1 0 auto; }
.pttarea { flex: none; display: flex; gap: 10px; align-items: stretch; }
.pttarea .ptt { flex: 1; min-width: 0; }
.tile.sos-foot { width: 84px; height: auto; flex: none; }
.alarmfoot { flex-direction: column; }
.mescreen { overflow-y: auto; }
.mescreen > * { flex-shrink: 0; }
@media (max-height: 700px) {
  .ptt { min-height: 104px; gap: 4px; }
  .ptt svg { width: 30px; height: 30px; }
  .ptt .label { font-size: 19px; }
  .screen { gap: 10px; }
  .scrollpart { gap: 10px; }
  .alarmhead { padding: 12px 16px 10px; }
}
/* compact (E980): no on-screen PTT/SOS; the whole screen scrolls when it must */
.compact .scrollpart { gap: 6px; }
.compact .grow .t { white-space: normal; overflow-wrap: anywhere; text-overflow: clip; line-height: 1.2; }
.compact .chname { font-size: 18px; -webkit-line-clamp: 3; }
.compact .alarmscr .card.lastcall .sub { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compact .alarmscr .card.lastcall.loc .sub { display: none; }
.compact .alarmscr .card.lastcall b { font-size: 13px; }
.compact .alarmfoot { gap: 6px; }
.compact .modal ~ .toast { top: 4px; bottom: auto; }
.compact .chome { overflow-y: auto; }
.compact .chome > * { flex-shrink: 0; }
/* list rows grow with wrapped text instead of being squeezed */
.list > * { flex-shrink: 0; }
