/* ==========================================================================
   AuraBily — 20-Page Comic eBook & Story Director Styles (Layer 07)
   Zero !important, zero #id selectors.
   ========================================================================== */

.book-shell-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  margin-bottom: var(--space-3);
}

.book-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.book-title-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  min-width: 180px;
}

.book-title-input {
  width: 100%;
  min-height: var(--ctrl-h-md);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-family: var(--font-serif);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--accent);
}

.book-title-input:focus {
  background: var(--surface-input);
  border-color: var(--accent-border);
  outline: none;
}

.book-export-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.book-progress-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.book-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.book-progress-track {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-base);
  overflow: hidden;
}

.book-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-gradient);
  border-radius: var(--radius-pill);
  transition: width var(--motion-normal) var(--ease-standard);
}

/* 20-Page + Cover Overview Grid */
.book-pages-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.book-page-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  cursor: pointer;
  transition:
    transform var(--motion-fast) var(--ease-standard),
    border-color var(--motion-fast) var(--ease-standard);
}

.book-page-card:hover {
  border-color: var(--accent-border);
}

.book-page-card:active {
  transform: scale(0.98);
}

.book-page-card.is-cover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-gold);
}

.book-page-card.is-active {
  border-color: var(--accent);
}

.book-page-thumb {
  position: relative;
  aspect-ratio: 3 / 4;
  background: var(--surface-base);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.book-page-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-page-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding: var(--space-3);
  text-align: center;
}

.book-page-num-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(17, 17, 16, 0.85);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
}

.book-page-status-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 0.64rem;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(17, 17, 16, 0.85);
  color: var(--text-secondary);
}

.book-page-status-badge[data-status="approved"] {
  color: var(--success);
  border: 1px solid rgba(104, 187, 145, 0.4);
}

.book-page-status-badge[data-status="rendered"] {
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.book-page-status-badge[data-status="lettered"] {
  color: var(--info);
  border: 1px solid rgba(139, 180, 232, 0.4);
}

.book-page-footer {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
  padding: var(--space-2);
}

.book-page-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-page-reorder-btns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-1);
  width: 100%;
}

.book-reorder-btn {
  min-width: var(--ctrl-h-md);
  min-height: var(--ctrl-h-md);
  width: 100%;
  border-radius: var(--radius-sm);
  background: var(--surface-overlay);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sd-anchor-header {
  min-height: var(--ctrl-h-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
}

.sd-popover-item {
  min-height: var(--ctrl-h-md);
}

.sd-explicit-toggle {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sd-chips-bar {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.sd-chips-bar > * {
  flex: 0 0 auto;
}

.sd-buttons-row {
  flex-wrap: wrap;
}

.sd-panel-top {
  flex-wrap: wrap;
}

.sd-panel-top-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.sd-panel-angle-select {
  min-height: var(--ctrl-h-md);
  font-size: var(--text-base);
  min-width: 0;
  max-width: 100%;
  padding: var(--space-2) var(--space-3);
}

.sd-panel-delete-btn {
  min-width: var(--ctrl-h-md);
  min-height: var(--ctrl-h-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sd-panel-reroll-btn {
  min-height: var(--ctrl-h-md);
  padding: var(--space-2) var(--space-3);
}

.sd-panel-desc {
  font-size: var(--text-base);
}

.sd-extra-field {
  flex: 1 1 100%;
  min-width: 0;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2);
}

.sd-extra-field input,
.sd-extra-field select {
  min-height: var(--ctrl-h-md);
  font-size: var(--text-base);
  min-width: 0;
}

.book-reorder-btn:hover {
  color: var(--accent);
}

/* Active Page Studio Toolbar */
.book-page-studio-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
  border: 1px solid var(--accent-border);
  margin-bottom: var(--space-3);
}

.book-page-nav-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* 6-Stage HIL Stepper */
.sd-dag-stepper {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  overflow-x: auto;
  scrollbar-width: none;
  padding: var(--space-2) 0;
}

.sd-dag-stepper::-webkit-scrollbar {
  display: none;
}

.dag-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-base);
  border: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.dag-step.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
  font-weight: 600;
}

.dag-step-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface-overlay);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
}

.dag-step.active .dag-step-dot {
  background: var(--accent);
  color: var(--text-inverse);
}

.dag-step-line {
  width: 12px;
  height: 1px;
  background: var(--border-structural);
  flex-shrink: 0;
}

/* Mobile-friendly Book Studio 2-column grid adjusts to 4 on wide viewports */
@media (min-width: 640px) {
  .book-pages-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1440px) {
  .book-pages-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
