/* Shared toolbar layout; only the reader stays visible while the content scrolls. */
html[data-appearance] body.reader-page > header.toolbar {
  position:sticky;
  top:0;
  z-index:110;
  overflow:visible;
}
html[data-appearance] body.creator-page > header.toolbar {
  position:relative;
  top:auto;
  z-index:40;
  overflow:visible;
}
:is(.reader-page,.creator-page) > .toolbar .toolbar-navigation-toggle { display:none; }
:is(.reader-page,.creator-page) > .toolbar .toolbar-account-menu { flex:none; }
:is(.reader-page,.creator-page) > .toolbar .reader-back { display:inline-flex; flex:none; align-items:center; justify-content:center; width:32px; min-height:44px; padding:0; border-radius:8px; color:var(--site-muted,var(--ink-light)); text-decoration:none; }
:is(.reader-page,.creator-page) > .toolbar .reader-back svg { width:22px; height:22px; }
:is(.reader-page,.creator-page) > .toolbar .reader-back:hover { color:var(--site-accent,var(--accent)); background:var(--site-tint,var(--paper)); }
:is(.reader-page,.creator-page) > .toolbar .reader-back:focus-visible { outline:2px solid var(--site-accent); outline-offset:2px; }
html[data-appearance] :is(.reader-page,.creator-page) > .toolbar .auth-box .appearance-toggle {
  display:inline-flex;
  flex:0 0 36px;
  align-items:center;
  justify-content:center;
  width:36px;
  height:36px;
  min-height:36px;
  margin:0;
  padding:7px;
}
@media(max-width:768px) {
  html[data-appearance] body:is(.reader-page,.creator-page) > header.toolbar {
    grid-template-columns:32px minmax(0,1fr) auto;
    padding:calc(8px + env(safe-area-inset-top,0px)) 12px 8px;
  }
  html[data-appearance] :is(.reader-page,.creator-page) > .toolbar > nav { display:none; }
  :is(.reader-page,.creator-page) > .toolbar .reader-back { grid-column:1;grid-row:1; }
  html[data-appearance] body:is(.reader-page,.creator-page) > .toolbar .logo { grid-column:2;grid-row:1; }
  html[data-appearance] :is(.reader-page,.creator-page) > .toolbar .auth-box { grid-column:3;grid-row:1;gap:2px; }
  html[data-appearance] :is(.reader-page,.creator-page) > .toolbar .auth-box .appearance-toggle { height:44px;min-height:44px; }
}
@media(max-width:420px) {
  html[data-appearance] body:is(.reader-page,.creator-page) > .toolbar .logo { font-size:13px;gap:5px;letter-spacing:0; }
  :is(.reader-page,.creator-page) > .toolbar .brand-symbol { width:30px;height:30px; }
}
@media(max-width:360px) {
  html[data-appearance] body:is(.reader-page,.creator-page) > header.toolbar { padding-inline:10px; }
  html[data-appearance] body:is(.reader-page,.creator-page) > .toolbar .logo { font-size:0;gap:0; }
  :is(.reader-page,.creator-page) > .toolbar .brand-symbol { width:28px;height:28px; }
}

/* Keep the worldline centered between the back button and the three tools. */
html[data-appearance] body.reader-page > header.toolbar {
  display:grid; grid-template-columns:108px minmax(0,1fr) 108px;
  grid-template-areas:"back branch actions";
  align-items:center; gap:3px 4px; width:min(100%,1180px); min-height:0; margin-inline:auto;
  padding:calc(4px + env(safe-area-inset-top,0px)) 18px 4px;
  border:1px solid var(--border); border-top:0; border-radius:0 0 18px 18px;
  background:var(--paper,var(--bg)); animation:none;
}
.reader-page > .toolbar .reader-back { grid-area:back; }
.reader-worldline {
  grid-area:branch; min-width:0; min-height:34px; padding:0 2px;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  border:0; border-radius:8px; background:transparent;
  color:var(--ink-light); font:inherit; font-size:12px; font-weight:500; cursor:pointer;
}
.reader-header-actions { grid-area:actions; display:flex; align-items:center; justify-content:flex-end; gap:3px; }
html[data-appearance] .reader-page > .toolbar :is(.reader-back,.reader-header-button,.reader-header-actions .appearance-toggle) {
  display:grid; place-items:center; width:34px; height:34px; min-height:34px; padding:0; margin:0;
  border:1px solid var(--border); border-radius:50%;
  background:transparent; color:var(--ink-light); cursor:pointer;
}
.reader-page > .toolbar :is(.reader-back,.reader-header-actions) svg { width:16px; height:16px; }
html[data-appearance] .reader-page > .toolbar :is(button:not(:disabled),.reader-back):hover {
  color:var(--accent-dark);
}
.reader-page > .toolbar :is(.reader-worldline,.reader-header-button,.reader-protagonist):focus-visible {
  outline:2px solid var(--accent); outline-offset:2px;
}
#reader-focus:disabled { opacity:.45; cursor:default; }
#reader-focus[aria-expanded="true"] .reader-eye-slash { display:none; }
.reader-protagonist-row {
  grid-column:1 / -1; display:flex; align-items:center; justify-content:space-between; gap:8px;
}
.reader-protagonist-row[hidden],
.reader-page.reader-protagonist-hidden .reader-protagonist-row { display:none; }
.reader-protagonist {
  display:flex; align-items:center;
  gap:8px; min-width:0; min-height:40px; padding:0 8px 0 0;
  border:0; border-radius:11px; background:transparent;
  color:var(--ink); text-align:left; font:inherit; cursor:pointer;
}
.reader-protagonist-avatar {
  display:grid; place-items:center; flex:0 0 38px; height:38px;
  overflow:hidden; border:1px solid var(--border); border-radius:12px;
  background:var(--card); color:var(--accent-dark);
  font-size:18px; font-weight:700;
}
.reader-protagonist-avatar img { width:100%; height:100%; object-fit:cover; }
.reader-protagonist-copy { display:grid; min-width:0; gap:2px; }
.reader-protagonist-copy > * { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.reader-protagonist-copy strong { font-size:16px; }
.reader-protagonist-copy small { color:var(--ink-light); font-size:11px; }
.reader-protagonist-copy small:empty { display:none; }
.reader-protagonist-row .toolbar-wallet { flex:none; }
.reader-page .reader-visually-hidden {
  position:absolute; width:1px; height:1px; padding:0; overflow:hidden;
  clip:rect(0,0,0,0); white-space:nowrap; border:0;
}
@media(max-width:768px) {
  html[data-appearance] body.reader-page > header.toolbar { padding-inline:12px; }
}
