@import "./mobile-overview.css";
@import "./mobile-direct.css";
@import "./mobile-contact.css";
@import "./mobile-group.css";
@import "./mobile-message-actions.css";
@import "./mobile-systems.css";

/*
 * AgentsNet — mobile-first layout.
 *
 * The shell is a single-column phone surface: a compact top bar, a vertically
 * scrolling content column, and a fixed bottom tab bar. Nothing is a desktop
 * card grid squeezed onto a phone — every surface is sized in relative units and
 * wraps, so the body never scrolls horizontally.
 */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  background: var(--bg-2);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
}

:where(button, a, input, textarea, select, [tabindex]):focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

#mobile {
  display: flex;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
}

.phone {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 460px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  overflow-x: hidden;
}

/* ── top bar ─────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: calc(var(--safe-top) + var(--sp-4)) calc(var(--safe-right) + var(--sp-4))
    var(--sp-3) calc(var(--safe-left) + var(--sp-4));
  background: var(--glass);
  -webkit-backdrop-filter: var(--platform-bar-filter);
  backdrop-filter: var(--platform-bar-filter);
  border-bottom: 1px solid var(--hair);
}
.topbar > div:first-child {
  min-width: 0;
}

.topbar__title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ISSUE-2 WI-3: the status chip is the elastic loser no more. Device capture
   (Pixel 9a, 2026-07-28) showed "Not confirmed · Tap to check" cut to
   "Not confirmed · Tap to che" — the chip shrank and its nowrap text was clipped
   mid-word. A status reading that is physically unreadable is the same failure
   this work item is about, one layer down. The title already ellipsizes
   gracefully, so it yields instead; the chip keeps its natural width. */
.topbar__actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  min-width: 0;
  flex: 0 0 auto;
}

.topbar__actions .freshness {
  min-width: var(--tap);
  /* Backstop for a genuinely narrow screen: ellipsis, never a mid-word cut. */
  overflow: hidden;
}

.freshness > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__you {
  position: relative;
  overflow: hidden;
  display: inline-grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  flex: 0 0 var(--tap);
  border-radius: 999px;
  color: var(--text);
  background: var(--panel-3);
  border: 1px solid var(--line);
  -webkit-tap-highlight-color: transparent;
  transition: opacity 160ms ease-out, transform 160ms ease-out;
}

.topbar__you-icon {
  width: 20px;
  height: 20px;
}

/* freshness chip */
.freshness {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.freshness__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}
/* The tap affordance on the idle chip (F-DG-7): a small trailing refresh glyph
   says "this is a button", without shouting over the freshness reading. */
.freshness__refresh {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  opacity: 0.75;
}
.freshness--fresh {
  color: var(--green-ink);
  background: var(--green-tint);
  border-color: var(--nav-on-line);
}
.freshness--fresh .freshness__dot {
  background: var(--green);
}
.freshness--recent {
  color: var(--blue-ink);
  background: var(--blue-tint);
}
.freshness--recent .freshness__dot {
  background: var(--blue);
}
.freshness--stale {
  color: var(--amber-ink);
  background: var(--amber-tint);
  border-color: var(--amber-bd);
}
.freshness--stale .freshness__dot {
  background: var(--amber);
}
.freshness--offline {
  color: var(--danger-ink);
  background: var(--danger-tint);
}
.freshness--offline .freshness__dot {
  background: var(--danger);
}
/* Preview mode: the chip reads as demo semantics, not a staleness alarm (F-5) */
.freshness--demo {
  color: var(--amber-ink);
  background: var(--amber-tint);
  border-color: var(--amber-bd);
}
.freshness--demo .freshness__dot {
  background: var(--amber);
}

/* ── scrolling content ───────────────────────────────────────────────── */
.content {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* Bottom clearance = tabbar (84px) + the floating row above it (help
     button / connect pill / demo badge, ~56px) so the last card can always
     scroll clear of every floating layer (dogfood P-03/P-09). */
  padding: var(--sp-4) calc(var(--safe-right) + var(--sp-4))
    calc(var(--sp-6) + 140px + var(--safe-bottom)) calc(var(--safe-left) + var(--sp-4));
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* Persistent per-tab panes (nav-tab lag fix, 2026-08-26): every tab keeps its
   DOM between switches and a switch only flips [hidden]. The pane reproduces
   the .content column gap so the cards inside space exactly as before, and the
   [hidden] rule must beat the pane's own display or hidden panes would still
   lay out. */
.tabpane {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.tabpane[hidden] {
  display: none;
}

/* Sub-regions inside a pane (in-pane tap lag fix, 2026-08-26): one holder per
   screen region so a tap rewrites only the region it changed. Same column gap
   as the pane so fragments inside a region space exactly as before, and the
   same [hidden] rule so an empty region leaves the layout entirely. */
.tabpane-region {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.tabpane-region[hidden] {
  display: none;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--faint);
  margin: var(--sp-2) 0 calc(-1 * var(--sp-1));
}

/* ── cards ───────────────────────────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
}

.card--accent {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border-color: var(--nav-on-line);
}

.card__eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.card__title {
  font-size: 16px;
  font-weight: 700;
  margin: 4px 0 6px;
  line-height: 1.25;
}

.card__body {
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-2);
  overflow-wrap: anywhere;
}

.card__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

/* ── pills / badges ──────────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--panel-3);
  color: var(--text-2);
  border: 1px solid var(--hair);
}
.pill--green {
  color: var(--green-ink);
  background: var(--green-tint);
}
.pill--amber {
  color: var(--amber-ink);
  background: var(--amber-tint);
}
.pill--blue {
  color: var(--blue-ink);
  background: var(--blue-tint);
}
.pill--danger {
  color: var(--danger-ink);
  background: var(--danger-tint);
}

.demo-badge {
  display: inline-flex;
  vertical-align: middle;
  align-items: center;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--amber-ink);
  background: var(--amber-tint);
  border: 1px solid var(--amber-bd);
}

/* [v6] Identity chips — one stable hue per ANbot (contract §2). */
.pill--id-blue {
  color: var(--id-blue);
  background: var(--id-blue-tint);
  border-color: transparent;
}
.pill--id-teal {
  color: var(--id-teal);
  background: var(--id-teal-tint);
  border-color: transparent;
}
.pill--id-violet {
  color: var(--id-violet);
  background: var(--id-violet-tint);
  border-color: transparent;
}
.pill--id-amber {
  color: var(--id-amber);
  background: var(--id-amber-tint);
  border-color: transparent;
}
.pill--id-rose {
  color: var(--id-rose);
  background: var(--id-rose-tint);
  border-color: transparent;
}
.pill--id-slate {
  color: var(--id-slate);
  background: var(--id-slate-tint);
  border-color: transparent;
}

/* Owner-unread badge (contract §5). GREEN, because unread is the owner's own
   normal backlog and not an alarm; --danger stays for things that failed. */
.unread-badge {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  background: var(--green);
  color: var(--on-green);
}
.readnote {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--faint);
}

/* Presence dots (contract §3). Each state has its own SHAPE as well as its own
   colour — solid / weakened / hollow / dashed — so the four readings survive a
   glance and a colour-blind eye. */
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.status-dot--on {
  background: var(--presence-on);
  box-shadow: var(--green-glow);
}
.status-dot--recent {
  background: var(--presence-recent);
}
.status-dot--standby {
  background: var(--blue);
}
.status-dot--quiet {
  background: var(--gold);
}
.status-dot--off {
  width: 8px;
  height: 8px;
  background: none;
  border: 1.5px solid var(--presence-off);
}
.status-dot--unknown {
  width: 8px;
  height: 8px;
  background: none;
  border: 1.5px dashed var(--presence-unknown);
}

/* ── roster (Team) ───────────────────────────────────────────────────── */
.roster-item {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
}
/* The avatar carries the ANbot's identity hue, never green (contract §2) — a
   green avatar beside an "Off duty" dot is two contradictory readings of the
   same teammate. `--id-slate` is the fallback and the external-speaker hue. */
.avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--r-md);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
  color: var(--id-slate);
  background: var(--id-slate-tint);
  border: 1px solid var(--line-2);
}
.avatar--blue {
  color: var(--id-blue);
  background: var(--id-blue-tint);
}
.avatar--teal {
  color: var(--id-teal);
  background: var(--id-teal-tint);
}
.avatar--violet {
  color: var(--id-violet);
  background: var(--id-violet-tint);
}
.avatar--amber {
  color: var(--id-amber);
  background: var(--id-amber-tint);
}
.avatar--rose {
  color: var(--id-rose);
  background: var(--id-rose-tint);
}
.avatar--slate {
  color: var(--id-slate);
  background: var(--id-slate-tint);
}
.roster-item__main {
  flex: 1 1 auto;
  min-width: 0;
}
.roster-item__name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
}
.roster-item__meta {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 1px;
}
.roster-item__focus {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 6px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
/* ISSUE-44's other half: the projection is always stamped with when it was
   true, so a screen full of data is never mistaken for a screen full of NOW. */
.roster-asof {
  padding: var(--sp-1) 0 2px;
  font-size: 11px;
  color: var(--faint);
  text-align: center;
}

/* ── approval card family (contract §5) ──────────────────────────────── */
/* OPEN cards wear a 3px amber bar — amber means "waiting on a decision" across
   the whole family, so the eye finds them without reading a word. A SETTLED
   card drops the bar and compresses: it is a receipt now, not a request. */
.appr {
  border-left: 3px solid var(--amber);
}
.appr--settled {
  border-left: 1px solid var(--line-2);
  border-color: var(--line-2);
  padding-top: 10px;
  padding-bottom: 10px;
  opacity: 0.92;
}
/* Arriving from a notification: the card the alert was about is outlined, so
   the owner's eye lands on it instead of on whatever is topmost. */
.appr--pinned {
  outline: 2px solid var(--green);
  outline-offset: 1px;
  box-shadow: var(--green-glow);
}
.appr__meta {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.appr__btns {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}
.appr__btns .btn {
  flex: 1 1 0;
  padding: 11px 6px;
}
.appr__outcome {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: 10px;
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
}
.expiry {
  margin-left: auto;
  font-size: 11px;
  color: var(--faint);
}

/* The fold row is a pill (contract §5) — visually a control, not a card, so it
   never reads as one more thing waiting on you. */
.collapse-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  border: 1px dashed var(--line);
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 12.5px;
  text-align: left;
}
.collapse-row__hint {
  margin-left: auto;
  color: var(--faint);
  font-size: 11px;
}

/* ── notification preview ────────────────────────────────────────────── */
.notif {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
}
.notif__glyph {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: var(--panel-3);
  font-size: 16px;
}
.notif__title {
  font-weight: 700;
  font-size: 14px;
}
.notif__body {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 2px;
  overflow-wrap: anywhere;
}
.notif__stage {
  font-size: 11px;
  color: var(--faint);
  margin-top: 6px;
}

/* ── clearances ──────────────────────────────────────────────────────── */
.clearance__head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.tier-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.4px;
  padding: 3px 8px;
  border-radius: 7px;
}
.tier-badge--t1 {
  color: var(--blue-ink);
  background: var(--blue-tint);
}
.tier-badge--t2 {
  color: var(--amber-ink);
  background: var(--amber-tint);
  border: 1px solid var(--amber-bd);
}
.gate-note {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px dashed var(--hair);
}

/* ── buttons ─────────────────────────────────────────────────────────── */
.btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: var(--tap);
  padding: 0 var(--sp-4);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 160ms ease-out, transform 160ms ease-out, background 160ms ease-out;
}
.btn--full {
  width: 100%;
}
.btn--primary {
  color: var(--bg-2);
  background: var(--grad-green);
}
.btn--ghost {
  color: var(--text);
  background: var(--panel-3);
  border: 1px solid var(--line);
}
.btn--danger {
  color: #fff;
  background: var(--danger);
}
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ── order composer (Line) ───────────────────────────────────────────── */
.composer {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

/* v0144rep XM-11/XM-12: a bidirectional thread must show which side spoke.
   Keep the inset small enough for a 320px viewport and leave status copy in
   text; direction is never communicated by colour alone. */
.inbox-message--incoming {
  margin-right: 24px;
}

.inbox-message--outgoing {
  margin-left: 24px;
  border-color: var(--blue);
}

/* D4b: native scrolling wins over a held phone-local row. The shared pointer
   reducer cancels once movement exceeds 8px; pan-y keeps the browser side from
   turning a long press into a scroll-blocking gesture. */
.inbox-message[data-message-kind="message"] {
  touch-action: pan-y;
  -webkit-touch-callout: none;
}

.inbox-message[data-notification-target="true"] {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.composer__input {
  width: 100%;
  min-height: 96px;
  resize: none;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--input-bg);
  padding: var(--sp-3);
  font-size: 14px;
  line-height: 1.45;
}
.composer__note {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
/* The remaining-character count sits under the box and turns amber near the
   limit — a task truncated mid-sentence is a task the home device carries out
   wrong, so the warning arrives before the last word is typed, not after. */
.charcount {
  margin-top: calc(-1 * var(--sp-2));
  font-size: 11px;
  color: var(--faint);
  text-align: right;
}
.charcount--low {
  color: var(--amber-ink);
}
/* Target chips: presence travels with the name so an off-duty teammate is
   visible BEFORE typing. D4 — this informs, it never blocks the send. */
.target-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: var(--sp-2);
}
.target-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--text-2);
  font-family: inherit;
  font-size: 12.5px;
}
.target-chip.on {
  border-color: transparent;
  background: var(--green-tint);
  color: var(--green-ink);
  font-weight: 600;
}
.queue-item {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
}
.queue-item__dot {
  margin-top: 5px;
}

/* ── empty / degraded ────────────────────────────────────────────────── */
.empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: var(--sp-6) var(--sp-4);
}
.banner {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
  font-size: 13px;
  line-height: 1.4;
}
.banner--amber {
  background: var(--amber-bg);
  border: 1px solid var(--amber-bd);
  color: var(--amber-ink);
}
/* ISSUE-44: the unreachable-home bar. It sits ABOVE the projection and never
   replaces it — losing the connection must not also lose the last known state
   of the team, which is exactly when the owner wants to look at it. */
.banner--danger {
  align-items: center;
  background: var(--danger-tint);
  border: 1px solid transparent;
  color: var(--danger-ink);
}
.banner--danger .btn {
  flex: 0 0 auto;
  margin-left: auto;
}

/* ── bottom tab bar ──────────────────────────────────────────────────── */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 460px;
  display: flex;
  z-index: 10;
  padding: var(--sp-2) calc(var(--safe-right) + var(--sp-2))
    calc(var(--sp-2) + var(--safe-bottom)) calc(var(--safe-left) + var(--sp-2));
  background: var(--glass);
  -webkit-backdrop-filter: var(--platform-bar-filter);
  backdrop-filter: var(--platform-bar-filter);
  border-top: 1px solid var(--hair);
}
.tab {
  position: relative;
  overflow: hidden;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 2px;
  min-height: var(--tap);
  border-radius: 12px;
  color: var(--muted);
  -webkit-tap-highlight-color: transparent;
  transition: color 160ms ease-out, background 160ms ease-out, transform 160ms ease-out,
    opacity 160ms ease-out;
}
.tab__icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  line-height: 1;
}
.tab__svg {
  width: 22px;
  height: 22px;
  display: block;
}
.tab__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tab--active {
  color: var(--green-ink);
  background: var(--nav-on-bg);
}
/* Contract §5: the tab badge counts decisions WAITING, so it is amber, not
   danger. Red is for things that went wrong; three approvals to read are a
   normal Tuesday, and painting them as failures is how people learn to ignore
   the badge that matters. */
.tab__badge {
  position: absolute;
  top: -4px;
  right: -8px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--amber);
  color: #221a04;
  font-size: 10px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

/* ── platform visual grammar ─────────────────────────────────────────── */
html.platform-ios .topbar,
html.platform-ios .tabbar {
  background: var(--glass);
}

html.platform-ios .card,
html.platform-ios .notif,
html.platform-ios .sheet__waiting {
  border-radius: 16px;
}

html.platform-ios .sheet__panel,
html.platform-ios .mobile-priming__card {
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
}

html.platform-ios :where(.btn, .tab, .freshness, .topbar__you, .about-row, .sheet__back, .mobile-onb__skip, .mobile-onb-help):active {
  opacity: 0.76;
  transform: scale(var(--platform-press-scale));
}

html.platform-android .card,
html.platform-android .notif,
html.platform-android .sheet__waiting {
  border-radius: var(--radius);
}

html.platform-android .btn {
  border-radius: 999px;
}

html.platform-android .tab {
  border-radius: 18px;
}

html.platform-android .tab--active {
  border-radius: 999px;
}

html.platform-android :where(.btn, .tab, .freshness, .topbar__you, .about-row, .sheet__back, .mobile-onb__skip, .mobile-onb-help)::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: currentColor;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease-out;
}

html.platform-android :where(.btn, .tab, .freshness, .topbar__you, .about-row, .sheet__back, .mobile-onb__skip, .mobile-onb-help):active::after {
  opacity: 0.12;
}

html.platform-android .btn--primary:active::after {
  opacity: 0.18;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* UX-1 — reachable exit from the camera scan.
 * The QR scan runs `windowed: true`, so the native camera renders BEHIND the
 * webview. Make the app surfaces transparent/hidden while scanning so the live
 * camera shows through, and leave only the #mobile-scan-cancel overlay
 * (created in pairing-controller.ts) visible on top with its Cancel button. */
html.mobile-scanning,
body.mobile-scanning {
  background: transparent !important;
}
body.mobile-scanning #mobile,
body.mobile-scanning .phone,
body.mobile-scanning #mobile-pairing {
  visibility: hidden !important;
}

/* UX-3 — the freshness chip is now the single refresh control (the old floating
 * engine strip is gone). It is a real <button>: tap to check for updates, with a
 * spinner while the wake is in flight. */
.freshness {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 160ms ease-out, transform 160ms ease-out;
}
.freshness:active {
  opacity: 0.85;
}
.freshness--checking {
  color: var(--muted);
  background: var(--panel-3);
  border-color: var(--hair);
}
.freshness__spinner {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid var(--hair);
  border-top-color: var(--green);
  animation: mobile-spin 0.7s linear infinite;
}
@keyframes mobile-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Compact button for inline use (the "This phone" card's next action). */
.btn--sm {
  min-height: var(--tap);
  padding: 0 var(--sp-3);
  font-size: 13px;
}

/* ── S6 pairing sheet (UX-3) ─────────────────────────────────────────────
 * A design-system bottom sheet: a dimmed backdrop with a rounded panel that
 * slides up from the bottom, a grabber, and a `‹ Back` control. Replaces the
 * old full-bleed pairing overlay + floating pill. */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  flex-direction: column;
  justify-content: flex-end;
  background: var(--scrim);
}
.sheet[data-open="true"] {
  display: flex;
}
.sheet__panel {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  box-sizing: border-box;
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-2) calc(var(--safe-right) + var(--sp-4))
    calc(var(--safe-bottom) + var(--sp-5)) calc(var(--safe-left) + var(--sp-4));
  animation: mobile-sheet-in var(--platform-sheet-duration) var(--platform-sheet-ease);
}
@keyframes mobile-sheet-in {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}
.sheet__grabber {
  width: 36px;
  height: 4px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--hair);
  margin: var(--sp-1) auto var(--sp-2);
}
.sheet__head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--tap);
}
.sheet__back {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: var(--tap);
  min-width: 58px;
  padding: 0 var(--sp-2) 0 0;
  font-size: 16px;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.sheet__back span[aria-hidden] {
  font-size: 22px;
  line-height: 1;
}
.sheet__back:active {
  opacity: 0.6;
}
.sheet__title {
  font-size: 18px;
  font-weight: 700;
}
.sheet__lead {
  margin: 0;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.45;
}
.sheet__error {
  margin: 0;
  color: var(--danger-ink);
  font-size: 14px;
  line-height: 1.45;
}
.sheet__hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.sheet__recover {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.sheet__waiting {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.4;
}
.sheet__wait-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
  box-shadow: var(--green-glow);
  animation: mobile-pulse 1.4s ease-in-out infinite;
}
@keyframes mobile-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

/* ── UX-2 onboarding + permission priming (additive) ─────────────────────────
 * First-run intro overlay, a re-view (help) entry, a Demo-mode badge, and the
 * post-pairing notification priming sheet. All self-mounted by onboarding.ts;
 * visibility is toggled inline (display:none ↔ flex), these rules only style. */

/* Keep the onboarding chrome out of the way of the live camera scan. */
body.mobile-scanning #mobile-onb-help,
body.mobile-scanning #mobile-demo-badge,
body.mobile-scanning #mobile-onboarding,
body.mobile-scanning #mobile-about,
body.mobile-scanning #mobile-priming {
  visibility: hidden !important;
}

/* ── S7 You/About sheet (ST-1B) ─────────────────────────────────────────── */
.mobile-about {
  z-index: 60;
}

.mobile-about__panel {
  gap: var(--sp-4);
}

.about-status {
  flex-wrap: wrap;
}

.about-version {
  margin-top: var(--sp-3);
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.about-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.about-row {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  color: var(--text);
  text-align: left;
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  -webkit-tap-highlight-color: transparent;
  transition: opacity 160ms ease-out, transform 160ms ease-out, background 160ms ease-out;
}

.about-row[disabled],
.about-row[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.about-row--danger {
  color: var(--danger-ink);
  background: var(--danger-tint);
  border-color: color-mix(in srgb, var(--danger) 28%, transparent);
}

.about-row__main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.about-row__label {
  font-size: 14px;
  font-weight: 800;
}

.about-row__detail {
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.about-confirm {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--radius);
  color: var(--danger-ink);
  background: var(--danger-tint);
  border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent);
}

.about-confirm--done {
  color: var(--green-ink);
  background: var(--green-tint);
  border-color: var(--nav-on-line);
}

.about-confirm__actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

/* first-run overlay */
.mobile-onb {
  position: fixed;
  inset: 0;
  z-index: 70;
  flex-direction: column;
  box-sizing: border-box;
  background: var(--bg);
  color: var(--text);
  overflow-y: auto;
  padding: calc(var(--safe-top) + var(--sp-5))
    calc(var(--safe-right) + var(--sp-5)) calc(var(--safe-bottom) + var(--sp-5))
    calc(var(--safe-left) + var(--sp-5));
  animation: mobile-onb-fade 180ms ease-out;
}
.mobile-onb__bar,
.mobile-onb__stage,
.mobile-onb__actions {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  box-sizing: border-box;
}
.mobile-onb__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.mobile-onb__skip {
  position: relative;
  overflow: hidden;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 var(--sp-3);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.mobile-onb__dots {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}
.mobile-onb__dot {
  position: relative;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  background: none;
}
.mobile-onb__dot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--line);
  transition: width 160ms ease-out, background 160ms ease-out;
}
.mobile-onb__dot.is-active::after {
  width: 22px;
  background: var(--green);
}
.mobile-onb__stage {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--sp-4);
  padding: var(--sp-6) 0;
}
.mobile-onb__art {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--green-ink);
  background: var(--green-tint);
  border: 1px solid var(--nav-on-line);
}
.mobile-onb__art svg {
  width: 52px;
  height: 52px;
}
.mobile-onb__title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
}
.mobile-onb__text {
  margin: 0;
  max-width: 34ch;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-2);
}
.mobile-onb__actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
/* entry-side disclosure under the demo CTA (F-11) */
.mobile-onb__note {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
  color: var(--text-2);
}

/* re-view (help) entry — a stopgap until S7/ST-1 lands "Replay the tour" */
.mobile-onb-help {
  position: fixed;
  overflow: hidden;
  z-index: 40;
  left: calc(var(--safe-left) + var(--sp-3));
  bottom: calc(var(--safe-bottom) + 76px);
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  color: var(--text-2);
  background: var(--glass);
  border: 1px solid var(--hair);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
}

/* Demo-mode badge — a real button since F-11: tapping it opens the
   leave-demo sheet, so the demo is never a one-way door. */
.mobile-demo-badge {
  position: fixed;
  z-index: 46;
  right: calc(var(--safe-right) + var(--sp-3));
  bottom: calc(var(--safe-bottom) + 78px);
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--amber-ink);
  background: var(--amber-tint);
  border: 1px solid var(--amber-bd);
  cursor: pointer;
}
/* invisible halo so the small pill still meets the touch-target size */
.mobile-demo-badge::after {
  content: "";
  position: absolute;
  inset: -12px;
}

/* iOS Add-to-Home teaching steps (F-2/F-3), inside the shared bottom sheet */
.mobile-install-steps {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-2);
}

/* post-pairing notification priming — a bottom sheet */
.mobile-priming {
  position: fixed;
  inset: 0;
  z-index: 55;
  flex-direction: column;
  justify-content: flex-end;
  box-sizing: border-box;
  background: var(--scrim);
  padding: var(--sp-4) calc(var(--safe-right) + var(--sp-4))
    calc(var(--safe-bottom) + var(--sp-4)) calc(var(--safe-left) + var(--sp-4));
}
.mobile-priming__card {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-5);
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: mobile-priming-rise 220ms ease-out;
}
.mobile-priming__glyph {
  font-size: 28px;
  line-height: 1;
}
.mobile-priming__title {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
}
.mobile-priming__body {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-2);
}
.mobile-priming__actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  width: 100%;
  margin-top: var(--sp-3);
}

@keyframes mobile-onb-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes mobile-priming-rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* M10 layout parity: the Rail spans the installed app; every route owns the header in the right pane. */
.mobile-shell { height: 100dvh; min-height: 0; }
/* Android edge-to-edge WebView reports a zero CSS safe-area inset on Pixel 9a
 * even while the system status bar overlays the page. Reserve the platform's
 * 24 CSS-pixel status-bar floor so the Rail and route-owned headers never sit
 * underneath the clock/icons. iOS keeps using its native env() inset. */
.platform-android .mobile-shell { padding-top: max(var(--safe-top), 24px); }
.mobile-shell__layout {
  display: grid;
  grid-template-columns: clamp(72px, 17.7vw, 76px) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}
.mobile-shell__rail { min-width: 0; min-height: 0; overflow: hidden; background: var(--rail); }
.mobile-shell__rail .mobile-rail { height: 100%; }
.mobile-shell .content {
  min-width: 0;
  min-height: 0;
  padding: 0;
  padding-bottom: var(--safe-bottom);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);
}
.mobile-shell .tabpane-region { gap: 0; }
.mobile-shell [data-shell-region="topbar"],
.mobile-shell [data-shell-region="banner"],
.mobile-shell [data-shell-region="header"],
.mobile-shell [data-shell-region="summary"],
.mobile-shell [data-shell-region="filters"],
.mobile-shell [data-shell-region="status"] { flex: 0 0 auto; min-width: 0; }
.mobile-shell [data-shell-region="rows"],
.mobile-shell [data-shell-region="body"],
.mobile-shell [data-shell-region="phone"],
.mobile-shell [data-shell-region="hero"] {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.mobile-shell h1, .mobile-shell h2 { overflow-wrap: anywhere; }
.mobile-shell .topbar { position: static; flex-wrap: wrap; }
.mobile-shell .mobile-direct__filters { flex-wrap: wrap; }

.mobile-pane__header {
  min-height: 66px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid var(--line-2);
  background: var(--panel);
}
.mobile-pane__header--tall { min-height: 76px; }
.mobile-pane__heading { min-width: 0; flex: 1 1 auto; }
.mobile-pane__title {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 1.125rem;
  line-height: 22px;
  font-weight: 600;
}
.mobile-pane__subtitle {
  margin: 2px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.6875rem;
  line-height: 15px;
}
.mobile-pane__generic-icon,
.mobile-pane__icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--green-ink);
  background: var(--green-tint);
}
.mobile-pane__icon-button {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
  border-radius: 11px;
  color: var(--muted);
  background: var(--panel-2);
}
.mobile-pane__generic-icon .icon,
.mobile-pane__icon-button .icon { width: 18px; height: 18px; }
.mobile-pane__sync {
  width: 100%;
  min-height: 34px;
  padding: 7px 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  background: var(--bg);
  border-bottom: 1px solid var(--line-2);
  font-size: 0.625rem;
  line-height: 14px;
  text-align: left;
}
.mobile-pane__sync .icon { width: 14px; height: 14px; margin-left: auto; }
.mobile-pane__sync-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-tint);
}
.mobile-pane__sync--stale .mobile-pane__sync-dot { background: var(--amber); box-shadow: none; }
.mobile-pane__sync--offline .mobile-pane__sync-dot { background: var(--danger); box-shadow: none; }

@media (max-width: 370px) {
  .mobile-shell__layout { grid-template-columns: 72px minmax(0, 1fr); }
  .mobile-pane__header { padding-inline: 9px; gap: 7px; }
  .mobile-pane__title { font-size: 1rem; }
}
