/* Phone layout and shared refinements from the owner's phone review (27 September 2026).
   Loads last. Rules outside the phone media query are small shared fixes; everything inside it
   applies only up to 700px, so the desktop and tablet layouts are unchanged. */

/* Shared: Settings actions read as one aligned list, each with an icon. */
.modal-action-list { gap: 0; margin-top: 12px; border-top: 1px solid var(--line); }
.modal-action-list > .btn,
.modal-action-list > .text-link { width: 100%; gap: 12px; padding: 12px 4px; min-height: 50px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; box-shadow: none; font-weight: 600; color: var(--blue); text-decoration: none; }
.modal-action-list > .btn:hover:not(:disabled),
.modal-action-list > .text-link:hover { background: var(--bg); }
.modal-action-list > .danger { margin-top: 0; color: #8a4f4b; }
.modal-action-list > :last-child { border-bottom: 0; }
.modal-action-list .icon { width: 19px; height: 19px; flex: none; }

/* Shared: the About dialog has its own illustration, not the landing artwork. */
.about-art { display: block; height: auto; aspect-ratio: 1400 / 875; margin: 22px 0 6px; border-radius: var(--radius-lg); mix-blend-mode: normal; box-shadow: 0 0 0 1px var(--line); }

/* Shared: step icons in the demo player are only used by the compact phone transport. */
.demo-step .icon { display: none; }
.demo-buttons .btn-label { white-space: nowrap; }

@media (max-width: 700px) {
  :root { --m-top: 56px; --m-tabs: 64px; }

  /* Top bar: fixed height, sticky, softly translucent. */
  .topbar { position: sticky; top: 0; z-index: 24; height: var(--m-top); min-height: 0; padding: 0 8px 0 16px; flex-wrap: nowrap; gap: 8px; background: rgba(247, 250, 253, 0.88); -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px); border-bottom: 1px solid rgba(206, 224, 235, 0.8); }
  .mobile-brand .brand { font-size: var(--text-3xl); }
  .top-actions { flex-wrap: nowrap; gap: 2px; margin-left: auto; }
  .mode-badge { height: 32px; min-height: 0; padding: 0 10px 0 9px; gap: 6px; font-size: var(--text-sm); font-weight: 500; border: 1px solid var(--line); background: var(--white); color: var(--muted); }
  .mode-badge .icon { width: 14px; height: 14px; opacity: 0.8; }
  .top-actions > .icon-btn { width: 40px; height: 40px; min-width: 40px; min-height: 40px; padding: 0; border-radius: var(--radius-circle); color: var(--ink-soft); }
  .top-actions > .icon-btn:active { background: var(--blue-tint); }
  .top-actions > .icon-btn .icon { width: 22px; height: 22px; stroke-width: 1.7; }

  /* Bottom tab bar: frosted, with a pill behind the active icon and a light duotone fill. */
  .sidebar { height: auto; min-height: 0; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, 0.94); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px); border-top: 1px solid rgba(206, 224, 235, 0.75); box-shadow: 0 -10px 28px rgba(0, 103, 177, 0.07); }
  .sidebar nav { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; align-items: stretch; }
  .nav-item, .nav-item.selected, .nav-item:hover { min-height: 52px; padding: 3px 0 2px; gap: 3px; border: 0; border-radius: var(--radius-md); background: none; font-size: var(--text-xs); font-weight: 500; line-height: 1.2; letter-spacing: 0.01em; color: var(--muted); -webkit-tap-highlight-color: transparent; }
  .nav-item .icon { box-sizing: content-box; width: 22px; height: 22px; padding: 4px 16px; border-radius: var(--radius-pill); stroke-width: 1.8; color: var(--muted); transition: background-color 0.2s ease, color 0.2s ease; }
  .nav-item.selected { color: var(--blue); font-weight: 650; }
  .nav-item.selected .icon { color: var(--blue); background: var(--blue-tint); stroke-width: 2; }
  .nav-item.selected .icon path { fill: currentColor; fill-opacity: 0.16; }
  .nav-item:active .icon { background: var(--soft); }
  .workspace { padding-bottom: calc(var(--m-tabs) + env(safe-area-inset-bottom)); }
  #toast { bottom: calc(var(--m-tabs) + 16px + env(safe-area-inset-bottom)); }

  /* Page headings: a calmer type scale. */
  .content-page { padding: 22px 16px 36px; }
  .page-heading { padding: 0 2px 20px; gap: 12px; }
  .page-heading .eyebrow { font-size: var(--text-xs); letter-spacing: 0.1em; line-height: 1.5; margin-bottom: 6px; }
  .page-heading h1,
  .content-page .page-heading h1 { font-size: var(--text-3xl); line-height: 1.15; letter-spacing: -0.6px; }
  .page-heading p,
  .content-page .page-heading p { font-size: var(--text-md); line-height: 1.55; max-width: none; margin-top: 8px; }
  .eyebrow,
  .modal .eyebrow,
  .landing-copy .eyebrow { font-size: var(--text-xs); letter-spacing: 0.1em; line-height: 1.5; }

  /* Landing: keep the "You" label above the young person's head, not over her face. */
  .landing-visual { margin: 64px 0 0; }
  .landing-scene .orbit-label { top: -50px; left: 0; right: 0; transform: none; padding: 0; border: 0; font-size: var(--text-base); text-align: left; white-space: normal; }
  /* The call to action, the note and the picture caption share the text column's left edge (owner request, 27 September 2026). */
  .landing-note { display: block; text-align: left; line-height: 1.6; }
  .landing-note .icon { display: inline-block; vertical-align: -2px; margin-right: 6px; }
  .patient-label { top: 0; left: 50.5%; transform: translate(-50%, -50%); flex-direction: row; align-items: baseline; gap: 6px; min-width: 0; padding: 5px 13px; border-radius: var(--radius-pill); box-shadow: 0 4px 14px rgba(0, 80, 140, 0.1); }
  .patient-label b,
  .patient-label span { font-size: var(--text-sm); }
  .patient-label b::after { content: "\00b7"; margin-left: 6px; color: #8fb3c6; font-weight: 400; }
  .patient-label:after { height: 9px; background: #8fb7ca; }
  .landing-cta .text { padding-inline: 0; }
  .landing-footer .landing-release { align-items: flex-start; }
  .landing-release .release-info { justify-content: flex-start; text-align: left; }

  /* Chat screen: fills the space between the bars, with no page scroll. */
  .chat-page { height: calc(100dvh - var(--m-top) - var(--m-tabs) - env(safe-area-inset-bottom)); min-height: 440px; padding: 8px 8px 8px; display: flex; flex-direction: column; }
  .chat-page > .page-heading { display: none; }
  .chat-layout.phone-chat { display: flex; flex: 1; height: auto; min-height: 0; gap: 0; }
  .chat-layout.phone-chat::after { content: none; display: none; }
  .phone-chat > .conversation { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; border-radius: var(--radius-lg); overflow: hidden; }

  /* The switch between the two chats. Its highlight follows a swipe. */
  .chat-switch-row { flex: none; display: flex; align-items: center; gap: 6px; padding: 8px; border-bottom: 1px solid var(--soft); background: var(--white); }
  .chat-switch { position: relative; flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: var(--radius-md); background: var(--surface); }
  .chat-switch-thumb { position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border-radius: var(--radius-sm); background: var(--white); box-shadow: 0 1px 3px rgba(0, 60, 110, 0.14), 0 0 0 0.5px rgba(0, 60, 110, 0.06); transform: translateX(calc(var(--pane, 0) * 100%)); will-change: transform; }
  .chat-tab { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 0; min-height: 36px; padding: 0 8px; border: 0; border-radius: var(--radius-sm); background: none; font: inherit; font-size: var(--text-base); font-weight: 600; color: var(--muted); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: color 0.2s ease; }
  .chat-tab > span:not(.side-badge) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chat-tab .icon { width: 17px; height: 17px; flex: none; stroke-width: 1.8; }
  .chat-tab[aria-selected="true"] { color: var(--blue); }
  .chat-tab:focus-visible { outline-offset: -2px; }
  .chat-tab .side-badge { margin-left: 0; }
  .chat-switch-row > .icon-btn { flex: none; width: 40px; height: 40px; min-width: 40px; min-height: 40px; border-radius: var(--radius-circle); color: var(--blue); }

  /* Two chats side by side; a sideways swipe moves between them. */
  .chat-pager { flex: 1; min-height: 0; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .chat-pager::-webkit-scrollbar { display: none; }
  .chat-pane { position: relative; flex: 0 0 100%; min-width: 0; min-height: 0; display: flex; flex-direction: column; scroll-snap-align: start; scroll-snap-stop: always; }
  #pane-main { background: var(--white); }
  .chat-pane > .chat-messages { flex: 1; min-height: 0; padding: 16px 14px 14px; }
  .phone-chat .chat-date { font-size: var(--text-xs); letter-spacing: 0.12em; margin-bottom: 16px; }

  .phone-chat .side-chat,
  .chat-layout.phone-chat:not(.huddle-hidden) .side-chat { position: static; inset: auto; display: flex; flex: 1; width: auto; min-height: 0; border: 0; border-radius: 0; box-shadow: none; background: var(--surface); z-index: auto; }
  .phone-chat .side-chat > header { display: flex; align-items: center; gap: 10px; padding: 9px 14px; background: var(--bg); border-bottom: 1px solid var(--line); }
  .phone-chat .side-chat .huddle-heading { display: none; }
  .phone-chat .side-chat-members { flex: 1; min-width: 0; margin: 0; font-size: var(--text-sm); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .phone-chat .side-chat-state { flex: none; font-size: var(--text-sm); line-height: 1.4; }
  .phone-chat .side-chat-state > span:first-child { display: none; }
  .phone-chat .side-chat-state > span:last-child { color: var(--accent-ink); font-weight: 600; }
  .phone-chat .side-chat .huddle-scroll { padding: 16px 12px 12px; margin-right: 0; scrollbar-gutter: auto; }
  .phone-chat .side-chat > footer { display: none; }
  .phone-chat .side-chat-bubble { font-size: var(--text-md); line-height: 1.55; }

  /* Composer: compact, so the conversation keeps most of the screen. */
  .phone-chat .composer-wrap:not(.demo-controls) { flex: none; padding: 8px 10px 8px; border-top: 1px solid var(--soft); }
  .phone-chat .suggestions { flex-wrap: nowrap; gap: 6px; margin: 0 -10px; padding: 0 10px 8px; overflow-x: auto; }
  .phone-chat .suggestions > button { flex: none; min-height: 34px; padding: 5px 12px; border-radius: var(--radius-pill); border-color: var(--line); background: var(--white); color: var(--blue); font-size: var(--text-sm); font-weight: 500; }
  .phone-chat .suggestions > button .icon { width: 13px; height: 13px; }
  .phone-chat .composer { align-items: flex-end; gap: 6px; padding: 3px 3px 3px 14px; border-radius: var(--radius-xl); background: var(--bg); }
  .phone-chat .composer textarea { min-height: 38px; padding: 8px 0; font-size: var(--text-lg); line-height: 1.4; }
  .phone-chat .send-btn { width: 38px; height: 38px; min-width: 38px; min-height: 38px; border-radius: var(--radius-circle); background: var(--blue); }
  .phone-chat .send-btn .icon { width: 17px; height: 17px; }
  .phone-chat .composer-meta { flex-wrap: nowrap; align-items: center; gap: 10px; margin-top: 6px; padding: 0 4px; font-size: var(--text-xs); line-height: 1.35; }
  .phone-chat .composer-meta label { flex: none; font-size: var(--text-sm); }
  .phone-chat .composer-meta select { min-height: 32px; max-width: 150px; font-size: var(--text-sm); color: var(--blue); font-weight: 600; }
  .phone-chat .composer-meta > span { flex: 1; min-width: 0; text-align: right; }
  .phone-chat .reply-preview { margin-bottom: 6px; }

  /* The person writes in the main chat; the side chat is for reading. */
  .phone-chat.on-side .composer-wrap:not(.demo-controls) { display: none; }

  /* Demo player: a compact media-player row on phones. */
  .phone-chat .demo-controls { flex: none; display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto minmax(0, 1fr); grid-template-areas: "seek seek seek seek seek" "time time . moment moment" ". back main next restart" "note note note note note" "extra extra extra extra extra"; column-gap: 18px; row-gap: 0; align-items: center; padding: 6px 16px 10px; border-top: 1px solid var(--blue-tint); }
  .phone-chat .demo-controls > #demo-playback-controls,
  .phone-chat .demo-controls .demo-control-row,
  .phone-chat .demo-controls .demo-buttons,
  .phone-chat .demo-controls .demo-time-row,
  .phone-chat .demo-controls .demo-fineprint { display: contents; }
  .phone-chat .demo-progress { grid-area: seek; margin: 0; }
  .phone-chat .demo-progress input { height: 28px; }
  .phone-chat #demo-time { grid-area: time; margin-top: -4px; font-size: var(--text-xs); font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.3; white-space: nowrap; }
  .phone-chat #demo-moment { grid-area: moment; justify-self: end; margin-top: -4px; font-size: var(--text-xs); font-variant-numeric: tabular-nums; line-height: 1.3; color: var(--muted); white-space: nowrap; }
  .phone-chat .demo-control-row > div:first-child { display: none; }
  .phone-chat .demo-buttons .btn { display: grid; place-items: center; gap: 0; min-width: 0; min-height: 0; padding: 0; border-radius: var(--radius-circle); }
  .phone-chat .demo-buttons .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .phone-chat .demo-main { grid-area: main; margin: 2px 0; width: 52px; height: 52px; box-shadow: 0 6px 16px rgba(0, 103, 177, 0.26); }
  .phone-chat .demo-main .icon { width: 22px; height: 22px; }
  .phone-chat .demo-step[data-action="demo-back"] { grid-area: back; }
  .phone-chat .demo-step[data-action="demo-next"] { grid-area: next; }
  .phone-chat .demo-step,
  .phone-chat .demo-restart { width: 40px; height: 40px; background: var(--white); border: 1px solid var(--line); color: var(--blue); box-shadow: none; }
  .phone-chat .demo-restart { grid-area: restart; justify-self: end; border-color: transparent; background: none; color: var(--muted); }
  .phone-chat .demo-step .icon { display: block; width: 17px; height: 17px; }
  .phone-chat .demo-restart .icon { width: 19px; height: 19px; }
  .phone-chat .demo-buttons .btn:disabled { opacity: 0.38; }
  .phone-chat .icon-play path,
  .phone-chat .icon-skipBack path,
  .phone-chat .icon-skipForward path { fill: currentColor; }
  .phone-chat .icon-pause { stroke-width: 3; }
  .phone-chat .demo-disclosure { grid-area: note; margin: 8px 0 0; font-size: var(--text-xs); line-height: 1.45; text-align: center; color: var(--muted); }
  .phone-chat .demo-service-note { display: none; }
  .phone-chat .demo-live-link { grid-area: extra; justify-self: center; min-height: 36px; font-size: var(--text-sm); }
}

@media (max-width: 700px) and (prefers-reduced-motion: reduce) {
  .nav-item .icon,
  .chat-tab { transition: none; }
}

/* Touch targets (owner request, 27 September 2026): every control on a phone is at least 44 by 44 px, the size Apple's
   Human Interface Guidelines and WCAG 2.5.5 recommend. Controls meant to look small keep their look and get a larger
   invisible hit area instead. */
.switch-hit { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; margin: -12px -4px; cursor: pointer; }
@media (max-width: 700px) {
  .top-actions > .icon-btn,
  .chat-switch-row > .icon-btn,
  .phone-chat .demo-step,
  .phone-chat .demo-restart { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
  .chat-tab,
  .icc-periods button,
  .plan-tool,
  .setting-row > .btn { min-height: 44px; }
  .phone-chat .demo-progress input { height: 44px; margin: -8px 0; }
  .mode-badge,
  .mobile-brand,
  .landing-head .brand-link { position: relative; }
  .mode-badge::after,
  .mobile-brand::after,
  .landing-head .brand-link::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 44px; transform: translateY(-50%); }
}

/* The conversation pane's status row on phones mirrors the side chat's: members at rest, who is typing while they type (WhatsApp group header). */
@media (max-width: 700px) {
  .pane-status { flex: none; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--bg); font-size: var(--text-sm); line-height: 1.4; color: var(--muted); }
  .pane-status .separator { margin: 0 4px; }
}
#chat-status.typing-now { color: var(--accent-ink); font-weight: 600; }
