/* Opt-in Phase 3 first slice only; this sheet is media=not all without ?phase3=1. */
html.phase3 {
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--test-safe-bottom, 0px), var(--sb, 0px));
  /* Ospi redesign: the floating live capsule is retired, so a side page only
     reserves the normal safe-area strip below its last control (one 12px
     breathing gap). The old 88px capsule gutter — and the 128px variant that
     used to clear the agent chip riding it — is what kept the Sessions list
     64px rows plus empty bottom space; both are gone. */
  --capsule-clearance: calc(var(--safe-bottom) + 12px);
}
@media (min-width: 860px) and (hover: hover) and (pointer: fine) {
  html.phase3 {
    --capsule-clearance: 0px;
  }
}
html.phase3 #app { display:block; visibility:hidden; }
html.phase3 #app.phase3-ready { visibility:visible; }
html.phase3 #sidebar, html.phase3 #scrim { display:none !important; }
html.phase3 #pager {
  width:100%; height:100%; display:flex; min-width:0;
  overflow-x:auto; overflow-y:hidden; scroll-snap-type:x mandatory;
  overscroll-behavior-x:contain; scrollbar-width:none;
  visibility:hidden;
}
html.phase3 #pager.ready { visibility:visible; }
html.phase3 #pager::-webkit-scrollbar { display:none; }
html.phase3 #pager.pager-locked { overflow-x:hidden; }
html.phase5 #pager.pager-locked {
  overflow-x: hidden !important;
  overscroll-behavior-x: none !important;
}
html.phase3 #pager > .page {
  box-sizing:border-box; flex:0 0 100%; width:100%; min-width:0;
  height:100%; display:flex; flex-direction:column; overflow:hidden;
  position:relative;
  scroll-snap-align:start; scroll-snap-stop:always;
  background:var(--bg);
}
html.phase3 #page-chat #main { width:100%; flex:1 1 auto; min-height:0; }
html.phase3 .pager-head {
  flex:none; display:flex; align-items:center; justify-content:space-between;
  min-height:48px; padding:var(--hdr-safe-top, env(safe-area-inset-top)) 12px 0;
  background:var(--surface); border-bottom:1px solid var(--line);
  box-sizing:content-box; gap:8px;
}
html.phase3 .pager-head strong { font-size:18px; min-width:0; }
html.phase3 .pager-head button,
html.phase3 .system-actions button, html.phase3 .session-actions button {
  border:0; border-radius:10px; background:var(--surface2);
  color:var(--text); padding:8px 12px; min-height:44px;
}
/* Phase 3 owns the Chat nav bar: one row, real title and live subtitle. */
html.phase3 #page-chat #hdr {
  height:calc(44px + var(--hdr-safe-top, env(safe-area-inset-top)));
  padding:var(--hdr-safe-top, env(safe-area-inset-top)) 8px 0;
}
html.phase3 #page-chat #hdr .hin {
  display:grid; grid-template-columns:44px minmax(0,1fr) 44px;
  gap:6px; height:44px; max-width:none;
}
html.phase3 #page-chat #hdr .hbtns,
html.phase3 #page-chat #hdr .hchips { display:none; }
html.phase3 #page-chat #hdr .htitle {
  grid-column:2; grid-row:1; width:100%; min-width:0;
  align-items:center; text-align:center; padding:0;
}
html.phase3 #page-chat #hdr .htitle-top-row { justify-content:center; }
html.phase3 #page-chat #hdr #sess-title { flex:0 1 auto; font-size:17px; }
html.phase3 #page-chat #hdr .sess-sub-cwd { padding-left:0; font:12px/16px system-ui,-apple-system,sans-serif; }
html.phase3 #page-chat #hdr .pager-header-btn {
  width:44px; height:44px; padding:10px; border:0; border-radius:10px;
  background:transparent; color:var(--ink-2, var(--muted));
  display:flex; align-items:center; justify-content:center;
}
html.phase3 #page-chat #hdr .pager-header-btn:active { background:var(--surface2); }
/* §7.6 — no permanent hairline. At rest the bar is just the page background
   (same opaque geometry: 44px + safe-area, unchanged); once the page's own
   content scrolls under it, the blur material + 1px var(--line) hairline fade
   in over ~180ms. One rule for all three bars — Chat (#hdr), System and Sessions
   (.pager-head) — so they can never drift apart. `.hdr-scrolled` is toggled by
   one passive listener in header.js (Phase 3 only; the default route has no
   rule for it and never gets the class). */
html.phase3 :is(#page-chat #hdr, .pager-head) {
  background: transparent;
  border-bottom-color: transparent;
  -webkit-backdrop-filter: blur(0px);
  backdrop-filter: blur(0px);
  transition: background-color 180ms ease, border-bottom-color 180ms ease, -webkit-backdrop-filter 180ms ease, backdrop-filter 180ms ease;
}
html.phase3 :is(#page-chat #hdr, .pager-head).hdr-scrolled {
  /* color-mix drops out on an older engine and leaves the bar transparent;
     the hairline below still lands, which is the load-bearing part. */
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom-color: var(--line);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
}
/* Long-press System Menu (planopus.md §7.6) */
html.phase3 .sys-menu-pop {
  position: fixed;
  z-index: 1000;
  min-width: 190px;
  max-width: calc(100vw - 16px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md, 14px);
  padding: 4px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  box-sizing: border-box;
}

html.phase3 .sys-menu-pop .sess-pop-btn {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm, 10px);
  color: var(--ink, var(--text));
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
}

html.phase3 .sys-menu-pop .sess-pop-btn:active {
  background: var(--surface-2, var(--surface2));
}

html.phase3 .sys-menu-pop .sess-pop-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--ink-2, var(--muted));
}

html.phase3 .sys-menu-pop .sess-pop-ic svg {
  width: 18px;
  height: 18px;
  display: block;
}

html.phase3 #page-chat #hdr [data-page-go="system"] { grid-column:1; grid-row:1; }
html.phase3 #page-chat #hdr [data-page-go="sessions"] { grid-column:3; grid-row:1; }
html.phase3 .session-actions, html.phase3 .system-actions {
  flex:none; display:flex; gap:6px; padding:8px 12px;
  background:var(--surface); border-bottom:1px solid var(--line);
}
html.phase3 .system-actions { flex-wrap:wrap; }
html.phase3 .side-content { flex:1 1 auto; min-height:0; overflow-y:auto; display:flex; flex-direction:column; }
html.phase3 #page-sessions #sidebar-panel {
  display:flex !important; visibility:visible !important; width:100% !important;
  flex:1 1 auto; min-height:0; overflow:hidden; height:auto;
}
html.phase3 #page-sessions .dhead { display:none; }
html.phase3 #page-sessions .dfoot { display:none; }
html.phase3 #page-sessions .sess-foot-actions { margin-bottom:var(--capsule-clearance); }
html.phase3 #settings-panel-content,
html.phase3 #system-content > :is(#pane-settings,#pane-notes,#pane-subagents,#pane-server),
html.phase3 #page-sessions :is(#pane-files,#file-list) {
  padding-bottom:var(--capsule-clearance);
  box-sizing:border-box;
}
html.phase3 #page-sessions :is(#pane-sessions,#pane-files),
html.phase3 #system-content > :is(#pane-settings,#pane-notes,#pane-subagents,#pane-server) {
  flex:1 1 auto; min-height:0; height:auto; overflow-y:auto;
}
html.phase3 #page-sessions #sess-dir { max-width:110px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
html.phase3 #transcript { touch-action:auto; }
html.phase3 :is(#transcript pre, #transcript .tbl-wrap, .crumbs, #attach, #tools-rail) { overscroll-behavior-x:contain; }
html.phase3 :is(#recbar, input[type="range"], .sheet-grabber) { touch-action:none; }
@media (min-width:1100px) {
  html.phase3:not(.phase5) #pager { display:grid; grid-template-columns:320px minmax(0,1fr) 360px; overflow-x:hidden; scroll-snap-type:none; }
  html.phase3:not(.phase5) #pager > .page { width:auto; min-width:0; }
  html.phase3:not(.phase5) #page-chat #main { min-width:0; }
  html.phase3 #live-capsule,
  html.phase3 #capsule-peek-sheet { display:none !important; }
  :is(html.phase3, html.phase5) #agent-run:not([hidden]) {
    display: inline-flex !important;
    position: relative !important;
    left: auto !important;
    bottom: auto !important;
    z-index: 2 !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex-shrink: 0 !important;
  }
  html.phase5:not(.phase5) .sys-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
}
/* Live capsule (§7.4): retired in the Ospi redesign (owner feedback). Its job
   moved to the Continue button in the Sessions action row, and the chat page
   keeps its own status band / agent chip. The body-level node stays in the DOM
   (pager.js still drives the side-page Done nudge off the same state machine)
   but is never displayed, so nothing can ever float over a list again. */
html.phase3 #live-capsule {
  display:none !important;
  position:fixed; left:50%; transform:translateX(-50%);
  bottom:calc(var(--safe-bottom) + 12px);
  width:min(92vw, 380px); min-height:48px; box-sizing:border-box;
  align-items:center; gap:10px; padding:7px 14px; margin:0;
  border:1px solid var(--line); border-radius:24px;
  background:var(--surface); color:var(--ink);
  font:inherit; text-align:left; z-index:45;
  box-shadow:0 8px 24px rgb(0 0 0 / .22);
  touch-action:pan-x;
  user-select:none; -webkit-user-select:none; -webkit-touch-callout:none;
}
html.phase3 #live-capsule * {
  user-select:none; -webkit-user-select:none; -webkit-touch-callout:none;
}
#agent-run { display: none; }
:is(html.phase3, html.phase5) #agent-run {
  order: -1;
  display: inline-flex; align-items: center; justify-content: center;
  align-self: center;
  width: 32px; height: 32px; min-width: 32px; flex: none;
  margin: 0; padding: 0; border: 0; border-radius: 50%;
  background: #F3E6D4; color: #8A4B12;
  box-shadow: inset 0 0 0 1px #e4d3bc;
  font: 700 13px/1 system-ui, -apple-system, sans-serif;
  touch-action: manipulation;
}
:is(html.phase3, html.phase5) #agent-run::before {
  content: '';
  width: 6px; height: 6px; margin-right: 3px;
  border-radius: 50%; background: #C47A2C;
}
:is(html.phase3, html.phase5) #agent-run[hidden] { display: none !important; }
:is(html.phase3, html.phase5) #agent-run.over-capsule {
  position: fixed; left: 16px; z-index: 80;
}
html.phase5 .sys-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
html.phase5 #sys-btn-agents {
  height: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font: 600 13px/1 system-ui, -apple-system, sans-serif;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: background 0.15s ease, border-color 0.15s ease;
}
html.phase5 #sys-btn-agents:active {
  background: var(--surface-2);
}
html.phase3 #live-capsule[hidden] { display:none; }
html.phase3 #live-capsule:active { background:var(--surface-2); }
html.phase3 #live-capsule .cap-g {
  flex:none; width:20px; height:20px; display:flex; align-items:center;
  justify-content:center; font-size:14px; line-height:1; color:var(--ink-2);
}
html.phase3 #live-capsule .cap-txt { flex:1 1 auto; min-width:0; display:flex; flex-direction:column; }
html.phase3 #live-capsule .cap-title,
html.phase3 #live-capsule .cap-sub { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
html.phase3 #live-capsule .cap-title { font-size:15px; font-weight:600; }
html.phase3 #live-capsule .cap-sub { font-size:12px; color:var(--ink-2); font-family:ui-monospace, SFMono-Regular, Menlo, monospace; }
html.phase3 #live-capsule .cap-meta { flex:none; font-size:12px; font-family:ui-monospace, SFMono-Regular, Menlo, monospace; color:var(--ink-2); }
html.phase3 #live-capsule[data-state="work"] .cap-g,
html.phase3 #live-capsule[data-state="tool"] .cap-g { animation:cap-spin 1.1s linear infinite; }
html.phase3 #live-capsule[data-state="write"] .cap-g { color:var(--warn); animation:cap-pulse 1.4s ease-in-out infinite; }
html.phase3 #live-capsule[data-state="ask"] .cap-g { color:var(--warn); position:relative; }
html.phase3 #live-capsule[data-state="ask"] .cap-g::after {
  content:''; position:absolute; inset:-3px; border-radius:50%;
  border:1.5px solid var(--warn); pointer-events:none;
  animation:cap-ring-pulse 1.6s ease-out infinite;
}
html.phase3 #live-capsule[data-state="stopped"] .cap-g { color:var(--danger); }
html.phase3 #live-capsule[data-state="done"] {
  color:var(--ok);
  animation: capsuleDoneBounce 520ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes capsuleDoneBounce {
  0% { transform: translateX(-50%) scale(1); }
  45% { transform: translateX(-50%) scale(1.06); }
  100% { transform: translateX(-50%) scale(1); }
}
/* Directional bounce for side content toward Chat (§7.5) */
html.phase3 .nudge-right {
  animation: nudgeBounceRight 533ms var(--spring-bouncy, cubic-bezier(0.34, 1.56, 0.64, 1));
}
html.phase3 .nudge-left {
  animation: nudgeBounceLeft 533ms var(--spring-bouncy, cubic-bezier(0.34, 1.56, 0.64, 1));
}
@keyframes nudgeBounceRight {
  0% { transform: translateX(0); }
  35% { transform: translateX(10px); }
  100% { transform: translateX(0); }
}
@keyframes nudgeBounceLeft {
  0% { transform: translateX(0); }
  35% { transform: translateX(-10px); }
  100% { transform: translateX(0); }
}
/* Refined amber inner-edge beam on side page toward Chat (§7.5) */
html.phase3 .side-beam {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  box-sizing: border-box;
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.15) 0%, #fbbf24 25%, #f59e0b 50%, #d97706 75%, rgba(217, 119, 6, 0.15) 100%);
  border-radius: 1.5px;
  transform-origin: center center;
}
html.phase3 :is(#page-system .side-beam, .side-beam-right) {
  right: 0;
  left: auto;
}
html.phase3 :is(#page-sessions .side-beam, .side-beam-left) {
  left: 0;
  right: auto;
}
html.phase3 .side-beam::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 24px;
  pointer-events: none;
}
html.phase3 :is(#page-system .side-beam, .side-beam-right)::after {
  right: 0;
  background: radial-gradient(ellipse at right center, rgba(245, 158, 11, 0.35) 0%, rgba(245, 158, 11, 0.1) 45%, transparent 75%);
}
html.phase3 :is(#page-sessions .side-beam, .side-beam-left)::after {
  left: 0;
  background: radial-gradient(ellipse at left center, rgba(245, 158, 11, 0.35) 0%, rgba(245, 158, 11, 0.1) 45%, transparent 75%);
}
html.phase3 .side-beam.glow-active {
  animation: sideBeamGlow 2400ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.8), 0 0 20px rgba(245, 158, 11, 0.45);
}
@keyframes sideBeamGlow {
  0% {
    opacity: 0;
    transform: scaleY(0.25);
  }
  15% {
    opacity: 1;
    transform: scaleY(1);
  }
  65% {
    opacity: 0.9;
    transform: scaleY(1);
  }
  100% {
    opacity: 0;
    transform: scaleY(1);
  }
}
/* Transient capsule preview sheet on hold (§7.4) */
html.phase3 #capsule-peek-sheet {
  position:fixed; left:50%; transform:translateX(-50%) translateY(8px);
  bottom:calc(var(--safe-bottom) + 68px);
  width:min(92vw, 380px); max-height:48vh; box-sizing:border-box;
  padding:12px 14px; border:1px solid var(--line); border-radius:16px;
  background:var(--surface); color:var(--ink);
  font:inherit; z-index:55;
  box-shadow:0 12px 32px rgb(0 0 0 / .28);
  opacity:0; pointer-events:none;
  transition:opacity 160ms ease, transform 160ms cubic-bezier(0.16, 1, 0.3, 1);
  display:flex; flex-direction:column; gap:8px; overflow:hidden;
  user-select:none; -webkit-user-select:none; -webkit-touch-callout:none;
}
html.phase3 #capsule-peek-sheet[hidden] { display:none; }
html.phase3 #capsule-peek-sheet.peek-visible {
  opacity:1; transform:translateX(-50%) translateY(0); pointer-events:auto;
}
html.phase3 .cap-peek-head {
  display:flex; align-items:center; justify-content:space-between;
  gap:8px; min-width:0; padding-bottom:6px;
  border-bottom:1px solid var(--line);
}
html.phase3 .cap-peek-title {
  font-size:13px; font-weight:600; color:var(--ink);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
html.phase3 .cap-peek-tool {
  font-size:11px; font-family:ui-monospace, SFMono-Regular, Menlo, monospace;
  color:var(--warn, #f59e0b); background:var(--surface-2, rgba(245, 158, 11, 0.1));
  padding:2px 6px; border-radius:6px; max-width:160px;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
html.phase3 .cap-peek-lines {
  display:flex; flex-direction:column; gap:4px;
  min-width:0; overflow-y:auto; max-height:calc(48vh - 44px);
}
html.phase3 .cap-peek-line {
  font-size:12px; line-height:1.45; color:var(--ink-2);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
html.phase3 .cap-peek-empty {
  font-size:12px; color:var(--ink-2); font-style:italic; padding:6px 0;
}
@keyframes cap-spin { from { transform:rotate(0deg); } to { transform:rotate(360deg); } }
@keyframes cap-pulse { 0%, 100% { opacity:1; } 50% { opacity:.35; } }
@keyframes cap-ring-pulse { 0% { transform:scale(1); opacity:.8; } 100% { transform:scale(1.3); opacity:0; } }
@media (prefers-reduced-motion: reduce) {
  /* §7.6: no fade — the hairline is simply there the moment content moves. */
  html.phase3 :is(#page-chat #hdr, .pager-head) { transition: none !important; }
  html.phase3 #capsule-peek-sheet {
    transition: none !important;
    transform: translateX(-50%) translateY(0) !important;
  }
  html.phase3 #live-capsule[data-state="work"] .cap-g,
  html.phase3 #live-capsule[data-state="tool"] .cap-g,
  html.phase3 #live-capsule[data-state="write"] .cap-g { animation:none; }
  html.phase3 #live-capsule[data-state="ask"] .cap-g::after { animation:none; display:none; }
  html.phase3 #live-capsule[data-state="done"] { animation:none; }
  html.phase3 .nudge-right,
  html.phase3 .nudge-left { animation:none !important; transform:none !important; }
  html.phase3 .side-beam.glow-active {
    /* The legacy v2 sheet disables every animation with !important. A static
       line remains visible for the JS's brief 900ms cue instead. */
    animation: none !important;
    opacity: .85;
    transform: none !important;
  }
}

/* ===================== Ospi left panel: System pill (§A) =====================
   Approved redesign. One 46px pill over three pre-rendered panels. The pill is
   a native x-scroll-snap strip with edge pads, so it ALWAYS overflows and the
   pager's [data-hscroll] guard pins the page for a gesture that starts on it.
   No bundler, tokens only, no hardcoded colours. The frost is two pseudo-panes
   (blur-advice.md §3) with a clear window at 50% ± 64px; the ring is 1.5px
   --accent, no ticks, no fill (blur-advice.md §5). The ring's own state class is
   namespaced (.ospi-ring-pulse): a bare `.pulse` is a global 8px live-dot utility
   in style.css, and it applied to the ring the first time it pulsed. */
/* Bottom-dock clearance (owner, this round x2): the pill docked at the page's
   bottom sat on the iOS home indicator in the INSTALLED app. The dock reserves
   max(home indicator, 12px) + 16px breathing room under the pill, and the
   installed shell grows the page box below the visual viewport by the measured
   --sb-fill (style.css html.pwa { height: calc(100dvh + var(--sb-fill)) }),
   which env()/safe-area-inset-bottom does NOT cover — so the same --sb-fill is
   added again. That pins the pill's bottom edge >= 24px above the VISUAL
   viewport bottom on a real installed iPhone (28px with no inset, 50px with a
   34px inset, 28px on the installed shell whose box grew by 34px).
   env() is read directly on purpose — NOT --capsule-clearance, which folds in
   --sb and the old 88px capsule gutter. --test-safe-bottom / --sb-fill are the
   harness hooks tokens.css and style.css already use, so headless geometry can
   simulate a home indicator and the installed shell. */
html.phase5 {
  --ospi-dock-clearance: calc(
    max(env(safe-area-inset-bottom, 0px), var(--test-safe-bottom, 0px), 12px)
    + var(--sb-fill, 0px)
    + 16px
  );
}
html.phase5 #system-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Bottom dock (owner, this round): the pill zone is the last flex item, so
     the panels scroller above it takes the remaining height and the pill is
     flush with the page's bottom edge. In-page flow on purpose — never
     position:fixed — so the pager keeps the horizontal gesture. */
}
/* Quiet edge for the dock: one full-width --line hairline on the zone's top,
   exactly the idiom .pager-head already uses on its bottom edge (a --surface
   bar would be a second opaque layer fighting the pill's frost panes, and the
   pill's own hairline + shadow would read as a floating island). Padding is 12
   on top and --ospi-dock-clearance below (safe strip + --sb-fill + 16px), so
   the 46px pill clears both the page's bottom edge and the gesture strip. */
html.phase5 .ospi-pill-zone {
  flex: none;
  padding: 12px 22px var(--ospi-dock-clearance, 28px);
  border-top: 1px solid var(--line);
}
html.phase5 .ospi-pill-wrap { position: relative; }
html.phase5 .ospi-pill {
  position: relative;
  height: 46px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line2);
  box-shadow: 0 2px 10px rgb(0 0 0 / .08);
  display: flex;
  align-items: center;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
html.phase5 .ospi-pill::-webkit-scrollbar { display: none; }
html.phase5 .ospi-pill-pad { flex: 0 0 calc(50% - 60px); }
html.phase5 .ospi-pill-opt {
  scroll-snap-align: center;
  flex: 0 0 auto;
  width: 120px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  text-align: center;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  color: var(--ink-2);
  cursor: pointer;
  transition: color .15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
html.phase5 .ospi-pill-opt.on { color: var(--ink); }
/* Owner: the sliding lens is gone. Left and right docks are a row of big buttons. */
html.phase5 .ospi-pill {
  height: auto;
  min-height: 0;
  padding: 6px;
  gap: 8px;
  overflow: hidden;
  scroll-snap-type: none;
  touch-action: manipulation;
  border-radius: 18px;
}
html.phase5 .ospi-pill-pad,
html.phase5 .ospi-pill-ring,
html.phase5 .ospi-pill-fade,
html.phase5 .ospi-pill-wrap::before,
html.phase5 .ospi-pill-wrap::after {
  display: none !important;
}
html.phase5 .ospi-pill-opt {
  flex: 1 1 0;
  width: auto;
  min-height: 42px;
  padding: 6px 4px;
  border-radius: 12px;
  border: 1px solid var(--line2);
  background: var(--bg);
  font-size: 13px;
  font-weight: 700;
  scroll-snap-align: none;
}
html.phase5 .ospi-pill-opt.on {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
/* Frosted lens panes. Backdrop-filter lives on the pseudo-element itself so the
   compositor blurs whatever is underneath at frame time; -webkit- prefix for
   WebKit. No filter/opacity/mask on any ancestor of .ospi-pill-wrap. */
html.phase5 .ospi-pill-wrap::before,
html.phase5 .ospi-pill-wrap::after {
  content: "";
  position: absolute;
  top: 1px;
  bottom: 1px;
  z-index: 1;
  pointer-events: none;
  -webkit-backdrop-filter: blur(2px) saturate(.7);
  backdrop-filter: blur(2px) saturate(.7);
  background: color-mix(in srgb, var(--surface) 25%, transparent);
}
html.phase5 .ospi-pill-wrap::before {
  left: 1px;
  right: calc(50% + 64px);
  border-radius: 999px 0 0 999px;
}
html.phase5 .ospi-pill-wrap::after {
  right: 1px;
  left: calc(50% + 64px);
  border-radius: 0 999px 999px 0;
}
html.phase5 .ospi-pill-ring {
  position: absolute;
  left: 50%;
  top: 3px;
  bottom: 3px;
  /* Stretched by top/bottom on purpose, but also states height and width so no
     utility class further down the cascade (style.css's 8px `.pulse` dot) can
     collapse the lens the first time the ring takes a state class. */
  height: auto;
  width: 128px;
  transform: translateX(-50%);
  border-radius: 999px;
  border: 1.5px solid var(--accent);
  background: none;
  pointer-events: none;
  z-index: 3;
}
html.phase5 .ospi-pill-ring.ospi-ring-pulse { animation: ospiRingPulse .28s cubic-bezier(.22, 1, .36, 1); }
@keyframes ospiRingPulse { 40% { transform: translateX(-50%) scale(1.04); } }
html.phase5 .ospi-pill-fade {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 58px;
  pointer-events: none;
  z-index: 2;
}
html.phase5 .ospi-pill-fade.l {
  left: 0;
  border-radius: 999px 0 0 999px;
  background: linear-gradient(90deg, var(--surface), transparent);
}
html.phase5 .ospi-pill-fade.r {
  right: 0;
  border-radius: 0 999px 999px 0;
  background: linear-gradient(270deg, var(--surface), transparent);
}
/* Accessibility: Increase Contrast / reduced transparency drops the frost and
   leaves sharp labels. Reduced motion keeps the frost, kills the pulse. */
@media (prefers-contrast: more), (prefers-reduced-transparency: reduce) {
  html.phase5 .ospi-pill-wrap::before,
  html.phase5 .ospi-pill-wrap::after {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  html.phase5 .ospi-pill-ring.ospi-ring-pulse { animation: none; }
}

/* ---- System panels (scroll above the docked pill) ------------------------ */
/* flex:1 1 auto takes every pixel the dock leaves, so the scroller's own box
   stops above the pill: no panel content is ever under the frost. The bottom
   padding matches the dock's own clearance (safe strip + --sb-fill + 16px), so
   the LAST card clears the pill AND the home indicator / installed-shell strip
   at scroll-end, when the panel area is flush against the dock. */
html.phase5 .ospi-panels {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 14px var(--ospi-dock-clearance, 28px);
  box-sizing: border-box;
}
html.phase5 .ospi-panel[hidden] { display: none; }
/* Agents view: the roster pane moved in from the Sessions page; the panel
   scroller above scrolls it, so it takes its natural height here. */
html.phase5 .ospi-panel[data-sysview="agents"] #pane-subagents {
  height: auto; flex: none; min-height: 0; background: transparent;
}
html.phase5 .ospi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
html.phase5 .ospi-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  padding: 10px 0;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--ink);
  font-family: inherit;
  font-size: 14.5px;
  text-align: left;
}
html.phase5 .ospi-row:last-child { border-bottom: 0; }
html.phase5 .ospi-row-btn {
  cursor: pointer;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
html.phase5 .ospi-row-btn:active { background: var(--surface-2); }
html.phase5 .ospi-k { color: var(--ink-2); min-width: 0; }
html.phase5 .ospi-v {
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 12.5px;
  color: var(--ink);
  max-width: 58%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
html.phase5 .ospi-chev { color: var(--ink-3); }
html.phase5 .ospi-primary { color: var(--accent); font-weight: 600; }
html.phase5 .ospi-grp {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 10px;
}
html.phase5 .ospi-grp .ospi-row { padding: 11px 14px; }

/* This chat */
html.phase5 .ospi-chat-head { display: flex; align-items: center; gap: 12px; }
html.phase5 .ospi-chat-id {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
html.phase5 .ospi-chat-id b {
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
html.phase5 .ospi-ctxring {
  --p: 0%;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--p), var(--surface-2) 0);
  display: flex;
  align-items: center;
  justify-content: center;
}
html.phase5 .ospi-ctxring b {
  width: 29px;
  height: 29px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 9.5px;
  font-weight: 600;
  color: var(--ink-2);
}

/* Settings vitals: three labelled 3px mini-meters, ok/warn/danger at 70/90. */
html.phase5 .ospi-vitals {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0 8px;
}
html.phase5 .ospi-okwrap {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  padding-right: 4px;
  font-size: 13px;
  font-weight: 600;
}
html.phase5 .ospi-okdot {
  width: 9px;
  height: 9px;
  margin-right: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--ok);
}
html.phase5 .ospi-okdot.off { background: var(--danger); }
html.phase5 .ospi-stat { flex: 1 1 0; min-width: 0; text-align: left; }
html.phase5 .ospi-stat > b {
  display: block;
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
html.phase5 .ospi-stat > b em {
  margin-left: 2px;
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 10px;
  font-style: normal;
  color: var(--ink-3);
}
html.phase5 .ospi-meter {
  display: block;
  height: 3px;
  margin-top: 5px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
}
html.phase5 .ospi-meter i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--ok);
}
html.phase5 .ospi-meter i.w { background: var(--warn); }
html.phase5 .ospi-meter i.d { background: var(--danger); }

/* Notifications lens: unread rows are cards, read rows live in the collapsible
   'Read · n' group below them (the Agents pane's Done pattern). Body text is a
   real 2-line clamp so one long answer cannot push the group off screen. */
html.phase5 .ospi-notif { display: flex; flex-direction: column; gap: 8px; }
html.phase5 .ospi-notif-read { display: flex; flex-direction: column; gap: 8px; }
html.phase5 .ospi-notif-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; }
html.phase5 .ospi-notif-bar[hidden] { display: none; }
html.phase5 #ospi-notif-count { font-size: 13px; font-weight: 600; color: var(--ink-2); }
html.phase5 .ospi-notif-mark { border: 0; background: none; padding: 6px 4px; color: var(--accent); font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer; -webkit-tap-highlight-color: transparent; }
html.phase5 .ospi-notif-mark:disabled { opacity: .5; }
html.phase5 .ospi-notif-mark:active { opacity: .7; }
html.phase5 .ospi-ncard {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 11px 13px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
html.phase5 .ospi-ncard:active { background: var(--surface-2); }
html.phase5 .ospi-ncard-top { display: flex; align-items: baseline; gap: 8px; }
html.phase5 .ospi-ncard-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
html.phase5 .ospi-ncard:not(.read) .ospi-ncard-title::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
}
html.phase5 .ospi-ncard-time {
  flex: none;
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 11px;
  color: var(--ink-3);
}
html.phase5 .ospi-ncard-body {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  margin-top: 3px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--ink-2);
}
html.phase5 .ospi-ncard-src {
  display: block;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
html.phase5 .ospi-ncard.read { opacity: .7; }
html.phase5 .ospi-notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  min-height: 40px;
  margin: 4px 0 0;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
html.phase5 .ospi-notif-chev {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .15s ease;
}
html.phase5 .ospi-notif-head.open .ospi-notif-chev { transform: rotate(180deg); }
html.phase5 .ospi-notif-head[hidden],
html.phase5 .ospi-notif-read[hidden] { display: none; }

/* ============ Ospi Sessions bottom pill: Sessions|Files|Notes|Agents (§B) ========= */
/* Top segmented control retired in Phase 7 in favor of bottom-docked frosted pill.
   See phase7-panels.css for layout and pill rules. */

html.phase5 .ospi-seg-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 4px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
html.phase5 .ospi-seg-btn + .ospi-seg-btn { border-left: 0; }
html.phase5 .ospi-seg-btn:first-child { border-radius: 10px 0 0 10px; }
html.phase5 .ospi-seg-btn:last-child { border-radius: 0 10px 10px 0; }
html.phase5 .ospi-seg-btn.on {
  background: var(--accent-soft, rgba(77, 105, 155, .10));
  color: var(--ink);
}
html.phase5 .ospi-seg-dot {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--surface);
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
html.phase5 .ospi-seg-dot[hidden] { display: none; }


/* Side-page ask strip (pager.js sideStripPaint): amber, same palette as the
   chat needs-input bar, under the System / Sessions header. */
html.phase3 .side-ask-strip {
  flex: none; display: flex; align-items: center; gap: 8px;
  min-height: 44px; width: 100%; border: 0; border-radius: 0;
  padding: 0 14px; box-sizing: border-box; text-align: left;
  background: var(--warn, #d9a53c); color: #241f0c;
  font: 600 13.5px/1.25 system-ui, -apple-system, sans-serif;
  letter-spacing: -0.01em; cursor: pointer; touch-action: manipulation;
}
html.phase3 .side-ask-strip[hidden] { display: none !important; }
html.phase3 .side-ask-strip:active { opacity: 0.9; }
html.phase3 .side-ask-strip .side-ask-text { min-width: 0; flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.phase3 .side-ask-strip .i { flex: none; }

/* Settings > Text size: three-option segmented row (pager.js applyTextScale). */
html.phase5 .ospi-textsize { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
html.phase5 .ospi-textsize-opts { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
html.phase5 .ospi-textsize-btn {
  min-height: 44px; min-width: 56px; padding: 0 12px; border: 0; background: transparent;
  color: var(--ink-2, var(--text)); font-size: 13px; touch-action: manipulation;
}
html.phase5 .ospi-textsize-btn + .ospi-textsize-btn { border-left: 1px solid var(--line); }
html.phase5 .ospi-textsize-btn.on { background: var(--accent); color: #fff; font-weight: 600; }

/* First-run pager hint (pager.js initPager): 28px nudge + one fading line. */
html.phase3 #page-chat.hint-nudge #main { animation: pager-hint-nudge 1.1s ease-in-out 1; }
@keyframes pager-hint-nudge {
  0%, 100% { transform: translateX(0); }
  35% { transform: translateX(-28px); }
  70% { transform: translateX(0); }
}
html.phase3 .pager-hint {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(var(--hdr-safe-top, env(safe-area-inset-top)) + 50px);
  z-index: 30; pointer-events: none; white-space: nowrap;
  padding: 4px 12px; border-radius: 999px; font-size: 12.5px;
  color: var(--ink-2, var(--text)); background: var(--surface-2, var(--surface));
  animation: pager-hint-fade 4s ease forwards;
}
@keyframes pager-hint-fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { html.phase3 #page-chat.hint-nudge #main { animation: none; } }
