/*
 * Skynet phone app (WO-209) — the TelaGo × Skynet dark layer.
 *
 * Every rule is scoped under `body.phone` or the phone app's own classes
 * (`.phone-app`, `.ph-*`, `#phone-*`), so the desktop console is untouched.
 * Colours are the SDS palette (indigo action, cyan accent, magenta review,
 * blue in motion, pink stalled) on TelaGo's dark ground; nothing here changes
 * an SDS token, it only adds `--ph-*` ones.
 *
 * Spacing is binding from Skynet-ADS/Build/ux-remediation/TELAGO-SPACING.md
 * (TSG 2026-09-26: "a lot of space between buttons and functions"): 24 px
 * gutter, 36 px between sections, 16 px between cards and buttons, 24 px card
 * padding, 44 px pills 12 px apart, 72 px list rows, one action per row.
 * test/phone-spacing.test.mjs pins these values; scripts/phone-dom-check.mjs
 * measures them in a real browser.
 */

.phone-app { display: none; }
body.phone:not(.signed-out) .phone-app { display: block; }
body.phone:not(.signed-out) #shell,
body.phone:not(.signed-out) #drawer-host { display: none !important; }

/* WO-243: the dark ground covers the whole document. The desktop base gives
   html and body a fixed 100% height and html keeps the light SDS canvas, so a
   phone screen taller than the viewport overflowed the body onto that light
   canvas (section labels went white-on-white below the first screen). */
html:has(> body.phone:not(.signed-out)) { background: var(--sds-color-bg); }
body.phone:not(.signed-out) { height: auto; min-height: 100dvh; }

body.phone {
  /* WO-286 (SKY-21, SKY-24, SKY-71): every phone colour is an SDS role, so the
     phone follows the system / light / dark choice like every other surface.
     These names are pure aliases; the values live in packages/skyui/sds. */

  /* Spacing (TELAGO-SPACING.md) */
  --ph-gutter: 24px;
  --ph-top: calc(20px + env(safe-area-inset-top, 0px));
  --ph-section: 36px;
  --ph-label-gap: 14px;
  --ph-card-gap: 16px;
  --ph-card-pad: 24px;
  --ph-kpi-pad: 20px;
  --ph-inner: 12px;
  --ph-action-gap: 16px;
  --ph-chip-gap: 12px;
  --ph-chip-h: 44px;
  --ph-icon-btn: 48px;
  --ph-btn-h: 56px;
  --ph-row-h: 72px;
  --ph-scope-row-h: 64px;
  --ph-check-row-h: 56px;
  --ph-tabbar: 84px;
  --ph-plus: 56px;
  --ph-report: 48px;
  --ph-radius-card: 20px;
  --ph-radius-btn: 14px;
  /* The keyboard inset (visualViewport) that sheets sit above. */
  --ph-kb: 0px;
  /* Tab bar + 16 px + the Report button + 32 px of air, plus the safe area. */
  --ph-content-bottom: calc(var(--ph-tabbar) + 16px + var(--ph-report) + 32px + env(safe-area-inset-bottom, 0px));

  background: var(--sds-color-bg);
  color: var(--sds-color-text);
  font-family: var(--sds-font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body.phone.ph-sheet-open { overflow: hidden; }

/* Resets at zero specificity (:where) so every .ph-* rule below wins. */
:where(.phone-app),
:where(.phone-app) * { box-sizing: border-box; }
:where(.phone-app) :where(button, input, textarea) { font-family: inherit; color: inherit; font-size: inherit; }
:where(.phone-app) :where(button) { background: none; border: 0; padding: 0; margin: 0; cursor: pointer; box-shadow: none; min-height: 0; }
/* Links are painted by their .ph-* class; this beats the SDS/app link colour. */
body.phone .phone-app a { color: inherit; text-decoration: none; }
:where(.phone-app) :where(h1, h2, h3, p, ul, ol) { margin: 0; padding: 0; }
:where(.phone-app) :where(ul, ol) { list-style: none; }
.phone-app :focus { outline: none; }
.phone-app :focus-visible { outline: 2px solid var(--sds-color-focus); outline-offset: 3px; }
.phone-app [hidden] { display: none !important; }

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

/* -- Screen ------------------------------------------------------------- */

.ph-screen {
  display: flex;
  flex-direction: column;
  gap: var(--ph-section);
  max-width: 600px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: var(--ph-top) var(--ph-gutter) var(--ph-content-bottom);
}
.ph-stack { display: flex; flex-direction: column; gap: var(--ph-card-gap); }
.ph-inner-stack { display: flex; flex-direction: column; gap: var(--ph-inner); }

.ph-head {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--ph-icon-btn);
}
.ph-mark { width: 32px; height: 32px; flex: none; }
/* WO-286: scoped so SDS base `.sds h1` does not win (it had painted 22 px). */
.phone-app .ph-head-title { flex: 1; min-width: 0; font-size: var(--sds-type-large-title); font-weight: 700; letter-spacing: 0; line-height: 1.15; }
.ph-date { font-size: var(--sds-type-callout); color: var(--sds-color-subtle); margin-top: 4px; }

.ph-avatar {
  width: var(--ph-icon-btn); height: var(--ph-icon-btn);
  flex: none;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--sds-color-fill-field);
  border: 1px solid var(--sds-color-border);
  font-size: var(--sds-type-headline); font-weight: 600;
}

.ph-back {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: var(--ph-icon-btn);
  padding-right: 16px;
  font-size: var(--sds-type-body); font-weight: 500;
  color: var(--sds-color-accent) !important;
  align-self: flex-start;
}

/* WO-286: scoped so SDS base `.sds h1` does not win; the one large title on the page (SKY-11). */
.phone-app .ph-title { font-size: var(--sds-type-large-title); font-weight: 700; line-height: 1.2; }
.ph-summary { font-size: var(--sds-type-body); line-height: 1.5; color: var(--sds-color-muted); }
.ph-body { font-size: var(--sds-type-body); line-height: 1.5; color: var(--sds-color-muted); }
.ph-meta { font-size: var(--sds-type-callout); line-height: 1.4; color: var(--sds-color-subtle); }

/* -- Section label + count badge ------------------------------------------ */

.ph-section { display: flex; flex-direction: column; gap: var(--ph-label-gap); }
/* WO-286 (SKY-12): the SDS section-header style, sentence case. Scoped under .phone-app so it beats
   SDS base `.sds h2` (which had been painting these labels at the 20 px section size). */
.phone-app .ph-label {
  display: flex; align-items: center; gap: 10px;
  font-size: var(--sds-type-section-header); font-weight: var(--sds-weight-semibold); letter-spacing: var(--sds-tracking-none);
  color: var(--sds-color-subtle);
}
.ph-badge {
  min-width: 24px; height: 24px;
  padding: 0 8px;
  display: inline-grid; place-items: center;
  border-radius: 999px;
  font-size: var(--sds-type-footnote); font-weight: 700; letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  background: var(--sds-color-fill-field);
  color: var(--sds-color-text);
}
.ph-badge[data-tone="review"] { background: var(--sds-color-warning-bg); color: var(--sds-color-warning); }
.ph-badge[data-tone="motion"] { background: var(--sds-color-info-bg); color: var(--sds-color-info); }
.ph-badge[data-tone="danger"] { background: var(--sds-color-danger-bg); color: var(--sds-color-danger); }

/* WO-277: the Apps "See all" is a real button (it toggles in place), so it drops the UA button chrome. */
button.ph-see-all { background: none; border: 0; padding: 0; font-family: inherit; cursor: pointer; }
.ph-see-all {
  display: inline-flex; align-items: center;
  min-height: 44px;
  align-self: flex-start;
  font-size: var(--sds-type-body); font-weight: 600;
  color: var(--sds-color-accent) !important;
}

/* -- Apps (WO-277): the company's apps with the desktop's marks ----------- */

.ph-apps {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--ph-card-gap);
}
.ph-app {
  display: flex; flex-direction: column; align-items: center; gap: var(--ph-inner);
  min-width: 0;
  padding: 20px 8px;
  background: var(--sds-color-panel);
  border: 1px solid var(--sds-color-hairline);
  border-radius: var(--ph-radius-card);
  text-align: center;
}
.ph-app .skydesk-app-mark { width: 52px; height: 52px; border-radius: 14px; flex: none; }
/* A near-black brand tile (GitHub, Supabase) keeps an edge on a dark card. The full-tile logo covers an
   inset shadow, so the edge is an inset outline (WO-286). */
.ph-app .skydesk-app-mark[data-tone="github"], .ph-app .skydesk-app-mark[data-tone="supabase"] { outline: 1px solid var(--sds-color-border); outline-offset: -1px; }
.ph-app-name {
  max-width: 100%;
  font-size: var(--sds-type-callout); font-weight: 600; line-height: 1.3; color: var(--sds-color-text);
  overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.ph-app-state { font-size: var(--sds-type-footnote); font-weight: 600; line-height: 1.2; color: var(--sds-color-muted); }
.ph-app[data-readiness="needs_setup"] .ph-app-state { color: var(--sds-color-warning); }
.ph-app[data-readiness="not_on_file"] .ph-app-state { color: var(--sds-color-danger); }
.ph-app[data-readiness="deploying"] .ph-app-state,
.ph-app[data-readiness="in_development"] .ph-app-state { color: var(--sds-color-info); }

/* -- Cards ------------------------------------------------------------- */

.ph-card {
  display: flex; flex-direction: column; gap: var(--ph-inner);
  background: var(--sds-color-panel);
  border: 1px solid var(--sds-color-hairline);
  border-radius: var(--ph-radius-card);
  padding: var(--ph-card-pad);
}
.ph-card-title { font-size: var(--sds-type-headline); font-weight: 600; line-height: 1.35; }
.ph-empty { color: var(--sds-color-muted); font-size: var(--sds-type-body); line-height: 1.5; }
.ph-empty strong { color: var(--sds-color-text); font-weight: 600; display: block; margin-bottom: 8px; }

/* A list row is its own card: 72 px, 16 px vertical padding, one action. */
.ph-row {
  display: flex; align-items: center; gap: 16px;
  min-height: var(--ph-row-h);
  padding: 16px 20px;
  background: var(--sds-color-panel);
  border: 1px solid var(--sds-color-hairline);
  border-radius: var(--ph-radius-card);
}
a.ph-row:active,
button.ph-row:active { background: var(--sds-color-raised); }
.ph-row-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ph-row-title { font-size: var(--sds-type-headline); font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.ph-row-sub { font-size: var(--sds-type-callout); line-height: 1.4; color: var(--sds-color-subtle); overflow-wrap: anywhere; }
.ph-row-end { flex: none; display: flex; align-items: center; gap: 12px; }
.ph-chevron { color: var(--sds-color-subtle); font-size: var(--sds-type-section); flex: none; }

.ph-disc {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--sds-color-fill-field);
  color: var(--sds-color-muted);
}
.ph-disc[data-tone="review"] { background: var(--sds-color-warning-bg); color: var(--sds-color-warning); }
.ph-disc[data-tone="motion"] { background: var(--sds-color-info-bg); color: var(--sds-color-info); }
.ph-disc[data-tone="danger"] { background: var(--sds-color-danger-bg); color: var(--sds-color-danger); }
.ph-disc[data-tone="live"] { background: var(--sds-color-success-bg); color: var(--sds-color-success); }

/* Status text (not tappable): dot + label */
.ph-status { display: inline-flex; align-items: center; gap: 8px; font-size: var(--sds-type-callout); font-weight: 600; color: var(--sds-color-muted); white-space: nowrap; }
.ph-status::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: currentColor; }
.ph-status[data-tone="review"] { color: var(--sds-color-warning); }
.ph-status[data-tone="motion"] { color: var(--sds-color-info); }
.ph-status[data-tone="danger"] { color: var(--sds-color-danger); }
.ph-status[data-tone="live"],
.ph-status[data-tone="done"] { color: var(--sds-color-success); }
.ph-status[data-tone="quiet"] { color: var(--sds-color-subtle); }

/* -- Pills and chips ---------------------------------------------------- */

.ph-pills { display: flex; flex-wrap: wrap; gap: var(--ph-chip-gap); }
.ph-pill {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: var(--ph-chip-h);
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--sds-color-border);
  background: var(--sds-color-fill-field);
  font-size: var(--sds-type-callout); font-weight: 600; line-height: 1.2;
  color: var(--sds-color-text);
  white-space: nowrap;
}
.ph-pill[aria-pressed="true"],
.ph-pill[aria-current="true"] {
  border-color: var(--sds-color-accent);
  background: var(--sds-color-accent-soft);
  color: var(--sds-color-accent);
}
/* Tags are labels, not controls: smaller and never tappable. */
.ph-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.ph-tag {
  display: inline-flex; align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--sds-color-border);
  background: var(--sds-color-fill-field);
  font-size: var(--sds-type-footnote); font-weight: 600;
  color: var(--sds-color-muted);
}
.ph-tag[data-tone="review"] { color: var(--sds-color-warning); border-color: color-mix(in srgb, var(--sds-color-warning) 40%, transparent); }
.ph-tag[data-tone="motion"] { color: var(--sds-color-info); border-color: color-mix(in srgb, var(--sds-color-info) 40%, transparent); }
/* WO-286 (SKY-22): where a note belongs is a company label (indigo tone), not a status. */
.ph-tag[data-tone="company"] { color: var(--sds-tone-indigo-fg); border-color: var(--sds-tone-indigo-border); }
.ph-tag[data-tone="live"] { color: var(--sds-color-success); border-color: color-mix(in srgb, var(--sds-color-success) 40%, transparent); }
.ph-tag[data-tone="danger"] { color: var(--sds-color-danger); border-color: color-mix(in srgb, var(--sds-color-danger) 40%, transparent); }
.ph-mono { font-family: var(--sds-font-mono); font-size: var(--sds-type-footnote); }

/* -- Buttons: one per row, full width, 56 high, 16 apart ----------------- */

.ph-actions { display: flex; flex-direction: column; gap: var(--ph-action-gap); }
.ph-actions-split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--ph-action-gap); }
.ph-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  min-height: var(--ph-btn-h);
  padding: 14px 18px;
  border-radius: var(--ph-radius-btn);
  font-size: var(--sds-type-body); font-weight: 600; line-height: 1.2;
  text-align: center;
}
.ph-btn-filled { background: var(--sds-color-action) !important; color: var(--sds-color-on-action) !important; }
.ph-btn-tinted { background: var(--sds-color-fill-tinted) !important; color: var(--sds-color-selection-text) !important; }
.ph-btn-gray { background: var(--sds-color-fill-gray) !important; color: var(--sds-color-text) !important; }
.ph-btn-destructive { background: var(--sds-color-danger-bg) !important; color: var(--sds-color-danger) !important; }
.ph-btn:disabled,
.ph-btn[aria-disabled="true"],
.ph-icon-btn.ph-btn-filled:disabled { background: var(--sds-color-fill-gray) !important; color: var(--sds-color-subtle) !important; cursor: default; }
.ph-reason { font-size: var(--sds-type-callout); color: var(--sds-color-subtle); line-height: 1.4; }

.ph-icon-btn {
  width: var(--ph-icon-btn); height: var(--ph-icon-btn);
  flex: none;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--sds-color-fill-gray);
  color: var(--sds-color-text);
}
.ph-icon-btn.ph-btn-filled { background: var(--sds-color-action); color: var(--sds-color-on-action); }
.ph-icon-btn:disabled { background: var(--sds-color-fill-gray); color: var(--sds-color-subtle); }

/* -- Today: capture pill, chips, KPI tiles --------------------------------- */

.ph-capture {
  display: flex; align-items: center; gap: var(--ph-action-gap);
  min-height: 64px;
  padding: 8px 8px 8px 20px;
  border-radius: 999px;
  background: var(--sds-color-panel);
  border: 1px solid var(--sds-color-border);
}
body.phone .ph-capture-input {
  flex: 1; min-width: 0;
  min-height: var(--ph-icon-btn);
  margin: 0; padding: 0;
  background: transparent; border: 0; border-radius: 0; box-shadow: none;
  outline: none;
  font-size: var(--sds-type-input);
  color: var(--sds-color-text);
}
body.phone .ph-capture-input::placeholder { color: var(--sds-color-subtle); opacity: 1; }

.ph-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ph-kpis-3 { grid-template-columns: repeat(3, 1fr); }
.ph-kpis-3 .ph-kpi { min-height: 104px; }
.ph-kpi {
  display: flex; flex-direction: column; justify-content: space-between; gap: 8px;
  min-height: 112px;
  padding: var(--ph-kpi-pad);
  border-radius: var(--ph-radius-card);
  background: var(--sds-color-panel);
  border: 1px solid var(--sds-color-hairline);
}
.ph-kpi-label { font-size: var(--sds-type-section-header); font-weight: var(--sds-weight-semibold); letter-spacing: var(--sds-tracking-none); color: var(--sds-color-subtle); }
.ph-kpi-value { font-size: var(--sds-type-title); font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ph-kpi[data-tone="review"] .ph-kpi-value { color: var(--sds-color-warning); }
.ph-kpi[data-tone="motion"] .ph-kpi-value { color: var(--sds-color-info); }
.ph-kpi[data-tone="danger"] .ph-kpi-value { color: var(--sds-color-danger); }
.ph-kpi[data-tone="live"] .ph-kpi-value { color: var(--sds-color-success); }
.ph-kpi-pending .ph-kpi-value { color: var(--sds-color-subtle); }

/* -- Banners, errors --------------------------------------------------- */

.ph-banner {
  padding: 16px 20px;
  border-radius: 16px;
  background: var(--sds-color-info-bg);
  color: var(--sds-color-info);
  font-size: var(--sds-type-body); line-height: 1.5;
}
.ph-error {
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px 20px;
  border-radius: 16px;
  background: var(--sds-color-danger-bg);
  color: var(--sds-color-danger);
  font-size: var(--sds-type-body); line-height: 1.5;
}
.ph-error strong { color: var(--sds-color-text); }
.ph-error-fix { color: var(--sds-color-muted); }
.ph-loading { color: var(--sds-color-subtle); font-size: var(--sds-type-body); }
.ph-callout {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 16px 20px;
  border-radius: 16px;
  background: var(--sds-color-accent-soft);
  color: var(--sds-color-muted);
  font-size: var(--sds-type-body); line-height: 1.5;
}
.ph-callout svg { flex: none; color: var(--sds-color-accent); margin-top: 2px; }

/* -- Refined note: checklist, questions ------------------------------------ */

.ph-checklist { display: flex; flex-direction: column; gap: var(--ph-action-gap); }
.ph-check-row {
  display: flex; align-items: center; gap: 16px;
  width: 100%;
  min-height: var(--ph-check-row-h);
  padding: 14px 20px;
  border-radius: 16px;
  background: var(--sds-color-panel);
  border: 1px solid var(--sds-color-hairline);
  text-align: left;
}
.ph-check {
  width: 24px; height: 24px; flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  border: 2px solid var(--sds-color-border);
}
.ph-check-row[aria-pressed="true"] .ph-check { background: var(--sds-color-selection); border-color: var(--sds-color-selection); color: var(--sds-color-on-selection); }
.ph-starts-agent { font-size: var(--sds-type-footnote); font-weight: 600; color: var(--sds-color-warning); white-space: nowrap; }

body.phone .ph-field {
  width: 100%;
  margin: 0;
  box-shadow: none;
  min-height: var(--ph-btn-h);
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--sds-color-raised);
  border: 1px solid var(--sds-color-border);
  color: var(--sds-color-text);
  font-size: var(--sds-type-input);
}
body.phone .ph-field::placeholder { color: var(--sds-color-subtle); opacity: 1; }
body.phone textarea.ph-field { min-height: 132px; resize: none; line-height: 1.5; }
body.phone .ph-field:focus { border-color: var(--sds-color-accent); }

.ph-original summary {
  display: flex; align-items: center;
  min-height: 44px;
  cursor: pointer;
  font-size: var(--sds-type-body); font-weight: 600;
  color: var(--sds-color-accent);
}
.ph-original[open] summary { margin-bottom: 12px; }
.ph-attachment-list { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }

/* -- Item progress ------------------------------------------------------- */

.ph-progress { display: flex; flex-direction: column; gap: 16px; }
.ph-step { display: flex; align-items: center; gap: 16px; font-size: var(--sds-type-body); }
.ph-step-dot {
  width: 14px; height: 14px; flex: none;
  border-radius: 999px;
  border: 2px solid var(--sds-color-border);
}
.ph-step[data-state="done"] .ph-step-dot { background: var(--sds-color-success); border-color: var(--sds-color-success); }
.ph-step[data-state="current"] .ph-step-dot { border-color: var(--sds-color-info); box-shadow: 0 0 0 4px color-mix(in srgb, var(--sds-color-info) 20%, transparent); }
.ph-step[data-state="todo"] { color: var(--sds-color-subtle); }
.ph-step-label { flex: 1; }
.ph-step-meta { font-size: var(--sds-type-callout); color: var(--sds-color-subtle); }
.ph-agent-line { display: flex; gap: 16px; align-items: flex-start; }

/* -- Run sheet ----------------------------------------------------------- */

.ph-scope-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: var(--ph-scope-row-h);
  padding: 12px 20px;
  border-radius: 16px;
  background: var(--sds-color-panel);
  border: 1px solid var(--sds-color-hairline);
}
.ph-scope-key { font-size: var(--sds-type-callout); color: var(--sds-color-subtle); }
.ph-scope-value { font-size: var(--sds-type-headline); font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.ph-does { display: flex; flex-direction: column; gap: 12px; font-size: var(--sds-type-body); line-height: 1.45; color: var(--sds-color-muted); }
.ph-does li { display: flex; gap: 12px; }
.ph-does li::before { content: "✓"; color: var(--sds-color-success); flex: none; }
.ph-does[data-kind="not"] li::before { content: "✕"; color: var(--sds-color-danger); }
/* Run: pinned 24 px above the tab bar with 24 px of clear space above it; the
   screen's bottom padding equals the pin, so the button never moves. The
   Report button steps up to sit 16 px above the Run button on this screen. */
.ph-screen[data-screen="run"] { padding-bottom: calc(var(--ph-tabbar) + 24px + env(safe-area-inset-bottom, 0px)); }
.ph-run-bar {
  position: sticky;
  bottom: calc(var(--ph-tabbar) + 24px + env(safe-area-inset-bottom, 0px));
  padding-top: 24px;
  /* Solid ground above (the 24 px of clear space) and below (down to the tab
     bar) so scrolled content never shows around the pinned Run button. */
  background: var(--sds-color-bg);
  box-shadow: 0 24px 0 var(--sds-color-bg);
  display: flex; flex-direction: column; gap: 12px;
}
.ph-run-bar .ph-reason { padding-right: calc(var(--ph-report) + 16px); }
.phone-app[data-screen="run"] .ph-report { bottom: calc(var(--ph-tabbar) + 24px + var(--ph-btn-h) + 16px + env(safe-area-inset-bottom, 0px)); }

/* -- Tab bar ------------------------------------------------------------- */

.ph-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--ph-tabbar) + env(safe-area-inset-bottom, 0px));
  padding: 0 8px env(safe-area-inset-bottom, 0px);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: var(--sds-color-chrome-toolbar);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  border-top: 0.5px solid var(--sds-color-hairline);
}
.ph-tab {
  justify-self: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-width: 56px; min-height: 56px;
  padding: 4px 6px;
  font-size: var(--sds-type-footnote); font-weight: 500;
  color: var(--sds-color-subtle) !important;
  position: relative;
}
.ph-tab[aria-current="page"] { color: var(--sds-color-accent) !important; }
.ph-tab-plus {
  justify-self: center;
  width: var(--ph-plus); height: var(--ph-plus);
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--sds-color-action) !important;
  color: var(--sds-color-on-action) !important;
  box-shadow: var(--sds-elevation-2);
}

/* Report an issue: 16 px above the tab bar, 24 px from the right edge. */
.ph-report {
  position: fixed; z-index: 39;
  right: var(--ph-gutter);
  bottom: calc(var(--ph-tabbar) + 16px + env(safe-area-inset-bottom, 0px));
  width: var(--ph-report); height: var(--ph-report);
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--sds-color-raised) !important;
  border: 1px solid var(--sds-color-border) !important;
  color: var(--sds-color-muted) !important;
  box-shadow: var(--sds-shadow-popover);
}

/* -- Sheets (capture, report, account) ------------------------------------ */

/* WO-312: a sheet is SkyUI's drawer, a bottom sheet at 640px and under (handle, rounded
   top, safe-area padding, Esc, scrim and the one close control are SkyUI's). The phone
   keeps its own spacing inside, and lifts the sheet above the on-screen keyboard. */
.ph-sheet-body { display: flex; flex-direction: column; gap: 24px; }
body.phone #phone-sheet .sds-drawer { bottom: var(--ph-kb); }
body.phone.ph-kb-open #phone-sheet .sds-drawer { max-block-size: calc(100dvh - var(--ph-kb) - 24px); }
.ph-pickers { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--ph-action-gap); }
.ph-picker {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 72px;
  border-radius: 16px;
  background: var(--sds-color-panel) !important;
  border: 1px solid var(--sds-color-hairline) !important;
  font-size: var(--sds-type-footnote); font-weight: 600;
  color: var(--sds-color-muted) !important;
}
.ph-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.ph-thumbs { display: flex; flex-wrap: wrap; gap: 12px; }
.ph-thumb { position: relative; width: 72px; height: 72px; border-radius: 12px; overflow: hidden; background: var(--sds-color-panel); border: 1px solid var(--sds-color-hairline); }
.ph-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-thumb-file { display: grid; place-items: center; height: 100%; padding: 6px; font-size: var(--sds-type-footnote); text-align: center; color: var(--sds-color-subtle); overflow: hidden; }
.ph-thumb-remove {
  position: absolute; top: 0; right: 0;
  width: 44px; height: 44px;
  display: grid; place-items: start end;
  padding: 4px !important;
  color: var(--sds-palette-white) !important;
}
.ph-thumb-remove svg { background: color-mix(in srgb, var(--sds-palette-black) 70%, transparent); border-radius: 999px; padding: 4px; box-sizing: content-box; }

/* -- Removed surface ("Open on desktop") ------------------------------------ */

.ph-desktop-only { text-align: left; }

/* -- Toast / update bar ----------------------------------------------------- */

/* WO-312: toasts are SkyUI's region; this hook sits them above the tab bar and the
   Report button, as the phone's own toast did. */
body.phone { --skyui-bottom-bar-block-size: calc(var(--ph-tabbar) + 16px + var(--ph-report)); }

/* The update offer is a SkyUI banner, in flow at the top of the page (never over content). */
body.phone .ph-update-host:not([hidden]) {
  padding: calc(env(safe-area-inset-top, 0px) + 8px) var(--ph-gutter) 0;
}


