/* Workshop: the Story map, chapters, undo and page status */

.workshop-view {
  min-height: 100vh;
  background:
    linear-gradient(var(--map-wash), var(--map-wash)),
    radial-gradient(circle at 88% 18%, var(--map-glow), transparent 18rem),
    var(--map-page);
}

.workshop-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  min-height: 78px;
  grid-template-columns: auto minmax(190px, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 12px max(24px, calc((100vw - var(--max-width)) / 2));
  border-bottom: 1px solid var(--map-header-line);
  background: var(--map-header);
  box-shadow: 0 4px 18px rgba(39, 34, 78, 0.05);
  backdrop-filter: blur(14px);
}

.back-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border: 0;
  border-radius: 11px;
  color: var(--ink-soft);
  background: transparent;
  font-weight: 800;
}

.back-button:hover {
  color: var(--ink);
  background: var(--violet-pale);
}

.workshop-book-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.workshop-title-input {
  width: min(100%, 440px);
  min-width: 0;
  padding: 7px 10px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  font-family: var(--font-display);
  font-size: 1.06rem;
  font-weight: 900;
  text-align: center;
  text-overflow: ellipsis;
}

.workshop-title-input:hover,
.workshop-title-input:focus {
  border-color: var(--line);
  background: var(--field);
}

.save-indicator {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.save-indicator[data-status="saving"] {
  color: var(--blue);
}

.save-indicator[data-status="error"] {
  color: var(--save-error-ink);
}

.save-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(39, 132, 99, 0.1);
}

.save-indicator[data-status="saving"] .save-dot {
  animation: save-pulse 900ms ease-in-out infinite;
}

.workshop-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.read-header-button:disabled {
  color: #88859b;
  border-color: var(--disabled-line);
  background: var(--disabled);
  box-shadow: none;
}

/* Shown at 900px and below. */
.workshop-more-button {
  display: none;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--ink-soft);
  background: var(--violet-faint);
}

.workshop-more-button:hover {
  color: var(--ink);
  background: var(--violet-pale);
}

.workshop-shell {
  display: grid;
  width: min(calc(100% - 40px), var(--max-width));
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 26px;
  margin: 0 auto;
  padding: 28px 0 64px;
}

/* The rail hidden: no rail in the markup, the main column takes the whole
   shell, the shell the room the --max-width token gives it (the header
   follows it), and a moment's words are larger, in step with the screen.
   At 780px and narrower the drop-down is the chapters anyway, and the
   780px block puts the words back and drops Show chapters. */
.workshop-view[data-focus="true"] {
  --max-width: 1480px;
}

.workshop-view[data-focus="true"] .workshop-shell {
  grid-template-columns: minmax(0, 1fr);
}

.workshop-view[data-focus="true"] .moment-text {
  font-size: clamp(1.2rem, 0.8rem + 0.55vw, 1.6rem);
}

/* The rail is as tall as the chapter beside it, so its inner box stays
   beside a long one: the box sticks under the header, ends 16px above the
   screen's bottom and scrolls on its own when its chapters are taller
   (renderWorkshop keeps its place). The inline padding gives the tabs'
   shadows and focus rings room inside the scroll. */
.chapter-rail-inner {
  position: sticky;
  top: 105px;
  max-height: calc(100vh - 121px);
  max-height: calc(100dvh - 121px);
  margin-inline: -8px;
  padding: 0 8px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.rail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 11px;
  padding: 0 5px;
}

.rail-heading h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.rail-heading span {
  margin-left: auto;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 800;
}

/* Hide chapters: the rail goes, the moments take its room (data-focus on
   .workshop-view, js/workshop.js). 44px like the tabs' ⋯, drawn into the
   heading's height. */
.rail-focus-button {
  display: grid;
  width: 44px;
  height: 44px;
  margin: -10px -9px -10px 2px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--ink-soft);
  background: transparent;
}

.rail-focus-button .book-icon,
.show-chapters-button .book-icon {
  width: 20px;
  height: 20px;
}

.rail-focus-button:hover {
  color: var(--ink);
  background: var(--violet-pale);
}

.chapter-list {
  display: grid;
  gap: 9px;
  margin-bottom: 11px;
}

/* A tab, and on the selected one its ⋯ over the right edge. */
.chapter-tab-item {
  position: relative;
}

.chapter-tab {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 78px;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 15px;
  color: var(--ink);
  background: var(--tab);
  text-align: left;
}

.chapter-tab:hover {
  border-color: var(--tab-line-hover);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.chapter-tab[aria-current="true"] {
  /* Room for the ⋯, so a long title truncates before it. */
  padding-right: 56px;
  border-color: var(--tab-line-current);
  background: var(--surface);
  box-shadow:
    inset 4px 0 0 var(--violet),
    var(--shadow-sm);
}

.chapter-tab-number {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 10px;
  color: var(--violet-dark);
  background: var(--violet-pale);
  font-size: 0.8rem;
  font-weight: 900;
}

.chapter-tab-copy {
  min-width: 0;
}

.chapter-tab-title {
  display: block;
  overflow: hidden;
  margin-bottom: 2px;
  font-size: 0.87rem;
  font-weight: 900;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-tab-meta {
  display: block;
  color: var(--ink-soft);
  font-size: 0.73rem;
}

.chapter-menu-button {
  position: absolute;
  top: 50%;
  right: 6px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--ink-soft);
  background: transparent;
  transform: translateY(-50%);
}

.chapter-menu-button:hover {
  color: var(--ink);
  background: var(--violet-pale);
}

.add-chapter-button {
  width: 100%;
  min-height: 48px;
  border: 1px dashed var(--add-chapter-line);
  border-radius: 14px;
  color: var(--violet-dark);
  background: var(--add-chapter);
  font-weight: 900;
}

.add-chapter-button:hover:not(:disabled) {
  border-style: solid;
  background: var(--violet-pale);
}

.add-chapter-button:disabled {
  opacity: 0.5;
}

/* Under a disabled add button: why a book takes no more chapters. */
.chapter-limit-note {
  margin: 8px 4px 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.35;
}

/* The chapters as a drop-down, with Add chapter and the chapter's ⋯. It
   takes the rail's place at 780px and narrower, and on a wider screen while
   the rail is hidden (data-focus on .workshop-view, Hide chapters). */
.chapter-picker {
  display: none;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  margin-bottom: 18px;
}

.chapter-picker label {
  display: block;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 900;
}

/* Drawn, not native: WebKit's native select ignores min-height, and a
   font under 16px makes iOS zoom in. */
.chapter-picker select {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 5px;
  padding: 9px 40px 9px 12px;
  overflow: hidden;
  border: 1px solid var(--picker-line);
  border-radius: 12px;
  color: var(--ink);
  background:
    var(--select-chevron) right 14px center / 16px 16px no-repeat,
    var(--field);
  font-size: 1rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
  -webkit-appearance: none;
  appearance: none;
}

.chapter-picker-add {
  align-self: end;
  min-height: 48px;
  padding-inline: 14px;
}

.chapter-picker-add:disabled {
  opacity: 0.5;
}

.chapter-picker .chapter-limit-note {
  grid-column: 1 / -1;
  margin: 0;
}

.chapter-picker-menu {
  align-self: end;
  width: 48px;
  height: 48px;
  padding: 0;
}

.workshop-view[data-focus="true"] .chapter-picker {
  display: grid;
}

/* With the rail hidden the drop-down is in the heading's row (js/workshop.js),
   after Show chapters and before the recipe, so the moments start as high as
   they do beside the rail. */
.workshop-intro .chapter-picker {
  flex: 1 1 24rem;
  min-width: 0;
  margin-bottom: 0;
}

.show-chapters-button {
  flex: none;
}

/* The chapter ⋯ sheet, inside the book sheet (css/reader.css). A long
   chapter title wraps, and the close button keeps its 44px. */
.chapter-sheet .book-sheet-header h2 {
  overflow-wrap: anywhere;
}

.chapter-sheet .book-sheet-close {
  flex: none;
}

.chapter-sheet .book-sheet-row[data-action="delete-chapter"]:not(:disabled) .book-sheet-tile {
  color: var(--delete-ink);
  background: var(--delete-tile);
}

.chapter-delete-confirm {
  padding: 0 8px 4px;
}

.chapter-delete-confirm p {
  margin: 0 0 18px;
  line-height: 1.45;
}

.chapter-delete-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

/* White on this rose is 6.5:1. */
.chapter-sheet .chapter-delete-button {
  color: #fff;
  background: #9c3d58;
}

.chapter-sheet .chapter-delete-button:hover {
  background: #82304a;
}

.deleted-chapters-note {
  margin: 0 8px 10px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.workshop-main {
  min-width: 0;
}

.workshop-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 18px;
}

.workshop-intro h1 {
  margin-bottom: 3px;
  font-size: clamp(2rem, 4vw, 3.15rem);
  line-height: 1;
}

.workshop-intro-copy {
  margin-bottom: 0;
  color: var(--ink-soft);
}

.recipe-summary-button {
  display: flex;
  min-width: 270px;
  min-height: 76px;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--recipe-summary-line);
  border-radius: 17px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.recipe-summary-button:hover {
  border-color: var(--violet);
  transform: translateY(-2px);
}

.recipe-bottle {
  position: relative;
  display: grid;
  width: 45px;
  height: 45px;
  flex: 0 0 45px;
  place-items: center;
  border-radius: 14px;
  color: var(--violet-dark);
  background: var(--violet-pale);
  font-size: 1.05rem;
}

.recipe-summary-copy {
  min-width: 0;
}

.recipe-summary-copy strong,
.recipe-summary-copy small {
  display: block;
}

.recipe-summary-copy strong {
  margin-bottom: 2px;
  font-size: 0.88rem;
}

.recipe-summary-copy small {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-arrow {
  margin-left: auto;
  color: var(--violet);
  font-weight: 900;
}

.chapter-editor {
  position: relative;
  padding: 30px;
  border: 1px solid var(--line-soft);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: var(--shadow-md);
}

.chapter-editor.is-highlighted {
  animation: chapter-arrival 1.25s ease-out;
}

.chapter-editor-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 23px;
}

.chapter-number-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--violet-dark);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.chapter-number-label::before {
  width: 19px;
  height: 2px;
  border-radius: 99px;
  background: var(--violet);
  content: "";
}

.idea-safe-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.idea-safe-note span {
  color: var(--teal);
}

.editor-field {
  display: block;
  margin-bottom: 20px;
}

.editor-field-label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.86rem;
  font-weight: 900;
}

.editor-field-helper {
  display: block;
  margin: -2px 0 8px;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.editor-input,
.editor-textarea {
  display: block;
  width: 100%;
  border: 1px solid var(--editor-line);
  border-radius: 12px;
  color: var(--ink);
  background: var(--field);
  box-shadow: inset 0 1px 2px rgba(39, 34, 78, 0.03);
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    background-color 150ms ease;
}

.editor-input {
  min-height: 49px;
  padding: 11px 13px;
}

.editor-textarea {
  min-height: 88px;
  padding: 12px 13px;
  line-height: 1.5;
  resize: vertical;
}

.editor-input:hover,
.editor-textarea:hover {
  border-color: var(--editor-line-hover);
}

.editor-input:focus,
.editor-textarea:focus {
  border-color: var(--violet);
  background: var(--field);
  box-shadow: 0 0 0 4px var(--focus-glow);
  outline: 0;
}

.chapter-title-input {
  min-height: 58px;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 900;
}

.moment-undo-stack {
  position: fixed;
  z-index: 40;
  top: 98px;
  right: 22px;
  width: min(calc(100% - 32px), 370px);
  display: grid;
  gap: 9px;
}

.delete-undo-toast {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 14px 13px 16px;
  border: 1px solid #c9c1df;
  border-radius: 16px;
  color: #fff;
  background: #302b62;
  box-shadow: 0 16px 38px rgba(29, 25, 67, 0.27);
}

.delete-undo-toast span {
  color: #e8e4ff;
  font-size: 0.8rem;
}

.delete-undo-toast strong {
  display: block;
  color: #fff;
  font-size: 0.88rem;
}

/* The toast is dark in both themes, so its button keeps the light gold. */
.delete-undo-button {
  flex: none;
  min-height: 44px;
  padding: 7px 13px;
  border: 1px solid #f1d483;
  border-radius: 11px;
  color: #4e3500;
  background: #fff2c9;
  font-weight: 900;
}

.delete-undo-button:hover:not(:disabled) {
  background: #ffe59a;
}

.delete-undo-button:disabled {
  opacity: 0.5;
}

/* A chapter's Pages panel: where its pages stand (data-status, colored as
   the page status card, or amber with data-moments while moments need
   writing), the buttons that write it, and its recipe. */
.chapter-pages {
  margin-top: 28px;
  padding: 17px 18px;
  border: 1px solid var(--status-line);
  border-radius: 20px;
  background: var(--status);
}

.chapter-pages[data-status="current"]:not([data-moments]) {
  border-color: var(--status-fresh-line);
  background: var(--status-fresh);
}

.chapter-pages[data-status="story-changed"],
.chapter-pages[data-status="settings-changed"],
.chapter-pages[data-moments] {
  border-color: var(--status-outdated-line);
  background: var(--status-outdated);
}

.chapter-pages[data-status="draft"] {
  border-color: var(--line-soft);
  background: var(--surface);
}

.chapter-pages-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.chapter-pages-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  color: var(--status-icon-ink);
  background: var(--status-icon);
  font-size: 1.05rem;
  font-weight: 900;
}

[data-status="current"]:not([data-moments]) .chapter-pages-icon {
  color: var(--green);
  background: var(--status-fresh-icon);
}

[data-status="story-changed"] .chapter-pages-icon,
[data-status="settings-changed"] .chapter-pages-icon,
[data-moments] .chapter-pages-icon {
  color: var(--status-outdated-icon-ink);
  background: var(--status-outdated-icon);
}

[data-status="draft"] .chapter-pages-icon {
  color: var(--ink-soft);
  background: var(--violet-pale);
}

.chapter-pages-copy h2 {
  margin: 0 0 3px;
  color: var(--violet-dark);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.chapter-pages-copy strong {
  display: block;
  font-size: 0.96rem;
  line-height: 1.3;
}

.chapter-pages-copy p {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-size: 0.81rem;
}

/* The words the chapter's pages hold, beside those of its moments. */
.chapter-pages-copy .chapter-pages-words {
  font-weight: 700;
}

/* Write N moments over the whole-chapter button, one width. */
.chapter-pages-actions {
  display: grid;
  gap: 8px;
}

.chapter-recipe-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.chapter-recipe-copy {
  min-width: 0;
}

.chapter-recipe-copy strong,
.chapter-recipe-copy small {
  display: block;
}

.chapter-recipe-copy strong {
  font-size: 0.84rem;
}

.chapter-recipe-copy small {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-status-wrap {
  position: sticky;
  z-index: 10;
  bottom: 14px;
  margin-top: 18px;
}

.page-status-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 17px 18px;
  border: 1px solid var(--status-line);
  border-radius: 20px;
  background: var(--status);
  box-shadow: 0 13px 35px rgba(39, 46, 91, 0.13);
  backdrop-filter: blur(14px);
}

.page-status-card[data-state="fresh"] {
  border-color: var(--status-fresh-line);
  background: var(--status-fresh);
}

.page-status-card[data-state="outdated"] {
  border-color: var(--status-outdated-line);
  background: var(--status-outdated);
}

.page-status-icon {
  display: grid;
  width: 45px;
  height: 45px;
  place-items: center;
  border-radius: 14px;
  color: var(--status-icon-ink);
  background: var(--status-icon);
  font-size: 1.13rem;
  font-weight: 900;
}

[data-state="fresh"] .page-status-icon {
  color: var(--green);
  background: var(--status-fresh-icon);
}

[data-state="outdated"] .page-status-icon {
  color: var(--status-outdated-icon-ink);
  background: var(--status-outdated-icon);
}

.page-status-copy strong,
.page-status-copy span {
  display: block;
}

.page-status-copy strong {
  margin-bottom: 2px;
  font-size: 0.96rem;
}

.page-status-copy span {
  color: var(--ink-soft);
  font-size: 0.81rem;
}

.page-status-copy .page-status-count {
  margin-top: 3px;
  color: var(--ink);
  font-weight: 800;
}

.page-status-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

/* The book bar in the Story map's colors, not the reader's, shown at 900px
   and below. */
.workshop-view .book-bar {
  display: none;
  border-top-color: var(--map-header-line);
  background: var(--paper);
  box-shadow: 0 -4px 18px rgba(39, 34, 78, 0.05);
}

.workshop-view .book-bar-item {
  color: var(--ink-soft);
}

.workshop-view .book-bar-item:hover:not([aria-current="page"], [aria-disabled="true"]) {
  color: var(--ink);
  background: var(--violet-pale);
}

.workshop-view .book-bar-item[aria-current="page"] {
  color: var(--violet);
}

.workshop-view .book-bar-item[aria-disabled="true"],
.workshop-view .book-bar-item[aria-disabled="true"]:hover {
  color: #9a96a8;
  background: transparent;
  cursor: not-allowed;
}

.workshop-view .book-bar-item:focus-visible {
  outline-color: var(--focus-ring);
}

@media (max-width: 1000px) {
  .workshop-header .account-name {
    display: none;
  }

  .workshop-header .account-compact-label {
    display: inline;
  }

  .workshop-header {
    grid-template-columns: auto minmax(160px, 1fr) auto;
    gap: 9px;
    padding-inline: 17px;
  }

  .save-indicator span:last-child {
    display: none;
  }

  .workshop-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  /* The recipe is full width below, so it wraps to a row of its own. */
  .workshop-intro {
    flex-wrap: wrap;
  }

  .recipe-summary-button {
    width: 100%;
    min-height: 68px;
  }
}

@media (max-width: 900px) {
  /* The book bar stays at the bottom, even under a short chapter. */
  .workshop-view {
    display: flex;
    flex-direction: column;
  }

  .workshop-header-actions [data-action="open-guide"],
  .workshop-header .read-header-button,
  .workshop-header .account-control {
    display: none;
  }

  .workshop-more-button {
    display: inline-grid;
  }

  .workshop-view .book-bar {
    display: grid;
    margin-top: auto;
  }

  /* The rail ends where the page status docks, above the book bar: its
     105px top, then the 71px and the bar's bottom padding below. */
  .chapter-rail-inner {
    max-height: calc(100vh - 176px - max(6px, env(safe-area-inset-bottom)));
    max-height: calc(100dvh - 176px - max(6px, env(safe-area-inset-bottom)));
  }

  /* Docked above the book bar: its 56px items, 6px top padding, 1px border
     and bottom padding, then an 8px gap. */
  .workshop-view .page-status-wrap {
    bottom: calc(71px + max(6px, env(safe-area-inset-bottom)));
  }

  /* The card ends the map instead of covering it: the bar's Read item does
     what its Read my book does, and chapters are written from their Pages
     panel. */
  .workshop-view .page-status-wrap:not(:has(.page-status-card[data-layout="ready"])) {
    position: static;
  }

  /* Docked when only the layout is behind: one row, the label and Update
     layout. */
  .workshop-view .page-status-card[data-layout="ready"] {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
    padding: 6px 6px 6px 16px;
    border-radius: 16px;
    /* Opaque, so the map scrolling under the strip does not show through. */
    background: var(--status-outdated-solid);
  }

  .workshop-view .page-status-card[data-layout="ready"] .page-status-icon,
  .workshop-view .page-status-card[data-layout="ready"] .page-status-copy span,
  .workshop-view .page-status-card[data-layout="ready"] [data-action="read-active"] {
    display: none;
  }

  .workshop-view .page-status-card[data-layout="ready"] .page-status-copy strong {
    margin-bottom: 0;
    line-height: 1.25;
  }

  .workshop-view .page-status-card[data-layout="ready"] .page-status-actions {
    grid-column: auto;
    flex-wrap: nowrap;
  }

  .workshop-view .page-status-card[data-layout="ready"] .page-status-actions .button {
    flex: none;
    padding-inline: 14px;
    white-space: nowrap;
  }

  /* The iOS keyboard would lift the bar and the strip over the text being
     typed. */
  .workshop-view:has(input:focus, textarea:focus) .book-bar {
    display: none;
  }

  .workshop-view:has(input:focus, textarea:focus) .page-status-card[data-layout="ready"] {
    display: none;
  }
}

@media (max-width: 780px) {
  .workshop-header {
    position: static;
    display: flex;
    flex-wrap: wrap;
    padding: 10px 12px;
  }

  .workshop-header > .back-button {
    order: 1;
  }

  .workshop-header-actions {
    order: 2;
    margin-left: auto;
  }

  .workshop-book-identity {
    order: 3;
    width: 100%;
    padding: 3px 4px 5px;
  }

  .workshop-title-input {
    width: 100%;
    text-align: left;
  }

  .save-indicator span:last-child {
    display: inline;
  }

  .workshop-shell {
    display: block;
    width: min(calc(100% - 24px), var(--max-width));
    padding-top: 17px;
  }

  .chapter-rail {
    display: none;
  }

  .workshop-view[data-focus="true"] .moment-text {
    font-size: 1rem;
  }

  /* Show chapters answers the rail's Hide chapters; the rail is not on
     screen at this width, so neither is the way back. */
  .workshop-intro .show-chapters-button {
    display: none;
  }

  .chapter-picker {
    display: grid;
  }

  /* Stacked, full width, under the thumb. */
  .chapter-delete-actions {
    flex-direction: column;
    align-items: stretch;
  }

  /* The book bar marks the Story map. */
  .workshop-intro .eyebrow {
    display: none;
  }

  .chapter-editor [data-field="chapter-change"] {
    resize: none;
  }

  /* Flat, so the fields and moments use the full content width. */
  .chapter-editor {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
  }

  .idea-safe-note {
    display: none;
  }

  .moment-undo-stack {
    top: 12px;
    right: 12px;
  }

  .page-status-wrap {
    bottom: 8px;
  }

  .page-status-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .page-status-actions {
    grid-column: 1 / -1;
  }

  .page-status-actions .button {
    flex: 1 1 150px;
  }

  /* The buttons under the words, full width. */
  .chapter-pages {
    padding: 15px;
  }

  .chapter-pages-top {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .chapter-pages-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 500px) {
  .chapter-picker {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .chapter-picker-add {
    width: 48px;
    padding: 0;
    font-size: 0;
  }

  .chapter-picker-add::before {
    content: "+";
    font-size: 1.4rem;
  }

  .workshop-intro h1 {
    font-size: 2rem;
  }

  .page-status-card {
    gap: 10px;
    padding: 13px;
  }

  .page-status-icon {
    width: 39px;
    height: 39px;
  }

  .page-status-copy strong {
    font-size: 0.87rem;
  }

  .page-status-copy span {
    font-size: 0.73rem;
  }

  .workshop-view .page-status-card[data-layout="ready"] .page-status-actions .button {
    padding-inline: 12px;
    font-size: 0.9rem;
  }
}

@keyframes save-pulse {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.82);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes chapter-arrival {
  0% {
    box-shadow:
      0 0 0 5px rgba(255, 208, 90, 0.65),
      var(--shadow-md);
  }
  100% {
    box-shadow:
      0 0 0 0 rgba(255, 208, 90, 0),
      var(--shadow-md);
  }
}
