/* fcc.cc/library — writing published here.
 *
 * Verse reading, the author studio and editor, the published index, writer
 * pages, the mature interstitial and the preview banner. Loaded after
 * styles.css so it can lean on the existing class vocabulary (.lib-btn,
 * .lib-pill, .lib-toast, .shelf-grid, .book-card, .section-head).
 *
 * Rules:
 *   - colour, type, space, radius and motion come from tokens.css only, so
 *     light, dark and (if it is ever promoted) sepia all work with no block
 *     of their own here
 *   - no colour literal appears below at all: every colour is a token, or a
 *     color-mix() of a token with the work's own palette hue
 *   - every keyframe animation has a prefers-reduced-motion opt-out
 *   - 44px minimum tap targets on controls, :focus-visible on everything
 *     focusable
 *
 * Wired in Phase 2 push iii (linked from index.html, added to the service
 * worker CORE_ASSETS with its own ?v= token).
 */

/* ══ Verse reading ═══════════════════════════════════════════════════════
 * A poem is shown as it was typed: ragged left, unhyphenated, no drop cap,
 * a narrower measure than prose, and real stanza gaps. The indent classes
 * vi-1 … vi-12 are emitted by api/app/text_render.py; the editor preview
 * emits the same markup through lib/verse.js.
 */

.book-page-preview--verse {
  text-align: left;
  hyphens: none;
  -webkit-hyphens: none;
  max-width: 34em;
  margin-inline: auto;
}

.book-page-preview--verse p,
.book-page-preview--verse .stanza {
  text-align: left;
  hyphens: none;
  -webkit-hyphens: none;
  text-indent: 0;
  padding-left: 0;
}

/* Never a drop cap on verse — the first letter of a poem is a word, not an
 * ornament. Beats body.drop-caps-on without !important by being more
 * specific than the .book-page-preview p:first-of-type rule it overrides.
 *
 * The `:first-of-type` pairs are load-bearing, not belt-and-braces: the phone
 * reader's own drop cap (styles.css `.mobile-reader-preview
 * p:first-of-type::first-letter`) is NOT gated on body.drop-caps-on and, with
 * its pseudo-class, outweighed the plain `p::first-letter` selectors below.
 * The floated 60px capital then pushed every following verse line right by
 * its width, so a one-space indent landed further in than a two-space one. */
body.drop-caps-on .book-page-preview--verse p:first-of-type::first-letter,
body.drop-caps-on .book-page-preview--verse p::first-letter,
.book-page-preview--verse p:first-of-type::first-letter,
.book-page-preview--verse p::first-letter {
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  float: none;
  color: inherit;
  margin: 0;
  padding: 0;
}

.book-page-preview--verse .verse { margin: 0 0 1.2em; }
.book-page-preview--verse .verse:last-child { margin-bottom: 0; }
.book-page-preview--verse .stanza { margin: 0 0 1.2em; }
.book-page-preview--verse .verse .stanza:last-child { margin-bottom: 0; }

.book-page-preview--verse h1,
.book-page-preview--verse h2,
.book-page-preview--verse h3 {
  text-align: left;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
}

/* Two spaces per level in the source, one ch per level on the page. */
.book-page-preview--verse .vi-1  { padding-left: 1ch; }
.book-page-preview--verse .vi-2  { padding-left: 2ch; }
.book-page-preview--verse .vi-3  { padding-left: 3ch; }
.book-page-preview--verse .vi-4  { padding-left: 4ch; }
.book-page-preview--verse .vi-5  { padding-left: 5ch; }
.book-page-preview--verse .vi-6  { padding-left: 6ch; }
.book-page-preview--verse .vi-7  { padding-left: 7ch; }
.book-page-preview--verse .vi-8  { padding-left: 8ch; }
.book-page-preview--verse .vi-9  { padding-left: 9ch; }
.book-page-preview--verse .vi-10 { padding-left: 10ch; }
.book-page-preview--verse .vi-11 { padding-left: 11ch; }
.book-page-preview--verse .vi-12 { padding-left: 12ch; }

.book-page-preview--verse .vi-1,
.book-page-preview--verse .vi-2,
.book-page-preview--verse .vi-3,
.book-page-preview--verse .vi-4,
.book-page-preview--verse .vi-5,
.book-page-preview--verse .vi-6,
.book-page-preview--verse .vi-7,
.book-page-preview--verse .vi-8,
.book-page-preview--verse .vi-9,
.book-page-preview--verse .vi-10,
.book-page-preview--verse .vi-11,
.book-page-preview--verse .vi-12 {
  display: inline-block;
}

/* On a phone a long line has to wrap somewhere; hang the wrap so the reader
 * can still see where each line of the poem starts. */
@media (max-width: 700px) {
  .book-page-preview--verse .stanza {
    padding-left: 2ch;
    text-indent: -2ch;
  }
}

/* ══ Scene break ═════════════════════════════════════════════════════════ */

.book-page-preview hr.scene-break,
.studio-preview hr.scene-break {
  border: 0;
  height: auto;
  margin: 1.8em 0;
  text-align: center;
  color: var(--color-text-faint);
}

.book-page-preview hr.scene-break::after,
.studio-preview hr.scene-break::after {
  content: "* * *";
  display: block;
  font-family: var(--font-display);
  font-size: 1.4em;
  letter-spacing: .3em;
  /* The tracking pushes the group right; pull it back so it reads centred. */
  text-indent: .3em;
}

/* ══ Motif cover ═════════════════════════════════════════════════════════
 * A work with no artwork gets its palette tone and its first letter. The two
 * stops and the glyph colour all derive from --motif-hue / --motif-hue-2,
 * set inline by lib/motif-cover.js.
 */

.motif-cover {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--radius-md);
  background-image: linear-gradient(
    148deg,
    color-mix(in srgb, var(--motif-hue, var(--color-accent)) 88%, var(--color-surface)) 0%,
    color-mix(in srgb, var(--motif-hue, var(--color-accent)) 52%, var(--color-page-bg)) 58%,
    color-mix(in srgb, var(--motif-hue-2, var(--motif-hue, var(--color-accent))) 34%, var(--color-page-bg)) 100%
  );
}

.motif-cover-glyph {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  line-height: .85;
  font-size: clamp(38px, 34%, 96px);
  /* Ink derived from the same hue: dark enough to read on the tint, and
   * deliberately NOT --color-text — the tint does not change with the theme,
   * so an ink that did would go white on a pale block in dark mode. */
  color: color-mix(in srgb, var(--motif-hue, var(--color-accent)) 34%, black);
}

.motif-cover--hero .motif-cover-glyph { font-size: clamp(56px, 30%, 140px); }

.motif-cover--avatar {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-pill);
  flex: 0 0 auto;
}
.motif-cover--avatar .motif-cover-glyph { font-size: 46px; }

/* ══ Studio ══════════════════════════════════════════════════════════════ */

.studio { max-width: 1000px; }

.studio-head { margin-bottom: var(--space-6); }

.studio-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: var(--font-size-3xl);
  line-height: 1.05;
  margin: 0 0 var(--space-2);
  color: var(--color-text);
}

.studio-dek {
  font-family: var(--font-reader);
  font-size: 18px;
  line-height: 1.5;
  color: var(--color-text-dim);
  margin: 0;
  max-width: 46em;
}

.studio-kicker {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin: 0 0 var(--space-2);
}

.studio-section-head { margin: var(--space-8) 0 var(--space-4); }

.studio-section-title {
  font-family: var(--font-display);
  font-size: var(--font-size-2xl);
  font-weight: 600;
  margin: 0;
  color: var(--color-text);
}

/* ── The front porch ── */

.studio-porch-hero {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  padding: var(--space-8) var(--space-6);
  margin-bottom: var(--space-6);
}

.studio-promises {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.studio-promise {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  padding: var(--space-5);
}

.studio-promise h3 {
  font-family: var(--font-ui);
  font-size: var(--font-size-md);
  font-weight: 600;
  margin: 0 0 var(--space-2);
  color: var(--color-text);
}

.studio-promise p {
  font-family: var(--font-ui);
  font-size: var(--font-size-md);
  line-height: 1.55;
  margin: 0;
  color: var(--color-text-dim);
}

.studio-note {
  font-family: var(--font-ui);
  font-size: var(--font-size-md);
  line-height: 1.55;
  color: var(--color-text-dim);
  margin: 0 0 var(--space-5);
  max-width: 46em;
}

/* The line on a work that came from /stories. A statement about the work,
 * not a warning about it — so it reads like the summary, and a plain rule
 * rather than a warn colour is what sets it apart. */
.studio-legacy-note {
  font-family: var(--font-ui);
  font-size: var(--font-size-md);
  line-height: 1.55;
  color: var(--color-text-dim);
  border-left: 2px solid var(--color-border-strong);
  padding-left: var(--space-3);
  margin: 0;
  max-width: 46em;
}

.studio-form {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  padding: var(--space-6);
  display: grid;
  gap: var(--space-5);
  max-width: 40em;
}

.studio-field { display: grid; gap: var(--space-2); }

.studio-field-label {
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-dim);
}

.studio-hint {
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  line-height: 1.5;
  color: var(--color-text-faint);
  margin: 0;
}

.studio-input,
.studio-textarea {
  font-family: var(--font-ui);
  font-size: var(--font-size-md);
  color: var(--color-text);
  background: var(--color-page-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: 11px 12px;
  min-height: 44px;
  width: 100%;
  box-sizing: border-box;
}

.studio-textarea { min-height: 120px; line-height: 1.55; resize: vertical; }

.studio-input:focus-visible,
.studio-textarea:focus-visible,
.quiet-select:focus-visible,
.inline-edit:focus-visible,
.inline-editor:focus-visible,
.studio-check:focus-visible,
.studio-tab:focus-visible,
.studio-chip:focus-visible,
.studio-tool:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.studio-checks {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}

.studio-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  font-family: var(--font-ui);
  font-size: var(--font-size-md);
  color: var(--color-text);
  cursor: pointer;
}

.studio-check input { width: 17px; height: 17px; accent-color: var(--color-accent); }

/* ── Works as cards that look like the thing ── */

.studio-works { display: grid; gap: var(--space-5); }

.studio-work {
  position: relative;
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: var(--space-5);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--work-hue, var(--color-border-strong));
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  padding: var(--space-5);
}

.studio-work-cover {
  position: relative;
  width: 108px;
  border-radius: var(--radius-md);
  overflow: hidden;
  align-self: start;
}

.studio-work-cover img {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
}

/* The cover is its own change control. */
.studio-cover-hint {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: 6px 8px;
  font-family: var(--font-ui);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  text-align: center;
  color: var(--color-accent-ink);
  background: color-mix(in srgb, var(--color-text) 72%, transparent);
  opacity: 0;
  transition: opacity var(--motion-fast) var(--motion-easing);
}

.studio-work-cover:hover .studio-cover-hint,
.studio-work-cover:focus-within .studio-cover-hint { opacity: 1; }

.studio-file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.studio-work-body { min-width: 0; display: grid; gap: var(--space-3); }

.studio-work-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 28px;
  line-height: 1.1;
  margin: 0;
  color: var(--color-text);
}

.studio-work-summary {
  font-family: var(--font-reader);
  font-size: 16px;
  line-height: 1.6;
  margin: 0;
  color: var(--color-text-dim);
}

.studio-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--space-4);
}

.studio-status-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  font-family: var(--font-ui);
  font-size: var(--font-size-md);
  color: var(--color-text-dim);
}

.studio-status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--color-text-faint);
  flex: 0 0 auto;
}
.studio-status-line[data-status="live"] .studio-status-dot { background: var(--color-ok); }
.studio-status-line[data-status="pending"] .studio-status-dot { background: var(--color-warn); }
.studio-status-line[data-status="hidden"] .studio-status-dot { background: var(--color-danger); }

/* ── Save status ── */

.studio-save-status {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--color-text-dim);
  min-height: 1.2em;
  margin-left: auto;
}

/* ── Edit in place ── */

.inline-edit {
  display: inline-block;
  border-radius: var(--radius-sm);
  padding: 1px 4px;
  margin: -1px -4px;
  cursor: text;
  transition: background var(--motion-fast) var(--motion-easing);
}

.inline-edit:hover,
.inline-edit:focus-visible {
  background: color-mix(in srgb, var(--color-accent) 10%, transparent);
}

.inline-edit--empty { color: var(--color-text-faint); font-style: italic; }

.inline-editor {
  font: inherit;
  color: var(--color-text);
  background: var(--color-page-bg);
  border: 1px solid color-mix(in srgb, var(--color-accent) 45%, var(--color-border-strong));
  border-radius: var(--radius-sm);
  padding: 1px 4px;
  width: 100%;
  box-sizing: border-box;
}

textarea.inline-editor { line-height: 1.55; resize: vertical; }

/* ── Quiet select ── */

.quiet-select-field { display: grid; gap: var(--space-1); min-width: 0; }

.quiet-select {
  font-family: var(--font-ui);
  font-size: var(--font-size-md);
  color: var(--color-text);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--color-border);
  border-radius: 0;
  padding: 10px 2px;
  min-height: 44px;
  width: 100%;
  cursor: pointer;
}

.quiet-select:hover { border-bottom-color: var(--color-accent); }

/* ── Parts list ── */

.studio-parts { list-style: none; margin: 0; padding: 0; display: grid; }

.studio-part-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-2);
  border-top: 1px solid var(--color-border);
  min-height: 44px;
}

.studio-part-row:last-child { border-bottom: 1px solid var(--color-border); }

.studio-part-main { min-width: 0; flex: 1 1 auto; }

.studio-part-title {
  font-family: var(--font-ui);
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--color-text);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-part-meta {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  font-variant-numeric: tabular-nums;
  color: var(--color-text-dim);
}

.studio-row-controls {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  opacity: 0;
  transition: opacity var(--motion-fast) var(--motion-easing);
}

.studio-part-row:hover .studio-row-controls,
.studio-part-row:focus-within .studio-row-controls { opacity: 1; }

/* Touch has no hover to reveal them. */
@media (hover: none) {
  .studio-row-controls { opacity: 1; }
}

.studio-pill-status {
  font-family: var(--font-ui);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--color-text-dim);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 3px 9px;
  white-space: nowrap;
}
.studio-pill-status[data-status="live"] { color: var(--color-ok); border-color: color-mix(in srgb, var(--color-ok) 40%, transparent); }
.studio-pill-status[data-status="scheduled"] { color: var(--color-info); border-color: color-mix(in srgb, var(--color-info) 40%, transparent); }
.studio-pill-status[data-status="hidden"] { color: var(--color-danger); border-color: color-mix(in srgb, var(--color-danger) 40%, transparent); }

/* ── Actions, links, readers, notices ── */

.studio-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.lib-btn--armed { border-color: var(--color-danger); color: var(--color-danger); }

.studio-link-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-top: 1px solid var(--color-border);
  min-height: 44px;
  flex-wrap: wrap;
}

.studio-link-label {
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  color: var(--color-text-dim);
  min-width: 7em;
}

.studio-link-path {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  overflow-wrap: anywhere;
}

.studio-copy-btn { min-height: 32px; }

.studio-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-4);
}

.studio-stat {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  padding: var(--space-4);
}

.studio-stat-value {
  font-family: var(--font-ui);
  font-size: var(--font-size-xl);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
  display: block;
}

.studio-stat-label {
  font-family: var(--font-ui);
  font-size: var(--font-size-xs);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--color-text-dim);
}

.studio-notice {
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-warn);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}

.studio-notice p {
  font-family: var(--font-ui);
  font-size: var(--font-size-md);
  line-height: 1.55;
  margin: 0 0 var(--space-1);
  color: var(--color-text);
}

.studio-notice time {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--color-text-faint);
}

/* ── Flash pulse ── */

@keyframes studio-flash-ok {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-accent) 40%, transparent); }
  40%  { box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-accent) 22%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-accent) 0%, transparent); }
}

.studio-flash-ok {
  animation: studio-flash-ok 950ms var(--motion-easing);
  background: color-mix(in srgb, var(--color-accent) 6%, var(--color-surface));
}

@media (prefers-reduced-motion: reduce) {
  .studio-flash-ok { animation: none; }
  .inline-edit,
  .studio-cover-hint,
  .studio-row-controls { transition: none; }
}

/* ══ Editor ══════════════════════════════════════════════════════════════ */

.studio-editor {
  display: grid;
  gap: var(--space-4);
  max-width: 56em;
  margin-inline: auto;
}

.studio-editor-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.studio-editor-back {
  font-family: var(--font-ui);
  font-size: var(--font-size-md);
  color: var(--color-text-dim);
}

.studio-editor-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 30px;
  line-height: 1.15;
  color: var(--color-text);
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: var(--space-2) 0;
  width: 100%;
  min-height: 44px;
}

.studio-editor-title:hover { border-bottom-color: var(--color-border); }
.studio-editor-title:focus-visible {
  outline: none;
  border-bottom-color: var(--color-accent);
}

/* The toolbar sticks below the reader toolbar, and on a phone it sits above
 * the software keyboard rather than scrolling away under it. */
.studio-toolbar {
  position: sticky;
  top: 56px;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.studio-tool {
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  min-height: 36px;
  padding: 0 10px;
  cursor: pointer;
}

.studio-tool:hover { color: var(--color-text); border-color: var(--color-border); }
.studio-tool[aria-pressed="true"] {
  color: var(--color-accent-ink);
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.studio-toolbar-hint {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--color-text-faint);
  margin-left: auto;
  padding-right: var(--space-1);
}

.studio-paper {
  font-family: var(--font-reader);
  font-size: 18px;
  line-height: 1.75;
  color: var(--color-text);
  background: var(--color-page-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-8) var(--space-6);
  min-height: 460px;
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
}

.studio-paper:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

.studio-paper--verse {
  font-variant-numeric: normal;
  white-space: pre-wrap;
  tab-size: 2;
}

.studio-preview {
  font-family: var(--font-reader);
  font-size: 18px;
  line-height: 1.85;
  color: var(--color-text);
  background: var(--color-page-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-8) var(--space-6);
  min-height: 460px;
}

.studio-editor-foot {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  font-variant-numeric: tabular-nums;
  color: var(--color-text-dim);
}

.studio-schedule-input {
  font-family: var(--font-ui);
  font-size: var(--font-size-md);
  color: var(--color-text);
  background: var(--color-page-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  min-height: 44px;
}

.studio-versions { list-style: none; margin: 0; padding: 0; }

.studio-version-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-top: 1px solid var(--color-border);
  min-height: 44px;
  font-family: var(--font-ui);
  font-size: var(--font-size-md);
  color: var(--color-text-dim);
}

/* ── Focus mode ── */

body.focus-mode .lib-rail,
body.focus-mode .lib-toolbar,
body.focus-mode .lib-tabbar { display: none; }

body.focus-mode .studio-editor { max-width: 56em; margin-inline: auto; }
body.focus-mode .studio-toolbar { top: 0; }

@media (max-width: 700px) {
  .studio-work { grid-template-columns: 1fr; }
  .studio-work-cover { width: 132px; }
  .studio-paper,
  .studio-preview { padding: var(--space-6) var(--space-4); }
  /* Above the keyboard, not under it: dvh tracks the visual viewport. */
  .studio-toolbar { position: sticky; top: 0; }
  .studio-editor { min-height: 100dvh; }
}

/* ── Parts sheet ──
 *
 * Phone-only. On a wide screen the studio card already shows the running
 * order one back-link away; on a phone that is a page load between two
 * chapters, so views/studio-part.js brings the list to the editor through
 * lib/mobile-bottom-sheet.js. Both the trigger and the sheet are display:none
 * above 700px, so a resize cannot leave a sheet stranded over a desktop
 * layout. The module toggles [hidden]; the media query decides the rest. */

.studio-parts-trigger,
.studio-sheet { display: none; }

.studio-sheet {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 9100; /* over .lib-tabbar, which is 9000 in styles.css */
  max-height: 60dvh;
  overflow-y: auto;
  background: var(--color-surface-raised);
  border-top: 1px solid var(--color-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  /* Clear the tab bar, which the sheet sits over rather than beside. */
  padding: var(--space-4) var(--space-4)
    calc(64px + env(safe-area-inset-bottom, 0px) + var(--space-4));
}

.studio-sheet-title {
  font-family: var(--font-ui);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--color-text-dim);
  margin: 0 0 var(--space-2);
}

.studio-sheet-list { list-style: none; margin: 0; padding: 0; display: grid; }

.studio-sheet-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 44px;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
  font-family: var(--font-ui);
  font-size: var(--font-size-md);
  color: var(--color-text);
  text-decoration: none;
}

.studio-sheet-link-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-sheet-link[aria-current="true"] {
  color: var(--color-accent);
  font-weight: 600;
}

@media (max-width: 700px) {
  .studio-parts-trigger { display: inline-flex; align-items: center; }
  .studio-sheet:not([hidden]) { display: block; }
}

/* ══ Published index ═════════════════════════════════════════════════════ */

.published-tabs {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-5);
}

.studio-tab {
  font-family: var(--font-ui);
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--color-text-dim);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  min-height: 44px;
  padding: 0 var(--space-3);
  cursor: pointer;
}

.studio-tab[aria-selected="true"] {
  color: var(--color-text);
  border-bottom-color: var(--color-accent);
}

.published-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  align-items: center;
}

.studio-chip {
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-dim);
  background: transparent;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  min-height: 34px;
  padding: 0 12px;
  cursor: pointer;
}

.studio-chip[aria-pressed="true"] {
  color: var(--color-accent-ink);
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.published-search {
  font-family: var(--font-ui);
  font-size: var(--font-size-md);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  min-height: 44px;
  padding: 0 16px;
  flex: 1 1 240px;
  max-width: 420px;
}

.published-poem {
  display: block;
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--work-hue, var(--color-accent));
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
}

.published-poem-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 26px;
  line-height: 1.15;
  margin: 0 0 var(--space-1);
  color: var(--color-text);
}

.published-poem-byline {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--color-text-dim);
}

/* ══ Writer page ═════════════════════════════════════════════════════════ */

.writer-head {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--space-6);
  margin-bottom: var(--space-6);
  display: flex;
  gap: var(--space-6);
  flex-wrap: wrap;
  align-items: flex-start;
}

.writer-head-text { flex: 1 1 320px; min-width: 0; }

.writer-kicker {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin: 0 0 var(--space-2);
}

.writer-name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: var(--font-size-3xl);
  line-height: 1.05;
  margin: 0 0 var(--space-3);
  color: var(--color-text);
}

.writer-dek {
  font-family: var(--font-reader);
  font-size: 18px;
  line-height: 1.55;
  color: var(--color-text-dim);
  margin: 0 0 var(--space-4);
  max-width: 42em;
}

.writer-byline {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--color-text-faint);
}

.writer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  margin-top: var(--space-4);
}

.writer-series { margin-bottom: var(--space-8); }

/* ══ Mature interstitial ═════════════════════════════════════════════════ */

.mature-interstitial {
  max-width: 34em;
  margin: var(--space-10) auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  padding: var(--space-8) var(--space-6);
}

.mature-interstitial h1 {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: var(--font-size-2xl);
  margin: 0 0 var(--space-3);
  color: var(--color-text);
}

.mature-interstitial p {
  font-family: var(--font-ui);
  font-size: var(--font-size-md);
  line-height: 1.6;
  color: var(--color-text-dim);
  margin: 0 0 var(--space-4);
}

.mature-interstitial .studio-actions { margin-top: var(--space-5); }

/* ══ Preview banner ══════════════════════════════════════════════════════ */

.preview-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-warn);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-6);
  font-family: var(--font-ui);
  font-size: var(--font-size-md);
  color: var(--color-text-dim);
}

.preview-work { max-width: 42em; margin-inline: auto; }

.preview-part { margin-bottom: var(--space-10); }

.preview-part-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: var(--font-size-2xl);
  text-align: center;
  margin: 0 0 var(--space-6);
  color: var(--color-text);
}

/* ══ Review queue ════════════════════════════════════════════════════════ */

.review-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}

.review-item h3 {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: var(--font-size-xl);
  margin: 0 0 var(--space-2);
  color: var(--color-text);
}

.review-declarations {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-2) var(--space-4);
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  color: var(--color-text-dim);
  margin: 0 0 var(--space-4);
}

.review-declarations b { color: var(--color-text); font-weight: 600; }

.review-preview {
  font-family: var(--font-reader);
  font-size: 17px;
  line-height: 1.8;
  color: var(--color-text);
  background: var(--color-page-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  max-height: 46em;
  overflow-y: auto;
  margin-bottom: var(--space-4);
}

/* ══ Reader: a work published in parts ═══════════════════════════════════
 * The reader is the Library's, not a second one. These rules add only what a
 * part needs that a single Gutenberg document does not: a part title under
 * the work title, the author's own reading, the notes that sit outside the
 * text, and the prev/next strip. Everything else — measure, typography,
 * theme — comes from styles.css and the reader-prefs engine.
 */

.reader-part-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: var(--font-size-xl);
  color: var(--color-text);
  margin: var(--space-2) 0 var(--space-3);
}

.reader-part-audio-wrap {
  margin: 0 0 var(--space-5);
}

.reader-part-audio-label {
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  color: var(--color-text-dim);
  margin: 0 0 var(--space-2);
}

.reader-part-audio {
  width: 100%;
  max-width: 34em;
}

/* A note is the author talking about the work; the work is the work. The
 * rule and the smaller UI face are the whole of the distinction, and they
 * have to hold in both themes, so both come from tokens. */
.part-note {
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  line-height: 1.65;
  color: var(--color-text-dim);
  max-width: 34em;
  margin-inline: auto;
  padding: var(--space-3) 0;
}

.part-note p { margin: 0; }
.part-note--before { border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-5); }
.part-note--after { border-top: 1px solid var(--color-border); margin-top: var(--space-5); }

/* ══ Part navigation ═════════════════════════════════════════════════════ */

.chapter-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  max-width: 34em;
  margin: var(--space-8) auto var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.chapter-nav-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 44px;
  justify-content: center;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--color-text);
  max-width: 45%;
  transition: border-color var(--motion-fast) var(--motion-easing);
}

.chapter-nav-link:hover,
.chapter-nav-link:focus-visible { border-color: var(--color-border-strong); }
.chapter-nav-link--next { text-align: right; margin-left: auto; }

.chapter-nav-dir {
  font-family: var(--font-ui);
  font-size: var(--font-size-xs);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--color-text-faint);
}

.chapter-nav-title {
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-nav-count {
  font-family: var(--font-ui);
  font-size: var(--font-size-xs);
  color: var(--color-text-faint);
  order: 0;
}

/* The parts list doubles as the reader's Contents panel; mark where you are.
 * .toc-item itself is styled in styles.css — this only adds the current
 * part, which a single-document book has no equivalent of. */
.toc-item--active {
  font-weight: 600;
  color: var(--color-text);
}

@media (max-width: 700px) {
  .chapter-nav { margin-top: var(--space-6); }
  .chapter-nav-link { max-width: 100%; flex: 1 1 100%; }
  .chapter-nav-link--next { text-align: left; margin-left: 0; }
  .chapter-nav-count { order: 3; width: 100%; text-align: center; }
}

/* ══ Writer page shell ═══════════════════════════════════════════════════ */

.writer-page { padding-bottom: var(--space-10); }
