/* ============================================================
   AI Storybook Studio - global design system
   A warm, papery, storybook aesthetic with a cinematic night mode.
   ============================================================ */

#native-story {
  /* Brand palette - warm watercolor storybook */
  --cream: #fbf4e6;
  --paper: #f6ecd6;
  --parchment: #efe1c6;
  --ink: #3a2a1e;
  --ink-soft: #5c4636;

  --gold: #dda63a;
  --gold-deep: #bd851f;
  --terracotta: #c96a45;
  --terracotta-deep: #a54e2f;
  --navy: #34507c;
  --navy-deep: #263d61;
  --sage: #8aa06f;
  --coral: #e0876b;

  /* Aliases kept so existing component CSS stays warm */
  --amber: var(--gold);
  --amber-deep: var(--gold-deep);
  --rose: var(--coral);
  --sky: #7cc4e8;
  --leaf: var(--sage);

  --accent: var(--terracotta);
  --accent-2: var(--gold);

  /* Semantic — warm light surfaces */
  --bg: var(--cream);
  --surface: rgba(255, 255, 255, 0.55);
  --surface-2: rgba(255, 255, 255, 0.85);
  --border: rgba(58, 40, 26, 0.14);
  --border-strong: rgba(58, 40, 26, 0.3);
  --text: #3a2a1e;
  --text-dim: #6c5744;
  --text-faint: #9c876f;

  --radius: 18px;
  --radius-sm: 11px;
  --radius-lg: 28px;

  --shadow-sm: 0 2px 8px rgba(90, 60, 30, 0.12);
  --shadow: 0 18px 44px rgba(90, 60, 30, 0.18);
  --shadow-glow: 0 0 60px rgba(221, 166, 58, 0.32);

  --serif: 'Fraunces', 'Georgia', serif;
  --sans: 'Nunito', system-ui, -apple-system, sans-serif;

  --maxw: 1180px;

  color-scheme: light;
}

#native-story * {
  box-sizing: border-box;
}

#native-story,
#native-story {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

#native-story {
  font-family: var(--sans);
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Fixed atmosphere layer — soft watercolor washes like the logo. */

#native-story h1,
#native-story h2,
#native-story h3,
#native-story h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.05;
  margin: 0;
  letter-spacing: -0.01em;
}

#native-story p {
  margin: 0;
}

#native-story a {
  color: inherit;
  text-decoration: none;
}

#native-story button {
  font-family: inherit;
  cursor: pointer;
}

#native-story ::selection {
  background: rgba(181, 123, 255, 0.4);
  color: #fff;
}

/* Reusable app-shell scaffolding ---------------------------------- */

#native-story .container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}
@container native-story (max-width: 560px) {
  #native-story .container {
    padding: 0 16px;
  }
}

#native-story .btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}
#native-story .btn:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}
#native-story .btn:active {
  transform: translateY(0);
}
#native-story .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
#native-story .btn-primary {
  --btn-bg: linear-gradient(135deg, var(--terracotta) 0%, var(--terracotta-deep) 100%);
  --btn-fg: #fff;
  border-color: transparent;
  box-shadow: 0 10px 26px rgba(165, 78, 47, 0.34);
}
#native-story .btn-primary:hover {
  box-shadow: 0 14px 34px rgba(165, 78, 47, 0.46);
}
#native-story .btn-sunlit {
  --btn-bg: linear-gradient(135deg, var(--gold) 0%, var(--gold-deep) 100%);
  --btn-fg: #4a2f0e;
  border-color: transparent;
  box-shadow: 0 10px 26px rgba(189, 133, 31, 0.34);
}
#native-story .btn-ghost {
  --btn-bg: transparent;
}
#native-story .btn-lg {
  padding: 15px 28px;
  font-size: 16px;
}
#native-story .btn-sm {
  padding: 8px 14px;
  font-size: 13px;
}

#native-story .chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

#native-story .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
}

#native-story .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 12px;
  font-weight: 800;
  color: var(--terracotta);
}

/* Form controls -------------------------------------------------- */

#native-story label.field {
  display: block;
  margin-bottom: 16px;
}
#native-story .field-label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  margin-bottom: 7px;
}
#native-story input[type='text'],
#native-story input[type='password'],
#native-story input[type='number'],
#native-story textarea,
#native-story select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#native-story input::placeholder,
#native-story textarea::placeholder {
  color: var(--text-faint);
}
#native-story input:focus,
#native-story textarea:focus,
#native-story select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 106, 69, 0.2);
}
#native-story textarea {
  resize: vertical;
  min-height: 92px;
  line-height: 1.5;
}
/* Custom dropdown (replaces native <select> so the option list matches the theme) */
#native-story .dd {
  position: relative;
  width: 100%;
}
#native-story .dd-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#native-story .dd-btn:hover {
  border-color: var(--border-strong);
}
#native-story .dd-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 106, 69, 0.2);
}
#native-story .dd-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#native-story .dd-arrow {
  flex: none;
  color: var(--text-faint);
}
#native-story .dd-list {
  position: absolute;
  z-index: 90;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #fffaf0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  max-height: 280px;
  overflow-y: auto;
}
#native-story .dd-opt {
  padding: 9px 11px;
  border-radius: 9px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.35;
  cursor: pointer;
}
#native-story .dd-opt.active {
  background: rgba(58, 40, 26, 0.06);
  color: var(--text);
}
#native-story .dd-opt.sel {
  background: rgba(201, 106, 69, 0.16);
  color: var(--terracotta-deep);
  font-weight: 700;
}

#native-story .scroll-lock {
  overflow: hidden;
}

/* Utility ------------------------------------------------------- */
#native-story .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  #native-story * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

#native-story .workspace-page {
  padding-top: 40px;
  padding-bottom: 64px;
}

#native-story .workspace-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
}

#native-story .workspace-heading h1 {
  margin: 8px 0;
  font-size: 38px;
  letter-spacing: 0;
}

#native-story .workspace-heading p {
  color: var(--text-dim);
}

#native-story .workspace-heading-actions,
#native-story .editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#native-story .icon-button {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-dim);
}

#native-story .icon-button:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

#native-story .workspace-alert {
  margin-bottom: 20px;
  padding: 13px 15px;
  border: 1px solid #e1a99e;
  border-radius: 6px;
  background: #fff1ee;
  color: #8d3829;
  font-size: 14px;
  font-weight: 700;
}

#native-story .library-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 300px;
  color: var(--text-dim);
}

#native-story .workspace-spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: native-story-workspace-spin .8s linear infinite;
}

@keyframes native-story-workspace-spin { to { transform: rotate(360deg); } }

#native-story .library-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 420px;
  padding: 40px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

#native-story .library-empty-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 18px;
  border-radius: 50%;
  background: rgba(221, 166, 58, 0.2);
  color: var(--terracotta-deep);
}

#native-story .library-empty h2 { margin-bottom: 8px; font-size: 26px; letter-spacing: 0; }

#native-story .library-empty p { max-width: 440px; margin-bottom: 20px; color: var(--text-dim); line-height: 1.5; }

#native-story .book-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
}

#native-story .book-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
}

#native-story .book-cover {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1.46;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--parchment);
}

#native-story .book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .25s ease;
}

#native-story .book-cover:hover img { transform: scale(1.025); }

#native-story .book-cover-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 100%;
  color: var(--terracotta-deep);
  background: linear-gradient(135deg, rgba(221, 166, 58, 0.24), rgba(201, 106, 69, 0.18));
  font-size: 18px;
  font-weight: 800;
}

#native-story .status-pill {
  position: absolute;
  left: 10px;
  top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(25,34,31,.82);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  backdrop-filter: blur(8px);
}

#native-story .status-pill svg { width: 14px; height: 14px; }

#native-story .status-completed { background: rgba(74, 105, 64, .9); }

#native-story .status-failed { background: rgba(150,58,43,.9); }

#native-story .book-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
}

#native-story .book-meta h2 {
  overflow: hidden;
  margin-bottom: 5px;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#native-story .book-meta p { color: var(--text-faint); font-size: 12px; }

#native-story .book-meta > div { min-width: 0; }

#native-story .book-meta .icon-button { width: 34px; height: 34px; }

#native-story .book-progress { height: 4px; background: rgba(58, 40, 26, 0.1); }

#native-story .book-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--terracotta), var(--gold)); }

#native-story .production-page { max-width: 1260px; }

#native-story .production-header {
  display: grid;
  grid-template-columns: 120px 1fr 40px;
  gap: 20px;
  align-items: start;
  margin-bottom: 28px;
}

#native-story .production-title { text-align: center; }

#native-story .production-title h1 { margin: 7px 0; font-size: 34px; letter-spacing: 0; }

#native-story .production-title p { color: var(--text-dim); }

#native-story .production-progress-row {
  display: grid;
  grid-template-columns: 54px 1fr 130px;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}

#native-story .production-progress-row > strong { font-size: 19px; }

#native-story .production-progress-row > span { color: var(--text-faint); font-size: 12px; text-align: right; }

#native-story .production-progress { height: 8px; overflow: hidden; border-radius: 999px; background: rgba(58, 40, 26, 0.12); }

#native-story .production-progress span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--terracotta), var(--gold)); transition: width .35s ease; }

#native-story .production-layout { display: grid; grid-template-columns: 280px minmax(0,1fr); gap: 24px; }

#native-story .stage-list { margin: 0; padding: 0; list-style: none; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }

#native-story .stage-item { display: flex; gap: 12px; padding: 16px; border-bottom: 1px solid var(--border); }

#native-story .stage-item:last-child { border-bottom: 0; }

#native-story .stage-icon { display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--parchment); color: var(--text-faint); }

#native-story .stage-icon svg { width: 15px; height: 15px; }

#native-story .stage-item div { display: flex; flex-direction: column; gap: 3px; }

#native-story .stage-item strong { font-size: 14px; }

#native-story .stage-item div span { color: var(--text-faint); font-size: 12px; line-height: 1.35; }

#native-story .stage-done .stage-icon { background: rgba(138, 160, 111, 0.25); color: #52683f; }

#native-story .stage-active { background: #fff8f4; }

#native-story .stage-active .stage-icon { background: #f8ddd1; color: var(--accent); animation: native-story-stage-pulse 1.5s ease-in-out infinite; }

#native-story .stage-failed .stage-icon { background: #ffe4de; color: #a64030; }

@keyframes native-story-stage-pulse { 50% { transform: scale(.9); opacity: .65; } }

#native-story .asset-board { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }

#native-story .asset-tile { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }

#native-story .asset-preview { position: relative; display: grid; place-items: center; aspect-ratio: 1.46; overflow: hidden; background: var(--parchment); color: var(--text-faint); }

#native-story .asset-preview img { width: 100%; height: 100%; object-fit: cover; }

#native-story .asset-pulse { position: absolute; width: 42px; height: 42px; border: 2px solid #c5d1ca; border-top-color: var(--accent); border-radius: 50%; animation: native-story-workspace-spin 1s linear infinite; }

#native-story .asset-caption { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 11px 12px; }

#native-story .asset-caption strong { font-size: 13px; }

#native-story .asset-caption span { color: var(--text-faint); font-size: 12px; }

#native-story .asset-ready { border-color: #88aa94; }

#native-story .asset-base { border-color: #ddb08e; }

#native-story .production-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }

#native-story .production-footer > span { color: var(--text-faint); font-family: ui-monospace, monospace; font-size: 12px; }

#native-story .editor-shell { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; background: var(--paper); }

#native-story .editor-toolbar { display: grid; grid-template-columns: 150px 1fr auto; align-items: center; gap: 16px; min-height: 62px; padding: 10px 18px; border-bottom: 1px solid var(--border); background: var(--surface); backdrop-filter: blur(12px); }

#native-story .editor-book-title { min-width: 0; display: flex; flex-direction: column; text-align: center; }

#native-story .editor-book-title strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }

#native-story .editor-book-title span { color: var(--text-faint); font-size: 12px; }

#native-story .editor-workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 132px minmax(0,1fr) 320px; }

#native-story .page-rail { overflow-y: auto; padding: 12px; border-right: 1px solid var(--border); background: var(--surface); }

#native-story .page-rail button { display: block; width: 100%; margin-bottom: 12px; padding: 6px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text-dim); }

#native-story .page-rail button.selected { border-color: var(--accent); background: var(--surface-2); color: var(--text); box-shadow: var(--shadow-sm); }

#native-story .page-rail button > span { display: grid; place-items: center; width: 100%; aspect-ratio: 1.46; overflow: hidden; margin-bottom: 5px; border-radius: 8px; background: var(--parchment); }

#native-story .page-rail img { width: 100%; height: 100%; object-fit: cover; }

#native-story .page-rail strong { font-size: 12px; }

#native-story .page-canvas { min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; overflow: auto; padding: 28px; background: var(--parchment); }

#native-story .page-stage { position: relative; width: min(100%, 920px); aspect-ratio: 1.46; overflow: hidden; border-radius: var(--radius); background: #1b1730; box-shadow: var(--shadow); }

#native-story .page-stage > img,
#native-story .page-stage > video { width: 100%; height: 100%; object-fit: cover; }

#native-story .page-stage::after { content: ''; position: absolute; inset: 45% 0 0; background: linear-gradient(transparent, rgba(10,16,14,.78)); pointer-events: none; }

#native-story .page-stage-empty { display: grid; place-items: center; width: 100%; height: 100%; color: #b2c1b9; }

#native-story .page-copy { position: absolute; z-index: 1; left: 6%; right: 6%; bottom: 6%; color: #fff; text-shadow: 0 2px 14px rgba(0,0,0,.55); }

#native-story .page-copy strong { font-family: var(--serif); font-size: 20px; }

#native-story .page-copy p { max-width: 70ch; margin-top: 7px; font-size: 15px; line-height: 1.45; }

#native-story .page-copy.cover-copy { bottom: 10%; text-align: center; }

#native-story .page-copy h1 { font-size: 42px; letter-spacing: 0; }

#native-story .canvas-label { color: var(--text-dim); font-size: 12px; font-weight: 700; }

#native-story .inspector { overflow-y: auto; padding: 24px 20px; border-left: 1px solid var(--border); background: var(--surface); }

#native-story .inspector-heading { margin-bottom: 22px; }

#native-story .inspector-heading h2 { margin-top: 6px; font-size: 23px; letter-spacing: 0; }

#native-story .inspector textarea { min-height: 100px; }

#native-story .inspector-note { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }

#native-story .inspector-note strong { font-size: 12px; }

#native-story .inspector-note p { margin-top: 7px; color: var(--text-dim); font-size: 12px; line-height: 1.5; }

#native-story .cowork-trace,
#native-story .page-idea-note {
  margin-bottom: 18px;
  padding: 13px;
  border-left: 3px solid var(--gold);
  background: rgba(221, 166, 58, 0.08);
}

#native-story .cowork-trace > strong,
#native-story .page-idea-note > strong {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
}

#native-story .cowork-trace button {
  display: block;
  width: 100%;
  padding: 8px 0;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: left;
}

#native-story .cowork-trace button span,
#native-story .cowork-trace button small { display: block; }

#native-story .cowork-trace button span { font-size: 12px; }

#native-story .cowork-trace button small { margin-top: 3px; color: var(--text-faint); font-size: 12px; }

#native-story .page-idea-note span {
  display: block;
  padding: 5px 0;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
}

@container native-story (max-width: 940px) {
  #native-story .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #native-story .production-layout { grid-template-columns: 1fr; }
  #native-story .stage-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; overflow: hidden; background: var(--border); }
  #native-story .stage-item { border: 0; background: var(--surface-2); }
  #native-story .stage-item div span { display: none; }
  #native-story .editor-workspace { grid-template-columns: 104px minmax(0,1fr) 280px; }
  #native-story .editor-toolbar { grid-template-columns: 110px 1fr auto; }
  #native-story .editor-actions .editor-save-action { display: none; }
}

@container native-story (max-width: 700px) {
  #native-story .workspace-page { padding-top: 24px; }
  #native-story .workspace-heading { align-items: flex-start; flex-direction: column; }
  #native-story .workspace-heading h1 { font-size: 32px; }
  #native-story .workspace-heading-actions { width: 100%; }
  #native-story .workspace-heading-actions .btn { flex: 1; }
  #native-story .book-grid { grid-template-columns: 1fr; }
  #native-story .production-header { grid-template-columns: 1fr 40px; }
  #native-story .production-header > .btn { grid-column: 1 / -1; width: max-content; }
  #native-story .production-title { text-align: left; }
  #native-story .production-title h1 { font-size: 28px; }
  #native-story .production-progress-row { grid-template-columns: 48px 1fr; }
  #native-story .production-progress-row > span { display: none; }
  #native-story .stage-list { grid-template-columns: 1fr 1fr; }
  #native-story .stage-item:last-child:nth-child(odd) { grid-column: 1 / -1; }
  #native-story .asset-board { grid-template-columns: 1fr 1fr; }
  #native-story .production-footer { align-items: flex-start; flex-direction: column; gap: 12px; }
  #native-story .editor-shell { inset: 0; overflow-y: auto; }
  #native-story .editor-toolbar { position: sticky; top: 0; z-index: 3; grid-template-columns: auto 1fr auto; }
  #native-story .editor-book-title span, #native-story .editor-actions .btn:not(.btn-primary):not(.editor-video-action):not(.editor-audio-action), #native-story .editor-actions .btn-primary svg { display: none; }
  #native-story .editor-video-action, #native-story .editor-audio-action { width: 38px; height: 38px; overflow: hidden; padding: 0; }
  #native-story .editor-video-action svg, #native-story .editor-audio-action svg { width: 17px; height: 17px; }
  #native-story .editor-video-action span, #native-story .editor-audio-action span { display: none; }
  #native-story .editor-workspace { display: flex; flex-direction: column; overflow: visible; }
  #native-story .page-rail { display: flex; flex: none; gap: 8px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  #native-story .page-rail button { flex: 0 0 96px; margin: 0; }
  #native-story .page-canvas { flex: none; min-height: 360px; padding: 20px 14px; }
  #native-story .page-copy p { font-size: 12px; }
  #native-story .page-copy h1 { font-size: 30px; }
  #native-story .inspector { flex: none; overflow: visible; border-left: 0; border-top: 1px solid var(--border); }
}

@container native-story (max-width: 420px) {
  #native-story .workspace-heading-actions .icon-button { display: none; }
  #native-story .asset-board { grid-template-columns: 1fr; }
  #native-story .editor-toolbar { padding-inline: 10px; }
  #native-story .editor-toolbar > .btn span { display: none; }
}

#native-story .reader {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: #05030f;
  overflow: hidden;
  user-select: none;
  /* The reader is a dark theater — keep shared tokens light in here. */
  color-scheme: dark;
  --text: #f4eefc;
  --text-dim: #c8bcd6;
  --text-faint: #9a8fac;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-2: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.14);
  --border-strong: rgba(255, 255, 255, 0.24);
}

#native-story .reader-slide {
  position: absolute;
  inset: 0;
}

/* ---------- Cinematic media ---------- */

#native-story .cinema-media {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

#native-story .cinema-layer {
  position: absolute;
  inset: -6%;
  width: 112%;
  height: 112%;
  object-fit: cover;
  will-change: transform;
}

#native-story .cinema-scene {
  inset: 0;
  width: 100%;
  height: 100%;
}

#native-story .cinema-scene svg {
  width: 100%;
  height: 100%;
}

#native-story .cinema-fallback {
  inset: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(1000px 600px at 50% 30%, #2a1c5c, #0b0720);
}

#native-story .cinema-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to top, rgba(3, 2, 12, 0.92) 0%, rgba(3, 2, 12, 0.15) 42%, rgba(3, 2, 12, 0) 62%),
    radial-gradient(120% 100% at 50% 45%, transparent 55%, rgba(3, 2, 12, 0.5) 100%);
}

/* Ken Burns motions */

@keyframes native-story-kb-zi {
  from { transform: scale(1.02); }
  to { transform: scale(1.16); }
}

@keyframes native-story-kb-zo {
  from { transform: scale(1.18); }
  to { transform: scale(1.03); }
}

@keyframes native-story-kb-pl {
  from { transform: scale(1.14) translateX(2.5%); }
  to { transform: scale(1.14) translateX(-2.5%); }
}

@keyframes native-story-kb-pr {
  from { transform: scale(1.14) translateX(-2.5%); }
  to { transform: scale(1.14) translateX(2.5%); }
}

@keyframes native-story-kb-dr {
  0% { transform: scale(1.08) translate(-1.2%, 0.6%); }
  50% { transform: scale(1.14) translate(1.2%, -0.6%); }
  100% { transform: scale(1.08) translate(-1.2%, 0.6%); }
}

#native-story .kb-zoom-in { animation: native-story-kb-zi 20s ease-in-out infinite alternate; }

#native-story .kb-zoom-out { animation: native-story-kb-zo 20s ease-in-out infinite alternate; }

#native-story .kb-pan-left { animation: native-story-kb-pl 24s ease-in-out infinite alternate; }

#native-story .kb-pan-right { animation: native-story-kb-pr 24s ease-in-out infinite alternate; }

#native-story .kb-drift { animation: native-story-kb-dr 26s ease-in-out infinite; }

/* ---------- Cover ---------- */

#native-story .reader-cover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  padding: 0 24px 15vh;
  z-index: 2;
}

#native-story .reader-age {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 14px;
}

#native-story .reader-title {
  font-size: clamp(38px, 8cqw, 92px);
  font-weight: 900;
  color: #fff;
  max-width: 15ch;
  text-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  line-height: 1;
}

#native-story .reader-dedication {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(15px, 2.4cqw, 21px);
  color: #eadfff;
  margin-top: 18px;
  max-width: 34ch;
  opacity: 0.9;
}

#native-story .reader-begin {
  margin-top: 30px;
}

/* ---------- Page text ---------- */

#native-story .reader-textwrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 20px 15vh;
  z-index: 2;
}

#native-story .reader-ideas {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: min(760px, calc(100cqw - 40px));
  margin: 0 auto 8px;
}

#native-story .reader-ideas span {
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 5px;
  background: rgba(15, 18, 17, 0.72);
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  font-weight: 700;
  backdrop-filter: blur(8px);
}

#native-story .reader-textcard {
  max-width: 760px;
  width: 100%;
  text-align: center;
}

#native-story .reader-header {
  font-family: var(--serif);
  font-weight: 600;
  font-style: italic;
  font-size: clamp(16px, 2.6cqw, 24px);
  letter-spacing: 0.02em;
  color: var(--amber);
  margin-bottom: 14px;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.7);
}

#native-story .reader-prose {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(21px, 3.6cqw, 34px);
  line-height: 1.42;
  color: #fdfbff;
  text-shadow: 0 3px 26px rgba(0, 0, 0, 0.75);
}

#native-story .reader-prose .word {
  transition: color 0.15s ease, text-shadow 0.15s ease;
}

#native-story .reader-prose .word.active {
  color: var(--amber);
  text-shadow: 0 0 26px rgba(244, 184, 96, 0.6);
}

/* ---------- End ---------- */

#native-story .reader-end {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 24px;
  z-index: 2;
}

#native-story .reader-end h2 {
  font-size: clamp(40px, 9cqw, 96px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}

#native-story .reader-moral {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(18px, 3cqw, 28px);
  color: #eadfff;
  max-width: 30ch;
  margin-top: 20px;
  line-height: 1.4;
}

#native-story .reader-end-actions {
  display: flex;
  gap: 12px;
  margin-top: 34px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ---------- Chrome ---------- */

#native-story .reader-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
}

#native-story .reader-toptools {
  display: flex;
  gap: 10px;
}

#native-story .reader-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: var(--surface);
  backdrop-filter: blur(10px);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  transition: background 0.2s, border-color 0.2s;
}

#native-story .reader-chip:hover {
  background: var(--surface-2);
}

#native-story .reader-chip.active {
  border-color: var(--amber);
  color: var(--amber);
}

#native-story .reader-chip-label {
  font-size: 13px;
}

#native-story .reader-bottombar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px calc(20px + env(safe-area-inset-bottom));
}

#native-story .reader-nav {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: var(--surface);
  backdrop-filter: blur(10px);
  color: #fff;
  transition: transform 0.15s, background 0.2s;
}

#native-story .reader-nav:hover:not(:disabled) {
  transform: scale(1.07);
  background: var(--surface-2);
}

#native-story .reader-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

#native-story .reader-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#native-story .reader-narrate {
  box-shadow: 0 8px 30px rgba(138, 92, 255, 0.5);
}

#native-story .reader-pagelabel {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
}

#native-story .reader-dots {
  display: flex;
  gap: 8px;
}

#native-story .reader-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.28);
  padding: 0;
  transition: transform 0.2s, background 0.2s;
}

#native-story .reader-dot.on {
  background: var(--amber);
  transform: scale(1.4);
}

/* Video export overlay */

#native-story .video-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(5, 3, 15, 0.9);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#native-story .video-card {
  text-align: center;
  max-width: 460px;
  width: 100%;
}

#native-story .video-card h2 {
  font-size: 26px;
  margin-bottom: 22px;
}

#native-story .video-spinner {
  width: 58px;
  height: 58px;
  margin: 0 auto 24px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--amber);
  animation: native-story-video-spin 0.9s linear infinite;
}

@keyframes native-story-video-spin {
  to {
    transform: rotate(360deg);
  }
}

#native-story .video-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

#native-story .video-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--amber));
}

#native-story .video-stage {
  margin-top: 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

#native-story .video-hint {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
}

@container native-story (max-width: 600px) {
  #native-story .reader-chip-label { display: none; }
  #native-story .reader-dots { display: none; }
  #native-story .reader-textwrap, #native-story .reader-cover { padding-bottom: 18vh; }
}

#native-story{position:relative;flex:1;min-width:0;min-height:0;height:100%;overflow:hidden;isolation:isolate;container-name:native-story;container-type:inline-size;font-family:var(--sans);font-size:14px;color:var(--text);background:var(--bg);color-scheme:dark;
--cream:#0a0a0f;--paper:#0a0a0f;--parchment:#0a0a0f;--ink:#e4e4e7;--ink-soft:#8d8d9a;
--bg:#0a0a0f;--surface:#13131a;--surface-2:#1a1a24;--border:#1e1e2e;--border-strong:#2a2a3a;
--text:#e4e4e7;--text-dim:#8d8d9a;--text-faint:#8d8d9a;--accent:#6366f1;--accent-2:#818cf8;
--terracotta:#6366f1;--terracotta-deep:#4f46e5;--gold:#818cf8;--gold-deep:#6366f1;--amber:#818cf8;--amber-deep:#6366f1;
--shadow-sm:0 2px 8px #00000033;--shadow:0 18px 44px #00000066;--shadow-glow:0 0 60px #6366f133;}

#native-story .reader{--text:#e4e4e7;--text-dim:#8d8d9a;--text-faint:#8d8d9a;--surface:#13131a;--surface-2:#1a1a24;--border:#1e1e2e;--border-strong:#2a2a3a;}

#native-story .btn-primary,#native-story .btn-sunlit{--btn-bg:#6366f1;--btn-fg:#fff;box-shadow:0 10px 26px #6366f133;}

#native-story .btn-primary:hover,#native-story .btn-sunlit:hover{box-shadow:0 14px 34px #6366f144;}

#native-story input:focus,#native-story textarea:focus,#native-story select:focus{box-shadow:0 0 0 3px #6366f133;}

#native-story .workspace-alert{background:#ef444412;border-color:#ef44444d;color:#fca5a5;margin-bottom:0;}

#native-story .native-reader-notice{position:absolute;z-index:60;top:72px;left:20px;right:20px;}
