#parent-preview {
  position: fixed;
  z-index: 90;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 600px);
  background: #fff8e9;
  color: #513f2f;
  box-shadow: 0 2px 10px #37220d20;
  font-size: 13px;
  line-height: 1.5;
  padding: calc(6px + env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px)) 6px
    max(10px, env(safe-area-inset-left, 0px));
  max-height: 70dvh;
  overflow: auto;
  box-sizing: border-box;
}
#parent-preview .preview-strip {
  display: flex;
  align-items: center;
  gap: 6px;
}
#parent-preview strong {
  flex: 1;
  white-space: nowrap;
}
#parent-preview button {
  border: 1px solid #d8c5a2;
  border-radius: 10px;
  background: #fffdf7;
  color: #513f2f;
  min-height: 32px;
  padding: 5px 9px;
  font: inherit;
  cursor: pointer;
}
#parent-preview summary {
  cursor: pointer;
  margin-top: 4px;
}
#parent-preview .preview-settings {
  padding: 6px 0 12px;
}
#parent-preview label {
  display: block;
  margin: 10px 0;
}
#parent-preview select,
#parent-preview input {
  font: inherit;
  font-size: 16px;
  display: block;
  width: 100%;
  padding: 8px;
  border: 1px solid #d8c5a2;
  border-radius: 8px;
  box-sizing: border-box;
  background: white;
  color: #513f2f;
}
#parent-preview .preview-buttons {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
#parent-preview p {
  margin: 8px 0;
}
#parent-preview .preview-issue {
  display: block;
  text-align: left;
  width: 100%;
  margin: 5px 0;
}
#parent-preview [role='status']:empty {
  display: none;
}
#parent-preview [role='status'] {
  color: #8f3b21;
  font-weight: 600;
}
body.has-parent-preview .app {
  padding-top: calc(74px + env(safe-area-inset-top, 0px));
}
#parent-preview.is-collapsed {
  left: auto;
  right: max(8px, env(safe-area-inset-right, 0px));
  top: calc(6px + env(safe-area-inset-top, 0px));
  transform: none;
  width: auto;
  padding: 0;
  border-radius: 12px;
}
#parent-preview.is-collapsed strong,
#parent-preview.is-collapsed details,
#parent-preview.is-collapsed [data-preview-action='return'] {
  display: none;
}
.parent-preview-dialog {
  max-width: calc(100vw - 40px);
  width: 350px;
  border: 0;
  border-radius: 18px;
  padding: 24px;
  color: #513f2f;
}
.parent-preview-dialog::backdrop {
  background: #231708aa;
}
.parent-preview-dialog input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  margin: 10px 0;
  font-size: 16px;
}
.parent-preview-dialog button,
.preview-start-error button {
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
}
.parent-preview-dialog a,
.preview-start-error a {
  display: block;
  margin-top: 16px;
}
.preview-start-error {
  padding: 30px;
  max-width: 480px;
  margin: auto;
}

/* OPS19 editing in the parent interface. */
#studio-bar {
  position: fixed;
  z-index: 95;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 600px);
  box-sizing: border-box;
  /* The page uses viewport-fit=cover; keep controls below the island/status bar.
     studio-edit's ResizeObserver includes this inset in the content offset. */
  padding: calc(6px + env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px)) 4px
    max(10px, env(safe-area-inset-left, 0px));
  background: #2f5d50;
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 2px 10px #0003;
}
#studio-bar .studio-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
}
#studio-bar strong,
#studio-bar .studio-current {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#studio-bar .studio-current em {
  font-style: normal;
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 8px;
  background: #ffffff26;
}
#studio-bar button {
  flex: none;
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid #ffffff66;
  border-radius: 10px;
  background: transparent;
  color: #fff;
  font-size: 13px;
}
#studio-bar button.studio-main {
  background: #f3b33d;
  border-color: #f3b33d;
  color: #3a2a12;
  font-weight: 700;
}
#studio-bar .studio-message {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.92;
}
#studio-bar .studio-message.is-alert {
  color: #ffd9a0;
  font-weight: 700;
}
body.studio-on .app {
  /* Follows the real bar height (it grows with the step guide), set by studio-edit.mjs. */
  padding-top: var(--studio-bar-h, 112px);
}
.edit-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  margin: 10px 0;
  padding: 10px 14px;
  box-sizing: border-box;
  border: 2px dashed #3f8a73;
  border-radius: 14px;
  background: #f1faf6;
  color: #23493e;
  font: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}
.edit-slot > b {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #3f8a73;
  color: #fff;
  font-size: 18px;
}
.edit-slot > span {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.edit-slot small {
  display: block;
  color: #4d6f64;
  font-size: 12px;
}
.edit-slot.is-filled {
  border-style: solid;
  border-color: #b8d8cc;
  background: #fff;
}
.edit-slot.is-filled > b {
  background: #9cc9b8;
}
.edit-slot-inline {
  margin: 0;
  min-height: 40px;
}
.edit-slot-half {
  margin: 4px 0;
}
.studio-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
}
.studio-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 8px;
  background: #fff3d6;
  color: #8a5a12;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.studio-badge[data-status='已上架'] {
  background: #e3f3ec;
  color: #2f6b56;
}
.studio-panel {
  margin: 12px 0;
  padding: 12px;
  border: 2px solid #b8d8cc;
  border-radius: 16px;
  background: #f8fcfa;
}
.studio-panel h3 {
  margin: 0 0 4px;
  font-size: 16px;
  color: #23493e;
}
.studio-panel h3 small,
.studio-panel h4 small {
  font-weight: 400;
  color: #5a7a70;
  font-size: 12px;
}
.studio-panel h4 {
  margin: 14px 0 4px;
  font-size: 14px;
  color: #23493e;
}
.studio-frames {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}
.studio-frame {
  display: grid;
  gap: 4px;
  padding: 4px;
  border: 2px dashed #3f8a73;
  border-radius: 10px;
  background: #fff;
  color: #23493e;
  font: inherit;
  cursor: pointer;
}
.studio-frame.is-filled {
  border-style: solid;
  border-color: #b8d8cc;
}
.studio-frame img,
.studio-frame b {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: #f1faf6;
  font-size: 22px;
}
.studio-frame small {
  font-size: 12px;
}
.studio-qa {
  margin: 8px 0;
  padding: 8px;
  border-radius: 12px;
  background: #fff;
}
.studio-qa-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: #23493e;
}
.studio-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.studio-hint {
  margin: 4px 0;
  font-size: 13px;
  color: #4d6f64;
}
.studio-dialog {
  width: min(560px, 94vw);
  max-height: 88dvh;
  border: 0;
  border-radius: 18px;
  padding: 18px;
  box-sizing: border-box;
  color: #2b2a26;
}
.studio-dialog h2 {
  margin: 0 0 8px;
  font-size: 19px;
}
.studio-where {
  margin: 0 0 10px;
  color: #4d6f64;
  font-size: 13px;
}
.studio-field {
  display: grid;
  gap: 4px;
  margin: 10px 0;
  font-size: 14px;
}
.studio-field input,
.studio-field textarea,
.studio-field select {
  font: inherit;
  font-size: 16px;
  padding: 10px;
  border: 1px solid #c9d8d2;
  border-radius: 10px;
}
.studio-field small {
  color: #5a7a70;
  font-size: 12px;
}
.studio-choices {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}
.studio-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
.studio-dialog button.studio-main,
.studio-dialog button.studio-alt {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 12px;
  font: inherit;
  font-size: 15px;
}
.studio-dialog button.studio-main {
  border: 0;
  background: #2f5d50;
  color: #fff;
}
.studio-dialog button.studio-alt {
  border: 1px solid #c9d8d2;
  background: #fff;
  color: #23493e;
}
.studio-order-trigger {
  margin: 0 0 8px;
  min-height: 44px;
}
.studio-order-fields {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.studio-order-list {
  list-style: none;
  max-height: 55dvh;
  overflow: auto;
  padding: 0 2px;
  margin: 0;
}
.studio-order-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  border-bottom: 1px solid #dce5e1;
}
.studio-order-number {
  color: #4d6f64;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.studio-order-list strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}
.studio-order-buttons {
  display: flex;
  gap: 4px;
}
.studio-order-buttons :is(button, select) {
  min-width: 44px;
  min-height: 44px;
  padding: 0 6px;
  border: 1px solid #c9d8d2;
  border-radius: 8px;
  background: #fff;
  color: #23493e;
  font: inherit;
  font-size: 14px;
}
.studio-order-buttons select {
  font-size: 16px;
}
.studio-order-fields :disabled {
  opacity: 0.45;
}
.studio-order-message {
  margin: 8px 0 0;
  color: #a2382d;
  font-size: 14px;
}
.studio-order-message:empty {
  display: none;
}
.studio-preview,
.studio-thumb {
  max-width: 100%;
  max-height: 220px;
  border-radius: 10px;
}
.studio-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
}
.studio-empty {
  color: #8a8a80;
}
.studio-sentence {
  margin: 10px 0;
  border: 1px solid #c9d8d2;
  border-radius: 12px;
}
.studio-issues {
  padding-left: 20px;
  line-height: 1.8;
}

.studio-field select[data-daily-set] {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

/* Image crop dialog (ops-images.mjs), used in the workbench and in in-place editing. */
.ops-image-dialog {
  width: min(92vw, 380px);
  max-height: 92dvh;
  padding: 18px 18px 14px;
  border: 0;
  border-radius: 20px;
  background: #fffaf3;
  box-shadow: 0 20px 60px #00000033;
  overflow: auto;
}
.ops-image-dialog::backdrop {
  background: #2a1f1499;
}
.ops-image-dialog h2 {
  margin: 0 0 4px;
  font-size: 18px;
}
.ops-image-dialog p {
  margin: 0 0 12px;
  font-size: 13px;
  color: #8a6f5a;
}
.ops-image-dialog canvas {
  display: block;
  width: 100%;
  max-width: 300px;
  height: auto;
  aspect-ratio: 1;
  margin: 0 auto 12px;
  border-radius: 12px;
  outline: 2px solid #e3cdb0;
}
.ops-image-dialog .editor-field {
  display: grid;
  gap: 4px;
  margin: 0 0 10px;
  font-size: 13px;
}
.ops-image-dialog input[type='range'] {
  width: 100%;
}
.ops-image-dialog button {
  min-height: 44px;
  border-radius: 12px;
  font-size: 15px;
}
.ops-image-dialog [data-cancel] {
  width: 100%;
  margin: 4px 0 8px;
  border: 1px solid #e3cdb0;
  background: #fff;
  color: #6b4a2a;
}
.ops-image-dialog [data-use-image] {
  width: 100%;
}

/* UXP09: edit chips on pictures and titles ("看到哪里，就点哪里改"). */
body.studio-on .book .cover,
body.studio-on .primary-book,
body.studio-on .album-hero,
body.studio-on .reader-page,
body.studio-on .episode-art {
  position: relative;
}
.episode-art {
  flex: none;
  display: inline-flex;
}
.edit-chip {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  padding: 4px 9px;
  border-radius: 999px;
  background: #1f5d4dee;
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 2px 6px #0003;
}
.album-hero > .edit-chip {
  top: 4px;
  left: 4px;
  right: auto;
}
h1 .edit-chip,
h2 .edit-chip {
  position: static;
  display: inline-block;
  margin-left: 8px;
  vertical-align: middle;
}
.episode-art .edit-chip {
  top: auto;
  bottom: -6px;
  right: -8px;
  padding: 2px 6px;
  font-size: 12px;
}
.studio-badge.sample,
.studio-sample {
  background: #fde7c4;
  color: #8a4b0f;
}
.edit-slot-danger {
  border-color: #e7b3a8 !important;
  color: #a33a22 !important;
}
/* "看看家长效果": hide every editing aid until the teacher goes back to editing. */
body.studio-peek #view .edit-slot,
body.studio-peek #view .edit-chip,
body.studio-peek #view .studio-panel,
body.studio-peek #view .studio-strip,
body.studio-peek #view .studio-hint,
body.studio-peek #view .studio-badge {
  display: none !important;
}
/* Shorter bar: current item, more menu, three actions, step guide. */
#studio-bar .studio-current {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#studio-bar .studio-current em {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 8px;
  background: #ffffff26;
  font-style: normal;
  font-size: 12px;
}
#studio-bar .studio-more {
  position: relative;
}
#studio-bar .studio-more summary {
  list-style: none;
  cursor: pointer;
  padding: 6px 10px;
  border: 1px solid #ffffff66;
  border-radius: 10px;
  font-size: 13px;
}
#studio-bar .studio-more summary::-webkit-details-marker {
  display: none;
}
#studio-bar .studio-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  display: grid;
  gap: 6px;
  min-width: 200px;
  padding: 10px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 30px #0004;
}
#studio-bar .studio-menu button {
  text-align: left;
  color: #1f3d34;
  background: #f3f7f5;
  border: 0;
}
#studio-bar .studio-buttons {
  gap: 8px;
}
#studio-bar .studio-buttons button {
  flex: 1;
}
.studio-steps {
  display: flex;
  gap: 6px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
}
.studio-steps li {
  flex: none;
}
.studio-steps button {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px dashed #ffffff99;
  background: none;
  color: #fff;
  font-size: 12px;
}
.studio-steps button.done {
  border-style: solid;
  background: #ffffff2e;
}

/* Whole-story actions stay beside the story, distinct from page editing. */
.studio-story-card > .episode-tile,
.studio-story-card > .reading-book-row {
  width: 100%;
}
.studio-delete-story,
.studio-restore-publish {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid #ead6d1;
  border-radius: 10px;
  background: #fff7f4;
  color: #993e32;
  font-size: 13px;
  margin: 6px 0 12px;
}
.studio-restore-publish {
  border-color: #c6dfd1;
  background: #f3faf5;
  color: #28664b;
  margin-right: 8px;
}
.studio-on .episode-list .studio-story-card {
  border-bottom: 1px solid #e9e5da;
  padding-bottom: 4px;
}
.studio-deleted-stories {
  margin: 20px 0;
  padding: 14px;
  border-radius: 12px;
  background: #f4f2ec;
}
.studio-deleted-stories summary {
  cursor: pointer;
  min-height: 32px;
  font-size: 14px;
  color: #6e7168;
}
.studio-deleted-stories > div {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.studio-deleted-stories > div span {
  flex: 1;
  overflow-wrap: anywhere;
}
.studio-deleted-stories button {
  flex-shrink: 0;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid #d5dcd5;
  border-radius: 8px;
  background: white;
}

.studio-on .studio-story-card {
  display: block;
}
.studio-batch-plan p {
  margin: 8px 0;
  font-size: 14px;
}
.studio-batch-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 34dvh;
  overflow: auto;
  border: 1px solid #dfe8e4;
  border-radius: 10px;
}
.studio-batch-list li {
  display: grid;
  grid-template-columns: 4.5em minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  padding: 8px 10px;
  font-size: 13px;
  border-top: 1px solid #eef3f1;
}
.studio-batch-list li:first-child {
  border-top: 0;
}
.studio-batch-list li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.studio-batch-list li.is-done b::after {
  content: ' ✓';
  color: #2f5d50;
}
.studio-batch-list .is-missing {
  color: #8a6d3b;
}
.studio-batch-error {
  color: #a8472b;
  font-size: 13px;
}
