:root {
  --bg-canvas: #faf7f2;
  --bg-surface: #ffffff;
  --bg-subtle: #f4efe6;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-light: #e2dcd0;
  --border-strong: #cbd5e1;
  --brand-primary: #b45309;
  --brand-primary-hover: #92400e;
  --brand-accent: #0f766e;
  --brand-accent-hover: #115e59;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #15803d;
  --success-bg: #f0fdf4;
  --focus-ring: #1d4ed8;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 4px 18px rgba(15, 23, 42, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  max-width: 100vw;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: clip;
  overflow-y: auto;
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  clip-path: inset(50%);
  overflow: hidden;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  white-space: nowrap;
}

/* Top Bar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border-light);
  backdrop-filter: blur(8px);
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 12px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  font-size: 1.35rem;
}

.brand-eyebrow {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand-primary);
}

.brand-title {
  font-size: 1.22rem;
  font-weight: 800;
  color: var(--text-primary);
}

.brand-title-link {
  color: var(--text-primary);
  text-decoration: none;
}

.brand-title-link:hover {
  color: var(--brand-primary);
  text-decoration: underline;
}

.platform-inline-link {
  color: var(--brand-accent);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.platform-inline-link:hover {
  color: var(--brand-primary);
}

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  margin: 0;
  padding: 0.25rem;
  gap: 0.35rem;
  background: var(--bg-subtle);
  border-radius: 999px;
  border: 1px solid var(--border-light);
}

.mode-tab {
  min-height: 44px;
  padding: 0.5rem 1.1rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.mode-tab:hover {
  color: var(--text-primary);
}

.mode-tab.is-active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

/* Main Shell */
.studio-shell {
  display: grid;
  grid-template-columns: 295px minmax(0, 1fr);
  gap: 1.5rem;
  max-width: 1520px;
  margin: 0 auto;
  padding: 1.5rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .studio-shell {
    grid-template-columns: minmax(0, 1fr);
  }
}

.bookshelf-sidebar,
.main-workspace,
.workspace-view,
.hero-strip,
.card {
  min-width: 0;
  max-width: 100%;
}

.bookshelf-sidebar {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  box-shadow: var(--shadow-card);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.sidebar-hint {
  margin: 0.45rem 0 0.9rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.project-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.project-item {
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  background: #fcfaf7;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.project-item.is-selected {
  border-color: var(--brand-primary);
  background: #fffbeb;
}

.project-select-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--text-primary);
}

.project-thumb {
  width: 50px;
  height: 50px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-light);
  background: #fef3c7;
}

.project-thumb svg,
.project-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.project-meta-title {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
}

.project-meta-sub {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* Workspace Hero & Cards */
.main-workspace {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.hero-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.4rem;
  background: linear-gradient(135deg, #fffbeb 0%, #ffffff 65%, #f0fdfa 100%);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
}

.hero-strip h1 {
  margin: 0;
  font-size: 1.45rem;
  color: var(--text-primary);
}

.hero-sub {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.active-book-pill {
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.status-toast {
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  background: var(--success-bg);
  border: 1px solid #86efac;
  color: #14532d;
  font-weight: 600;
}

.status-toast.is-error {
  background: var(--danger-bg);
  border-color: #fca5a5;
  color: #7f1d1d;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  box-shadow: var(--shadow-card);
}

.card h2,
.card h3 {
  margin-top: 0;
  color: var(--text-primary);
}

.section-sub {
  margin: 0.25rem 0 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* Wizard Layout */
.wizard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.95fr);
  gap: 1.35rem;
  align-items: start;
}

@media (max-width: 1120px) {
  .wizard-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.progress-tracker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 0.85rem 0 0.65rem;
}

@media (max-width: 680px) {
  .progress-tracker {
    grid-template-columns: repeat(2, 1fr);
  }
}

.step-item {
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 600;
  text-align: center;
  border: 1px solid transparent;
}

.step-item.is-active {
  background: #fef3c7;
  color: #78350f;
  border-color: #f59e0b;
}

.step-item.is-done {
  background: #ecfdf5;
  color: #065f46;
  border-color: #6ee7b7;
}

.wizard-progress {
  width: 100%;
  height: 10px;
  margin-bottom: 1.25rem;
  accent-color: var(--brand-primary);
}

/* Forms & Gestalt Spacing */
.form-row-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 680px) {
  .form-row-two {
    grid-template-columns: minmax(0, 1fr);
  }
}

.form-group {
  margin-block-end: 1.25rem;
}

.form-group label {
  display: block;
  margin-block-end: 0.35rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.req-star {
  color: var(--danger);
}

.field-hint {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="password"],
input[type="file"],
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 0.68rem 0.85rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-primary);
  background-color: #ffffff;
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
}

@media (pointer: coarse) {
  input[type="text"],
  input[type="email"],
  input[type="url"],
  input[type="number"],
  input[type="password"],
  input[type="file"],
  select,
  .btn {
    min-height: 52px;
  }
}

textarea {
  min-height: 84px;
  resize: vertical;
}

/* Required Field Feedback per Modern Web Guidance (:user-invalid + fallback) */
.error-msg {
  display: none;
  margin-top: 0.35rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--danger);
}

input:user-invalid,
input.user-invalid-fallback {
  border-color: var(--danger);
  background-color: var(--danger-bg);
}

input:user-invalid ~ .error-msg,
input.user-invalid-fallback ~ .error-msg {
  display: block;
}

input:required:user-valid {
  border-color: var(--success);
}

.choice-fieldset {
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin: 0 0 1.25rem;
}

.choice-fieldset legend {
  padding: 0 0.45rem;
  font-weight: 700;
  color: var(--text-primary);
}

.radio-pill-grid,
.checkbox-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.radio-option,
.chip-option {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 48px;
  padding: 0.5rem 0.9rem;
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  background: #ffffff;
}

.radio-option input,
.chip-option input,
.checkbox-inline-group input {
  width: 1.15rem;
  height: 1.15rem;
  min-height: auto;
  accent-color: var(--brand-primary);
}

.radio-option label,
.chip-option label {
  margin: 0;
  font-weight: 600;
  cursor: pointer;
}

.checkbox-inline-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-top: 0.5rem;
}

.checkbox-inline-group label {
  margin: 0;
  cursor: pointer;
}

/* Specialty Template & Format Cards */
.template-card-grid,
.format-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.selectable-card {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.9rem;
  border: 2px solid var(--border-light);
  border-radius: 12px;
  background: #fcfaf7;
  cursor: pointer;
}

.selectable-card:has(input:checked) {
  border-color: var(--brand-primary);
  background: #fffbeb;
}

.selectable-card input {
  width: 1.2rem;
  height: 1.2rem;
  min-height: auto;
  margin-top: 0.2rem;
  accent-color: var(--brand-primary);
  flex-shrink: 0;
}

.card-choice-title {
  display: block;
  font-weight: 700;
  color: var(--text-primary);
}

.card-choice-badge {
  display: inline-block;
  margin: 0.2rem 0;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.74rem;
  font-weight: 700;
}

.card-choice-desc {
  display: block;
  font-size: 0.83rem;
  color: var(--text-secondary);
}

.custom-specialty-box {
  padding: 1rem;
  margin-bottom: 1.25rem;
  border-radius: 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.face-hero-upload-box {
  padding: 1.05rem;
  margin-bottom: 1.25rem;
  border-radius: 14px;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 2px solid #f59e0b;
}

.face-hero-upload-box .form-group {
  margin-block-end: 0.65rem;
}

.preset-switcher-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin: 0.4rem 0 0.65rem;
}

.preset-switcher-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.stage-ai-bar {
  display: flex;
  justify-content: center;
  margin: -0.35rem 0 0.85rem;
}

.proof-summary-banner {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.9rem 1rem;
  margin: 0.85rem 0 1.2rem;
  border-radius: 12px;
  background: #fffbeb;
  border: 1.5px solid #f59e0b;
}

.proof-summary-banner img {
  border-radius: 10px;
  object-fit: cover;
  border: 1.5px solid #d97706;
  flex-shrink: 0;
}

.savings-pill {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: #dcfce7;
  color: #14532d;
  font-size: 0.8rem;
  font-weight: 700;
}

.approval-checkbox-box {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.9rem 1rem;
  margin-bottom: 1.15rem;
  border-radius: 12px;
  background: #f0fdf4;
  border: 1.5px solid #86efac;
}

.approval-checkbox-box input[type="checkbox"] {
  width: 1.35rem;
  height: 1.35rem;
  min-height: auto;
  margin-top: 0.15rem;
  accent-color: #15803d;
  flex-shrink: 0;
}

.approval-checkbox-box label {
  margin: 0;
  font-size: 0.92rem;
  cursor: pointer;
}

.sub-card-heading {
  margin-top: 1.2rem;
  font-size: 1rem;
}

.dropship-steps-list {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.orders-queue {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.order-card {
  padding: 1rem;
  border-radius: 12px;
  background: #fcfaf7;
  border: 1.5px solid var(--border-light);
}

.order-card-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.order-ship-line {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.order-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.uploaded-photo-badge {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.95rem;
  margin-top: 0.55rem;
  padding: 0.8rem 0.95rem;
  border-radius: 14px;
  background: #ffffff;
  border: 2px solid #6ee7b7;
}

.uploaded-photo-badge img {
  border-radius: 50%;
  object-fit: cover;
}

.p2c-pair {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.p2c-avatar-frame {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.p2c-avatar-frame img {
  width: 74px;
  height: 74px;
  border: 2.5px solid #cbd5e1;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.08);
}

.p2c-cartoon-frame img {
  border-color: #f59e0b;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.28);
}

.p2c-avatar-frame figcaption {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-secondary);
  white-space: nowrap;
}

.p2c-cartoon-frame figcaption {
  color: var(--brand-primary);
}

.p2c-arrow {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--brand-primary);
  margin-bottom: 1rem;
}

.detected-features-pill {
  display: inline-block;
  align-self: flex-start;
  padding: 0.18rem 0.6rem;
  margin: 0.2rem 0;
  border-radius: 999px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #78350f;
  font-size: 0.78rem;
  font-weight: 700;
}

.book-mode-highlight {
  background: #f0fdf4;
  border-color: #34d399;
}

.preview-style-toggle,
.editor-style-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.5rem 0 0.75rem;
}

.cartoon-tone-tuner {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px dashed #fbbf24;
}

.skin-swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.skin-swatch-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  min-height: 44px;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1.5px solid var(--border-strong);
  background: #ffffff;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.skin-swatch-btn.is-selected {
  border-color: var(--brand-primary);
  background: #fffbeb;
  box-shadow: 0 0 0 2px rgba(180, 83, 9, 0.18);
}

.swatch-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.25);
  flex-shrink: 0;
}
  background: #fef3c7;
  border: 2px solid #f59e0b;
  flex-shrink: 0;
}

.photo-badge-copy {
  flex: 1;
}

.photo-badge-copy strong {
  display: block;
  font-size: 0.92rem;
  color: var(--text-primary);
}

.photo-badge-copy span {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.scene-preview-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.55rem 0 0.75rem;
}

.scene-pill {
  min-height: 36px;
  padding: 0.3rem 0.68rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.scene-pill.is-selected {
  background: #fef3c7;
  border-color: #d97706;
  color: #78350f;
}

.editor-quick-actions,
.repersonalize-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
  margin-top: 0.75rem;
}

.repersonalize-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.repersonalize-field label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.repersonalize-field input,
.repersonalize-field select {
  width: auto;
  min-width: 155px;
  min-height: 44px;
  padding: 0.45rem 0.7rem;
}

.wizard-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}

/* Live Character Stage */
.character-stage {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 340px;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid var(--border-light);
  background: #fef3c7;
  margin-bottom: 1rem;
}

.character-stage svg,
.character-stage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.spec-readout {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.spec-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  background: var(--bg-subtle);
  font-size: 0.88rem;
}

.spec-row dt {
  color: var(--text-secondary);
  font-weight: 600;
}

.spec-row dd {
  margin: 0;
  color: var(--text-primary);
  font-weight: 700;
  text-align: right;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 48px;
  padding: 0.65rem 1.2rem;
  border-radius: 10px;
  border: 1.5px solid transparent;
  font-size: 0.96rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-sm {
  min-height: 38px;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
}

.btn-lg {
  min-height: 54px;
  padding: 0.85rem 1.5rem;
  font-size: 1.05rem;
}

.btn-primary {
  background: var(--brand-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--brand-primary-hover);
}

.btn-accent {
  background: var(--brand-accent);
  color: #ffffff;
}

.btn-accent:hover {
  background: var(--brand-accent-hover);
}

.btn-secondary {
  background: #ffffff;
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-subtle);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* View 2: TellMyTale-Style Scroll-Snap Carousel & Editor */
.editor-header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.page-strip-nav {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  -webkit-overflow-scrolling: touch;
}

.page-pill-strip {
  display: flex;
  gap: 0.4rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.page-pill-btn {
  min-height: 38px;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.page-pill-btn[aria-current="true"] {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #ffffff;
}

.spread-carousel {
  display: flex;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 1.15rem;
  overflow-x: auto;
  padding: 0.5rem 0.25rem 1.1rem;
  scroll-snap-type: x proximity;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.spread-slide {
  flex: 0 0 min(370px, 84vw);
  scroll-snap-align: start;
  background: #ffffff;
  border: 2px solid var(--border-light);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.spread-slide.is-active-slide {
  border-color: var(--brand-primary);
  box-shadow: 0 8px 24px rgba(180, 83, 9, 0.16);
}

.slide-art-box {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #fef3c7;
  overflow: hidden;
}

.slide-art-box svg,
.slide-art-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.slide-page-badge {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.slide-text-box {
  padding: 1rem 1.1rem;
  background: #fffdf9;
  border-top: 1px solid var(--border-light);
  flex: 1;
}

.slide-text-box h4 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  color: var(--text-primary);
}

.slide-text-box p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
  white-space: pre-line;
}

.editor-inspector-grid,
.kdp-top-grid,
.kdp-bottom-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

@media (max-width: 980px) {
  .editor-inspector-grid,
  .kdp-top-grid,
  .kdp-bottom-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.artwork-actions-stack {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-top: 0.85rem;
}

/* View 3: KDP Export & Checklist */
.kdp-pill {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  background: #ccfbf1;
  color: #115e59;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.compile-cta-box {
  margin: 1.15rem 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
}

.download-links-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
}

.download-card {
  display: block;
  padding: 0.9rem 1.05rem;
  border-radius: 12px;
  border: 1.5px solid var(--border-strong);
  background: #fcfaf7;
  color: var(--text-primary);
  text-decoration: none;
}

.download-card:hover {
  border-color: var(--brand-accent);
  background: #f0fdfa;
}

.download-primary {
  background: #ecfdf5;
  border-color: #10b981;
}

.download-card strong {
  display: block;
  font-size: 0.96rem;
}

.download-card span {
  display: block;
  font-size: 0.83rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

.preflight-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.preflight-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  font-size: 0.86rem;
}

.pass-badge {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #15803d;
  color: #ffffff;
  font-size: 0.74rem;
  font-weight: 700;
}

.copy-block {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.copy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.copy-val {
  margin: 0;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 0.92rem;
}

.code-box {
  margin: 0;
  padding: 0.75rem;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 0.82rem;
  overflow-x: auto;
  white-space: pre-wrap;
}

.keyword-list {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text-primary);
  font-size: 0.9rem;
}

/* Native Accordions (<details name="kdp-step-guide">) */
.guide-accordion {
  border: 1px solid var(--border-light);
  border-radius: 10px;
  margin-bottom: 0.65rem;
  background: #fcfaf7;
}

.guide-accordion summary {
  padding: 0.85rem 1rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
}

.guide-accordion[open] {
  background: #ffffff;
  border-color: var(--brand-accent);
}

.accordion-body {
  padding: 0 1.1rem 0.95rem;
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.accordion-body ol {
  margin: 0;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.studio-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* Native Modal Dialog + Backdrop */
dialog {
  width: min(600px, 92vw);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 0;
  background: #ffffff;
  color: var(--text-primary);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
}

dialog::backdrop {
  background-color: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.dialog-inner {
  padding: 1.4rem;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}

/* Zeffy Community Youth Mission & 3-Tier Cards */
.cause-mission-pill {
  display: inline-block;
  margin-bottom: 0.45rem;
  padding: 0.28rem 0.8rem;
  border-radius: 999px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #78350f;
  font-size: 0.8rem;
  font-weight: 800;
}

.zeffy-tier-fieldset {
  background: #fffdf7;
  border-color: #f59e0b;
}

.zeffy-tier-grid {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.zeffy-tier-card {
  background: #ffffff;
}

.zeffy-url-highlight {
  padding: 0.9rem 1rem;
  border-radius: 12px;
  background: #fffbeb;
  border: 1.5px solid #f59e0b;
}

.form-row-three {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.zeffy-live-cta-box {
  margin-top: 1.15rem;
  padding: 1.1rem;
  border-radius: 14px;
  background: linear-gradient(135deg, #fffbeb 0%, #ecfdf5 100%);
  border: 2px solid #10b981;
}

.zeffy-live-cta-box p {
  margin: 0.4rem 0 0.85rem;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

#zeffy-modal-dialog {
  width: min(760px, 95vw);
}

.zeffy-modal-inner {
  padding: 1rem;
}

.zeffy-embed-iframe {
  width: 100%;
  height: min(680px, 76dvh);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: #ffffff;
}

/* ==========================================================================
   MOBILE-FIRST TOUCH & PHONE RESPONSIVE FLOW (iPhone / Android / iPad)
   ========================================================================== */
@media (max-width: 1024px) {
  .studio-shell {
    padding: 0.9rem;
    gap: 1rem;
  }

  .bookshelf-sidebar {
    padding: 0.9rem 1rem;
  }

  .sidebar-hint {
    margin: 0.35rem 0 0.65rem;
  }

  /* Horizontal swipeable story shelf on mobile/tablet so users don't scroll past 5 stacked cards! */
  .project-list {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 0.35rem;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .project-item {
    flex: 0 0 min(260px, 76vw);
    scroll-snap-align: start;
  }
}

@media (max-width: 768px) {
  .top-bar {
    padding: 0.7rem 0.9rem;
    gap: 0.65rem;
  }

  .brand-eyebrow {
    font-size: 0.68rem;
  }

  .brand-title {
    font-size: 1.12rem;
  }

  /* Smooth single-row horizontal touch-scroll navigation tabs */
  .mode-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .mode-nav::-webkit-scrollbar {
    display: none;
  }

  .mode-tabs {
    flex-wrap: nowrap;
    width: max-content;
    min-width: 100%;
  }

  .mode-tab {
    white-space: nowrap;
    padding: 0.5rem 0.9rem;
    font-size: 0.88rem;
  }

  .header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    width: 100%;
  }

  .header-actions .btn {
    flex: 1 1 auto;
    font-size: 0.8rem;
    padding: 0.4rem 0.65rem;
  }

  .hero-strip {
    padding: 1rem;
  }

  .hero-strip h1 {
    font-size: 1.22rem;
    line-height: 1.3;
  }

  .hero-sub {
    font-size: 0.9rem;
  }

  .active-book-pill {
    width: 100%;
    text-align: center;
  }

  .card {
    padding: 1rem;
  }

  .form-row-three {
    grid-template-columns: minmax(0, 1fr);
  }

  .repersonalize-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .repersonalize-field,
  .repersonalize-field input,
  .repersonalize-field select,
  .repersonalize-bar .btn {
    width: 100%;
  }

  .wizard-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .wizard-actions .btn,
  .btn-block-mobile,
  .compile-cta-box .btn {
    width: 100%;
  }

  .order-card-actions {
    flex-direction: column;
  }

  .order-card-actions .btn {
    width: 100%;
  }

  .spec-row {
    flex-direction: column;
    gap: 0.2rem;
  }

  .spec-row dd {
    text-align: left;
  }
}

@media (max-width: 640px) {
  dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 90dvh;
    margin: auto 0 0 0;
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
  }

  .dialog-footer {
    flex-direction: column-reverse;
  }

  .dialog-footer .btn {
    width: 100%;
  }
}

/* =========================================================================
   v2.4.0 TellMyTale-Inspired 3D Personalized Book Covers & Trust Polish
   ========================================================================= */
.featured-covers-card {
  margin-bottom: 1.25rem;
  background: linear-gradient(180deg, #fffdf8 0%, #fef9ed 100%);
  border: 1.5px solid #f3d9a4;
  min-width: 0;
  max-width: 100%;
}

.featured-covers-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1.2rem;
  margin-bottom: 0.9rem;
}

.featured-covers-title {
  margin: 0.35rem 0 0;
  font-size: 1.18rem;
  color: var(--text-primary);
}

.trait-value-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.24rem 0.7rem;
  border-radius: 999px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #92400e;
  font-size: 0.76rem;
  font-weight: 800;
}

.trust-check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
  font-size: 0.79rem;
  font-weight: 700;
  color: #0f766e;
}

.featured-covers-shelf {
  display: flex;
  gap: 1rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  padding: 0.35rem 0.2rem 0.8rem;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.book-3d-card {
  flex: 0 0 168px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0.65rem 0.55rem 0.75rem;
  border-radius: 14px;
  border: 2px solid #ebe4d5;
  background: #ffffff;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.book-3d-card:hover {
  transform: translateY(-3px);
  border-color: #d97706;
  box-shadow: 0 10px 22px rgba(180, 83, 9, 0.14);
}

.book-3d-card.is-selected {
  border-color: var(--brand-primary);
  background: #fffbeb;
  box-shadow: 0 8px 20px rgba(180, 83, 9, 0.18);
}

.book-3d-mockup {
  position: relative;
  width: 136px;
  aspect-ratio: 768 / 920;
  border-radius: 4px 10px 10px 4px;
  overflow: hidden;
  background: #1e293b;
  /* Realistic 3D fanned white page edges + studio book shadow! */
  box-shadow:
    3px 1px 0 #f8fafc,
    4px 2px 0 #cbd5e1,
    6px 3px 0 #f8fafc,
    7px 4px 0 #94a3b8,
    10px 10px 18px rgba(15, 23, 42, 0.24);
  margin-bottom: 0.6rem;
}

.book-3d-mockup::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* Hardcover spine crease along left edge + glossy cover sheen */
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.34) 0%,
    rgba(255, 255, 255, 0.30) 4.5%,
    rgba(0, 0, 0, 0.18) 7.5%,
    rgba(255, 255, 255, 0.06) 24%,
    rgba(255, 255, 255, 0) 100%
  );
}

.book-3d-mockup img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.book-3d-trait {
  display: inline-block;
  padding: 0.14rem 0.48rem;
  border-radius: 999px;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  color: #0f766e;
  font-size: 0.68rem;
  font-weight: 800;
  margin-bottom: 0.28rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-3d-title {
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.25;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.live-cover-title-banner {
  padding: 0.48rem 0.8rem;
  margin-bottom: 0.65rem;
  border-radius: 10px;
  background: linear-gradient(90deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #f59e0b;
  color: #78350f;
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
}

.character-stage.is-book-cover-3d {
  aspect-ratio: 768 / 920;
  max-width: 400px;
  margin-inline: auto;
  border-radius: 6px 16px 16px 6px;
  box-shadow:
    5px 2px 0 #ffffff,
    7px 3px 0 #cbd5e1,
    10px 5px 0 #ffffff,
    12px 6px 0 #94a3b8,
    16px 18px 30px rgba(15, 23, 42, 0.24);
  position: relative;
}

.character-stage.is-book-cover-3d::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.30) 0%,
    rgba(255, 255, 255, 0.28) 4%,
    rgba(0, 0, 0, 0.15) 7%,
    rgba(255, 255, 255, 0) 22%
  );
}

.slide-art-box.is-cover-slide {
  aspect-ratio: 768 / 920;
}

.project-thumb {
  width: 52px;
  height: 62px;
  border-radius: 3px 7px 7px 3px;
  box-shadow: 2px 1px 0 #e2e8f0, 3px 3px 7px rgba(15, 23, 42, 0.18);
}

.photo-trust-strip {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.45rem;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  font-size: 0.77rem;
  line-height: 1.35;
}
