/* Editor · Story tab (created pages): storyboard panels, dialogue lines, drafts. */
.st-actions {
  flex-wrap: wrap;
}
.st-panels,
.st-lines,
.st-drafts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.st-panel {
  display: grid;
  gap: 6px;
  padding: 8px 10px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.st-panel:focus-within {
  border-color: var(--accent-2);
}
.st-panel-head {
  display: flex;
  align-items: center;
  gap: 6px;
}
.st-lines {
  gap: 4px;
}
/* Type · speaker · delete on one row, the line itself full width below: the inspector is
   only ~340–380 px wide, so the text never shares a row. */
.st-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "kind speaker del"
    "text text text";
  align-items: center;
  gap: 4px;
  padding-bottom: 4px;
}
.st-line + .st-line {
  padding-top: 4px;
  border-top: 1px dashed var(--line);
}
.st-line .st-kind {
  grid-area: kind;
}
.st-line .st-speaker {
  grid-area: speaker;
}
.st-line .st-del {
  grid-area: del;
}
.st-line .st-text {
  grid-area: text;
}
.st-line input {
  padding: 5px 8px;
  font-size: 12.5px;
}
.st-add-line {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}
.st-field {
  display: grid;
  gap: 4px;
}
.st-field > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
.st-drafts li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 12.5px;
}
.st-drafts li.current {
  border-color: var(--accent-2-line);
  background: var(--accent-2-soft);
}
.st-drafts img {
  width: 48px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--stage);
  flex: none;
}
.st-drafts li > div {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.st-drafts strong {
  font-weight: 600;
}
.st-drafts small {
  color: var(--text-3);
}
.st-field .hint {
  font-weight: 400;
}
.st-field > span {
  font-size: 12.5px;
}

/* Action bar at the top of the Story tab */
.st-bar {
  display: grid;
  gap: 8px;
}
.st-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.st-actions .seed-wrap {
  margin-left: auto;
}
.st-dirty {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.st-dirty[hidden] {
  display: none;
}

/* Views that don't apply yet (page not drawn) */
.view-tabs label.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.view-tabs label.disabled > span {
  pointer-events: none;
}

/* Canvas overlay for a created page that has not been drawn */
.undrawn {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: color-mix(in srgb, var(--stage) 82%, transparent);
  z-index: 3;
}
.undrawn[hidden] {
  display: none;
}
.undrawn-card {
  display: grid;
  justify-items: center;
  gap: 8px;
  max-width: 340px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: pop-in var(--t-slow) var(--ease-out);
}
/* Only the card's own icon: an accent icon inside the accent button would vanish. */
.undrawn-card > .icon {
  color: var(--accent);
}
.undrawn-card strong {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.undrawn-card p {
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
}

/* Save state with a Retry action */
.save-state .link-btn {
  font-size: 12px;
}

/* ───────────── Editor UX pass: toolbar, loading, linkage, story, mobile ───────────── */

/* Toolbar: grouped controls */
.eb-pager {
  display: flex;
  align-items: center;
  gap: 2px;
}
.eb-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.eb-group .icon-btn,
.eb-group .zoom-label {
  border-radius: var(--radius-sm);
}
.eb-right {
  gap: 8px;
}
.ed-help-btn {
  font-weight: 700;
  font-size: 15px;
  line-height: 1;
}
.icon-btn[aria-pressed="true"] {
  color: var(--accent-2);
  background: var(--accent-2-soft);
}

/* Skeleton while the page image loads */
.surface.loading::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--surface) 70%, transparent) 50%, transparent 70%) 0 0 / 220% 100% no-repeat,
    color-mix(in srgb, var(--stage) 55%, #fff);
  animation: ed-shimmer 1.2s linear infinite;
}
@keyframes ed-shimmer {
  from {
    background-position: 220% 0, 0 0, 0 0;
  }
  to {
    background-position: -220% 0, 0 0, 0 0;
  }
}

/* Box ↔ card linkage */
.tbox.linked {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  z-index: 2;
}
.block-card {
  border-left-width: 4px;
  scroll-margin: 12px;
}
.block-card[data-kind="speech"],
.block-card[data-kind="thought"] {
  border-left-color: var(--accent-line);
}
.block-card[data-kind="narration"] {
  border-left-color: var(--accent-2);
}
.block-card[data-kind="sfx"],
.block-card[data-kind="sign"] {
  border-left-color: var(--line-strong);
}
.block-card.linked:not(.selected) {
  border-color: var(--accent-2-line);
  border-left-color: var(--accent-2);
  box-shadow: 0 0 0 3px var(--accent-2-soft);
}
.block-card.selected {
  border-left-color: var(--accent);
}
.tab-head {
  align-items: center;
}
.ed-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.ed-empty {
  gap: 10px;
}
.ed-empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* Offline / waiting notes and notices */
.ed-offline {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-3);
  background: var(--accent-3-soft);
  line-height: 1.45;
}
.ed-offline .icon {
  flex: none;
  margin-top: 2px;
}
.notice-warn {
  border-color: var(--accent-3-line);
  background: var(--accent-3-soft);
}
.notice-warn > .icon,
.notice-warn strong {
  color: var(--warn);
}
.ed-error-text {
  overflow-wrap: anywhere;
}
.ed-notice-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

/* Story tab: action bar */
.st-bar {
  gap: 10px;
}
.st-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.st-actions .st-more {
  margin-left: auto;
}
.st-seed-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.st-seed-row .seed-wrap {
  margin: 0;
}
.st-seed-row .seed {
  width: 110px;
}
.st-seed-row .hint {
  margin: 0;
  flex: 1 1 160px;
}
.st-pulse {
  box-shadow: 0 0 0 2px var(--accent-soft);
  animation: st-pulse 1.6s ease-in-out infinite;
}
@keyframes st-pulse {
  50% {
    box-shadow: 0 0 0 5px var(--accent-soft);
  }
}
.st-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.st-section-head h3 {
  margin: 0;
}
.insp-section h3 .count {
  margin-left: 2px;
  padding: 0 7px;
  border-radius: var(--radius-sm);
  background: var(--tone);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 18px;
  font-variant-numeric: tabular-nums;
}

/* Story tab: collapsible panel cards */
.st-panel {
  padding: 6px 8px 10px;
  gap: 8px;
}
.st-panel.collapsed {
  padding-bottom: 6px;
}
.st-panel-head {
  display: flex;
  align-items: center;
  gap: 4px;
}
.st-panel-toggle {
  /* Contains its visually-hidden label: an absolutely positioned child with no positioned
     ancestor escapes the inspector's scroll box and stretches the page. */
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.st-panel-toggle:hover {
  background: var(--tone);
}
.st-panel-toggle:focus-visible,
.st-thumb:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.st-chevron {
  flex: none;
  color: var(--text-3);
  transform: rotate(-90deg);
  transition: transform var(--t) var(--ease-out);
}
.st-panel-toggle[aria-expanded="true"] .st-chevron {
  transform: none;
}
.st-panel-title {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 1px;
}
.st-panel-title strong,
.st-panel-title small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.st-panel-title strong {
  font-size: 13px;
  font-weight: 600;
}
.st-panel-title small {
  font-size: 12px;
  color: var(--text-3);
}
.st-line-count {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  background: var(--tone);
  font-size: 11.5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.st-panel-body {
  display: grid;
  gap: 6px;
  padding: 0 2px;
}
.st-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.st-line {
  padding-left: 8px;
  border-left: 3px solid var(--line);
}
.st-line[data-kind="speech"] {
  border-left-color: var(--accent-line);
}
.st-line[data-kind="thought"] {
  border-left-color: color-mix(in srgb, var(--accent) 30%, var(--line));
}
.st-line[data-kind="narration"] {
  border-left-color: var(--accent-2);
}
.st-add-panel {
  width: 100%;
  justify-content: center;
  border: 1px dashed var(--line-strong);
}

/* Story tab: drafts as a thumbnail strip */
.st-strip {
  list-style: none;
  margin: 0;
  padding: 2px 2px 8px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
}
.st-strip li {
  flex: none;
  scroll-snap-align: start;
}
.st-thumb {
  position: relative;
  display: block;
  width: 72px;
  height: 100px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--stage);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease);
}
.st-thumb:hover:not(:disabled) {
  border-color: var(--line-strong);
}
.st-thumb.current {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px var(--accent-2-soft);
  cursor: default;
}
.st-thumb:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.st-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.st-thumb-n,
.st-thumb-tag {
  position: absolute;
  left: 4px;
  padding: 0 5px;
  border-radius: var(--radius-sm);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 17px;
}
.st-thumb-n {
  top: 4px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
}
.st-thumb-tag {
  bottom: 4px;
  background: var(--accent-3);
  color: var(--on-accent-3);
}
.st-draft-meta {
  margin: 0;
}

/* Keyboard shortcuts popover */
.ed-shortcuts {
  position: fixed;
  z-index: 60;
  max-height: min(70vh, 560px);
  overflow-y: auto;
  padding: 12px 14px 14px;
  outline: none;
}
.ed-shortcuts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.ed-shortcuts h4 {
  margin: 10px 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}
.ed-shortcuts dl {
  margin: 0;
  display: grid;
  gap: 4px;
}
.ed-shortcuts dl > div {
  display: grid;
  grid-template-columns: minmax(92px, max-content) 1fr;
  gap: 8px;
  align-items: baseline;
  font-size: 12.5px;
}
.ed-shortcuts dt {
  white-space: nowrap;
}
.ed-shortcuts dd {
  margin: 0;
  color: var(--text-2);
}

/* Narrow screens: canvas stays usable, the inspector stacks below with sticky tabs. */
@media (max-width: 960px) {
  .view-editor .canvas-wrap {
    height: min(58vh, 640px);
  }
  .view-editor .inspector .tabs {
    position: sticky;
    top: var(--topbar-h); /* below the sticky app bar */
    z-index: 5;
    background: var(--bg-elev);
  }
  .view-editor .inspector .tab-body {
    scroll-margin-top: calc(var(--topbar-h) + 48px);
  }
}
@media (max-width: 640px) {
  .view-editor .editor-bar {
    gap: 8px;
    padding: 8px 12px;
  }
  .view-editor .editor-bar .chips-row,
  .view-editor .editor-bar .divider {
    display: none;
  }
  .view-editor .eb-left {
    flex: 1;
    justify-content: space-between;
  }
  .view-editor .eb-right {
    order: 2;
    width: 100%;
    justify-content: space-between;
  }
  .view-editor .view-tabs label > span {
    padding: 2px 6px;
  }
  .view-editor .canvas {
    padding: 10px;
  }
  .st-two {
    grid-template-columns: 1fr;
  }
}
@media (prefers-reduced-motion: reduce) {
  .surface.loading::after,
  .st-pulse {
    animation: none;
  }
  .st-chevron {
    transition: none;
  }
}

/* ═════ Minimal studio pass: editor ═════ */
/* Activity is an icon-only tab at the end of the row. */
.tab.tab-icon {
  margin-left: auto;
  padding-left: 10px;
  padding-right: 10px;
}
/* Folded "more" groups (seed, notes, continuity…). */
.insp-more {
  display: grid;
  gap: 10px;
}
.insp-more > summary {
  cursor: pointer;
  list-style: none;
  width: fit-content;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}
.insp-more > summary::-webkit-details-marker {
  display: none;
}
.insp-more > summary::before {
  content: "+ ";
  font-family: var(--font-mono);
  color: var(--text-3);
}
.insp-more[open] > summary::before {
  content: "− ";
}
.insp-more > summary:hover {
  color: var(--text);
}
.insp-more > summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.insp-more .st-field > span {
  font-size: 12px;
}
/* Text boxes: only the selected card shows its original text, size and bubble info. */
.block-card:not(.selected) .source,
.block-card:not(.selected) .bc-foot {
  display: none;
}
.block-card .translation {
  order: 0;
}
.st-seed-row .hint {
  margin: 0;
}
.insp-more[open] > :not(summary) {
  margin-top: 10px;
}
