/* ==========================================================================
   NotifySync dashboard
   One theme: white content, navy chrome, slate rail, cyan accents.
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-soft: #f5f7fa;
  --panel: #ffffff;
  --panel-2: #f7f9fb;
  --panel-3: #eef2f6;
  --text: #333333;
  --text-strong: #2a3540;
  --muted: #7c8a99;
  --faint: #9aa7b4;
  --line: #e7ecf1;
  --line-strong: #d6dee7;
  --brand: #3598dc;
  --brand-2: #36c6ee;
  --brand-3: #32c5d2;
  --brand-soft: rgba(53, 152, 220, 0.12);
  --ok: #26c281;
  --warn: #f3c200;
  --danger: #e7505a;
  --danger-soft: rgba(231, 80, 90, 0.1);
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 14px 34px -14px rgba(43, 54, 67, 0.3);
  --shadow-soft: 0 2px 10px rgba(43, 54, 67, 0.07);
  --sidebar: 238px;
  --topbar: 56px;
  --chrome: #2b3643;
  --chrome-2: #364150;
  --font: "Open Sans", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
.block { width: 100%; }

::selection { background: rgba(53, 152, 220, 0.28); }

html { scroll-behavior: smooth; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 2px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-track { background: transparent; }

/* A tab reveal fades the page up gently; reduced-motion users get none of it. */
.view:not([hidden]) { animation: viewIn 0.22s ease; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .view:not([hidden]) { animation: none; }
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 2px;
}

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 2px; }

/* ==========================================================================
   Auth screen
   ========================================================================== */

.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(420px, 0.85fr);
}

.auth-aside {
  position: relative;
  overflow: hidden;
  padding: 40px 48px;
  display: flex;
  flex-direction: column;
  gap: 34px;
  color: #fff;
  background:
    radial-gradient(760px 480px at 82% 12%, rgba(255, 255, 255, 0.14), transparent 62%),
    radial-gradient(700px 520px at 12% 100%, rgba(20, 90, 140, 0.55), transparent 64%),
    linear-gradient(150deg, #3598dc 0%, #2a7fb9 58%, #1f6a9e 100%);
}

.auth-aside::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(circle at 30% 30%, black, transparent 78%);
  mask-image: radial-gradient(circle at 30% 30%, black, transparent 78%);
  pointer-events: none;
}

.auth-brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand strong { display: block; font-size: 17px; letter-spacing: -0.02em; color: #fff; }
.auth-brand span:last-child { display: block; font-size: 12px; color: rgba(255, 255, 255, 0.75); }

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #fff;
  background: var(--brand-2);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.14);
  flex: none;
}

.auth-copy {
  position: relative;
  z-index: 1;
  margin-top: auto;
  display: grid;
  gap: 18px;
  max-width: 560px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 2px;
  font-size: 11.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #eaf7fd;
  background: rgba(255, 255, 255, 0.1);
}

.auth-copy h1 {
  font-size: clamp(32px, 3.9vw, 50px);
  font-weight: 600;
  color: #fff;
}

.auth-copy h1 span {
  color: #c9f2fb;
}

.auth-copy > p:not(.eyebrow) { max-width: 48ch; font-size: 15px; }

.auth-copy > p.muted { color: rgba(255, 255, 255, 0.88); }

.auth-points {
  position: relative;
  z-index: 1;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  font-size: 13.5px;
  color: rgba(255, 255, 255, 0.92);
}

.auth-points li { display: flex; align-items: center; gap: 10px; }

.tick {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex: none;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.42);
}

.tick::after {
  content: "";
  width: 8px;
  height: 4px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}

.auth-stats {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 38px;
  margin-top: auto;
  padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.22);
}

.auth-stats strong { display: block; font-size: 21px; color: #fff; }
.auth-stats span { font-size: 11.5px; color: rgba(255, 255, 255, 0.74); }

.auth-main {
  display: grid;
  place-items: center;
  padding: 40px 32px;
  background: var(--bg-soft);
}

.auth-card {
  width: min(430px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-3);
}

.auth-tab {
  border: 0;
  padding: 9px 10px;
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s ease, color 0.15s ease;
}

.auth-tab.active {
  color: #fff;
  background: var(--brand);
}

.auth-form { display: grid; gap: 14px; }
.auth-form h2 { font-size: 22px; }
.auth-form .field { margin-top: 2px; }
.auth-form .btn { margin-top: 4px; }

.auth-hint { font-size: 12px; line-height: 1.55; color: var(--faint); margin-top: 2px; }

.auth-card-foot {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--panel-2);
}

.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 58px; }

.pw-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 2px;
}

.pw-toggle:hover { color: var(--text); background: var(--panel-3); }


/* ==========================================================================
   App shell
   ========================================================================== */

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.app-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: var(--topbar);
  height: calc(100dvh - var(--topbar));
  display: flex;
  flex-direction: column;
  padding: 6px 0 14px;
  background: var(--chrome-2);
  color: #c5ced8;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  min-width: 0;
}

.brand .brand-mark {
  /* A 320 px phone has no room to spare: the row used to shrink the logo tile
     down to a 3 px sliver. The mark keeps its box, the text is what gives. */
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-2);
  box-shadow: none;
}

.brand strong { display: block; font-size: 17px; line-height: 1.1; letter-spacing: -0.02em; color: #fff; font-weight: 600; }
.brand-text > span:last-child { display: block; font-size: 10.5px; color: rgba(255, 255, 255, 0.62); }

.nav { flex: 1; overflow-y: auto; padding: 6px 0; }

.nav-label {
  margin: 14px 18px 5px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8592a0;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  border-left: 3px solid transparent;
  color: #c5ced8;
  font-size: 13.5px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item svg { flex: none; opacity: 0.9; }
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, 0.055); }

.nav-item.active {
  color: #fff;
  background: var(--brand-2);
  border-left-color: #1fa9d1;
}

/* The reference highlights the active row with a notch cut out of the rail. */
.nav-item.active::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 10px;
  background: var(--bg);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  pointer-events: none;
}

.nav-item.active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 8px;
  border-radius: 999px;
  font-style: normal;
  font-size: 10.5px;
  font-weight: 700;
  text-align: center;
  color: #c5ced8;
  background: rgba(255, 255, 255, 0.1);
}

.nav-badge:empty { display: none; }
.nav-item.active .nav-badge { color: #fff; background: rgba(255, 255, 255, 0.26); }

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 14px 12px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.user-meta { min-width: 0; flex: 1; }
.user-meta strong { display: block; font-size: 12.8px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta span { display: block; font-size: 11px; color: #8d9aa8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-foot .icon-btn {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.14);
  color: #b7c2cc;
}

.sidebar-note { font-size: 10.8px; line-height: 1.5; color: #8592a0; padding: 0 4px; }

.avatar {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex: none;
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
  background: var(--brand-2);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.avatar.sm { width: 30px; height: 30px; font-size: 11.5px; }
.avatar.lg { width: 46px; height: 46px; font-size: 15px; }

.shell { min-width: 0; display: flex; flex-direction: column; background: var(--bg); }


.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: var(--chrome);
  border-bottom: 1px solid rgba(0, 0, 0, 0.22);
  color: #c8d2dc;
}

.page-head { max-width: 1480px; margin: 0 auto 22px; }
.page-head h1 { font-size: 24px; font-weight: 600; color: var(--text-strong); letter-spacing: -0.02em; }
.page-head p { margin-top: 3px; font-size: 13px; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* The one switch that scopes every view to a single phone. */
.device-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
  color: #9fb0bf;
}

.device-switch select {
  max-width: 200px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 2px;
  color: #dbe4ec;
  padding: 5px 8px;
  font-size: 12px;
}

.device-switch select:hover { background: rgba(255, 255, 255, 0.14); }
.device-switch select:focus { outline: none; border-color: var(--brand); }
.device-switch select option { color: #333; background: #fff; }

.topbar .icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 2px;
  border-color: transparent;
  background: transparent;
  color: #c0ccd7;
}

.topbar .icon-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border-color: transparent;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 2px;
  font-size: 11.5px;
  color: #c8d2dc;
  background: rgba(255, 255, 255, 0.07);
  white-space: nowrap;
}

.live .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8592a0;
}

.live.on { color: #8fe8c3; border-color: rgba(38, 194, 129, 0.45); }
.live.on .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(38, 194, 129, 0.18); }
.live.off { color: #f2a2a7; border-color: rgba(231, 80, 90, 0.45); }
.live.off .dot { background: var(--danger); }

.dot.ok { background: var(--ok); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--muted);
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}

.icon-btn:hover { color: var(--text); background: var(--panel-3); border-color: var(--line-strong); transform: translateY(-1px); }

.avatar-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: transparent;
}

.avatar-btn:hover { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.14); }

.only-mobile { display: none; }

.menu {
  position: absolute;
  top: calc(var(--topbar) + 4px);
  right: 16px;
  width: 232px;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  z-index: 60;
  color: var(--text);
}

.menu-head { padding: 10px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 5px; }
.menu-head strong { display: block; font-size: 13px; color: var(--text-strong); }
.menu-head span { display: block; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

.menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  font-size: 13px;
}

.menu button:hover { background: var(--panel-3); }
.danger-text { color: var(--danger); }

.main { padding: 22px 26px 44px; min-width: 0; }

.view { display: grid; gap: 16px; max-width: 1480px; margin: 0 auto; }

.page-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-bar h2 { font-size: 21px; }
.page-bar p { margin-top: 3px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(43, 54, 67, 0.55);
  backdrop-filter: blur(2px);
}


/* ==========================================================================
   Buttons, fields, chips
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  box-shadow: var(--shadow-soft);
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s, box-shadow 0.15s ease;
}

.btn:hover { background: var(--panel-3); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-soft); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }

.btn.primary {
  border-color: transparent;
  color: #fff;
  background: var(--brand);
}

.btn.primary:hover { background: #2f89c8; }

.btn.ghost { background: transparent; }

.btn.subtle {
  background: var(--bg-soft);
  border-color: var(--line);
  color: var(--muted);
}

.btn.danger {
  color: var(--danger);
  border-color: rgba(231, 80, 90, 0.35);
  background: var(--danger-soft);
}

.btn.danger:hover { background: rgba(231, 80, 90, 0.18); }

.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: var(--radius-sm); }
.btn.icon { width: 34px; height: 34px; padding: 0; }

.field { display: grid; gap: 6px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--muted); }

.field input,
.field select,
.search input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input::placeholder,
.search input::placeholder { color: var(--faint); }

.field input:focus,
.field select:focus,
.search input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(53, 152, 220, 0.18);
}

.field select {
  appearance: none;
  cursor: pointer;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.form-error { min-height: 16px; font-size: 12.5px; color: var(--danger); }
.form-error:empty { display: none; }
.form-ok { font-size: 12.5px; color: var(--ok); }

.search { position: relative; flex: 1; min-width: 200px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search input { padding-left: 36px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.chip:hover { color: var(--text); border-color: var(--line-strong); }

.chip.active {
  color: #fff;
  border-color: transparent;
  background: var(--brand);
}


/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  min-width: 0;
  transition: box-shadow 0.18s ease, border-color 0.18s ease;
}

.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.card-head h3 { font-size: 15px; font-weight: 600; color: var(--text-strong); }
.card-head p { margin-top: 2px; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; }
.grid-2.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* The phone's own status, as one card: the identity head, three tone-coded
   tiles, the permission strip and a small fact footer. */
.status-card { overflow: hidden; }
.status-card .card-head { position: relative; }
.status-ident { min-width: 0; }
.status-ident h3 { overflow-wrap: anywhere; }
.status-ident p { margin-top: 2px; }

/* The icon sits on the brand gradient so the head reads as the live device. */
.status-card .status-head {
  padding: 16px 18px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
.status-card .status-head::after {
  content: '';
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--brand), var(--brand-3), transparent);
  opacity: 0.4;
}
.status-card .status-head .device-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-3));
  box-shadow: 0 8px 16px -10px rgba(53, 152, 220, 0.9);
}

.status-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

/* Each tile carries a 3px rail whose colour is the tile's tone: the battery
   level for the charge, the brand for the place and the display. */
.status-tile {
  position: relative;
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 12px 14px 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  overflow: hidden;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.status-tile::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--tone, linear-gradient(180deg, var(--brand-2), var(--brand)));
}

.status-tile:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.status-tile.tone-ok { --tone: linear-gradient(180deg, #45d59d, var(--ok)); }
.status-tile.tone-mid { --tone: linear-gradient(180deg, #f7d455, #e8a800); }
.status-tile.tone-low { --tone: linear-gradient(180deg, #f08b90, var(--danger)); }

.status-tile-label {
  display: inline-flex;
  justify-self: start;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.status-tile-label svg { flex: none; color: var(--faint); }

.status-tile-value {
  font-size: 20px;
  font-weight: 650;
  line-height: 1.2;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.status-tile-foot { margin-top: auto; font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }

/* The battery gauge: the rail behind it is the track, the fill follows the
   level and slows down instead of jumping when the phone reports a new one. */
.status-meter {
  display: block;
  height: 6px;
  margin: 6px 0 5px;
  border-radius: 999px;
  background: var(--panel-3);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
}

.status-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4ad6a3, var(--ok));
  transition: width 0.45s ease;
}

.status-tile.tone-mid .status-meter i {
  background: linear-gradient(90deg, #f8db74, #e8a800);
}

.status-tile.tone-low .status-meter i {
  background: linear-gradient(90deg, #f2a1a6, var(--danger));
}

@media (prefers-reduced-motion: no-preference) {
  /* A slow breath marks the gauge as "charging", not just "75%". */
  .status-tile.charging .status-meter i { animation: chargeBreathe 2.6s ease-in-out infinite; }
}

@keyframes chargeBreathe {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.2); }
}

.status-link {
  justify-self: start;
  margin-top: 5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--brand);
}

.status-link::after { content: '\2197'; font-size: 11px; }
.status-link:hover { color: var(--brand-3); text-decoration: underline; }

/* Permissions: a titled strip with the allowed count and a ratio bar, then the
   chips themselves. */
.status-split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px dashed var(--line-strong);
}

.status-split-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.status-count {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #1c8f5f;
  background: rgba(38, 194, 129, 0.12);
}

.status-count.warn { color: #b4342a; background: var(--danger-soft); }

.status-perm-meter {
  flex: 0 1 280px;
  display: block;
  height: 4px;
  min-width: 48px;
  margin-top: 0;
  margin-left: auto;
  border-radius: 999px;
  background: var(--panel-3);
  overflow: hidden;
}

.status-perm-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-2), var(--brand));
  transition: width 0.4s ease;
}

.status-perm-meter.warn i { background: linear-gradient(90deg, #f7d455, var(--danger)); }

.perm-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* One chip per permission: a round mark, then the label. Green is allowed,
   red is missing, grey is "the phone did not say". */
.perm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.perm:hover { border-color: var(--line-strong); transform: translateY(-1px); }

.perm b {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  font-size: 9.5px;
  font-weight: 800;
  line-height: 1;
  background: var(--panel-3);
  color: var(--muted);
}

.perm.ok { color: #1c8f5f; border-color: rgba(38, 194, 129, 0.35); background: rgba(38, 194, 129, 0.08); }
.perm.ok b { color: #1c8f5f; background: rgba(38, 194, 129, 0.18); }
.perm.bad { color: #b4342a; border-color: rgba(231, 80, 90, 0.38); background: rgba(231, 80, 90, 0.08); }
.perm.bad b { color: #b4342a; background: rgba(231, 80, 90, 0.18); }

.status-note { margin-top: 10px; font-size: 11.5px; color: var(--muted); }

/* The facts the card can back up: when the phone was last heard, when the
   snapshot was taken, how old the fix is and which platform sent it. */
.status-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px 14px;
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.status-meta > div { min-width: 0; }

.status-meta dt {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.status-meta dd {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.status-meta dd.mono {
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
  font-size: 11px;
  color: var(--muted);
}

/* No snapshot yet (an older app build): a quiet icon + the one thing to do. */
.status-waiting { display: flex; align-items: flex-start; gap: 12px; padding: 2px 0 4px; }
.status-waiting strong { display: block; font-size: 13.5px; color: var(--text-strong); }
.status-waiting p { margin-top: 4px; max-width: 62ch; }

.status-waiting-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--brand);
  background: var(--brand-soft);
}

/* ==========================================================================
   Tables and feeds
   ========================================================================== */

.table-wrap { overflow-x: auto; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  background: var(--bg-soft);
  border-radius: var(--radius) var(--radius) 0 0;
}

.toolbar .grow { flex: 1; min-width: 200px; }
.toolbar .spacer { flex: 1; }
.toolbar select { max-width: 190px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }

.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 16px;
  text-align: left;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.1s ease; }
.table tbody tr:hover { background: rgba(53, 152, 220, 0.055); }

.row-app { display: flex; align-items: center; gap: 9px; min-width: 130px; }
.app-dot {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 2px;
  flex: none;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: var(--app-color, var(--brand));
}

.row-app strong { display: block; font-size: 12.5px; font-weight: 600; }
.row-app span { display: block; font-size: 10.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; max-width: 150px; }

.row-title { font-weight: 650; font-size: 13px; color: var(--text-strong); }

/* Only visible on phones: the app column there is too narrow for names such as
   "Google Play Store", so each row prints its app name above the title instead. */
.row-app-label { display: none; }
.row-text { margin-top: 2px; font-size: 12.5px; color: var(--muted); max-width: 520px; overflow-wrap: anywhere; }

/* Long texts (SMS + notification bodies) collapse behind a "See more" link. */
.clamp-text { white-space: pre-wrap; }
.more-link {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand);
  font: inherit;
  font-size: 11.5px;
  font-weight: 650;
  cursor: pointer;
}
.more-link:hover { text-decoration: underline; }
.more-link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 2px; }

.row-meta { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.row-meta strong { display: block; color: var(--text); font-weight: 600; }

.row-actions { text-align: right; white-space: nowrap; }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--panel-3);
}

/* A bubble that reaches the feed anyway (a newer web build in front of an older
   app VPS) keeps its own colour, so it never looks like a notification. */
.tag.chat-in { color: #1c8f5f; background: rgba(38, 194, 129, 0.14); }
.tag.chat-out { color: #2570a8; background: rgba(53, 152, 220, 0.14); }

/* Calls, SMS and favourites use the same chip; the colour is the whole meaning. */
.tag.call-incoming { color: #1c8f5f; background: rgba(38, 194, 129, 0.14); }
.tag.call-outgoing { color: #2570a8; background: rgba(53, 152, 220, 0.14); }
.tag.call-missed,
.tag.call-rejected,
.tag.call-blocked { color: #b4342a; background: rgba(220, 53, 42, 0.14); }
.tag.call-voicemail { color: #8a6d1f; background: rgba(214, 173, 42, 0.18); }
.tag.sms-in { color: #1c8f5f; background: rgba(38, 194, 129, 0.14); }
.tag.sms-out { color: #2570a8; background: rgba(53, 152, 220, 0.14); }
.tag.starred { color: #8a6d1f; background: rgba(214, 173, 42, 0.18); }
.star { color: #d6ad2a; }

.table-empty { padding: 42px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.table-empty strong { display: block; color: var(--text); margin-bottom: 6px; }

/* Numbered pager under the phone mirrors ("‹ Prev 1 2 3 … 12 Next ›"). */
.pager-slot:empty { display: none; }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

.pg {
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.pg:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.pg.active { border-color: var(--brand); background: var(--brand); color: #fff; }
.pg:disabled { opacity: 0.45; cursor: default; }
/* Prev/Next carry a word, so they get their own padding instead of a fixed box. */
.pg-nav { padding: 0 12px; white-space: nowrap; }
.pg-gap { padding: 0 2px; color: var(--faint); }
.pager-info { margin-left: 6px; color: var(--muted); font-size: 11.5px; white-space: nowrap; }

/* "Mark, then delete": the leading tick column of a table and its select-all. */
.pick {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--brand);
  cursor: pointer;
}

.table .col-check { width: 34px; padding-right: 0; }
.table td.col-check { vertical-align: middle; }
.table tbody tr.picked { background: var(--brand-soft); }
.table tbody tr.picked:hover { background: var(--brand-soft); }

.pick-all {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--muted);
  cursor: pointer;
}

/* --------------------------------------------------------------------------------
   Call recordings inside the Calls list: the REC pill on a row, the inline
   player that opens under it, and the Play / Download actions.
   -------------------------------------------------------------------------------- */

.rec-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.rec-badge svg { flex: 0 0 auto; }

/* The direction badge of a call row: Google Dialer-style filled circles. */
.call-dir {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background: var(--panel-3);
  color: var(--muted);
}

.call-dir.dir-in { background: var(--ok); color: #fff; }
.call-dir.dir-out { background: var(--brand); color: #fff; }
.call-dir.dir-missed { background: var(--danger); color: #fff; }
.call-dir.dir-contact { background: var(--panel-3); color: var(--muted); }
.call-dir.dir-voice { background: var(--brand-soft); color: var(--brand); }
/* The camera clips reuse the badge, so give the video kind a solid blue dot of
   its own - the mic keeps the soft tint. A snapshot takes the same soft tint in
   the cyan accent, so photo and voice stay apart at a glance. */
.call-dir.dir-video { background: var(--brand); color: #fff; }
.call-dir.dir-photo { background: var(--brand-soft); color: var(--brand-2); }

/* Play / Download inline in the call row's main cell. */
.rec-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 5px;
}

.rec-inline .rec-badge { margin-top: 0; }
.rec-inline .rec-play { display: inline-flex; align-items: center; gap: 5px; }

.row-meta .meta-date {
  display: block;
  font-weight: 600;
}
.row-meta .meta-time {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
}

.row-actions .rec-play,
.row-actions .rec-download {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Playback popup: one dark card over a blurred page - a video stage, or a
   sound deck with a big toggle, a draggable seek bar and a live waveform.
   ------------------------------------------------------------------------- */

body.media-open { overflow: hidden; }

/* The shared .backdrop block lives further down the file, so these two rules
   are written `.backdrop.media-backdrop` to win on specificity, not order. */
.backdrop.media-backdrop {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(9, 13, 19, 0.74);
  backdrop-filter: blur(6px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px;
}

.media-card {
  --media-fg: #f2f6fa;
  --media-dim: #93a3b5;
  --media-line: rgba(255, 255, 255, 0.09);
  width: min(760px, 100%);
  margin: auto;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: radial-gradient(130% 150% at 50% 0%, #1c2636 0%, #10161f 60%);
  color: var(--media-fg);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.85);
  animation: pop 0.16s ease;
}

.media-head { display: flex; align-items: flex-start; gap: 14px; padding: 18px 20px 14px; }
.media-id { display: grid; gap: 3px; min-width: 0; }
.media-id strong { font-size: 16px; line-height: 1.3; color: #fff; }
.media-sub { font-size: 12px; color: var(--media-dim); }

.media-chip {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(53, 152, 220, 0.18);
  color: #7cc4f5;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.media-tools { display: flex; gap: 8px; margin-left: auto; flex: 0 0 auto; }

.media-tool {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--media-line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.05);
  color: #dbe6f1;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s ease, transform 0.12s ease;
}

.media-tool:hover { background: rgba(255, 255, 255, 0.15); transform: translateY(-1px); }
.media-tool:focus-visible { outline: 2px solid #4ea8ee; outline-offset: 2px; }

.media-stage-video { display: flex; justify-content: center; padding: 0 20px; }

/* A portrait clip is taller than wide: let the intrinsic ratio size the box
   instead of stretching a full-width element into a wall of black. */
.media-video {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(62vh, 540px);
  background: #000;
  border-radius: 12px;
  object-fit: contain;
}

/* A snapshot is a still picture: same stage, same intrinsic sizing, no black
   wall and no controls - the whole point is seeing it. */
.media-stage-photo { display: flex; justify-content: center; padding: 0 20px; }

.media-photo {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(64vh, 560px);
  border-radius: 12px;
  background: #0b0f15;
  object-fit: contain;
}

/* A file that takes its time: the stage keeps its shape from the first paint and
   a spinner holds the middle, so a slow photo never reads as an empty card. */
.media-stage { position: relative; }

.media-stage-video.is-loading,
.media-stage-photo.is-loading { min-height: min(46vh, 340px); }

.media-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 12px;
  background: rgba(9, 13, 19, 0.62);
  color: #b9c7d6;
  font-size: 12px;
  letter-spacing: 0.01em;
  pointer-events: none;
}

.media-loading .spinner {
  width: 24px;
  height: 24px;
  border-width: 2.5px;
  border-color: rgba(255, 255, 255, 0.16);
  border-top-color: #7cc4f5;
}

/* The sound deck: a glowing disc and a still waveform that moves on play. */
.media-stage-audio { display: grid; justify-items: center; gap: 18px; padding: 14px 20px 6px; }

.media-disc {
  width: 96px;
  height: 96px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(150deg, var(--brand-2), var(--brand));
  color: #fff;
  box-shadow: 0 0 0 10px rgba(53, 152, 220, 0.12), 0 18px 34px -16px rgba(53, 152, 220, 0.9);
}

.media-stage-audio.is-playing .media-disc { animation: media-pulse 1.6s ease-in-out infinite; }

@keyframes media-pulse {
  0%, 100% { box-shadow: 0 0 0 10px rgba(53, 152, 220, 0.14), 0 18px 34px -16px rgba(53, 152, 220, 0.9); }
  50% { box-shadow: 0 0 0 20px rgba(53, 152, 220, 0.04), 0 18px 34px -16px rgba(53, 152, 220, 0.7); }
}

.media-wave { display: flex; align-items: center; gap: 4px; width: min(420px, 100%); height: 64px; }

.media-wave span {
  flex: 1;
  min-width: 2px;
  height: var(--h, 40%);
  border-radius: 999px;
  background: linear-gradient(180deg, var(--brand-2), var(--brand));
  opacity: 0.5;
  transform-origin: center;
  animation: media-bob 0.9s var(--d, 0s) ease-in-out infinite alternate;
  animation-play-state: paused;
}

.media-stage-audio.is-playing .media-wave span { animation-play-state: running; opacity: 0.95; }

@keyframes media-bob {
  from { transform: scaleY(0.4); }
  to { transform: scaleY(1); }
}

.media-bar { display: flex; align-items: center; gap: 14px; padding: 16px 20px 4px; }

.media-toggle {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(150deg, var(--brand-2), var(--brand));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 22px -12px rgba(53, 152, 220, 0.9);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.media-toggle:hover { transform: scale(1.06); filter: brightness(1.06); }
.media-toggle:focus-visible { outline: 2px solid #4ea8ee; outline-offset: 3px; }

.media-seek {
  --pct: 0%;
  flex: 1;
  min-width: 0;
  height: 22px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.media-seek::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-2) 0 var(--pct), rgba(255, 255, 255, 0.14) var(--pct) 100%);
}

.media-seek::-moz-range-track { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); }
.media-seek::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--brand-2); }

.media-seek::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -4px;
  border-radius: 50%;
  border: 3px solid var(--brand-2);
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.media-seek::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 3px solid var(--brand-2);
  background: #fff;
}

.media-seek:focus-visible { outline: 2px solid #4ea8ee; outline-offset: 4px; border-radius: 999px; }

.media-time {
  font-size: 12px;
  color: var(--media-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.media-error { margin: 4px 20px 0; font-size: 12.5px; color: #ffb4b9; }
.media-error a { color: #7cc4f5; }

.media-foot { display: flex; justify-content: flex-end; padding: 12px 20px 16px; }
.media-hint { font-size: 11px; color: rgba(255, 255, 255, 0.35); }

@media (max-width: 560px) {
  .media-backdrop { padding: 10px; }
  .media-card { border-radius: 14px; }
  .media-head { padding: 14px 14px 10px; gap: 10px; }
  .media-id strong { font-size: 15px; }
  .media-stage-video { padding: 0 12px; }
  .media-video { max-height: 52vh; }
  .media-stage-photo { padding: 0 12px; }
  .media-photo { max-height: 54vh; }
  .media-stage-audio { gap: 14px; padding: 10px 14px 2px; }
  .media-disc { width: 78px; height: 78px; }
  .media-wave { height: 52px; gap: 3px; }
  .media-bar { padding: 14px 14px 2px; gap: 10px; }
  .media-foot { padding: 10px 14px 12px; }
  .media-hint { display: none; }
}

.empty-state { padding: 46px 22px; text-align: center; display: grid; gap: 8px; justify-items: center; }
.empty-state strong { font-size: 15px; }
.empty-state p { color: var(--muted); font-size: 13px; max-width: 46ch; }

.skeleton {
  border-radius: 2px;
  background: linear-gradient(90deg, var(--panel-2) 25%, var(--panel-3) 37%, var(--panel-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

.skel-line { height: 12px; }
.skel-card { height: 110px; }


/* ==========================================================================
   Chats
   ========================================================================== */

.chats {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  /* minmax(0, 1fr) keeps the row pinned to the panel height. With an implicit
     auto row the row grew to the full height of every message, so the fixed
     height below was ignored, both columns overflowed and neither the chat
     list nor the thread could be scrolled. */
  grid-template-rows: minmax(0, 1fr);
  height: calc(100dvh - 152px);
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.chat-side {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--bg-soft);
}

.chat-side-head { padding: 14px 14px 10px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.chat-side-title { display: flex; align-items: center; gap: 8px; }
.chat-side-title h3 { font-size: 14px; }
.chat-side-title span { margin-left: auto; font-size: 11px; color: var(--muted); }

.app-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.app-chips::-webkit-scrollbar { display: none; }

.app-chips .chip { padding: 5px 9px; font-size: 11.5px; }

.conv-search {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--panel);
  color: var(--text);
  font-size: 12.5px;
  outline: none;
}

.conv-search:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(53, 152, 220, 0.16); }

/* min-height:0 is required: without it a flex child refuses to shrink below
   its content, so the list grew past the panel and the older conversations were
   clipped instead of becoming scrollable. */
.conv-list { flex: 1; min-height: 0; overflow-y: auto; }

.conv {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.conv:hover { background: var(--panel-2); }
.conv:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

.conv.active {
  background: var(--brand-soft);
  box-shadow: inset 3px 0 0 var(--brand);
}

.conv.picked { background: var(--brand-soft); }

/* The tick is a flex child of the row, so it needs its own hit area. */
.conv-pick {
  display: inline-grid;
  place-items: center;
  flex: none;
  margin: -6px 0;
  padding: 6px 2px;
  cursor: pointer;
}

/* "Select all" + "Delete (n)": only the delete button appears once something
   is ticked, so the row keeps its height either way. */
.conv-bulk { display: flex; align-items: center; gap: 8px; }
.conv-bulk .pick-all { margin-right: auto; }

.conv-main { min-width: 0; flex: 1; }
.conv-name { display: block; font-size: 13px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-preview { display: block; font-size: 11.8px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.conv-side { display: grid; justify-items: end; gap: 4px; flex: none; }
.conv-time { font-size: 10.5px; color: var(--faint); white-space: nowrap; }

.conv-count {
  min-width: 19px;
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  color: var(--brand);
  background: var(--brand-soft);
}

.chat-panel { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }

.thread-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  z-index: 2;
}

.thread-id { flex: 1; min-width: 0; }
.thread-id h3 { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-id p { font-size: 11.5px; color: var(--muted); }
.thread-count { margin-left: auto; font-size: 11.5px; color: var(--muted); white-space: nowrap; }

.chat-back { display: none; }

.thread-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg);
}

.day-sep {
  align-self: center;
  margin: 16px 0 10px;
  padding: 4px 12px;
  border-radius: 2px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.msg-row { display: flex; gap: 8px; margin-top: 6px; max-width: 100%; }
.msg-row.out { justify-content: flex-end; }

.bubble {
  position: relative;
  max-width: min(68%, 620px);
  padding: 9px 13px 7px;
  border-radius: 3px 3px 3px 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 13.2px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.msg-row.out .bubble {
  border-radius: 3px 3px 0 3px;
  border-color: transparent;
  background: var(--brand);
  color: #fff;
}

.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 3px;
  font-size: 10px;
  color: var(--faint);
}

.msg-row.out .msg-meta { color: rgba(255, 255, 255, 0.72); }

/* The × that deletes one bubble, in the meta line so it never covers the text. */
.msg-del {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: inherit;
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.bubble:hover .msg-del,
.msg-del:focus-visible { opacity: 0.8; }
.msg-del:hover { opacity: 1; background: rgba(0, 0, 0, 0.16); }
.msg-row.out .msg-del:hover { background: rgba(255, 255, 255, 0.22); }
/* A touch screen has no hover, so the × has to be visible from the start, and
   a finger needs a taller box than a mouse pointer does for the two small
   controls that carry the marking flow: the tick boxes and the filter menus.
   Narrow windows get the same treatment - a 320 px window is a phone. */
@media (hover: none), (max-width: 560px) {
  .msg-del { opacity: 0.6; }
  .toolbar select,
  .card-head select.clip-filter,
  .device-switch select { min-height: 30px; }
  .pick { width: 18px; height: 18px; }
}

.thread-empty { margin: auto; text-align: center; color: var(--muted); font-size: 13px; display: grid; gap: 6px; justify-items: center; }
.thread-empty strong { color: var(--text); font-size: 15px; }

.jump {
  position: absolute;
  right: 26px;
  bottom: 22px;
  padding: 7px 13px;
  border-radius: 2px;
  border: 1px solid rgba(53, 152, 220, 0.45);
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  box-shadow: var(--shadow);
}

.chat-note { padding: 10px 18px 14px; font-size: 11px; color: var(--faint); text-align: center; }


/* ==========================================================================
   Devices
   ========================================================================== */

.device-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

.device-card { display: grid; gap: 12px; padding: 18px; grid-template-columns: minmax(0, 1fr); }

.device-head { display: flex; align-items: center; gap: 11px; }
/* The status chip is `nowrap`, so the name column has to be what gives way;
   without min-width:0 the flex row outgrows the card and the chip gets clipped
   against the card edge on a phone. */
.device-head > div { min-width: 0; }
.device-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 2px;
  color: var(--brand);
  background: rgba(53, 152, 220, 0.12);
}
.device-head h3 { font-size: 14.5px; overflow-wrap: anywhere; }
.device-head p { font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }

/* online / idle chip: a dot, then the word. The dot breathes while the phone
   is live so the card reads as a status, not a label. */
.device-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  color: #1c8f5f;
  background: rgba(38, 194, 129, 0.14);
  white-space: nowrap;
}

.device-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(38, 194, 129, 0.18);
}

.device-status.idle { color: var(--muted); background: var(--panel-3); }
.device-status.idle::before { box-shadow: none; }

@media (prefers-reduced-motion: no-preference) {
  .device-status:not(.idle)::before { animation: livePulse 2.4s ease-in-out infinite; }
}

@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(38, 194, 129, 0.18); }
  50% { box-shadow: 0 0 0 6px rgba(38, 194, 129, 0.04); }
}

.key-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border: 1px dashed var(--line-strong);
  border-radius: 2px;
  background: var(--panel-2);
}

.key-value {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 11.5px; color: var(--muted); }
.device-meta b { color: var(--text); font-weight: 600; }
.device-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.unlinked-note { padding: 0 18px 16px; margin: 0; }

.how-to { display: grid; gap: 14px; padding: 18px; }
.steps { display: grid; gap: 10px; counter-reset: step; }

.step {
  position: relative;
  padding: 11px 12px 11px 45px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel-2);
  font-size: 12.8px;
}

.step::before {
  position: absolute;
  left: 12px;
  top: 11px;
  counter-increment: step;
  content: counter(step);
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--brand);
}

.step code,
code.inline {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 11.5px;
  padding: 1px 5px;
  border-radius: 2px;
  background: var(--panel-3);
}

/* ==========================================================================
   Settings
   ========================================================================== */

.settings-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.settings-col { display: grid; gap: 16px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; }

.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.profile-head h3 { font-size: 16px; }
.profile-head p { font-size: 12px; color: var(--muted); }

.divider { height: 1px; background: var(--line); margin: 18px 0; }

.danger-zone { border-color: rgba(231, 80, 90, 0.3); }
.danger-zone .card-head h3 { color: var(--danger); }

.stat-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 12.8px; }
.stat-line:last-child { border-bottom: 0; }
.stat-line span { color: var(--muted); }
.stat-line b { font-weight: 650; }


/* ==========================================================================
   Modal and toast
   ========================================================================== */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(43, 54, 67, 0.62);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 22px;
  z-index: 80;
}

.modal-card {
  width: min(520px, 100%);
  max-height: calc(100dvh - 44px);
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  animation: pop 0.14s ease;
}

@keyframes pop {
  from { transform: translateY(8px) scale(0.99); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; }
.modal-head h3 { font-size: 16px; }
.modal-head p { margin-top: 3px; font-size: 12.5px; color: var(--muted); }
.modal-head .modal-close { margin-left: auto; }

.modal-body { padding: 4px 20px 18px; display: grid; gap: 13px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  display: grid;
  gap: 9px;
  max-width: min(360px, calc(100vw - 40px));
  /* Toasts carry no controls, so they must never eat a tap meant for the page
     underneath (they sit over the table pager and the last rows on a phone). */
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--brand);
  border-radius: 2px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 12.8px;
  animation: toast-in 0.18s ease;
}

.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all 0.18s ease; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1180px) {
  .grid-2,
  .grid-2.even { grid-template-columns: minmax(0, 1fr); }
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 980px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { display: none; }
  .auth-main { min-height: 100dvh; }

  .app-body { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--topbar);
    height: calc(100dvh - var(--topbar));
    width: 264px;
    transform: translateX(-102%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .only-mobile { display: inline-grid; }
  .main { padding: 18px 16px 36px; }
  .topbar { padding: 0 14px; }
  .live span:last-child { display: none; }
  .live { padding: 5px 8px; }
}

@media (max-width: 760px) {
  .chats { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - 168px); position: relative; }
  .chat-side { height: 100%; }
  .chat-panel { display: none; position: absolute; inset: 0; z-index: 3; }
  .chats.thread-open .chat-panel { display: flex; }
  .chats.thread-open .chat-side { display: none; }
  .chat-back { display: inline-grid; }
  .bubble { max-width: 82%; }

  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .device-grid { grid-template-columns: minmax(0, 1fr); }
  .page-head p { display: none; }


  /*
   * Phone toolbar: the search box takes a row of its own, the two filters pair
   * up, and the row-count pill shares the last row with "Delete selected" so the
   * bulk button never sits alone on a line that is mostly empty.
   */
  .toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    padding: 12px;
  }
  .toolbar .search { grid-column: 1 / -1; min-width: 0; }
  .toolbar select { width: 100%; max-width: none; }
  .toolbar .pill { justify-self: start; }
  .toolbar .btn { justify-self: end; }

  /*
   * On a phone the old rule hid the message column, which left each row showing
   * only the app and device. Keep the message visible and hide the redundant
   * device column instead; fixed layout stops the table from becoming wider
   * than the card (which made it look like there was no way to scroll).
   */
  .table {
    table-layout: fixed;
  }
  .table th:nth-child(3),
  .table td:nth-child(3) {
    display: none;
  }
  .table th:nth-child(1),
  .table td:nth-child(1) {
    width: 44px;
  }
  /* The app avatar is sized inline by appAvatar(); shrink it on a phone, and
     print the app name above the title so long names are not clipped. */
  .table .app-dot {
    width: 24px !important;
    height: 24px !important;
    font-size: 10px !important;
  }
  .row-app-label {
    display: block;
    margin-bottom: 2px;
    font-size: 9.8px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--faint);
    overflow-wrap: anywhere;
  }
  .table th:nth-child(4),
  .table td:nth-child(4) {
    width: 58px;
  }
  .table th:nth-child(5),
  .table td:nth-child(5) {
    width: 40px;
    padding-left: 4px;
    padding-right: 2px;
  }
  .table th,
  .table td {
    padding: 10px 8px;
  }
  .table th {
    position: static;
  }
  .row-app {
    min-width: 0;
    gap: 7px;
  }
  /* Column 1 is just the app avatar; the name lives in .row-app-label. */
  .row-app > div {
    display: none;
  }
  .row-title {
    font-size: 12.5px;
  }
  .row-text {
    max-width: none;
    font-size: 12px;
  }
  .row-actions {
    padding-right: 4px;
  }
  .row-actions .icon-btn {
    width: 30px;
    height: 30px;
  }

  /*
   * The phone mirrors (.table.pickable) carry a leading tick column, so every
   * column after it sits one place to the right of the rules above: the tick is
   * 1, the device 4, the time 5 and the actions 6. Re-state them here instead of
   * touching the notification table's numbers.
   */
  .table.pickable th:nth-child(1),
  .table.pickable td:nth-child(1) {
    width: 28px;
    padding-right: 0;
  }
  .table.pickable th:nth-child(2),
  .table.pickable td:nth-child(2) {
    width: 40px;
  }
  .table.pickable th:nth-child(3),
  .table.pickable td:nth-child(3) {
    display: table-cell;
    width: auto;
  }
  .table.pickable th:nth-child(4),
  .table.pickable td:nth-child(4) {
    display: none;
  }
  /* "11:18 PM" needs ~40px, and the 30px delete button needs its own 30px box;
     without the wider columns the last cell stuck 4px out of the card and the
     trash icon was clipped by the card edge. */
  .table.pickable th:nth-child(5),
  .table.pickable td:nth-child(5) {
    width: 58px;
    padding-left: 4px;
    padding-right: 4px;
  }
  .table.pickable th:nth-child(6),
  .table.pickable td:nth-child(6) {
    width: 40px;
    padding-left: 4px;
    padding-right: 2px;
  }

  /*
   * The phone tables (Calls, SMS, Contacts) dropped the Device column and
   * merged date + time into one, so each has five columns: tick, app, message,
   * date&time, actions. Restate those two trailing columns here; on a narrow
   * screen the date hides and only the time stays.
   */
  .table-5c.pickable th:nth-child(4),
  .table-5c.pickable td:nth-child(4) {
    display: table-cell;
    width: auto;
    min-width: 52px;
  }
  .table-5c.pickable th:nth-child(5),
  .table-5c.pickable td:nth-child(5) {
    width: 40px;
    padding-left: 4px;
    padding-right: 2px;
  }
  .table-5c .meta-date { display: none; }

  /*
   * A call/voice row carries Play + Download under its type badge. The shared
   * narrow column (40px, ~one avatar) made that pair wrap and left the row
   * twice as tall, so give this column room for both buttons side by side.
   */
  .table-5c.pickable th:nth-child(2),
  .table-5c.pickable td:nth-child(2) {
    width: 70px;
  }
  .table-5c .rec-inline {
    flex-wrap: nowrap;
    gap: 4px;
  }
  .table-5c .rec-inline .icon-btn {
    width: 30px;
    height: 30px;
  }

  /* Three buttons in the thread head leave no room for the counter on a phone. */
  .thread-count { display: none; }
}

@media (max-width: 520px) {
  .auth-main { padding: 22px 14px; }
  .auth-card { padding: 20px; }
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar-actions { gap: 2px; }
  .topbar-actions .icon-btn { width: 32px; height: 32px; }
  .topbar .brand-text > span:last-child { display: none; }
  /* With the live pill, the device switch and two icon buttons on the row, the
     brand name overlapped the switch instead of shrinking - the logo tile is
     enough identity at this width. */
  .topbar .brand-text { display: none; }
  .device-switch svg { display: none; }
  .device-switch select { max-width: 110px; }
  .msg-meta { font-size: 9.5px; }

  /* The permission tally keeps its line; the ratio bar takes the row under it
     instead of wrapping between the title and the count. */
  .status-split { flex-wrap: wrap; }
  .status-count { order: 2; margin-left: auto; }
  .status-perm-meter { order: 3; flex: 1 1 100%; margin: 6px 0 0; }

  /*
   * Twelve page buttons plus "‹ Prev", "Next ›" and "Page 3 of 12" do not fit on
   * a phone: the row wrapped into two lines and pushed the card taller than the
   * screen. Smaller buttons and no trailing label keep it on one line - the
   * highlighted number already tells which page is open.
   */
  .pager { gap: 4px; padding: 10px 8px; }
  .pg { min-width: 26px; height: 27px; padding: 0 6px; font-size: 11.5px; }
  .pg-nav { padding: 0 9px; }
  .pager-info { display: none; }

  /* "Delete selected (60)" is too long for a half-width toolbar cell here. */
  .bulk-extra { display: none; }
  .toolbar .btn.sm { padding: 6px 8px; }

  /*
   * Thread head on a phone: back + avatar + name + "Older (2/3)" + delete left
   * the name about four characters wide. Tighter gaps, a one-line Older button
   * without its page counter keep the conversation name readable.
   */
  .thread-head { gap: 8px; padding: 11px 12px; }
  .thread-head .btn { white-space: nowrap; }
  .thread-head .btn.sm { padding: 6px 8px; font-size: 11px; }
  .older-page { display: none; }

  /* The app filter chips scrolled sideways with the scrollbar hidden, so the
     last one looked chopped off with no hint that it could be swiped. */
  .app-chips { flex-wrap: wrap; overflow-x: visible; }

  /*
   * Battery and location side by side at this width left the coordinate pair
   * breaking after the comma, which reads like two unrelated numbers. One tile
   * per row keeps "23.8103, 90.4125" and its "±26 m · time" line intact.
   */
  .status-tiles { grid-template-columns: minmax(0, 1fr); }

  /* The head loses its side padding to match the narrower tiles, and the fact
     footer pairs up rather than squeezing into one grey line. */
  .status-card .status-head { padding: 14px 14px; }
  .status-card .status-head::after { left: 14px; right: 14px; }
  .status-head .device-icon { width: 36px; height: 36px; border-radius: 10px; }
  .status-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 360px) {
  .topbar .brand-text { display: none; }

  /* At this width the name had ~80px; the initial-circle avatar is the least
     useful thing in the row, so hand its space to the conversation name. */
  .thread-head .avatar { display: none; }
  .thread-id h3 { font-size: 13.5px; }
}

/* --------------------------------------------------------- camera view */

.cam-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  margin-top: 14px;
  max-width: 100%;
  /* The card-head has 16px; the controls match it instead of touching the
     card's own border. */
  padding: 0 16px;
}

.cam-controls .field {
  /* Always shrinkable: the row can never poke out of the card border,
     whatever the window width or browser zoom. */
  flex: 1 1 170px;
  min-width: 0;
}

.cam-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
  max-width: 100%;
}

.cam-status {
  margin-top: 12px;
  min-height: 18px;
  padding: 0 16px;
}

.cam-status.ok {
  color: var(--ok);
}

.cam-status.err {
  color: var(--danger);
}

/* The destructive action lives at the bottom of the Control card - in the
   header it used to wrap under the description on narrow screens. */
.cam-danger-row {
  display: flex;
  margin-top: 14px;
  padding: 0 16px 16px;
}

/* One phone leaves nothing to switch or delete on the control card, so the
   picker field and the destructive row hide until a second phone pairs
   (their display rules above would otherwise beat the hidden attribute). */
.cam-controls .field[hidden],
.cam-danger-row[hidden],
.card-head select.clip-filter[hidden] {
  display: none;
}

/* The tiny build tag in the sidebar foot - the quickest way to tell an old
   cached page from the current one. */
.ui-version {
  font-size: 10px;
  letter-spacing: 0.08em;
  opacity: 0.55;
}

/* The floating "N selected · Delete · Cancel" bar the clip tabs share. */
.clip-selbar {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--chrome);
  color: #e8eef4;
  box-shadow: 0 12px 30px -8px rgba(20, 28, 38, 0.55);
}

.clip-selbar[hidden] { display: none; }

.clip-sel-count {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* The per-phone filter next to Refresh, and the "load older clips" row. */
.card-head select.clip-filter {
  max-width: 210px;
}

.clip-more {
  padding: 0 16px 16px;
  text-align: center;
}

/* The "No clips yet" line, aligned like everything else. */
#camEmpty,
#voiceEmpty,
#photoEmpty,
#galleryEmpty {
  padding: 0 16px 16px;
}

/* The screen-off-only switch under the voice controls: a check box with a
   reason under it, not a bare toggle - the sentence is what makes the mode
   understandable before it is turned on. */
.cam-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 14px;
  padding: 0 16px;
  cursor: pointer;
}

.cam-check input {
  margin: 3px 0 0;
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
  flex: 0 0 auto;
}

.cam-check span {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text);
}

.cam-check em {
  display: block;
  font-style: normal;
  color: var(--muted);
  font-size: 11.5px;
}

/* The camera roll: square tiles, the phone's own aspect ratio kept inside
   them so a portrait photo is not stretched into a landscape cell. */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
  padding: 14px 16px 4px;
}

.gallery-item {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.gallery-open {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel-3);
  cursor: zoom-in;
}

.gallery-open img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-open:hover,
.gallery-open:focus-visible {
  border-color: var(--brand);
}

.gallery-item figcaption {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 10.5px;
  color: var(--muted);
  min-width: 0;
}

.gallery-item figcaption span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The popup's photo: never wider than the dialog, never taller than the
   window it is shown in. */
.gallery-large {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  max-height: 68vh;
  border-radius: 10px;
}

/* The live ear's level line: a row of bars that lifts while the phone is
   actually sending. It is honest - it is the poll's own answer, not a
   decorative animation. */
.live-meter {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 22px;
  margin: 0 16px 16px;
}

.live-meter[hidden] { display: none; }

.live-meter span {
  flex: 0 0 3px;
  height: 5px;
  border-radius: 2px;
  background: var(--line);
  transition: height 220ms ease, background-color 220ms ease;
}

.live-meter.on span {
  background: var(--ok);
  animation: live-bar 900ms ease-in-out infinite alternate;
}

.live-meter.on span:nth-child(2n) { animation-delay: 120ms; }
.live-meter.on span:nth-child(3n) { animation-delay: 240ms; }
.live-meter.on span:nth-child(4n) { animation-delay: 60ms; }
.live-meter.on span:nth-child(5n) { animation-delay: 300ms; }

@keyframes live-bar {
  from { height: 5px; }
  to { height: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .live-meter.on span { animation: none; height: 12px; }
}

@media (max-width: 720px) {
  .cam-buttons {
    margin-left: 0;
  }
  .cam-controls .field {
    flex: 1 1 100%;
    min-width: 0;
  }
}

