/* ==========================================================================
   Komp v2 Phase 5 — Sessions Page Redesign
   planopus.md §8.23, .team/phase5-pages-prep.md §2.2
   Scoped strictly under html.phase5
   ========================================================================== */

/* Tools rail consolidation (planopus.md §8.13): Laptop screen and Compact
   context are hidden in the + tools rail under Phase 5 only. */
html.phase5 #btn-screen,
html.phase5 #btn-compact {
  display: none;
}

/* Modern composer polish mirrored for the phase5 sheet (active alone too): the
   moved mic keeps only its SVG (decorative caption hidden) and the retired
   default radial glow behind ＋ / Send is suppressed. */
html.phase5 #composer #p4-toolbar small {
  display: none;
}

html.phase5 #composer :is(#btn-plus, #btn-send)::before {
  content: none;
}

html.phase5 #sess-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0 12px;
}

/* Sessions action row: "Continue" is the retired floating capsule, re-homed to
   the right of Open folder / New and shown ONLY while a chat is mid-reply
   (sessions.js updateContinueBtn). It takes no slot at rest. */
html.phase5 #btn-continue-chat {
  flex: 0 0 auto;
  gap: 6px;
  padding: 6px 12px;
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft, rgba(77, 105, 155, .08));
  color: var(--accent);
}

html.phase5 #btn-continue-chat:active {
  background: rgba(77, 105, 155, .16);
}

html.phase5 #btn-continue-chat::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: sess-v5-ring-pulse 1.8s ease-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  html.phase5 #btn-continue-chat::before {
    animation: none;
  }
}

/* --------------------------------------------------------------------------
   Groups
   -------------------------------------------------------------------------- */
html.phase5 .sess-v5-group {
  display: flex;
  flex-direction: column;
}

html.phase5 .sess-v5-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px 3px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
  user-select: none;
  -webkit-user-select: none;
}

html.phase5 .sess-v5-group-title {
  flex: 1;
}

html.phase5 .sess-v5-group-count {
  font-size: 11px;
  font-family: var(--mono, ui-monospace, monospace);
  /* Phase 7: the extra 0.8 opacity dropped this 11px label under 3:1 on
     dark themes (and under 2.5:1 in light). --ink-3 is already the tertiary
     step, so the opacity was doing nothing but hiding the count. */
  color: var(--ink-3);
}

/* Collapsible Temp Group */
html.phase5 details.sess-v5-temp {
  display: flex;
  flex-direction: column;
}

html.phase5 details.sess-v5-temp summary::-webkit-details-marker {
  display: none;
}

html.phase5 details.sess-v5-temp summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

html.phase5 details.sess-v5-temp summary .sess-v5-group-title::before {
  content: '▸ ';
  display: inline-block;
  transition: transform 0.15s ease;
  font-size: 10px;
}

html.phase5 details.sess-v5-temp[open] summary .sess-v5-group-title::before {
  transform: rotate(90deg);
}

html.phase5 .sess-v5-clear-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--ink-2);
  border-radius: var(--radius-xs, 6px);
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 8px;
}

html.phase5 .sess-v5-clear-btn:active {
  background: var(--surface-2);
  color: var(--ink);
}

html.phase5 .sess-v5-group-rows {
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   Row & Scroll-Snap Container (44px height, owner redesign)
   -------------------------------------------------------------------------- */
/* Density: the row is one 44px line (title + right-aligned time/badges) instead
   of the old two-line 64px cell, and the retired capsule's 88px bottom gutter is
   gone too, so roughly 1.5× as many sessions fit on the same phone screen. The
   row still slides left over a clipped 44px strip; Pin + Archive sit in a real
   slot at the right edge and stay 44px tap targets. touch-action stays pan-x
   pan-y: sessions.js claims only a leftward (or open-row) horizontal first move,
   so vertical list scroll and a right swipe back to Chat still belong to the
   browser and #pager. It is `manipulation` (not `auto`) because two rows are now
   only 44px apart: `auto` lets Chromium fold two quick taps on neighbouring rows
   into a double-tap-zoom gesture and swallow the second tap's click (measured in
   the harness: a lost tap every few rounds). `manipulation` keeps pan + pinch
   and removes the double-tap zoom, so every row tap always delivers its click.
   The relative-time label, running ring, amber needs-input dot, pin glyph and
   unread "New" mark are all still drawn — they moved onto the single line (see
   .sess-v5-trailing below). */
html.phase5 .sess-v5-row-snap {
  position: relative;
  width: 100%;
  height: 44px;
  overflow: hidden;
  background: var(--surface);
  touch-action: manipulation;
}

html.phase5 .sess-v5-row {
  flex: 0 0 100%;
  width: 100%;
  min-width: 100%;
  height: 44px;
  min-height: 44px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s ease, background-color 0.15s ease;
}

html.phase5 .sess-v5-row:active {
  background: var(--surface-2);
}

/* Accent bar on active session. Opaque: the translucent --accent-soft tint
   is layered over a solid --surface so nothing behind the row shows through. */
html.phase5 .sess-v5-row.active {
  background-color: var(--surface);
  background-image: linear-gradient(var(--accent-soft), var(--accent-soft));
  border-left: 3px solid var(--accent);
}

html.phase5 .sess-v5-row-snap.swiping .sess-v5-row {
  background-color: var(--surface);
}



/* Folder monogram (32px circle, warm hue) */
html.phase5 .sess-v5-monogram {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* Content is exactly one line now: the headline. The preview line stays in the
   DOM (sessions.js still writes it, and the warm-reuse signature still reads it)
   but is not drawn at this density — the row is the title plus the right-aligned
   time/badges. */
html.phase5 .sess-v5-content {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
}

html.phase5 .sess-v5-headline {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

html.phase5 .sess-v5-title {
  font-size: 15px;
  line-height: 20px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

html.phase5 .sess-v5-cwd-chip {
  font-size: 10px;
  line-height: 14px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--ink-2);
  flex-shrink: 0;
}

html.phase5 .sess-v5-preview {
  display: none;
}

html.phase5 .sess-v5-preview.sess-v5-preview-empty {
  visibility: hidden;
}

/* Trailing meta and status indicators: time, then the live badges, on the same
   line as the title (right-aligned). */
html.phase5 .sess-v5-trailing {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  min-width: 0;
}

html.phase5 .sess-v5-time {
  font-size: 12px;
  line-height: 16px;
  font-family: var(--mono, ui-monospace, monospace);
  color: var(--ink-3);
  white-space: nowrap;
}

html.phase5 .sess-v5-badges {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 14px;
}

/* Live ring (CSS only, running row) */
html.phase5 .sess-v5-live-ring {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: sess-v5-ring-pulse 1.8s ease-out infinite;
  box-sizing: border-box;
  flex-shrink: 0;
}

@keyframes sess-v5-ring-pulse {
  0% { transform: scale(0.9); opacity: 0.95; }
  50% { transform: scale(1.2); opacity: 0.35; }
  100% { transform: scale(0.9); opacity: 0.95; }
}

@media (prefers-reduced-motion: reduce) {
  html.phase5 .sess-v5-live-ring {
    animation: none;
    opacity: 0.85;
  }
}

/* Pin glyph */
html.phase5 .sess-v5-pin-glyph {
  width: 13px;
  height: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  flex-shrink: 0;
}

html.phase5 .sess-v5-pin-glyph svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
}

/* Unread count badge */
html.phase5 .sess-v5-unread-badge {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  /* Phase 7: white on the light accents measured 1.44:1 (kapur-night) and
     1.00:1 (monolith). --accentInk is the ink the theme already uses on an
     accent fill. */
  color: var(--accentInk, #ffffff);
  background: var(--accent, #b45309);
  border-radius: 999px;
  padding: 0 5px;
  min-width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Swipe Actions (Pin, Archive — 144px width)
   -------------------------------------------------------------------------- */
html.phase5 .sess-v5-row.unread .sess-v5-title {
  font-weight: 600;
}

/* Closed: invisible and never a tap target. Swiping: shown behind the row,
   still not tappable. Open: raised above everything in the strip and the
   only thing under the finger there (the row has slid 144px left of it).
   The strip is exactly the row: top:0/bottom:0 pin it to the row's own box at
   any height (no height of its own to drift), and its 144px width is what
   ROW_SLOT_W in sessions.js measures and slides by, so the two can never drift
   apart. */
html.phase5 .sess-v5-actions {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  box-sizing: border-box;
  width: 144px;
  display: flex;
  z-index: 0;
  visibility: hidden;
  pointer-events: none;
  overflow: hidden;
  touch-action: manipulation;
}

html.phase5 .sess-v5-row-snap.swiping .sess-v5-actions {
  visibility: visible;
}

html.phase5 .sess-v5-row-snap.open .sess-v5-actions {
  visibility: visible;
  pointer-events: auto;
  z-index: 2;
}

html.phase5 .sess-v5-row-snap.open .sess-v5-row {
  pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
  html.phase5 .sess-v5-row {
    transition: none;
  }
}

/* One action = one 72px × 44px half of the strip, exactly the row's height, so
   the button is a real 44px tap target with no band above or below. The 24px
   body line-height (base.css) used to inflate the 11px label's line box to 24px
   and the inline icon box to 27px: 27 + 3 + 24 = 54px of content in a 44px row,
   which overflowed 5px top and bottom and got clipped by the snap's
   overflow:hidden (the owner's oversized/clipped Archive + Pin). Both children
   now carry their own line-height, so the column is 18 + 2 + 12 = 32px inside
   the 44px button: 6px of vertical inset, centered. */
html.phase5 .sess-v5-action-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  box-sizing: border-box;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 2px;
  font-size: 11px;
  line-height: 12px;
  font-weight: 600;
  cursor: pointer;
  color: #ffffff;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* Icon box: a flex box, never an inline line box, so the 18px glyph can never
   push the column past the row. */
html.phase5 .sess-v5-act-ic {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

html.phase5 .sess-v5-action-btn svg {
  display: block;
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
}

/* Short label (Pin / Archive / Discard): one 12px line, ellipsised if a longer
   word ever lands here, never taller than the 44px button allows. */
html.phase5 .sess-v5-act-lbl {
  flex: 0 1 auto;
  max-width: 100%;
  font-size: 11px;
  line-height: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html.phase5 .sess-v5-action-pin {
  background-color: var(--info, #2563eb);
  /* Phase 7: the shared #ffffff label measured 2.09:1 on the light --info
     fill every dark theme uses. --on-info is the per-theme ink for it. */
  color: var(--on-info, #ffffff);
}

html.phase5 .sess-v5-action-pin:active {
  filter: brightness(0.9);
}

html.phase5 .sess-v5-action-archive {
  background-color: var(--danger, #dc2626);
  /* Design-system ink for a --danger fill (AA in all 12 themes). */
  color: var(--on-danger, #ffffff);
}

html.phase5 .sess-v5-action-archive:active {
  filter: brightness(0.9);
}

/* --------------------------------------------------------------------------
   Row Context Menu (.sess-pop)
   -------------------------------------------------------------------------- */
html.phase5 .sess-pop {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md, 14px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  padding: 4px;
  z-index: 1000;
  min-width: 190px;
  position: fixed;
}

html.phase5 .sess-pop-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  /* 44px minimum touch target (owner rule): the compact 44px rows must not
     shrink the menu into a miss-tap list. */
  min-height: 44px;
  box-sizing: border-box;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm, 10px);
  cursor: pointer;
  text-align: left;
}

html.phase5 .sess-pop-btn:active {
  background: var(--surface-2);
}

html.phase5 .sess-pop-btn.danger {
  color: var(--danger, #dc2626);
}

html.phase5 .sess-pop-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}

html.phase5 .sess-pop-ic svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

/* ==========================================================================
   Komp v2 Phase 5 — System Page Overview & Push Stack (Slice B)
   planopus.md §8.18, .team/phase5-pages-prep.md §2.1
   Scoped strictly under html.phase5
   ========================================================================== */

/* Hide Phase 3 legacy system-actions navigation under Phase 5 */
html.phase5 #page-system .system-actions {
  display: none !important;
}

/* Header status line */
html.phase5 #page-system .pager-head {
  min-height: 52px;
  padding-bottom: 6px;
  align-items: center;
}

html.phase5 .sys-head-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

html.phase5 .sys-head-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}

html.phase5 .sys-status-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1;
}

html.phase5 .sys-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--ok, #10b981);
}

html.phase5 .sys-status-dot.offline {
  background: var(--muted, #888);
}

/* Overview layout */
html.phase5 .sys-overview {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 14px 32px;
  box-sizing: border-box;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* Button Row: one row of four at 390px (Settings, Server, Notes, Agents). */
html.phase5 #sys-usage-refresh.spinning { animation: sys-spin 1s linear infinite; }
@keyframes sys-spin { to { transform: rotate(360deg); } }
html.phase5 #sys-usage-refresh.ok { color: var(--ok, #2e6f40); }
html.phase5 #sys-usage-refresh.err {
  color: var(--danger, #dc2626);
  animation: sys-shake 320ms ease-in-out 1;
}
@keyframes sys-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}
/* One accent-soft flash on a card whose numbers moved. Opacity only, so it
   stays on the compositor like the step-complete flash. */
html.phase5 .sys-ucard.flash::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--accent-soft);
  pointer-events: none;
  animation: sys-flash 600ms ease-out 1 both;
}
@keyframes sys-flash {
  from { opacity: 1; }
  to { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  html.phase5 #sys-usage-refresh.spinning,
  html.phase5 #sys-usage-refresh.err { animation: none; }
  html.phase5 .sys-ucard.flash::after { animation: none; opacity: 0; }
}
html.phase5 .sys-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

html.phase5 .sys-act {
  height: 44px;
  padding: 0 4px;
  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;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

html.phase5 .sys-act:active {
  background: var(--surface-2);
}

/* This Chat row (planopus.md §8.18): slim 44px paper row above usage card */
html.phase5 #sys-chat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font: 600 14px/1 system-ui, -apple-system, sans-serif;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  width: 100%;
  box-sizing: border-box;
}

html.phase5 #sys-chat-row:active {
  background: var(--surface-2);
}

html.phase5 #sys-chat-row .sys-chat-label {
  font-weight: 600;
  font-size: 14px;
  color: inherit;
}

html.phase5 #sys-chat-row .sys-chat-stats {
  font-size: 12px;
  font-weight: 500;
  font-family: var(--mono, ui-monospace, monospace);
  color: var(--ink-2);
}

html.phase5 #sys-chat-row.armed {
  background: color-mix(in srgb, var(--warn, #d97706) 12%, var(--surface));
  border-color: var(--warn, #d97706);
  color: var(--warn, #d97706);
  justify-content: center;
}

html.phase5 #sys-chat-row.armed .sys-chat-label {
  color: var(--warn, #d97706);
  font-weight: 600;
}

/* Usage Section */
html.phase5 .sys-usage {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md, 16px);
  background: var(--surface);
}

html.phase5 .sys-usage-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

html.phase5 #sys-usage-age {
  font-weight: 500;
  font-size: 11px;
  color: var(--ink-3);
}

html.phase5 #sys-usage-refresh {
  margin-left: auto;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
}

html.phase5 #sys-usage-refresh:active {
  background: var(--surface-2);
}

html.phase5 .sys-usage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
}

html.phase5 .sys-ucard {
  position: relative;
  min-width: 0;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--ink) 4%, var(--surface));
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

/* Drag grip: a 44px corner target whose own touch-action keeps the vertical
   list scroll alive (a long-press on the card body would fight the scroll). */
html.phase5 .sys-udrag {
  position: absolute;
  top: 0;
  right: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Phase 7: the grip is the only affordance for reordering a System tile;
     --ink-3 at 55% opacity was invisible on the dark themes. */
  color: var(--ink-2);
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

html.phase5 .sys-udrag::before {
  content: '';
  width: 12px;
  height: 18px;
  background-image: radial-gradient(currentColor 1.1px, transparent 1.2px);
  background-size: 6px 6px;
}

html.phase5 .sys-ucard.sys-ucard-dragging {
  opacity: 0.65;
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.18);
}

html.phase5 .sys-ucard.sys-ucard-over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

html.phase5 .sys-ucard:active {
  background: var(--surface-2);
}

html.phase5 .sys-ucard.sys-ucard-full {
  grid-column: 1 / -1;
}

html.phase5 .sys-ucard-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  padding-right: 22px;
}

html.phase5 .sys-urow {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  color: var(--ink-2);
}

html.phase5 .sys-urow-p {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

html.phase5 .sys-ubar {
  height: 4px;
  margin: 3px 0 7px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--ink) 10%, transparent);
  overflow: hidden;
}

html.phase5 .sys-ubar i {
  display: block;
  height: 100%;
  background: var(--accent);
}

html.phase5 .sys-ubar i.warn {
  background: var(--warn, #d97706);
}

html.phase5 .sys-ubar i.hot {
  background: var(--danger, #dc2626);
}

/* Last reported, not live: kept until the window resets. */
html.phase5 .sys-ubar i.faded {
  opacity: .35;
}

html.phase5 .sys-usage-empty {
  font-size: 13px;
  color: var(--ink-3);
  grid-column: 1 / -1;
  padding: 8px 0;
}

/* Provider Usage Sheet List */
html.phase5 .sys-prow {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

/* Push Stack */
html.phase5 #system-stack {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  z-index: 25;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--spring-smooth, 0.28s cubic-bezier(0.16, 1, 0.3, 1));
  will-change: transform;
  pointer-events: none;
}

html.phase5 #system-stack.pushed {
  transform: translateX(0);
  pointer-events: auto;
}

html.phase5 .sys-stack-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;
}

html.phase5 .sys-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: transparent;
  color: var(--accent, #3b82f6);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 6px;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}

html.phase5 .sys-back-btn:active {
  background: var(--surface-2);
}

html.phase5 .sys-stack-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

html.phase5 .sys-stack-head-spacer {
  width: 44px;
}

html.phase5 .sys-stack-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--capsule-clearance, 24px);
  box-sizing: border-box;
}

html.phase5 .sys-stack-body > :is(#pane-settings, #pane-notes, #pane-subagents, #pane-server) {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  overflow-y: auto;
}

/* Server sub-page: same real vps_stats cards as the sheet, hosted in the stack. */
html.phase5 #pane-server {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 32px;
  box-sizing: border-box;
  min-height: 0;
  background: var(--bg);
}

html.phase5 #pane-server[hidden] {
  display: none !important;
}

html.phase5 #pane-server #vps-pane-bar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 0;
  padding: 0;
}

html.phase5 #pane-server #btn-vps-pane-refresh {
  height: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font: 600 14px/1 system-ui, -apple-system, sans-serif;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

html.phase5 #pane-server #btn-vps-pane-refresh:active {
  background: var(--surface-2);
}

html.phase5 #vps-pane-body {
  min-height: 0;
}

/* ==========================================================================
   Phase 5 — hub subagent status rows (planopus.md §8.2, §8.10)
   A user-role [hub:subagent] wake-up is machinery, not chat: a quiet 44px
   event line instead of the right-aligned owner bubble. Scoped html.phase5 so
   default /v2/, ?phase3=1 and ?phase4=1 alone keep the plain bubble.
   ========================================================================== */
html.phase5 .msg-hub-event {
  align-self: stretch;
  max-width: 100%;
  margin: 2px 0;
}

html.phase5 .msg-hub-event .hub-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm, 10px);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  line-height: 16px;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

html.phase5 .msg-hub-event .hub-row:active {
  background: var(--surface-2);
}

html.phase5 .msg-hub-event .hub-glyph {
  flex: none;
  width: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
}

html.phase5 .msg-hub-event[data-status="finished"] .hub-glyph { color: var(--ok); }
html.phase5 .msg-hub-event[data-status="stalled"] .hub-glyph { color: var(--ink-3); }
html.phase5 .msg-hub-event[data-status="attention"] .hub-glyph { color: var(--danger); }
html.phase5 .msg-hub-event[data-status="running"] .hub-glyph { color: var(--accent-ink); }

html.phase5 .msg-hub-event .hub-label {
  flex: none;
  font-weight: 600;
  color: var(--ink);
}

html.phase5 .msg-hub-event .hub-worker {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 12px;
  color: var(--ink-3);
}

html.phase5 .msg-hub-event .hub-chev {
  flex: none;
  margin-left: auto;
  font-size: 12px;
  color: var(--ink-3);
}

html.phase5 .msg-hub-event.hub-open .hub-chev {
  transform: rotate(180deg);
}

html.phase5 .msg-hub-event .hub-full {
  margin: 4px 0 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm, 10px);
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 12px;
  line-height: 17px;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
}

html.phase5 .msg-hub-event .hub-full[hidden] {
  display: none;
}
