/* aim-phone.css — the shared kit for PHONE MODE views (ADR-0151 D10): Today, Work, Site, Notifications,
   Schedule, Me. Built from the canvas (https://claude.ai/artifact/Q61JaPRX6JfCiFjgsMHhQ3; source kept in
   docs/mobile-canvas). Every class is ph-*, and only phone views render ph-* markup, so no media query guards
   this file: desktop mode never mounts a phone view. Tokens only (aim-canonical.css, incl. the ADR-0151 set). */

.ph {
    min-height: 100dvh;
    background: var(--ground);
    color: var(--ink);
    padding-bottom: calc(var(--tabbar-height) + var(--safe-bottom) + 24px);
}

.ph-defs { position: absolute; width: 0; height: 0; }
.ph-stop--ok { stop-color: var(--ok); }
.ph-stop--warn { stop-color: var(--warn); }
.ph-stop--bad { stop-color: var(--bad); }
.ph-stop--info { stop-color: var(--action); }
.ph-stop--fade { stop-opacity: 0.45; }

.ph-i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.ph-i--s { width: 18px; height: 18px; }

/* ---- Hero: the brand panel ------------------------------------------------ */
.ph-hero {
    position: relative;
    overflow: hidden;
    background: var(--brand);
    color: var(--on-action);
    padding: calc(var(--safe-top) + 20px) max(16px, var(--safe-right)) 18px max(16px, var(--safe-left));
    border-radius: 0 0 var(--radius-sheet) var(--radius-sheet);
}

.ph-omark {
    position: absolute;
    top: -40px;
    right: -90px;
    width: 260px;
    height: 199px;
    fill: color-mix(in srgb, var(--on-action) 8%, transparent);
    fill-rule: evenodd;
    pointer-events: none;
}

.ph-hero__row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ph-hero__date {
    font-size: var(--text-m-label);
    font-weight: 600;
    opacity: 0.8;
}

.ph-hero__title {
    margin: 0;
    color: var(--on-action); /* the global h1 colour would otherwise win over the hero's inherited one */
    font-size: var(--text-m-title);
    font-weight: 800;
    line-height: 1.15;
}

.ph-iconbtn {
    position: relative;
    width: var(--tap);
    height: var(--tap);
    border-radius: var(--radius-control);
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--on-action) 13%, transparent);
    color: var(--on-action);
    text-decoration: none;
    flex-shrink: 0;
    border: 0; /* also used on <button>, which brings a default border */
    cursor: pointer;
}

.ph-pip {
    position: absolute;
    top: 10px;
    right: 11px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--warn);
    border: 2px solid var(--brand);
}

.ph-tiles {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 16px;
}

.ph-tile {
    background: color-mix(in srgb, var(--on-action) 12%, transparent);
    border-radius: var(--radius-control);
    padding: 10px 12px;
}

.ph-tile__num {
    font-size: var(--text-m-title);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.ph-tile__lbl {
    font-size: var(--text-m-caption);
    opacity: 0.85;
}

/* ---- Body ------------------------------------------------------------------ */
.ph-body {
    padding: 16px max(16px, var(--safe-right)) 0 max(16px, var(--safe-left));
}

.ph-sect {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 0 0 10px;
}

.ph-sect--gap { margin-top: 20px; }

.ph-h2 {
    margin: 0;
    font-size: var(--text-m-headline);
    font-weight: 700;
}

.ph-link {
    font-size: var(--text-m-label);
    font-weight: 700;
    color: var(--action);
    text-decoration: none;
    min-height: var(--tap);
    display: inline-flex;
    align-items: center;
}

.ph-card {
    position: relative;
    overflow: hidden;
    background: var(--raised);
    border-radius: var(--radius-card-m);
    box-shadow: var(--lift-1);
}

.ph-card--pad { padding: 16px; }

.ph-slot {
    position: absolute;
    top: 0;
    right: 0;
    width: 76px;
    height: 40px;
    pointer-events: none;
}

.ph-mini {
    position: absolute;
    left: 0;
    top: 0;
    width: 11px;
    height: 100%;
    pointer-events: none;
}

.ph-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    padding-right: 48px;
}

.ph-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--text-m-caption);
    font-weight: 700;
    line-height: 1.3;
    white-space: nowrap;
}

.ph-badge--ok { background: var(--ok-wash); color: var(--ok); }
.ph-badge--warn { background: var(--warn-wash); color: var(--warn); }
.ph-badge--bad { background: var(--bad-wash); color: var(--bad); }
.ph-badge--n { background: var(--sunken); color: var(--ink-muted); }
.ph-badge--info { background: var(--action-wash); color: var(--action-hover); }

.ph-cap {
    font-size: var(--text-m-caption);
    font-weight: 500;
    color: var(--ink-faint);
}

.ph-cap--m { margin-top: 2px; font-size: var(--text-m-label); }

.ph-name {
    display: block;
    margin-top: 8px;
    font-size: var(--text-m-title);
    font-weight: 800;
    line-height: 1.2;
    color: var(--ink);
    text-decoration: none;
}

.ph-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.ph-facts:empty { display: none; }

.ph-fact {
    font-size: var(--text-m-caption);
    font-weight: 600;
    color: var(--ink-muted);
    background: var(--sunken);
    border-radius: var(--radius-sm);
    padding: 3px 8px;
}

.ph-actions {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 8px;
    margin-top: 14px;
}

.ph-btn {
    min-height: calc(var(--tap) + 4px);
    border-radius: var(--radius-control);
    border: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    font: 700 var(--text-m-body) / 1 var(--font-primary);
    text-decoration: none;
    cursor: pointer;
}

.ph-btn--p {
    background: var(--action);
    color: var(--on-action);
    box-shadow: var(--lift-2);
}

.ph-btn--s {
    background: var(--raised);
    color: var(--brand-on);
    border: 2px solid var(--line);
}

.ph-empty,
.ph-error {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
}

.ph-empty .ph-btn,
.ph-error .ph-btn { margin-top: 8px; }

.ph-strong { font-size: var(--text-m-body); font-weight: 700; }
.ph-muted { font-size: var(--text-m-label); color: var(--ink-muted); }

/* ---- Later today rows ------------------------------------------------------ */
.ph-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 12px 14px 12px 20px;
    color: inherit;
    text-decoration: none;
}

.ph-row__when {
    width: 54px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.ph-row__time {
    font-size: var(--text-m-label);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.ph-row__main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.ph-row__name {
    font-size: var(--text-m-body);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ph-chev { color: var(--ink-faint); }

.ph-div { border-top: 1px solid var(--line); }

/* ---- Loading ----------------------------------------------------------------- */
.ph-sk {
    height: 14px;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--ground) 25%, var(--sunken) 50%, var(--ground) 75%);
    background-size: 200% 100%;
    animation: ph-shimmer 1.5s ease-in-out infinite;
}

@keyframes ph-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .ph-sk { animation: none; }
}

/* ---- Compact hero: page title + one action, optional search (Work, Notifications, ...) ---- */
.ph-hero--compact { padding-bottom: 14px; }
.ph-hero--compact .ph-omark { width: 220px; height: 169px; top: -50px; right: -80px; }

.ph-search {
    position: relative;
    display: block;
    margin-top: 16px;
}

.ph-search .ph-i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-faint);
    pointer-events: none;
}

.ph-search input {
    width: 100%;
    box-sizing: border-box;
    min-height: calc(var(--tap) + 4px);
    border: 0;
    border-radius: var(--radius-control);
    background: var(--raised);
    color: var(--ink);
    padding: 0 14px 0 46px;
    font: 500 var(--text-m-body) var(--font-primary);
}

/* ---- Segmented control: switches a view (Mine / Decide / Pool) ---- */
.ph-seg {
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    gap: 4px;
    padding: 4px;
    border-radius: var(--radius-control);
    background: color-mix(in srgb, var(--anchor) 70%, var(--ground));
}

.ph-seg button {
    min-height: var(--tap);
    border: 0;
    border-radius: calc(var(--radius-control) - 3px);
    background: transparent;
    color: var(--ink-muted);
    font: 700 var(--text-m-label) var(--font-primary);
    cursor: pointer;
}

.ph-seg button[aria-pressed="true"] {
    background: var(--raised);
    color: var(--ink);
    box-shadow: var(--lift-1);
}

/* ---- Chip row: one scrolling line of filters ---- */
.ph-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 12px calc(-1 * max(16px, var(--safe-right))) 0 calc(-1 * max(16px, var(--safe-left)));
    padding: 0 max(16px, var(--safe-right)) 2px max(16px, var(--safe-left));
}

.ph-chips::-webkit-scrollbar { display: none; }

.ph-chip {
    flex-shrink: 0;
    min-height: 40px;
    padding: 0 14px;
    border-radius: var(--radius-control);
    border: 2px solid var(--line);
    background: var(--raised);
    color: var(--ink-muted);
    font: 600 var(--text-m-label) var(--font-primary);
    white-space: nowrap;
    cursor: pointer;
}

.ph-chip[aria-pressed="true"] {
    background: var(--brand-on);
    border-color: var(--brand-on);
    color: var(--on-action);
}

/* ---- Queue rows: name, chip + meta, age, ONE verb (design language §20.3) ---- */
.ph-qrow {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 72px;
    padding: 12px 12px 12px 22px;
}

.ph-qrow__main {
    flex: 1;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.ph-qrow__name {
    display: block;
    font-size: var(--text-m-body);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ph-qrow__meta {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 4px;
    min-width: 0;
}

.ph-qrow__meta .ph-cap {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ph-code {
    flex-shrink: 0;
    padding: 2px 7px;
    border-radius: var(--radius-sm);
    background: var(--anchor);
    color: var(--brand-on);
    font-size: var(--text-m-caption);
    font-weight: 700;
}

.ph-qrow__side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.ph-verb {
    min-height: 40px;
    padding: 0 14px;
    border-radius: var(--radius-control);
    border: 2px solid var(--line);
    background: var(--raised);
    color: var(--brand-on);
    font: 700 var(--text-m-label) var(--font-primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.ph-verb:disabled { opacity: 0.5; cursor: not-allowed; }

.ph-group {
    width: 100%;
    margin-top: 12px;
    min-height: 60px;
    border: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    text-align: left;
    font-family: var(--font-primary);
    color: var(--ink);
    cursor: pointer;
}

.ph-note {
    margin: 10px 0 0;
    padding: 10px 14px;
    border-radius: var(--radius-control);
    font-size: var(--text-m-label);
    font-weight: 600;
}

.ph-note--ok { background: var(--ok-wash); color: var(--ok); }
.ph-note--bad { background: var(--bad-wash); color: var(--bad); }

/* ---- Detail hero extras (Site) ---- */
.ph-hero__date--gap { position: relative; margin-top: 12px; }
.ph-hero__title--gap { margin-top: 12px; }
.ph-hero .ph-hero__title { position: relative; padding: 0; margin: 2px 0 0; }

.ph-hero__badges {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.ph-badge--glass { background: color-mix(in srgb, var(--on-action) 16%, transparent); color: var(--on-action); }

.ph-iconbtn--light { background: var(--sunken); color: var(--brand-on); }

/* ---- Fact tiles: four up ---- */
.ph-facts4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.ph-card--fact { padding: 10px; }

.ph-fact__val {
    margin-top: 2px;
    font-size: var(--text-m-headline);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ph-card--link { display: block; color: inherit; text-decoration: none; }

.ph-issue { display: flex; gap: 10px; align-items: flex-start; padding-right: 40px; }
.ph-issue__icon { margin-top: 1px; }

.ph-ink--bad { color: var(--bad); }
.ph-ink--warn { color: var(--warn); }
.ph-ink--ok { color: var(--ok); }
.ph-ink--brand { color: var(--brand-on); }

.ph-trunc { max-width: 60%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Workflow steps: one segment per stage, the current one ringed ---- */
.ph-steps { display: flex; gap: 4px; margin-top: 4px; }

.ph-step {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: var(--line);
}

.ph-step--done { background: var(--ok); }
.ph-step--now { background: var(--action); }

.ph-steps__now { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }

/* ---- Info rows (where it is, nearest A&E) ---- */
.ph-irow { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 12px 14px; }
.ph-irow__main { flex: 1; min-width: 0; }
.ph-strong--n { font-weight: 600; font-size: var(--text-m-label); line-height: 1.35; }

/* ---- Bottom action bar (detail screens: replaces the tab bar) ---- */
.ph-body--bar { padding-bottom: calc(var(--tap) + var(--safe-bottom) + 40px); }

.ph-bbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1010;
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 12px max(16px, var(--safe-right)) calc(12px + var(--safe-bottom)) max(16px, var(--safe-left));
    background: var(--raised);
    border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
    box-shadow: var(--lift-3);
}

/* ---- The canvas stepper (up to six stages): labelled circles joined by a rule ---- */
.ph-stepper {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
}

.ph-stepper__item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.ph-stepper__item + .ph-stepper__item::before {
    content: "";
    position: absolute;
    top: 13px;
    right: calc(50% + 15px);
    width: calc(100% - 30px);
    height: 3px;
    background: var(--line);
}

.ph-stepper__item--done + .ph-stepper__item::before,
.ph-stepper__item--done + .ph-stepper__item--done::before { background: var(--ok); }

.ph-stepper__dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sunken);
    border: 2px solid var(--line);
    box-sizing: border-box;
}

.ph-stepper__item--done .ph-stepper__dot { background: var(--ok); border-color: var(--ok); color: var(--on-action); }
.ph-stepper__item--now .ph-stepper__dot { background: var(--raised); border: 3px solid var(--action); box-shadow: inset 0 0 0 5px var(--raised), inset 0 0 0 10px var(--action); }

.ph-stepper__lbl {
    max-width: 100%;
    font-size: var(--text-m-caption);
    font-weight: 600;
    color: var(--ink-faint);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ph-stepper__item--now .ph-stepper__lbl { color: var(--ink); font-weight: 800; }

/* ---- Me: who you are, then grouped setting rows ---- */
.ph-me { position: relative; display: flex; align-items: center; gap: 14px; }

.ph-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--raised);
    color: var(--brand-on);
    font-size: var(--text-m-headline);
    font-weight: 800;
}

.ph-me__name { font-size: var(--text-m-headline); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ph-lbl {
    margin: 16px 0 6px 4px;
    font-size: var(--text-m-label);
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--ink-muted);
}

.ph-srow {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 8px 14px;
    border: 0;
    background: transparent;
    color: var(--ink);
    text-decoration: none;
    text-align: left;
    font-family: var(--font-primary);
    cursor: pointer;
}

.ph-srow__ic {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-control);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sunken);
    color: var(--brand-on);
}

/* Rows are links: hold their colours against the global a / a:visited / a:hover rules. */
a.ph-srow, a.ph-srow:visited, a.ph-srow:hover { color: var(--ink); text-decoration: none; }
a.ph-srow .ph-cap { color: var(--ink-faint); }

.ph-srow__t { flex: 1; min-width: 0; font-size: var(--text-m-body); font-weight: 600; }
.ph-srow__sub { display: block; margin-top: 1px; font-weight: 500; }

.ph-srow--bad { color: var(--bad); }
.ph-srow--bad .ph-srow__ic { background: var(--bad-wash); color: var(--bad); }

.ph-div--in { margin-left: 62px; }

/* ---- Light top bar: list screens that are not a dashboard (Notifications) ---- */
.ph-top {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: calc(var(--safe-top) + 12px) max(16px, var(--safe-right)) 12px max(16px, var(--safe-left));
    background: var(--raised);
    border-radius: 0 0 var(--radius-sheet) var(--radius-sheet);
    box-shadow: var(--lift-1);
}

.ph-top__title {
    flex: 1;
    margin: 0;
    padding: 0;
    font-size: var(--text-m-headline);
    font-weight: 800;
    color: var(--ink);
}

.ph-link--btn { border: 0; background: none; padding: 0 4px; cursor: pointer; font-family: var(--font-primary); }

/* ---- Notification rows ---- */
.ph-nrow {
    position: relative;
    width: 100%;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 14px 14px 22px;
    border: 0;
    background: transparent;
    text-align: left;
    font-family: var(--font-primary);
    color: var(--ink);
    cursor: pointer;
}

.ph-nrow__ic {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: var(--radius-control);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sunken);
    color: var(--brand-on);
}

.ph-nrow__ic--info { background: var(--action-wash); color: var(--action-hover); }
.ph-nrow__ic--ok { background: var(--ok-wash); color: var(--ok); }
.ph-nrow__ic--warn { background: var(--warn-wash); color: var(--warn); }
.ph-nrow__ic--bad { background: var(--bad-wash); color: var(--bad); }

.ph-nrow__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ph-nrow__top { display: flex; gap: 8px; justify-content: space-between; align-items: baseline; }

.ph-nrow__t {
    font-size: var(--text-m-label);
    font-weight: 600;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ph-nrow__t--unread { font-weight: 700; }
.ph-nrow__time { white-space: nowrap; }
.ph-nrow__ctx { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ph-dot {
    width: 9px;
    height: 9px;
    margin-top: 6px;
    border-radius: 50%;
    background: var(--action);
    flex-shrink: 0;
}

/* ---- Schedule: week strip in the hero, then a timeline ---- */
.ph-week {
    position: relative;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 5px;
    margin-top: 14px;
}

.ph-day {
    min-height: 66px;
    border: 0;
    border-radius: var(--radius-control);
    background: color-mix(in srgb, var(--on-action) 10%, transparent);
    color: var(--on-action);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-family: var(--font-primary);
    cursor: pointer;
}

.ph-day[aria-pressed="true"] { background: var(--raised); color: var(--brand-on); }
.ph-day__w { font-size: var(--text-m-caption); font-weight: 600; opacity: 0.85; }
.ph-day__n { font-size: var(--text-m-headline); font-weight: 800; }
.ph-day__dots { display: flex; gap: 3px; height: 5px; }
.ph-day__dot { width: 5px; height: 5px; border-radius: 50%; background: color-mix(in srgb, var(--on-action) 75%, transparent); }
.ph-day[aria-pressed="true"] .ph-day__dot { background: var(--action); }

.ph-timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.ph-timeline__item { display: flex; gap: 10px; align-items: flex-start; }

.ph-timeline__when {
    width: 52px;
    flex-shrink: 0;
    padding-top: 14px;
    font-size: var(--text-m-label);
    font-weight: 700;
    color: var(--ink-muted);
    font-variant-numeric: tabular-nums;
}

.ph-timeline__card { flex: 1; min-width: 0; }
.ph-slot--s { width: 60px; height: 32px; }

/* ---- Comments: chat thread + composer ---- */
.ph--chat { display: flex; flex-direction: column; }

.ph-thread {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px max(16px, var(--safe-right)) calc(var(--tap) + var(--safe-bottom) + 40px) max(16px, var(--safe-left));
}

.ph-pill {
    align-self: center;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--brand-on) 8%, transparent);
    color: var(--ink-muted);
    font-size: var(--text-m-caption);
    font-weight: 700;
}

.ph-pill--btn { border: 0; cursor: pointer; font-family: var(--font-primary); min-height: 36px; }

.ph-msg { display: flex; gap: 8px; align-items: flex-end; max-width: 85%; }
.ph-msg--mine { align-self: flex-end; flex-direction: column; align-items: flex-end; }
.ph-msg__who { margin: 0 0 4px 4px; }
.ph-msg__who b { color: var(--ink-muted); }
.ph-msg__meta { margin: 4px 4px 0; }

.ph-avatar--s { width: 32px; height: 32px; font-size: var(--text-m-caption); background: var(--anchor); }

.ph-bubble {
    padding: 10px 14px;
    border-radius: 18px 18px 18px 6px;
    background: var(--raised);
    box-shadow: var(--lift-1);
    font-size: var(--text-m-label);
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.ph-bubble--mine { border-radius: 18px 18px 6px 18px; background: var(--brand-on); color: var(--on-action); box-shadow: none; }

.ph-composer { gap: 8px; }
.ph-composer__field { flex: 1; min-width: 0; }

.ph-composer__field input {
    width: 100%;
    box-sizing: border-box;
    min-height: var(--tap);
    border: 0;
    border-radius: var(--radius-control);
    background: var(--sunken);
    color: var(--ink);
    padding: 0 14px;
    font: 500 var(--text-m-body) var(--font-primary);
}

.ph-iconbtn--send { background: var(--action); color: var(--on-action); }
.ph-iconbtn:disabled { opacity: 0.5; cursor: not-allowed; }

.ph-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Map: full-bleed map, floating search, bottom sheet above the tab bar ---- */
.ph-mapscreen { position: relative; height: 100dvh; overflow: hidden; padding-bottom: 0; }
.ph-map { position: absolute; inset: 0; background: var(--sunken); }
.ph-map--failed > * { visibility: hidden; }

.ph-mapbar {
    position: absolute;
    top: calc(var(--safe-top) + 12px);
    left: max(16px, var(--safe-left));
    right: max(16px, var(--safe-right));
    z-index: 5;
}

.ph-search--float { margin-top: 0; }
.ph-chips--float { margin-top: 10px; }
.ph-chips--float .ph-chip { box-shadow: var(--lift-1); }
.ph-search--float input { box-shadow: var(--lift-2); }

.ph-mapme { margin-right: max(16px, var(--safe-right)); box-shadow: var(--lift-2); }

.ph-mapfail { margin-top: 10px; }

/* The sheet and the centre-on-me button move together: the button always sits just above the sheet. */
.ph-sheetwrap {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(var(--tabbar-height) + var(--safe-bottom));
    z-index: 6;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    pointer-events: none;
}

.ph-sheetwrap > * { pointer-events: auto; }

.ph-sheet {
    align-self: stretch;
    max-height: 55dvh;
    overflow-y: auto;
    padding: 0 max(16px, var(--safe-right)) 20px max(16px, var(--safe-left));
    background: var(--raised);
    border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
    box-shadow: var(--lift-3);
}

.ph-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 10px auto 0; }

.ph-card--sel { border: 2px solid var(--action); box-shadow: none; }

/* Pins: the state colour in a teardrop, white centre. --pin-c is set per pin from the state tokens. */
.ph-pin {
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    --pin-c: var(--action); /* default; phone-map.ts sets the state colour on each pin's own style */
    background: var(--pin-c);
    border: 3px solid var(--raised);
    box-shadow: var(--lift-2);
    cursor: pointer;
}

.ph-pin::after {
    content: "";
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    background: var(--raised);
}

.ph-pin--on { width: 40px; height: 40px; }
.ph-pin--on::after { inset: 11px; }

.ph-me-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--action);
    border: 3px solid var(--raised);
    box-shadow: 0 0 0 10px color-mix(in srgb, var(--action) 18%, transparent);
}

/* ---- On site: the open visit, in the header of the everyday screens (PhoneOnSitePill) ---- */
.ph-onsite {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: var(--tap);
    margin-top: 14px;
    padding: 0 12px 0 14px;
    border-radius: var(--radius-control);
    background: color-mix(in srgb, var(--on-action) 14%, transparent);
    color: var(--on-action);
    font: 600 var(--text-m-label) var(--font-primary);
    text-decoration: none;
}

a.ph-onsite:link, a.ph-onsite:visited { color: var(--on-action); }

.ph-onsite__dot {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--on-action) 25%, transparent);
}

.ph-onsite--due .ph-onsite__dot { background: var(--warn); }
.ph-onsite--late .ph-onsite__dot { background: var(--bad); }
.ph-onsite__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-onsite__time { opacity: .85; font-variant-numeric: tabular-nums; }
.ph-onsite__due { padding: 3px 8px; border-radius: var(--radius-sm); background: var(--warn); color: var(--on-action); font-weight: 700; }
.ph-onsite--late .ph-onsite__due { background: var(--bad); }
