/* =======================================================================================
   Dekhing — Document-screen redesign (Phase 2+)
   Loaded after device-dashboard.css + shell.css, so these rules win at equal specificity.
   Reuses the shell.css design tokens. Restyles the SHARED document-screen chrome
   (.app-usage-header / .app-usage-content) plus Files and Send File specifics — WITHOUT
   changing any element ID or the DOM the feature JS produces.
======================================================================================= */

/* ---- Shared screen header ----
   The back button (.back-button) is position:fixed at the top-left and the status pill floats
   at the top-centre, so the header MUST reserve space for both (as the original 76px/68px padding
   did) or they overlap the title/actions. */
.app-usage-header {
  gap: var(--sp-3);
  padding: max(72px, calc(env(safe-area-inset-top) + 52px)) var(--sp-5) var(--sp-4) 66px;
  border-bottom: 1px solid var(--hairline);
  background: linear-gradient(180deg, var(--s-1), rgba(11,18,32,.72));
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
@media (max-width: 400px) { .app-usage-header { padding-left: 60px; } }
.app-usage-title {
  font-size: var(--fs-h2); font-weight: 700; letter-spacing: -.01em; color: var(--t-hi);
}
.device-activity-updated { color: var(--t-faint); font-size: var(--fs-cap); }

.header-icon-button {
  width: 40px; height: 40px; border-radius: var(--r-md);
  border: 1px solid var(--hairline); background: var(--s-2); color: var(--t-mid);
  display: inline-grid; place-items: center; cursor: pointer;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.header-icon-button:hover { background: var(--s-hover); color: var(--t-hi); border-color: var(--hairline-strong); }
.header-icon-button.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft-2); }
.header-icon-button.danger { color: #FCA5A5; }
.header-icon-button.danger:hover { background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.4); color: #FECACA; }

/* ---- Shared content container: centered, comfortable ---- */
.app-usage-content {
  max-width: 1040px; margin: 0 auto; width: 100%;
  padding: var(--sp-6) var(--sp-5) calc(env(safe-area-inset-bottom) + var(--sp-8));
}

/* ---- Loading + empty/unavailable states ---- */
.list-loading { color: var(--t-lo); font-size: var(--fs-sm); }
.device-activity-unavailable {
  margin: var(--sp-5) 0; padding: var(--sp-6);
  border: 1px dashed var(--hairline-strong); border-radius: var(--r-lg);
  background: rgba(2,6,23,.4); color: var(--t-lo); text-align: center; font-size: var(--fs-sm);
}

/* =======================================================================================
   FILES — modern file explorer
======================================================================================= */
.files-breadcrumb-row {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-bottom: var(--sp-4);
  padding: var(--sp-2) var(--sp-3);
  background: var(--s-2); border: 1px solid var(--hairline); border-radius: var(--r-md);
}
.files-up-button {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: var(--r-sm);
  border: 1px solid var(--hairline); background: var(--s-3); color: var(--t-mid);
  display: inline-grid; place-items: center; cursor: pointer;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.files-up-button:hover { background: var(--s-hover); color: var(--accent); }
.files-breadcrumb { gap: 2px; font-size: var(--fs-sm); }
.files-crumb {
  color: var(--t-lo); padding: 5px 9px; border-radius: var(--r-sm); min-height: 32px;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.files-crumb:hover { background: var(--s-hover); color: var(--t-hi); }
.files-crumb:last-of-type { color: var(--t-hi); font-weight: 600; }
.files-crumb-sep { color: var(--t-faint); }

/* list becomes one clean panel of hover rows */
.files-list {
  display: block;
  background: var(--s-2); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--el-1);
}
.files-row {
  gap: var(--sp-3);
  padding: 11px var(--sp-4);
  border: 0; border-bottom: 1px solid var(--hairline); border-radius: 0;
  background: transparent; box-shadow: none;
  transition: background var(--dur-1) var(--ease);
}
.files-row:last-child { border-bottom: 0; }
.files-row:hover { background: var(--s-hover); }

.files-row-icon {
  width: 40px; height: 40px; flex: 0 0 40px;
  display: grid; place-items: center; border-radius: 10px;
  background: rgba(148,163,184,.10); border: 1px solid var(--hairline); color: var(--t-mid);
}
.files-row-folder .files-row-icon {
  background: var(--accent-soft); border-color: var(--accent-soft-2); color: var(--accent);
}
.files-row-name { font-size: var(--fs-body); font-weight: 600; color: var(--t-hi); }
.files-row-meta { font-size: var(--fs-cap); color: var(--t-faint); }

.files-row-more {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent; color: var(--t-faint);
  display: inline-grid; place-items: center; cursor: pointer;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.files-row-more:hover { background: var(--s-3); color: var(--t-hi); border-color: var(--hairline); }

/* select-mode checkbox — hidden until select mode, clearly visible unchecked box, green when selected */
.files-row-checkbox {
  width: 22px; height: 22px; flex: 0 0 22px; border-radius: 6px;
  border: 2px solid var(--t-faint); background: rgba(2,6,23,.5);
  display: none; box-sizing: border-box;
}
.files-list.select-mode .files-row-checkbox { display: inline-block; }
/* Folders aren't multi-selectable (only files are) — keep the space so icons stay aligned,
   but don't show a checkbox that can't be ticked. */
.files-list.select-mode .files-row-folder .files-row-checkbox { visibility: hidden; }
.files-row.selected { background: var(--accent-soft); }
.files-row.selected .files-row-checkbox {
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%2304140A' d='M9.55 17.6 4.4 12.45l1.4-1.4 3.75 3.75 8.25-8.25 1.4 1.4z'/%3E%3C/svg%3E") center / 15px no-repeat;
  border-color: var(--accent);
}

.files-download-status {
  margin-top: var(--sp-4); padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md); background: var(--accent-soft); border: 1px solid var(--accent-soft-2);
  color: var(--accent); font-size: var(--fs-sm); font-weight: 500;
}

/* drag-drop overlay */
.files-drop-overlay {
  border: 2px dashed var(--accent); border-radius: var(--r-lg);
  background: rgba(34,197,94,.08); color: var(--accent); font-weight: 700;
}

/* ---- Selection action bar: floating pill ---- */
.selection-bar {
  position: fixed; left: 50%; bottom: max(var(--sp-5), env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 60; width: max-content; max-width: calc(100vw - var(--sp-8));
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  background: var(--glass-nav); border: 1px solid var(--hairline-strong);
  border-radius: var(--r-pill); box-shadow: var(--el-4);
  backdrop-filter: blur(20px) saturate(140%); -webkit-backdrop-filter: blur(20px) saturate(140%);
}
.selection-bar-count { font-size: var(--fs-sm); font-weight: 700; color: var(--t-hi); }
.selection-bar-actions { display: flex; gap: var(--sp-2); }
.selection-bar-button {
  padding: 8px var(--sp-4); border-radius: var(--r-pill);
  border: 1px solid var(--hairline-strong); background: var(--s-2); color: var(--t-hi);
  font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.selection-bar-button:hover { background: var(--s-hover); border-color: var(--accent-soft-2); }
.selection-bar-button.danger { color: #FCA5A5; }
.selection-bar-button.danger:hover { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.45); color: #FECACA; }
.selection-bar-button.neutral { color: var(--t-lo); }

/* Copy/Move clipboard bar — an inline banner under the breadcrumb that persists while the user
   navigates to a destination folder, then offers "Paste here". */
.files-clipboard-bar {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  margin: 0 0 var(--sp-3); padding: var(--sp-3) var(--sp-4);
  background: var(--accent-soft); border: 1px solid var(--accent-soft-2);
  border-radius: var(--r-md);
}
.files-clipboard-label { flex: 1 1 220px; min-width: 0; font-size: var(--fs-sm); font-weight: 600; color: var(--t-hi); }
.files-clipboard-actions { display: flex; gap: var(--sp-2); }
.files-clipboard-button {
  padding: 8px var(--sp-4); border-radius: var(--r-pill);
  border: 1px solid transparent; background: var(--accent); color: #04120A;
  font-size: var(--fs-sm); font-weight: 700; cursor: pointer;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.files-clipboard-button:hover { filter: brightness(1.08); }
.files-clipboard-button.neutral {
  background: var(--s-2); border-color: var(--hairline-strong); color: var(--t-lo);
}
.files-clipboard-button.neutral:hover { background: var(--s-hover); color: var(--t-hi); }

/* Files search — filters the current folder listing client-side */
.files-search-row { position: relative; display: flex; align-items: center; margin: 0 0 var(--sp-3); }
.files-search-row .search-input { width: 100%; padding-right: 40px; }
.files-search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 50%; border: none; background: transparent;
  color: var(--t-faint); cursor: pointer; display: grid; place-items: center;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.files-search-clear:hover { color: var(--t-hi); background: var(--s-hover); }

/* =======================================================================================
   SEND FILE — upload flow as a centered card with a drop-zone feel
======================================================================================= */
#uploadScreen .app-usage-content { max-width: 620px; }
.upload-hint {
  color: var(--t-lo); font-size: var(--fs-sm); line-height: 1.6;
  margin: 0 0 var(--sp-5);
}
#uploadPickButton {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-2);
  width: 100%; min-height: 168px; padding: var(--sp-7);
  border: 2px dashed var(--hairline-strong); border-radius: var(--r-xl);
  background: rgba(2,6,23,.4); color: var(--t-mid);
  font-size: var(--fs-body); font-weight: 600; cursor: pointer;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
#uploadPickButton::before {
  content: ""; width: 46px; height: 46px; border-radius: 50%;
  background: var(--accent-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'%3E%3Cpath fill='%2322C55E' d='M9 16h6v-6h4L12 2 5 10h4v6zm-4 2h14v2H5v-2z'/%3E%3C/svg%3E") center/24px no-repeat;
  border: 1px solid var(--accent-soft-2);
}
#uploadPickButton:hover { border-color: var(--accent); background: rgba(34,197,94,.06); color: var(--t-hi); }

.upload-selected-name {
  margin: var(--sp-4) 0 0; text-align: center;
  font-size: var(--fs-sm); color: var(--t-lo);
  font-family: "Fira Code", ui-monospace, monospace;
}
.upload-progress-bar {
  margin-top: var(--sp-4); height: 8px; border-radius: var(--r-pill);
  background: var(--s-3); border: 1px solid var(--hairline); overflow: hidden;
}
.upload-progress-fill {
  height: 100%; border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width var(--dur-2) var(--ease);
}

/* Shared primary/secondary action buttons used across these screens */
.dialog-action-list { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-5); }
.error-dialog-button {
  padding: 12px var(--sp-6); border-radius: var(--r-md);
  border: 1px solid transparent; background: var(--accent); color: #04140A;
  font-size: var(--fs-body); font-weight: 700; cursor: pointer;
  transition: transform var(--dur-1) var(--ease), background var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), opacity var(--dur-1) var(--ease);
}
.error-dialog-button:hover { background: #26D366; transform: translateY(-1px); box-shadow: 0 10px 26px rgba(34,197,94,.24); }
.error-dialog-button:active { transform: translateY(0); }
.error-dialog-button:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.error-dialog-button.neutral { background: var(--s-2); color: var(--t-hi); border-color: var(--hairline-strong); }
.error-dialog-button.neutral:hover { background: var(--s-hover); box-shadow: none; }
.error-dialog-button.danger { background: transparent; color: #FCA5A5; border-color: rgba(239,68,68,.5); }
.error-dialog-button.danger:hover { background: rgba(239,68,68,.12); color: #FECACA; box-shadow: none; }

@media (max-width: 640px) {
  .app-usage-content { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .selection-bar { gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); }
  .selection-bar-button { padding: 8px var(--sp-3); }
}

/* =======================================================================================
   COMMUNICATION (Phase 3) — Call Log, Messages, Contacts
   Shared list rows use .contact-row (+ .row-avatar / .contact-row-badge / .row-icon-button).
   SMS thread uses .sms-bubble-row-sent|received. Nothing here changes IDs or JS output.
======================================================================================= */

/* list container becomes one clean panel of hover rows */
.contact-list {
  display: block;
  background: var(--s-2); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--el-1);
}
.contact-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 11px var(--sp-4);
  border: 0; border-bottom: 1px solid var(--hairline); border-radius: 0;
  background: transparent; box-shadow: none; cursor: pointer;
  transition: background var(--dur-1) var(--ease);
}
.contact-row:last-child { border-bottom: 0; }
.contact-row:hover { background: var(--s-hover); }

.row-avatar {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 50%;
  display: grid; place-items: center;
  color: #04140A; font-weight: 800; font-size: 16px;
  border: 1px solid rgba(255,255,255,.14);
}

.contact-row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.contact-row-top { display: flex; align-items: baseline; gap: var(--sp-3); }
.contact-row-name { font-size: var(--fs-body); font-weight: 600; color: var(--t-hi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-row-time { margin-left: auto; flex: 0 0 auto; font-size: var(--fs-cap); color: var(--t-faint); }
.contact-row-sub { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.contact-row-number { font-size: var(--fs-cap); color: var(--t-lo); }
.contact-row-duration { font-size: var(--fs-cap); color: var(--t-faint); }
.contact-row-body { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--t-lo); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* Notifications screen row — app name/time reuse .contact-row-name/-time above; title+body are
   specific to a notification's own content, so they're their own classes rather than overloading
   .contact-row-body (which Contacts uses for a single-line phone number, different semantics). */
.notification-title { margin-top: 2px; font-size: var(--fs-sm); font-weight: 600; color: var(--t-hi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notification-body {
  margin-top: 2px; font-size: var(--fs-sm); color: var(--t-lo); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* Package name sub-line on Installed Apps rows — one line, slightly more muted than the version/size line above it */
.apps-pkg { -webkit-line-clamp: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--t-faint); font-size: 11px; margin-top: 1px; display: block; }

/* Notification row swipe-to-clear structure — the outer <li> (.notification-row, the direct
   .contact-list child) owns the row divider + clips the swipe reveal; .notification-row-content
   (a .contact-row itself, holding the real content) sits opaquely on top of .notification-swipe-bg
   and gets translated right by initNotificationSwipe() in call-log-sms.js. The divider moved here
   from .contact-row's own border-bottom because .contact-row:last-child no longer identifies "the
   last ROW" once .contact-row is nested one level deeper (each .notification-row's .contact-row is
   trivially its own only/last child either way, so .contact-row's own border rules are neutralized
   below rather than relied on). */
.notification-row { position: relative; overflow: hidden; border-bottom: 1px solid var(--hairline); }
.notification-row:last-child { border-bottom: 0; }
.notification-row-content {
  position: relative; z-index: 1; background: var(--s-2);
  border: 0; border-radius: 0;
  touch-action: pan-y; /* keep vertical list scroll working; JS owns the horizontal drag */
}
.notification-swipe-bg {
  position: absolute; inset: 0; z-index: 0;
  display: flex; align-items: center; padding: 0 var(--sp-5);
  background: #DC2626; color: #fff; opacity: 0;
  transition: opacity var(--dur-1) var(--ease);
}
.notification-swipe-bg svg { width: 22px; height: 22px; }
/* Real app icon in place of the colored-initial .row-avatar (see notificationAvatarHtml() in
   call-log-sms.js) — shown in its own real shape as sent by the device, not force-cropped into
   .row-avatar's inherited circle (border-radius:50%), hence the override to a soft square instead.
   object-fit:contain (not cover) shows the whole icon uncropped even if it isn't perfectly square;
   the background fills in behind any transparent padding an adaptive icon's bitmap may have.
   border:none overrides .row-avatar's hairline ring, drawn for the flat-color initial avatar —
   unnecessary/distracting around a real icon image. */
.row-avatar-icon { border-radius: var(--r-sm); border: none; object-fit: contain; background: var(--s-3); }

.contact-row-badge {
  font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 8px; border-radius: var(--r-pill);
  background: rgba(148,163,184,.14); color: var(--t-lo);
}
.contact-row-badge-incoming, .contact-row-badge-received { background: var(--accent-soft); color: var(--accent); }
.contact-row-badge-outgoing, .contact-row-badge-sent { background: rgba(59,130,246,.18); color: #60A5FA; }
.contact-row-badge-missed, .contact-row-badge-rejected, .contact-row-badge-blocked { background: rgba(239,68,68,.16); color: #F87171; }
.contact-row-badge-installed { background: var(--accent-soft); color: var(--accent); }
.contact-row-badge-uninstalled { background: rgba(239,68,68,.16); color: #F87171; }
.contact-row-badge-updated { background: rgba(59,130,246,.18); color: #60A5FA; }

.contact-row-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.row-icon-button {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent; color: var(--t-faint);
  display: inline-grid; place-items: center; cursor: pointer;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.row-icon-button:hover { background: var(--s-3); color: var(--accent); border-color: var(--hairline); }
.row-icon-button[data-row-action="delete-call"]:hover,
.row-icon-button[data-row-action="delete-conversation"]:hover { color: #F87171; }
.row-icon-button.danger:hover { color: #F87171; border-color: rgba(248,113,113,.3); background: rgba(239,68,68,.1); }

.apps-row-name { white-space: normal; overflow: visible; text-overflow: unset; }
.apps-install-date { font-size: var(--fs-cap); color: var(--t-faint); margin-top: 2px; }
.app-blocked-active { color: #EF4444 !important; border-color: rgba(239,68,68,.35) !important; background: rgba(239,68,68,.12) !important; }

/* ---- Active Call Card (pinned at top of Call Log) ---- */
.active-call-card {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-4); margin: var(--sp-3) var(--sp-4) 0;
  border-radius: var(--r-md); border: 1px solid rgba(52,211,153,.35);
  background: linear-gradient(135deg, rgba(16,185,129,.12), rgba(52,211,153,.06));
  flex: 0 0 auto;
}
.active-call-card.ringing {
  border-color: rgba(251,191,36,.4);
  background: linear-gradient(135deg, rgba(245,158,11,.14), rgba(251,191,36,.06));
}
.active-call-indicator { position: relative; width: 14px; height: 14px; flex: 0 0 auto; }
.active-call-pulse {
  display: block; width: 14px; height: 14px; border-radius: 50%;
  background: #10B981;
  animation: call-pulse 1.4s ease-in-out infinite;
}
.active-call-card.ringing .active-call-pulse { background: #F59E0B; }
@keyframes call-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .5; transform: scale(1.4); }
}
.active-call-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.active-call-label { font-size: var(--fs-cap); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #10B981; }
.active-call-card.ringing .active-call-label { color: #F59E0B; }
.active-call-name { font-size: var(--fs-body); font-weight: 600; color: var(--t-hi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.active-call-number { font-size: var(--fs-cap); color: var(--t-lo); }
.active-call-duration { font-size: var(--fs-cap); color: var(--t-faint); font-variant-numeric: tabular-nums; }

/* ---- Messages thread (chat bubbles) ---- */
#smsThreadContent.sms-thread-content { display: flex; flex-direction: column; padding-bottom: var(--sp-3); }
.sms-thread-messages { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3) 0; }
.sms-bubble-row { display: flex; }
.sms-bubble-row-sent { justify-content: flex-end; }
.sms-bubble-row-received { justify-content: flex-start; }
.sms-bubble {
  max-width: min(78%, 520px);
  padding: 9px 13px; border-radius: 16px;
  font-size: var(--fs-body); line-height: 1.45; box-shadow: var(--el-1);
}
.sms-bubble-row-received .sms-bubble {
  background: var(--s-3); border: 1px solid var(--hairline);
  border-bottom-left-radius: 5px; color: var(--t-hi);
}
.sms-bubble-row-sent .sms-bubble {
  background: linear-gradient(145deg, var(--accent-dim), var(--accent));
  border-bottom-right-radius: 5px; color: #04140A;
}
.sms-bubble-body { margin: 0; white-space: pre-wrap; word-break: break-word; }
.sms-bubble-time { display: block; margin-top: 3px; font-size: 10px; opacity: .72; text-align: right; }

/* ---- Compose bar ---- */
.compose-wrap {
  position: sticky; bottom: 0; z-index: 5;
  padding: var(--sp-3) var(--sp-4) max(var(--sp-3), env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--s-0) 34%);
}
.compose-error { max-width: 1040px; margin: 0 auto var(--sp-2); color: #F87171; font-size: var(--fs-cap); }
.compose-bar { display: flex; align-items: center; gap: var(--sp-2); max-width: 1040px; margin: 0 auto; }
.compose-input {
  flex: 1 1 auto; min-width: 0; padding: 12px var(--sp-4);
  border-radius: var(--r-pill); border: 1px solid var(--hairline-strong);
  background: var(--s-2); color: var(--t-hi); font-size: var(--fs-body);
}
.compose-input::placeholder { color: var(--t-faint); }
.compose-input:focus { outline: none; border-color: var(--accent-soft-2); box-shadow: 0 0 0 3px var(--accent-soft); }
.compose-send-button {
  width: 46px; height: 46px; flex: 0 0 46px; border-radius: 50%;
  border: none; background: var(--accent); color: #04140A;
  display: inline-grid; place-items: center; cursor: pointer;
  transition: transform var(--dur-1) var(--ease), background var(--dur-1) var(--ease), opacity var(--dur-1) var(--ease);
}
.compose-send-button:hover:not(:disabled) { background: #26D366; transform: scale(1.05); }
.compose-send-button:disabled { opacity: .4; cursor: not-allowed; }

/* ---- Search bar (Contacts) ---- */
.search-bar-row { margin-bottom: var(--sp-4); }
.search-input {
  width: 100%; box-sizing: border-box; padding: 11px var(--sp-4) 11px 42px;
  border-radius: var(--r-md); border: 1px solid var(--hairline-strong);
  background: var(--s-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'%3E%3Cpath fill='%2364748B' d='M15.5 14h-.79l-.28-.27a6.5 6.5 0 1 0-.7.7l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0A4.5 4.5 0 1 1 14 9.5 4.5 4.5 0 0 1 9.5 14z'/%3E%3C/svg%3E") 13px center / 18px no-repeat;
  color: var(--t-hi); font-size: var(--fs-body);
}
.search-input::placeholder { color: var(--t-faint); }
.search-input:focus { outline: none; border-color: var(--accent-soft-2); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---- Contacts edit form ---- */
.quick-message-field-label {
  display: block; font-size: var(--fs-cap); font-weight: 600; color: var(--t-lo);
  margin: var(--sp-4) 0 6px; text-transform: uppercase; letter-spacing: .05em;
}

/* ---- New-message contact picker results ---- */
.contact-picker-results {
  margin-top: var(--sp-2); border: 1px solid var(--hairline); border-radius: var(--r-md);
  background: var(--s-2); overflow: hidden;
}
.contact-picker-row { display: flex; align-items: center; gap: var(--sp-3); padding: 10px var(--sp-3); cursor: pointer; }
.contact-picker-row:hover { background: var(--s-hover); }
.contact-picker-row-main { display: flex; flex-direction: column; min-width: 0; }
.contact-picker-row-name { font-size: var(--fs-body); font-weight: 600; color: var(--t-hi); }
.contact-picker-row-phone { font-size: var(--fs-cap); color: var(--t-lo); }

/* =======================================================================================
   MONITORING & MEDIA (Phase 4) — App Usage analytics + Gallery
======================================================================================= */

/* ---- App Usage: sections + stat grid ---- */
.device-activity-body { display: flex; flex-direction: column; gap: var(--sp-7); }
.da-section { min-width: 0; }
.da-section-title {
  margin: 0 0 var(--sp-3); font-size: var(--fs-title); font-weight: 700;
  letter-spacing: -.01em; color: var(--t-hi);
}
.stat-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); }
.stat-tile {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4); min-width: 0;
  border-radius: var(--r-md); background: var(--s-2); border: 1px solid var(--hairline);
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.stat-tile:hover { border-color: var(--hairline-strong); background: var(--s-hover); }
.stat-icon {
  width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center;
  border-radius: 9px; background: rgba(148,163,184,.10); color: var(--t-mid); border: 1px solid var(--hairline);
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-tile-text { display: flex; flex-direction: column; min-width: 0; gap: 3px; }
.device-activity-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--t-faint);
}
.device-activity-value {
  font-size: var(--fs-body); font-weight: 700; color: var(--t-hi);
  /* wrap long values (Current App / Last Open App / Storage) instead of clipping them */
  overflow-wrap: anywhere; word-break: break-word; line-height: 1.3; min-width: 0;
}
/* let tiles with a wrapped value grow and keep the icon top-aligned rather than vertically centred */
.stat-tile { align-items: flex-start; }
.stat-tile .stat-icon { margin-top: 1px; }
.stat-value-row { display: flex; align-items: center; gap: 6px; }

/* ---- App Usage: top-apps list with usage bars ---- */
.da-most-used { color: var(--t-lo); font-size: var(--fs-sm); margin: 0 0 var(--sp-3); }
.da-most-used strong { color: var(--t-hi); }
.da-app-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.da-app-row {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md); background: var(--s-2); border: 1px solid var(--hairline);
}
.da-app-row-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); }
.da-app-name-block { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.da-app-name { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-body); font-weight: 600; color: var(--t-hi); min-width: 0; }
.da-app-rank {
  width: 20px; height: 20px; flex: 0 0 20px; display: grid; place-items: center; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 800;
}
.da-app-package { font-size: var(--fs-cap); color: var(--t-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.da-app-time { flex: 0 0 auto; font-size: var(--fs-sm); font-weight: 700; color: var(--t-lo); }
.da-app-bar-track { margin-top: var(--sp-2); height: 6px; border-radius: var(--r-pill); background: var(--s-3); overflow: hidden; }
.da-app-bar-fill { height: 100%; border-radius: var(--r-pill); background: linear-gradient(90deg, var(--accent-dim), var(--accent)); transition: width var(--dur-3) var(--ease); }

/* =======================================================================================
   GALLERY — modern media grid + lightbox
======================================================================================= */
.gallery-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }
.gallery-date-header {
  grid-column: 1 / -1; margin: var(--sp-3) 0 2px;
  font-size: var(--fs-cap); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--t-faint);
}
.gallery-date-header:first-child { margin-top: 0; }
.gallery-tile {
  position: relative; aspect-ratio: 1; padding: 0; overflow: hidden;
  border-radius: var(--r-md); border: 1px solid var(--hairline); background: var(--s-3);
  display: grid; place-items: center; cursor: pointer;
  transition: transform var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.gallery-tile:hover { transform: translateY(-2px); border-color: var(--accent-soft-2); box-shadow: var(--el-2); }
.gallery-tile:active { transform: translateY(0) scale(.98); }
.gallery-tile-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.gallery-tile-placeholder { color: var(--t-faint); }
.gallery-tile-placeholder svg { width: 30px; height: 30px; }
.gallery-tile-duration {
  position: absolute; bottom: 6px; right: 6px; z-index: 2;
  padding: 2px 7px; border-radius: 6px; background: rgba(2,6,23,.78); color: #fff;
  font-size: 10px; font-weight: 700; font-family: "Fira Code", monospace;
}
.gallery-tile-date {
  position: absolute; bottom: 6px; left: 6px; z-index: 2;
  padding: 2px 7px; border-radius: 6px; background: rgba(2,6,23,.6); color: #E2E8F0; font-size: 10px;
}
.gallery-tile-checkbox {
  position: absolute; top: 7px; right: 7px; z-index: 3; display: none;
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; background: rgba(2,6,23,.4);
}
.gallery-grid.select-mode .gallery-tile-checkbox { display: block; }
.gallery-tile.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.gallery-tile.selected .gallery-tile-checkbox {
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%2304140A' d='M9 16.2l-3.5-3.5L4 14.2 9 19.2 20 8.2l-1.5-1.5z'/%3E%3C/svg%3E") center/15px no-repeat;
  border-color: var(--accent);
}

/* Lightbox (also used for file preview) */
.gallery-lightbox {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: var(--sp-6);
  background: rgba(2,6,23,.94);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.gallery-lightbox-media { max-width: 94vw; max-height: 88vh; border-radius: var(--r-md); box-shadow: var(--el-4); }
.gallery-lightbox-download { left: auto; right: max(var(--sp-4), env(safe-area-inset-right)); }
.gallery-lightbox-status {
  position: fixed; bottom: var(--sp-7); left: 50%; transform: translateX(-50%);
  padding: var(--sp-2) var(--sp-4); border-radius: var(--r-pill);
  background: var(--glass-nav); border: 1px solid var(--hairline-strong); color: var(--t-hi); font-size: var(--fs-sm);
}

.gallery-album-tile .gallery-tile-date {
  left: 0; right: 0; bottom: 0; border-radius: 0 0 var(--r-lg) var(--r-lg);
  padding: var(--sp-1) var(--sp-2); background: rgba(2, 6, 23, .7);
  font-size: var(--fs-cap); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gallery-filter-chip { padding: 0 0 var(--sp-2); }
.gallery-filter-chip-btn {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3); border-radius: var(--r-pill);
  border: 1px solid var(--accent); background: var(--accent-soft);
  color: var(--accent); font-size: var(--fs-cap); font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.gallery-filter-chip-btn:hover { background: var(--accent-soft-2); }
#galleryAlbumsButton.active {
  background: var(--accent-soft); color: var(--accent); border-color: var(--accent);
}

@media (max-width: 640px) {
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: var(--sp-2); }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* Call recordings — date filter + sentinel (enterprise token overrides) */
.rec-date-filter { border-bottom: 1px solid var(--hairline); gap: var(--sp-2); padding: var(--sp-2) var(--sp-4); }
.rec-date-input { background: var(--s-2); border: 1px solid var(--hairline); border-radius: var(--r-sm); color: var(--t-hi); font-size: var(--fs-cap); padding: var(--sp-1) var(--sp-2); color-scheme: dark; }
.rec-date-input:focus { border-color: var(--accent); }
.rec-date-sep { color: var(--t-lo); }
.rec-date-clear { border-color: var(--hairline); color: var(--t-lo); font-size: var(--fs-cap); }
.rec-date-clear:hover { background: rgba(239,68,68,.12); color: #ef4444; border-color: #ef4444; }
.rec-filter-count { color: var(--accent); font-size: var(--fs-cap); }
.rec-load-sentinel { padding: var(--sp-5) 0; }

/* =======================================================================================
   PHASE 5 — Remote Control polish + global accessibility / motion pass
======================================================================================= */

/* ---- Remote Control screen ---- */
.remote-control-content {
  max-width: 1040px; margin: 0 auto; width: 100%;
  gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-5) max(var(--sp-5), calc(env(safe-area-inset-bottom) + var(--sp-3)));
}
.remote-control-video {
  border: 1px solid var(--hairline); border-radius: var(--r-lg);
  box-shadow: var(--el-3); background: #000;
}
.remote-control-status {
  color: var(--t-lo); font-size: var(--fs-sm);
  padding: var(--sp-2) var(--sp-4); border-radius: var(--r-pill);
  background: var(--s-2); border: 1px solid var(--hairline);
}
.remote-control-actions {
  gap: var(--sp-2); padding: var(--sp-2);
  background: var(--glass-nav); border: 1px solid var(--hairline); border-radius: var(--r-pill);
  box-shadow: var(--el-2);
  backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
}
.remote-control-action-button {
  width: 58px; height: 46px; border-radius: var(--r-md);
  border: 1px solid var(--hairline); background: var(--s-2); color: var(--t-mid);
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.remote-control-action-button:hover { background: var(--s-hover); color: var(--accent); border-color: var(--accent-soft-2); }
.remote-control-action-button:active { transform: scale(.93); background: var(--s-3); }

/* ---- Global keyboard-focus visibility (complements the existing button rule; adds inputs,
        links, rows and tiles). :where() keeps specificity at 0 so real styles always win. ---- */
:where(a, input, textarea, select, [tabindex]):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 5px;
}
.contact-row:focus-visible, .files-row:focus-visible,
.gallery-tile:focus-visible, .stat-tile:focus-visible {
  outline: 2px solid var(--accent); outline-offset: -2px;
}
/* Inputs get a clear focus ring across every screen */
.login-input:focus, .search-input:focus, .compose-input:focus,
input[type="search"]:focus, input[type="text"]:focus, input[type="tel"]:focus {
  outline: none; border-color: var(--accent-soft-2); box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---- Reduced motion: honour the OS setting everywhere (belt-and-suspenders over style.css) ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
  .ent-conn-badge.is-online .ent-dot, .dot.live { animation: none !important; }
}

/* ---- Respect users who prefer more contrast ---- */
@media (prefers-contrast: more) {
  :root {
    --hairline: rgba(148,163,184,.28);
    --hairline-strong: rgba(148,163,184,.42);
    --t-lo: #CBD5E1; --t-faint: #94A3B8;
  }
}

/* =======================================================================================
   Targeted fixes (real-device feedback)
======================================================================================= */

/* (1) SMS timestamps: the global .72 opacity made the dark time on the green "sent" bubble
   hard to read. Set explicit, readable per-direction colours at full opacity. */
.sms-bubble-time { opacity: 1; }
.sms-bubble-row-received .sms-bubble-time { color: rgba(203,213,225,.72); }
.sms-bubble-row-sent .sms-bubble-time { color: rgba(4,20,10,.8); font-weight: 500; }

/* (2) Remove the per-conversation delete button from Messages. */
.row-icon-button[data-row-action="delete-conversation"] { display: none; }

/* (4) Call Log / Messages date headers sit INSIDE the .contact-list panel; give them the same
   left inset as the rows so the first one isn't clipped against the panel's edge. */
.list-date-header {
  list-style: none;
  margin: 0;
  padding: var(--sp-3) var(--sp-4) var(--sp-2);
  font-size: var(--fs-cap); font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--t-faint);
  background: rgba(2,6,23,.35);
  border-bottom: 1px solid var(--hairline);
}
.list-date-header:first-child { padding-top: var(--sp-3); }

/* Remove the "Download all" button from the Gallery header (hidden, not deleted, so gallery.js's
   unguarded $("galleryDownloadAllButton").addEventListener can't crash). */
#galleryDownloadAllButton { display: none; }

/* =======================================================================================
   VISUAL POLISH (device picker, skeleton loaders, empty states) — CSS only, no ID/JS changes
======================================================================================= */

/* ---- Device Picker (connectScreen) ---- */
.device-picker { width: min(100%, 440px); margin: 0 auto; padding: var(--sp-6) var(--sp-5); }
.device-picker-title {
  margin: 0 0 4px; text-align: center;
  font-size: var(--fs-display); font-weight: 800; letter-spacing: -.02em; color: var(--t-hi);
}
.device-picker-subtitle { margin: 0 0 var(--sp-5); text-align: center; font-size: var(--fs-sm); color: var(--t-lo); }
.device-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.device-card {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  padding: var(--sp-4); text-align: left;
  border-radius: var(--r-lg); border: 1px solid var(--hairline);
  background: var(--s-2); box-shadow: var(--el-1); cursor: pointer;
  transition: transform var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.device-card:hover { transform: translateY(-2px); border-color: var(--accent-soft-2); background: var(--s-hover); box-shadow: var(--el-2); }
.device-card:active { transform: translateY(0) scale(.99); }
.device-card-icon {
  width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center;
  border-radius: 12px; background: var(--accent-soft); border: 1px solid var(--accent-soft-2); color: var(--accent);
}
.device-card-icon svg { width: 24px; height: 24px; }
.device-card-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 auto; }
.device-card-name { font-size: var(--fs-body); font-weight: 700; color: var(--t-hi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-card-status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-cap); color: var(--t-faint); }
.device-card-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--t-faint); box-shadow: none; }
.device-card-status .dot.live { background: var(--accent); box-shadow: 0 0 8px rgba(34,197,94,.7); }
/* chevron affordance */
.device-card::after {
  content: ""; margin-left: auto; flex: 0 0 auto; width: 8px; height: 8px; margin-right: 4px;
  border-right: 2px solid var(--t-faint); border-top: 2px solid var(--t-faint);
  transform: rotate(45deg); transition: border-color var(--dur-1) var(--ease);
}
.device-card:hover::after { border-color: var(--accent); }
.device-list-empty {
  margin-top: var(--sp-4); padding: var(--sp-6);
  border: 1px dashed var(--hairline-strong); border-radius: var(--r-lg);
  background: rgba(2,6,23,.4); color: var(--t-lo); text-align: center; font-size: var(--fs-sm);
}

/* ---- Skeleton loaders: turn the plain spinner+text into shimmer placeholder rows.
   The "Loading…" text is kept for screen readers (visually hidden), not removed. ---- */
.list-loading {
  position: relative; display: block; overflow: hidden;
  min-height: 296px; color: transparent;
  border-radius: var(--r-lg); border: 1px solid var(--hairline); background: var(--s-2);
}
.list-loading .list-loading-spinner { display: none; }
.list-loading > span:not(.list-loading-spinner) {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.list-loading::before {
  content: ""; position: absolute; inset: 0;
  background-color: var(--s-2);
  background-repeat: repeat-y;
  background-image:
    radial-gradient(circle 16px at 30px 28px, rgba(148,163,184,.13) 99%, transparent 100%),
    linear-gradient(to bottom, transparent 20px, rgba(148,163,184,.13) 20px 30px, transparent 30px),
    linear-gradient(to bottom, transparent 36px, rgba(148,163,184,.08) 36px 44px, transparent 44px);
  background-size: 100% 56px, 150px 56px, 100px 56px;
  background-position: 0 8px, 60px 8px, 60px 8px;
}
.list-loading::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(148,163,184,.10) 50%, transparent 80%);
  background-size: 220% 100%;
  animation: skeleton-sweep 1.5s ease-in-out infinite;
}
@keyframes skeleton-sweep { 0% { background-position: 160% 0; } 100% { background-position: -60% 0; } }
@media (prefers-reduced-motion: reduce) { .list-loading::after { animation: none; } }

/* ---- Friendlier empty / unavailable states: add a neutral icon above the message ---- */
.device-activity-unavailable::before {
  content: ""; display: block; width: 46px; height: 46px; margin: 0 auto var(--sp-3);
  border-radius: 50%; border: 1px solid var(--hairline);
  background: rgba(148,163,184,.08) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'%3E%3Cpath fill='%2364748B' d='M19 3H4.99C3.89 3 3 3.9 3 5v14c0 1.1.89 2 1.99 2H19c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 12h-4c0 1.66-1.35 3-3 3s-3-1.34-3-3H4.99V5H19v10z'/%3E%3C/svg%3E") center / 24px no-repeat;
}

/* In-app audio player (Files preview) — plays from an in-memory blob, no download to disk. Custom
   themed transport (play/seek/time) so it matches the enterprise UI, not the native browser player. */
.file-preview-audio {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-3);
  width: min(92vw, 420px); padding: var(--sp-7) var(--sp-6);
  border-radius: var(--r-xl); background: var(--s-2); border: 1px solid var(--hairline);
  box-shadow: var(--el-4);
}
.file-preview-audio-icon {
  width: 84px; height: 84px; flex: 0 0 84px; display: grid; place-items: center; border-radius: 50%;
  background: var(--accent-soft); border: 1px solid var(--accent-soft-2); color: var(--accent);
}
.file-preview-audio-name {
  font-size: var(--fs-body); font-weight: 600; color: var(--t-hi); text-align: center;
  overflow-wrap: anywhere; max-width: 100%;
}
.file-preview-audio-meta {
  font-size: var(--fs-cap); font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--t-lo);
}
.file-preview-audio-modified {
  font-size: var(--fs-cap); color: var(--t-faint); text-align: center;
}
.file-preview-audio-controls {
  display: flex; align-items: center; gap: var(--sp-4); width: 100%; margin-top: var(--sp-3);
}
.file-preview-audio-play {
  flex: 0 0 auto; width: 52px; height: 52px; border-radius: 50%; border: none; cursor: pointer;
  display: grid; place-items: center; background: var(--accent); color: #04120A;
  transition: filter var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.file-preview-audio-play:hover { filter: brightness(1.08); }
.file-preview-audio-play:active { transform: scale(.96); }
.file-preview-audio-track { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.file-preview-audio-seek {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px;
  background: rgba(148,163,184,.25); cursor: pointer; outline: none;
}
.file-preview-audio-seek::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--s-2); cursor: pointer; margin-top: -1px;
}
.file-preview-audio-seek::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: var(--accent);
  border: 2px solid var(--s-2); cursor: pointer;
}
.file-preview-audio-seek:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft-2); }
.file-preview-audio-time {
  display: flex; justify-content: space-between;
  font-size: var(--fs-cap); color: var(--t-lo); font-variant-numeric: tabular-nums;
}

/* Persistent audio mini-player — a floating bottom bar that keeps playing after the preview closes */
.audio-mini {
  position: fixed; left: 50%; bottom: max(var(--sp-4), env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 70; width: min(calc(100vw - var(--sp-6)), 460px);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--glass-nav, var(--s-2)); border: 1px solid var(--hairline-strong);
  border-radius: var(--r-pill); box-shadow: var(--el-4);
  backdrop-filter: blur(20px) saturate(140%); -webkit-backdrop-filter: blur(20px) saturate(140%);
}
.audio-mini-art {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--accent-soft-2);
  display: grid; place-items: center; cursor: pointer;
  background: var(--accent-soft); color: var(--accent);
  transition: filter var(--dur-1) var(--ease);
}
.audio-mini-art:hover { filter: brightness(1.1); }
.audio-mini-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.audio-mini-name {
  font-size: var(--fs-sm); font-weight: 600; color: var(--t-hi);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.audio-mini-progress { height: 4px; border-radius: 999px; background: rgba(148,163,184,.25); overflow: hidden; }
.audio-mini-fill { display: block; height: 100%; width: 0%; background: var(--accent); border-radius: 999px; }
.audio-mini-btn {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
  display: grid; place-items: center; background: var(--accent); color: #04120A;
  transition: filter var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.audio-mini-btn:hover { filter: brightness(1.08); }
.audio-mini-btn:active { transform: scale(.94); }
.audio-mini-stop { background: var(--s-3, var(--s-2)); color: var(--t-lo); border: 1px solid var(--hairline-strong); }
.audio-mini-stop:hover { background: var(--s-hover); color: var(--t-hi); }

/* Gallery lightbox image is pinch/pan zoomable — take over touch gestures from the browser */
#galleryLightboxImage { touch-action: none; transform-origin: center center; will-change: transform; }

/* Location screen — plain OpenStreetMap iframe embed + coordinate stat tiles */
.location-result { display: flex; flex-direction: column; gap: var(--sp-4); }
.location-map {
  width: 100%; height: min(48vh, 380px); border: 1px solid var(--hairline); border-radius: var(--r-lg);
  background: var(--s-1, var(--s-2));
}
.location-maps-link {
  display: inline-flex; align-items: center; gap: var(--sp-2); align-self: flex-start;
  padding: 10px var(--sp-4); border-radius: var(--r-pill);
  background: var(--accent); color: #04120A; font-size: var(--fs-sm); font-weight: 700;
  text-decoration: none; transition: filter var(--dur-1) var(--ease);
}
.location-maps-link:hover { filter: brightness(1.08); }

/* Find Device screen — Ring/Lock/Location stacked as one full-width row per action (the map+coords
   below only appear once Location is actually tapped, same as Ring/Lock only firing once confirmed
   — nothing on this screen happens automatically just from opening it). Lock uses the danger tint
   since it's the most disruptive of the three (matches its red confirm-dialog icon); Ring/Lock
   still require their own confirmation before anything actually fires (see findDeviceConfirmDialog
   / lockDeviceConfirmDialog) — these are entry points, not the actions themselves. */
.find-device-actions { display: flex; flex-direction: column; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.find-device-action-button {
  display: flex; flex-direction: row; align-items: center; gap: var(--sp-4);
  width: 100%; padding: var(--sp-4); border-radius: var(--r-lg);
  background: var(--s-2); border: 1px solid var(--hairline-strong); color: var(--t-hi);
  font-size: var(--fs-body); font-weight: 700; text-align: left; cursor: pointer;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.find-device-action-button svg { flex: 0 0 auto; color: var(--accent); }
.find-device-action-button:hover { background: var(--s-hover); border-color: var(--accent-soft-2); }
.find-device-action-button:active { transform: scale(.98); }
.find-device-action-button.danger svg { color: #FCA5A5; }
.find-device-action-button.danger:hover { background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.4); }

/* Find Device — ringing dialog. Icon pulses while the alarm is active; the fill bar drains over
   FIND_DEVICE_RING_MS (set from JS via inline style, see app.js) to visualize the device's own
   auto-stop timer. Both are neutralized automatically by the global prefers-reduced-motion rule
   above. */
.find-device-ringing-icon { animation: find-device-pulse 1s ease-in-out infinite; }
@keyframes find-device-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
.find-device-ring-progress {
  margin: var(--sp-4) 0; height: 8px; border-radius: var(--r-pill);
  background: var(--s-3); border: 1px solid var(--hairline); overflow: hidden;
}
.find-device-ring-fill {
  display: block; height: 100%; width: 100%; border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
}

/* ── Ambient Recorder — enterprise design-system overrides ── */
.ambient-rec-icon-col { background: var(--accent-dim); color: var(--accent); border-radius: var(--r-lg); }
.ambient-rec-name { font-size: var(--fs-body); font-weight: 600; color: var(--t-hi); }
.ambient-rec-meta { font-size: var(--fs-caption); color: var(--t-lo); }
.ambient-rec-play-btn { background: var(--accent-dim); color: var(--accent); }
.ambient-rec-play-btn:hover { background: var(--accent); }
.ambient-rec-del-btn { color: var(--t-lo); }

.ambient-new-btn { background: var(--accent); border-radius: var(--r-pill); font-size: var(--fs-caption); }
.ambient-empty-title { font-size: var(--fs-body-lg); font-weight: 700; color: var(--t-hi); }
.ambient-empty-sub { font-size: var(--fs-body); color: var(--t-lo); }
.ambient-empty-icon { background: var(--accent-dim); color: var(--accent); border-radius: var(--r-xl); }

.ambient-modal-icon-wrap { background: var(--accent-dim); color: var(--accent); border-radius: var(--r-xl); }
.ambient-duration-label { color: var(--t-lo); }
.ambient-time-input {
  background: var(--s-2); border-color: var(--hairline-strong);
  color: var(--t-hi); border-radius: var(--r-md); font-weight: 700;
}
.ambient-time-input:focus { border-color: var(--accent); }
.ambient-time-unit { color: var(--t-lo); }
.ambient-time-sep { color: var(--t-md, var(--t-lo)); }

/* Banner enterprise overrides */
.ambient-banner {
  background: var(--s-2); border-color: var(--hairline-strong);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg, 0 8px 32px rgba(0,0,0,.25));
}
.ambient-banner-title { font-size: var(--fs-body); color: var(--t-hi); }
.ambient-banner-sub { font-size: var(--fs-caption); color: var(--t-lo); }
.ambient-banner-bar-fill { background: var(--accent); }
.ambient-banner-save-btn { font-size: var(--fs-caption); }
