/* Page view (SPEC §13.4): full-viewport frame, top toolbar strip + floating dock (≥ 600 px), reserved bars (< 600 px),
   viewer badge, state screens, build card, live preview, banners, overlays, panels. */

.page-root {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
}

#stage, .stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
}

.page-frame {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  height: 100dvh;
  border: 0;
  background: transparent;
  transition: opacity .25s var(--ease);
}
.page-frame.frame-pending { opacity: 0; pointer-events: none; z-index: 0; }

/* ---- Live preview ----------------------------------------------------------------------------------------- */
.preview-host {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s var(--ease);
}
.preview-host[data-visible="true"] { opacity: 1; }
.preview-host::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 2px;
  animation: fx-pulse 2.4s ease-in-out infinite;
}
.preview-host[data-leaving="true"]::after { display: none; }
#preview-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}

/* ---- Build card ------------------------------------------------------------------------------------------- */
.build-card {
  position: absolute;
  left: 50%;
  top: 44%;
  z-index: 4;
  width: min(520px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow: auto;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--raised);
  box-shadow: var(--shadow);
  transition: opacity .35s var(--ease), transform .35s var(--ease);
  animation: fx-rise .4s var(--ease);
}
.build-card[data-faded="true"] { opacity: 0; pointer-events: none; transform: translate(-50%, -48%); }
.build-top { display: flex; align-items: center; gap: 14px; }
.build-emoji {
  display: grid;
  place-items: center;
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--surface);
  font-size: 30px;
  line-height: 1;
  animation: fx-breathe 2.4s ease-in-out infinite;
}
@keyframes fx-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .build-emoji { animation: none; } }
.build-heading { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.build-title { font-size: 18px; font-weight: 700; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.build-status { display: flex; align-items: center; gap: 8px; color: var(--mute); font-size: 14px; }
.build-prompt {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.build-steps { display: flex; flex-direction: column; gap: 6px; }
.build-steps:empty { display: none; }
.build-foot { display: flex; align-items: flex-start; gap: 12px; font-size: 13px; color: var(--mute); line-height: 1.45; }
.build-time {
  flex: none;
  min-width: 44px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--ink-softer);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: center;
  color: var(--ink);
}

/* ---- State screens ---------------------------------------------------------------------------------------- */
.state-wrap {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 72px 20px 24px;
  overflow: auto;
  background: var(--bg);
}
.has-chrome .state-wrap { padding-bottom: 150px; }
.state-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 440px;
  text-align: center;
  animation: fx-rise .35s var(--ease);
}
.state-card h1, .state-card h2 {
  font-size: clamp(22px, 4vw, 28px);
  line-height: 1.2;
  font-weight: 750;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.state-card h1:focus { outline: none; }
.state-text { color: var(--mute); font-size: 16px; text-wrap: balance; }
.state-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 8px; }
.state-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 6px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent);
}
.state-icon[data-tone="error"] { background: var(--danger-soft); color: var(--danger); }
.state-icon .icon-lg { width: 28px; height: 28px; }
.state-skeleton { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.state-skeleton span { display: block; height: 14px; border-radius: 7px; background: var(--ink-soft); animation: fx-pulse 1.4s ease-in-out infinite; }
.state-skeleton span:nth-child(1) { width: 64px; height: 64px; border-radius: 20px; margin-bottom: 8px; }
.state-skeleton span:nth-child(2) { width: 70%; }
.state-skeleton span:nth-child(3) { width: 45%; }
.state-loading .state-text { font-size: 15px; }
.flag-wrap { z-index: 6; }

.page-header {
  position: fixed;
  top: calc(12px + var(--safe-top));
  left: calc(16px + var(--safe-left));
  z-index: 20;
}
.page-logo { display: inline-flex; padding: 8px 6px; color: var(--ink); text-decoration: none; }
.page-logo:hover { text-decoration: none; }

/* ---- Hung overlay ----------------------------------------------------------------------------------------- */
.hung {
  position: fixed;
  inset: 0;
  z-index: 25;   /* above the dock and toolbar: its card must never sit under a tall dock */
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fx-fade-in .2s;
}
.hung-card {
  padding: 28px 24px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--raised);
  box-shadow: var(--shadow);
}

/* ---- Toolbar (≥ 600 px: floating, top right) -------------------------------------------------------------- */
.toolbar {
  position: fixed;
  top: calc(12px + var(--safe-top));
  right: calc(12px + var(--safe-right));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: calc(100% - 24px);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.5);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  box-shadow: var(--shadow-sm);
}
.tb-home {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 10px 0 12px;
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
}
.tb-home:hover { background: var(--ink-soft); text-decoration: none; }
.wordmark-tb { font-size: 17px; }
.tb-meta { display: none; }
.tb-actions { display: flex; align-items: center; gap: 2px; }
.tb-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color .15s;
}
.tb-btn:hover, .tb-btn[aria-expanded="true"] { background: var(--ink-soft); }
.tb-btn .icon { width: 18px; height: 18px; }
.tb-btn.tb-icon { width: 36px; padding: 0; justify-content: center; }
.tb-btn::after { content: ''; position: absolute; inset: -4px 0; }
.tb-share-icon { display: inline-flex; }
#btn-share { background: var(--accent); color: var(--accent-ink); margin-right: 2px; }
#btn-share:hover, #btn-share[aria-expanded="true"] { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }

/* ---- Banner slot ------------------------------------------------------------------------------------------ */
.banner-slot {
  position: fixed;
  top: calc(66px + var(--safe-top));
  left: 50%;
  z-index: 19;
  width: min(640px, calc(100% - 24px));
  transform: translateX(-50%);
}
.banner-slot[hidden] { display: none; }

/* ---- Dock (≥ 600 px: floating, bottom center) ------------------------------------------------------------- */
.dock {
  position: fixed;
  left: 50%;
  bottom: calc(16px + var(--safe-bottom));
  z-index: 20;
  width: min(720px, calc(100% - 32px));
  transform: translateX(-50%);
}
.dock-panel {
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--raised);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: fx-rise .3s var(--ease);
}
.dock-scroll {
  max-height: min(38vh, 400px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 16px 6px;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}
.dock-scroll:has(> #dock-history[hidden]):has(> #dock-narration:empty) { display: none; }
.dock[data-open="false"]:not([data-running="true"]) .dock-scroll:has(> #dock-history[hidden]) { display: none; }

.dock-narration { display: flex; flex-direction: column; gap: 8px; font-size: 15px; line-height: 1.55; }
.narr { color: var(--mute); white-space: pre-wrap; overflow-wrap: anywhere; }
.narr:empty { display: none; }
.turn-user { align-self: flex-end; max-width: 88%; }
.bubble-user { background: var(--accent); color: var(--accent-ink); border-radius: 18px 18px 6px 18px; }
.turn-meta { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.turn-emoji { font-size: 20px; line-height: 1; }
.turn-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.reply { align-self: stretch; animation: fx-rise .3s var(--ease); }
.bubble-reply { background: var(--surface); border-radius: 6px 18px 18px 18px; }
.msg.reply[data-collapsed="true"] .bubble-reply,
.bubble[data-tone="error"][data-collapsed="true"] .bubble-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.bubble[data-tone="error"][data-collapsed="true"] { cursor: pointer; }
.rev-chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  margin-right: 8px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  vertical-align: 1px;
}
.bubble-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bubble-actions .btn { margin-top: 10px; }

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--ink-softer);
  font-size: 13.5px;
  line-height: 1.35;
  animation: fx-rise .25s var(--ease);
}
.step-mark {
  flex: none;
  position: relative;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent);
  animation: fx-spin .8s linear infinite;
}
.step[data-state="end"] .step-mark, .step[data-state="note"] .step-mark { animation: none; border: 0; background: var(--ok); }
.step[data-state="end"] .step-mark::after, .step[data-state="note"] .step-mark::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2.5px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.step[data-state="note"] .step-mark { background: var(--accent); }
.step[data-state="note"] .step-mark::after { left: 7px; top: 3px; width: 2px; height: 6px; border-width: 0 2px 0 0; transform: none; }
.step[data-ok="false"] .step-mark { background: var(--danger); }
.step[data-ok="false"] .step-mark::after { left: 4px; top: 7px; width: 8px; height: 2px; border: 0; background: #fff; transform: none; }
.step-label { font-family: var(--mono); font-size: 12.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.step-result { margin-left: auto; flex: none; color: var(--mute); font-size: 12.5px; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .step-mark { animation: none; border-color: var(--accent); } }

.live-card, .anon-hint {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  font-size: 14.5px;
  animation: fx-rise .35s var(--ease);
}
.anon-hint { border-color: var(--line); background: var(--surface); color: var(--ink); }
.live-head { display: flex; align-items: flex-start; gap: 10px; }
.live-dot {
  flex: none;
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px var(--ok-soft);
}
.live-text { font-weight: 600; overflow-wrap: anywhere; }
.live-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.live-sub { font-size: 13px; color: var(--mute); }

.dock-history { display: flex; flex-direction: column; gap: 12px; padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px dashed var(--line); }
.dock-history .msg { display: flex; flex-direction: column; gap: 4px; }
.dock-history .msg[data-role="user"] { align-items: flex-end; }
.dock-history .msg[data-role="user"] .msg-meta { flex-direction: row-reverse; }
.dock-history .bubble { font-size: 14.5px; padding: 8px 12px; max-width: 92%; }
.dock-history .bubble-user { border-radius: 16px 16px 6px 16px; }
.dock-history .bubble-err { background: var(--danger-soft); }
.msg-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--mute); }
.msg-author { font-weight: 650; color: var(--ink); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-meta .rev-chip { margin: 0; height: 18px; font-size: 11px; }
.history-note { color: var(--mute); font-size: 14px; text-align: center; padding: 6px 0; }
.history-more { align-self: center; font-size: 13px; }

.dock-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 16px;
  color: var(--mute);
  font-size: 13.5px;
  border-bottom: 1px solid var(--line);
  background: var(--ink-softer);
}
.dock-status[hidden] { display: none; }
.status-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.status-time { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }

.dock-bar { display: flex; align-items: flex-end; gap: 8px; padding: 8px 8px 8px 6px; }
.dock-input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  max-height: 180px;
  padding: 9px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  line-height: 1.45;
}
.dock-input::placeholder { color: color-mix(in srgb, var(--mute) 85%, transparent); }
.dock-input:focus-visible { outline: none; }
.dock-input:disabled { opacity: .7; }
.dock-send, .dock-stop {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  transition: background-color .15s, opacity .15s, transform .15s var(--ease);
}
.dock-send .icon { width: 20px; height: 20px; stroke-width: 2.4; }
.dock-send:disabled { background: var(--ink-soft); color: var(--mute); }
.dock-send:not(:disabled):active, .dock-stop:active { transform: scale(.94); }
.dock-stop { background: var(--ink); color: var(--bg); }
.dock-send::after, .dock-stop::after { content: ''; position: absolute; inset: -2px; }

.dock-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 8px 6px;
  font-size: 13px;
  color: var(--mute);
}
.dock-tool {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--mute);
  font-weight: 600;
  font-size: 13px;
}
.dock-tool:hover, .dock-tool[aria-expanded="true"] { background: var(--ink-soft); color: var(--ink); }
.dock-tool::after { content: ''; position: absolute; inset: -7px 0; }
.dock-min-btn { width: 30px; padding: 0; justify-content: center; }
.dock-spacer { flex: 1; }
.dock-quota { font-size: 13px; color: var(--mute); }
.dock-quota .link-btn { font-size: 13px; }

.dock-fab {
  position: fixed;
  right: calc(20px + var(--safe-right));
  bottom: calc(20px + var(--safe-bottom));
  z-index: 20;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 52px;
  min-width: 52px;
  padding: 0 18px 0 16px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
  box-shadow: var(--shadow);
  animation: fx-rise .25s var(--ease);
}
.dock-fab .fab-ring {
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  border: 2px solid transparent;
  pointer-events: none;
}
.dock-fab[data-running="true"] .fab-ring {
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent);
  animation: fx-spin 1.1s linear infinite;
}
@media (prefers-reduced-motion: reduce) { .dock-fab[data-running="true"] .fab-ring { animation: fx-pulse 1.6s ease-in-out infinite; border-color: var(--accent); } }

/* ---- Viewer badge ------------------------------------------------------------------------------------------- */
.badge {
  position: fixed;
  right: calc(16px + var(--safe-right));
  bottom: calc(16px + var(--safe-bottom));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0;
  height: 38px;
  padding: 0 4px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
  background: color-mix(in srgb, var(--raised) 88%, transparent);
  backdrop-filter: blur(14px) saturate(1.5);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  box-shadow: var(--shadow-sm), 0 6px 20px rgba(0, 0, 0, .12);
  font-size: 13px;
  animation: fx-rise .3s var(--ease);
}
.badge-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
}
.badge-btn:hover { background: var(--ink-soft); text-decoration: none; }
.badge-btn::after { content: ''; position: absolute; inset: -7px 0; }
.badge-brand { padding: 0 8px 0 10px; }
.wordmark-badge { font-size: 14px; }
.badge-report { color: var(--mute); }
.badge-close { width: 30px; padding: 0; justify-content: center; color: var(--mute); }
.badge-sep { width: 1px; height: 16px; background: var(--line); }
.badge[data-collapsed="true"] { padding: 0; height: auto; border: 0; background: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
.badge-expand {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow-sm), 0 4px 14px rgba(0, 0, 0, .18);
}
.badge-expand::after { content: ''; position: absolute; inset: -6px; }
.badge-logo { width: 10px; height: 14px; border: 2.5px solid currentColor; border-radius: 4px; }

/* ---- Share popover ------------------------------------------------------------------------------------------ */
.share { display: flex; flex-direction: column; }
.share-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 0; }
.share-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.share-section { padding: 14px 16px; border-bottom: 1px solid var(--line); margin: 0; }
.share-section:last-child { border-bottom: 0; }
.plain-fieldset { border: 0; min-width: 0; padding: 0; margin: 0; }
fieldset.share-section { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.share-label { padding: 0; margin-bottom: 10px; font-size: 13px; font-weight: 700; color: var(--mute); text-transform: uppercase; letter-spacing: .05em; }
.share-linkrow { display: flex; gap: 8px; }
.share-link { min-height: 40px; padding: 8px 12px; font-family: var(--mono); font-size: max(16px, 1rem); background: var(--surface); }
@media (min-width: 600px) { .share-link { font-size: 13.5px; } }
.share-copy { flex: none; min-height: 40px; }
.share-note { font-size: 13.5px; color: var(--mute); margin-top: 8px; }
.share-section > .share-note:first-child { margin-top: 0; }
.share-anon { font-size: 13px; color: var(--mute); background: var(--surface); }
.choice-body { display: inline-flex; align-items: center; gap: 8px; }
.choice-body .icon { color: var(--mute); }
.share-listed { margin-top: 10px; }
.share-flagged { color: var(--danger); }
.share-signin { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.share-signin .share-note { margin: 0; }
.editor-form { display: flex; gap: 8px; }
.editor-form .field { min-height: 40px; padding: 8px 12px; }
.editor-form .btn { flex: none; min-height: 40px; }
.editor-list { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.editor-row { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 4px 0; }
.avatar-sm { width: 28px; height: 28px; font-size: 12px; }
.editor-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.editor-email { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-status { font-size: 12.5px; color: var(--mute); }
.editor-status[data-joined="true"] { color: var(--ok); }
.editor-empty { margin: 0; }

/* ---- Versions panel ----------------------------------------------------------------------------------------- */
.versions-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: min(380px, 100vw);
  padding-top: var(--safe-top);
  border-left: 1px solid var(--line);
  background: var(--raised);
  box-shadow: -12px 0 40px rgba(0, 0, 0, .14);
  animation: fx-panel-in .25s var(--ease);
}
@keyframes fx-panel-in { from { transform: translateX(24px); opacity: 0; } }
.versions-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px 18px; }
.versions-note { display: flex; align-items: center; gap: 8px; margin: 0 18px 10px; font-size: 13.5px; color: var(--mute); }
.version-list { flex: 1; overflow-y: auto; padding: 0 10px calc(16px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 4px; }
.version-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid transparent;
}
.version-row:hover { background: var(--ink-softer); }
.version-row[data-viewing="true"] { border-color: var(--accent-line); background: var(--accent-soft); }
.version-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.version-line .rev-chip { margin: 0; }
.version-time { margin-left: auto; font-size: 12.5px; color: var(--mute); }
.version-note { font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.version-by { font-size: 12.5px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.version-actions { display: flex; gap: 6px; }
.version-actions:empty { display: none; }
.versions-panel.as-sheet {
  top: auto;
  left: 0;
  width: 100vw;
  max-height: 78dvh;
  border-left: 0;
  border-top: 1px solid var(--line);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .2);
  animation: fx-sheet-in .26s var(--ease);
}

/* ---- Narrow screens: owner/editor reserve space (SPEC §13.4) ------------------------------------------------ */
@media (max-width: 599px) {
  .page-root.has-chrome {
    display: grid;
    /* the explicit column keeps a long nowrap title from widening the toolbar and the frame past the viewport */
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 48px minmax(0, 1fr) calc(56px + var(--safe-bottom));
    padding-top: var(--safe-top);
  }
  .page-root.has-chrome .toolbar {
    position: relative;
    top: auto;
    right: auto;
    grid-row: 1;
    z-index: 21;
    max-width: none;
    width: 100%;
    height: 48px;
    padding: 0 4px 0 2px;
    gap: 0;
    border-radius: 0;
    border-width: 0 0 1px;
    background: var(--raised);
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .page-root.has-chrome .stage, .page-root.has-chrome #stage {
    position: relative;
    inset: auto;
    grid-row: 2;
    min-height: 0;
  }
  .page-root.has-chrome .page-frame { height: 100%; }
  .tb-home { padding: 0 6px 0 10px; height: 44px; }
  .wordmark-tb { font-size: 15px; }
  .tb-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    padding: 0 4px;
    font-size: 14.5px;
    font-weight: 650;
  }
  .tb-emoji { flex: none; font-size: 17px; line-height: 1; }
  .tb-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tb-vis { flex: none; display: inline-flex; color: var(--mute); }
  .tb-versions { display: none; }
  .tb-btn { height: 40px; }
  #btn-share { padding: 0 12px; }
  #btn-share .tb-label { display: none; }
  #btn-share { width: 40px; padding: 0; justify-content: center; }
  .tb-btn.tb-icon { width: 44px; height: 44px; }

  .banner-slot { top: calc(56px + var(--safe-top)); width: calc(100% - 16px); }
  .bar { padding: 8px 8px 8px 12px; font-size: 13.5px; }

  .has-chrome .dock {
    left: 0;
    right: 0;
    bottom: var(--kb, 0px);
    width: 100%;
    transform: none;
  }
  .has-chrome .dock-panel {
    border-radius: 18px 18px 0 0;
    border-width: 0;
    box-shadow: 0 -1px 0 var(--line), 0 -6px 24px rgba(0, 0, 0, .08);
    padding-bottom: var(--safe-bottom);
    animation: none;
  }
  .has-chrome .dock[data-open="false"] .dock-tools,
  .has-chrome .dock[data-open="false"] .dock-status { display: none; }
  .has-chrome .dock[data-open="false"] .dock-scroll { display: none; }
  .has-chrome .dock-scroll { max-height: calc(60dvh - 120px); }
  .has-chrome .dock-bar { min-height: 56px; padding: 7px 8px 7px 6px; align-items: center; }
  .has-chrome .dock-input { min-height: 40px; padding: 9px 10px; }
  .has-chrome .dock-tool-label { display: none; }
  .has-chrome .dock-tool { width: 34px; padding: 0; justify-content: center; }
  .has-chrome .dock-min-btn { display: none; }
  .has-chrome .dock-fab { bottom: calc(12px + var(--safe-bottom)); }
  .has-chrome .state-wrap { padding: 24px 20px; }
  .build-card { top: 50%; padding: 18px; gap: 12px; }
  .build-emoji { width: 48px; height: 48px; font-size: 26px; }
  .build-note { font-size: 12.5px; }

  .badge { right: calc(12px + var(--safe-right)); bottom: calc(12px + var(--safe-bottom)); }
}
.dock-panel:focus-within { border-color: var(--accent-line); }
.dock-history:has(+ #dock-narration:empty) { border-bottom: 0; margin-bottom: 0; }
.dock-input::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-note { color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.status-note:empty { display: none; }
/* Owner/editor ≥ 600 px: the toolbar sits in a 56 px top strip and the frame starts below it, so it never covers the
   page's own top-right controls (SPEC §13.4). The strip shows .page-root's background; viewers are unchanged. */
@media (min-width: 600px) {
  .page-root.has-chrome #stage { top: calc(56px + var(--safe-top)); }
  .page-root.has-chrome .page-frame { height: 100%; }
  .page-root.has-chrome .toolbar { top: calc(5px + var(--safe-top)); }
}
@media (min-width: 600px) {
  .page-root[data-panel="true"] .dock,
  .page-root[data-panel="true"] .banner-slot {
    left: calc((100% - 380px) / 2);
    width: min(720px, calc(100% - 380px - 32px));
  }
  .page-root[data-panel="true"] .toolbar { right: calc(392px + var(--safe-right)); }
}
@media (max-width: 599px) {
  #btn-share { width: 36px; height: 36px; margin-right: 4px; }
}
/* Idle collapse (every width, SPEC §13.4): only the one-line preview of the newest reply/error stays */
.has-chrome .dock[data-peek="true"] #dock-narration > :not(.peek-target) { display: none; }
.has-chrome .dock[data-peek="true"] .dock-scroll { padding-top: 10px; padding-bottom: 8px; }
.has-chrome .dock[data-peek="true"] .dock-tools { display: none; }
