:root {
  --bg-obsidian: var(--bg);
  --bg-surface: var(--surface);
  --bg-elevated: var(--surface-subtle);
  --bg-glass: var(--surface-raised);
  --text-primary: var(--text);
  --border-hairline: var(--hairline);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* Scoped touch-gesture and interactive UI protection (keeps EXIF/caption text selectable) */
button,
[role="button"],
label,
nav,
header,
canvas,
svg,
img,
input[type="range"],
.strip-scroll-container,
.strip-canvas-row,
.top-bar,
.control-dock,
.dock-panel-container {
  -webkit-user-select: none;
  user-select: none;
}

[hidden] {
  display: none !important;
}

/* High-contrast keyboard focus ring across all interactive controls */
:where(button, a, input, select, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.app-shell.ui-busy .top-bar,
.app-shell.ui-busy .canvas-stage,
.app-shell.ui-busy .control-dock {
  pointer-events: none;
  opacity: 0.72;
  transition: opacity 0.15s ease;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

/* Desktop Simulator Wrapper */
.desktop-frame-toolbar {
  display: none;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  background: var(--bg-obsidian);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  container: app-shell / inline-size;
}

@media (min-width: 680px) {
  body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: var(--bg);
  }

  .desktop-frame-toolbar {
    width: 100%;
    height: 40px;
    padding: 0 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-hairline);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    flex-shrink: 0;
  }

  .desktop-toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .brand-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
  }

  .desktop-toolbar-title {
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-primary);
  }

  .desktop-toolbar-hint {
    color: var(--text-secondary);
    padding-left: 10px;
    border-left: 1px solid var(--border-hairline);
  }

  .desktop-toolbar-actions {
    display: flex;
    gap: 6px;
  }

  .desktop-mode-btn {
    background: var(--surface-subtle);
    color: var(--text-secondary);
    border: 1px solid var(--hairline);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
  }

  .desktop-mode-btn.active {
    background: var(--accent-soft);
    color: var(--accent-text);
    border-color: var(--accent);
  }

  body.phone-shell-mode .app-shell {
    width: 430px;
    height: calc(100dvh - 56px);
    max-height: 910px;
    margin: auto 0;
    border-radius: 38px;
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-pop);
  }

  body.expanded-studio-mode .app-shell {
    width: 100%;
    max-width: 1080px;
    height: calc(100dvh - 40px);
    border-left: 1px solid var(--border-hairline);
    border-right: 1px solid var(--border-hairline);
  }
}

/* Minimal Top Bar */
.top-bar {
  height: 46px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-hairline);
  flex-shrink: 0;
  z-index: 20;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-mark {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.16em;
  color: var(--text-primary);
}

.history-btns {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 2px;
}

.history-btn {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

/* Expanded invisible hit target for reliable mobile finger taps (Apple HIG 44px standard) */
.history-btn::after {
  content: '';
  position: absolute;
  top: -6px;
  bottom: -6px;
  left: -5px;
  right: -5px;
}

.history-btn:active:not(:disabled) {
  transform: scale(0.92);
}

.history-btn:disabled {
  opacity: 0.28;
  cursor: default;
}

.view-mode-toggle {
  display: flex;
  background: var(--bg);
  padding: 2px;
  border-radius: 8px;
  border: 1px solid var(--border-hairline);
}

.view-mode-btn {
  position: relative;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.view-mode-btn[aria-selected="true"],
.view-mode-btn.active {
  background: var(--surface-subtle);
  color: var(--text);
}

.view-mode-btn[aria-selected="true"]::after {
  content: '';
  position: absolute;
  inset: auto 8px 1px;
  border-block-end: 2px solid var(--accent);
  border-radius: 1px;
}

.top-add-btn {
  height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  background: var(--accent);
  border: 1px solid transparent;
  color: var(--text-on-accent);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}

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

/* Spacious Canvas Stage */
.canvas-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  overflow: hidden;
  padding: 10px 12px 6px;
}

/* Empty State Card */
.empty-state-card {
  max-width: 300px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  border-radius: 16px;
  padding: 22px 18px;
  text-align: center;
  margin: auto;
  z-index: 15;
}

.empty-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.empty-subtitle {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.empty-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.primary-amber-btn {
  height: 38px;
  padding: 0 16px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--text-on-accent);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 12.5px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
}

.primary-amber-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.secondary-glass-btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--surface-subtle);
  color: var(--text);
  border: 1px solid var(--control-border);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Single-Slide Interactive Stage */
.swipe-stage-wrapper {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.canvas-mount {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  box-shadow: var(--shadow-pop), 0 0 0 1px var(--border);
  border-radius: 2px;
  touch-action: none;
}

#activeSlideCanvas {
  display: block;
  cursor: grab;
  touch-action: none;
}

#activeSlideCanvas:active {
  cursor: grabbing;
}

.gesture-toast {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.gesture-toast.visible {
  opacity: 1;
}

.slide-nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-pop);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
}

.slide-nav-arrow::after {
  content: '';
  position: absolute;
  inset: -8px;
}

.slide-nav-arrow.prev { left: 0px; }
.slide-nav-arrow.next { right: 0px; }
.slide-nav-arrow:disabled {
  opacity: 0;
  pointer-events: none;
}

/* Continuous Multi-Slide Strip Overview Stage */
.strip-stage-wrapper {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.strip-scroll-container {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  display: flex;
  align-items: center;
  padding: 8px 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
}

@supports not (scrollbar-color: auto) {
  .strip-scroll-container {
    scrollbar-width: auto;
  }
  .strip-scroll-container::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }
  .strip-scroll-container::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
  }
  .strip-scroll-container::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
  }
}

.strip-canvas-row {
  display: inline-flex;
  align-items: center;
  margin: 0 auto;
  box-shadow: var(--shadow-pop);
  border: 1px solid var(--border);
}

.strip-slide-cell {
  position: relative;
  display: flex;
  flex-shrink: 0;
  cursor: pointer;
}

.strip-slide-cell:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 100%;
  border-right: 1.5px dashed var(--accent);
  z-index: 5;
  pointer-events: none;
}

.strip-slide-cell.active-slide {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 6;
}

.strip-slide-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(11, 11, 11, 0.82);
  color: #EDEDED;
  font-family: var(--font-mono);
  font-size: 9.5px;
  padding: 2px 5px;
  border-radius: 4px;
  pointer-events: none;
}

.strip-helper-caption {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Stage Footer Bar: Scrollable Pagination Row + Wrapping Controls Row */
.stage-footer-bar {
  container: stage-footer / inline-size;
  position: relative;
  inline-size: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 0 2px;
  flex-shrink: 0;
  margin-block-start: 4px;
}

.slide-pagination-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  inline-size: 100%;
  min-inline-size: 0;
  min-block-size: 16px;
}

.stage-controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: safe center;
  justify-content: space-between;
  gap: 6px 8px;
  inline-size: 100%;
  min-inline-size: 0;
}

.slide-actions-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-inline-start: auto;
}

.minimal-crop-pill {
  display: inline-flex;
  align-items: center;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  border-radius: 999px;
  min-block-size: 28px;
  padding: 0 3px;
  flex-shrink: 0;
}

.pill-action {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  padding: 0 7px;
  min-inline-size: 26px;
  min-block-size: 26px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (prefers-reduced-motion: no-preference) {
  .pill-action {
    transition: color 0.15s ease, background 0.15s ease;
  }
}

.pill-action:active,
.pill-action.active {
  color: var(--accent-text);
}

.pill-action.active.all-bleed {
  color: var(--text-on-accent) !important;
  background: var(--accent);
  border-radius: 999px;
  padding: 1px 7px;
  min-block-size: 24px;
}

.pill-divider {
  width: 1px;
  height: 11px;
  background: var(--border-strong);
  margin: 0 1px;
  flex-shrink: 0;
}

.slide-dots {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 1 auto;
  min-inline-size: 0;
  max-inline-size: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  padding-block: 5px;
  padding-inline: 2px;
  margin-block: -5px;
}

@supports not (scrollbar-width: none) {
  .slide-dots::-webkit-scrollbar {
    display: none;
  }
}

.slide-dot {
  position: relative;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--control-border);
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  scroll-snap-align: center;
}

@media (prefers-reduced-motion: no-preference) {
  .slide-dot {
    transition: all 0.15s ease;
  }
}

.slide-dot::after {
  content: '';
  position: absolute;
  inset: -9px -4px;
}

.slide-dot.active {
  width: 14px;
  border-radius: 999px;
  background: var(--accent);
}

.slide-dot.pano-linked {
  width: 9px;
  border-radius: 2px;
}

.slide-counter-text {
  font-family: var(--font-mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
  padding: 0 2px;
}

.slide-stepper-group {
  display: inline-flex;
  align-items: stretch;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  border-radius: 999px;
  min-block-size: 28px;
  overflow: hidden;
  flex-shrink: 0;
}

.slide-stepper-group .slide-mini-btn {
  min-block-size: 26px;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0 9px;
  font-size: 10.5px;
}

.slide-stepper-group .slide-mini-btn:first-child {
  border-right: 1px solid var(--border-hairline);
}

.slide-mini-btn {
  min-inline-size: 28px;
  min-block-size: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (prefers-reduced-motion: no-preference) {
  .slide-mini-btn {
    transition: all 0.15s ease;
  }
}

.slide-mini-btn.muted {
  color: var(--text-secondary);
  min-inline-size: 28px;
  padding: 0 8px;
}

.slide-mini-btn.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent);
}

@media (pointer: coarse) {
  .minimal-crop-pill,
  .slide-stepper-group,
  .slide-mini-btn {
    min-block-size: 30px;
  }
  .pill-action,
  .slide-stepper-group .slide-mini-btn {
    min-block-size: 28px;
  }
  .slide-mini-btn.muted {
    min-inline-size: 32px;
  }
}

@container stage-footer (inline-size < 360px) {
  .stage-controls-row {
    gap: 5px 6px;
  }
  .pill-action {
    padding: 0 5px;
    font-size: 10.5px;
  }
  .slide-actions-group {
    gap: 4px;
  }
  .slide-mini-btn {
    padding: 0 7px;
    font-size: 10px;
  }
  .slide-stepper-group .slide-mini-btn {
    padding: 0 7px;
    font-size: 10px;
  }
}

@container stage-footer (inline-size >= 680px) {
  .stage-controls-row {
    max-inline-size: 680px;
    margin-inline: auto;
  }
}

.btn-auto-story {
  color: var(--accent-text) !important;
  font-weight: 600;
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-auto-story:active {
  background: var(--accent);
  color: var(--text-on-accent) !important;
}

/* Tactile 1:1 Seam Scrubber Floating HUD */
.seam-scrubber-hud {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-raised);
  border: 1px solid var(--accent);
  box-shadow: var(--shadow-pop);
  border-radius: 999px;
  padding: 6px 14px 7px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  inline-size: min(340px, calc(100% - 8px));
  z-index: 40;
  animation: seamHudFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes seamHudFadeIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.seam-hud-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 9.5px;
  color: var(--text-secondary);
}

.seam-hud-tag {
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--accent-text);
}

.seam-hud-ratio {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text);
}

.seam-hud-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  padding: 0 2px;
}

.seam-hud-close:hover {
  color: var(--text);
}

.seam-scrub-slider {
  width: 100%;
  height: 14px;
  accent-color: var(--accent);
  cursor: ew-resize;
}

/* Streamlined 4-Step Bottom Dock */
.control-dock {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.dock-panel-container {
  height: 146px;
  padding: 10px 14px;
  overflow: hidden;
}

.dock-panel-container.finetune-open {
  height: auto;
  min-height: 146px;
  max-height: min(292px, 46dvh);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.dock-panel {
  display: none;
  height: 100%;
}

.dock-panel-container.finetune-open .dock-panel.active {
  height: auto;
}

.dock-panel.active {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 22px;
}

.panel-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
}

.panel-header-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.text-link-btn {
  background: none;
  border: none;
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 0;
}

.text-link-btn.muted {
  color: var(--text-secondary);
}

/* STEP 1: PHOTOS FILMSTRIP */
.photo-filmstrip {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  height: 102px;
  padding: 2px 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

@supports not (scrollbar-width: none) {
  .photo-filmstrip::-webkit-scrollbar {
    display: none;
  }
}

.filmstrip-item {
  position: relative;
  width: 76px;
  height: 94px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  background: var(--bg-elevated);
  flex-shrink: 0;
  cursor: pointer;
}

.filmstrip-item.assigned-active {
  border-color: var(--accent);
}

.filmstrip-select-btn {
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  background: transparent;
  display: block;
  cursor: pointer;
}

.filmstrip-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.filmstrip-remove-btn {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(11, 11, 11, 0.82);
  color: #EDEDED;
  border: none;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.filmstrip-remove-btn::after {
  content: '';
  position: absolute;
  inset: -4px;
}

.filmstrip-index-tag {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(11, 11, 11, 0.82);
  color: #EDEDED;
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 4px;
  pointer-events: none;
}

.filmstrip-reorder-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 22px;
  background: rgba(11, 11, 11, 0.82);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.filmstrip-move-btn {
  flex: 1;
  height: 100%;
  background: transparent;
  border: none;
  color: #EDEDED;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.filmstrip-move-btn:active:not(:disabled) {
  background: rgba(108, 184, 204, 0.25);
  color: #6CB8CC;
}

.filmstrip-move-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.filmstrip-add-tile {
  width: 76px;
  height: 94px;
  border-radius: 8px;
  border: 1.5px dashed var(--control-border);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  cursor: pointer;
}

/* STEP 2: LAYOUT (RATIO + VISUAL SPLIT CARDS) */
.layout-step-rows {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1 1 auto;
  min-height: 0;
  gap: 5px;
}

.compact-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  width: 52px;
  flex-shrink: 0;
}

.flip-orient-btn {
  width: 52px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.flip-orient-btn:active {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent);
}

.flip-icon {
  font-size: 11px;
  color: var(--accent-text);
}

.ratio-pills-row,
.layout-pills-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  min-inline-size: 0;
}

@supports not (scrollbar-width: none) {
  .ratio-pills-row::-webkit-scrollbar,
  .layout-pills-row::-webkit-scrollbar {
    display: none;
  }
}

.ratio-pill {
  height: 36px;
  min-width: 58px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.ratio-pill strong {
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.ratio-pill span {
  font-size: 8.5px;
  color: var(--text-secondary);
}

.ratio-pill.active,
.layout-pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
}

.ratio-pill.active span {
  color: var(--accent-text);
}

.layout-pill {
  height: 58px;
  min-width: 78px;
  padding: 5px 8px;
  border-radius: 9px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  flex-shrink: 0;
}

.layout-icon-box {
  width: 32px;
  height: 26px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  padding: 2px;
  display: flex;
  gap: 2px;
  opacity: 0.85;
  position: relative;
}

.layout-icon-box .cell {
  background: currentColor;
  opacity: 0.45;
  flex: 1;
  border-radius: 1px;
}

.layout-pill-name {
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

/* STEP 3: THEME & MARGIN (MERGED VIEW) */
.theme-main-view {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.themes-carousel {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

@supports not (scrollbar-width: none) {
  .themes-carousel::-webkit-scrollbar {
    display: none;
  }
}

.theme-card {
  width: 106px;
  height: 76px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-hairline);
  padding: 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  flex-shrink: 0;
  text-align: left;
}

.theme-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.theme-card-preview {
  width: 100%;
  height: 36px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 5px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.theme-mini-slot {
  height: 100%;
  flex: 1;
  border-radius: 1.5px;
}

.theme-card-name {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Unified Margin + Color Bar under Theme Cards */
.margin-and-color-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding-top: 4px;
  border-top: 1px solid var(--border-hairline);
}

.primary-margin-slider {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 145px;
  flex-shrink: 0;
}

.primary-margin-slider label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 68px;
}

.primary-margin-slider label span {
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.primary-margin-slider input[type="range"] {
  width: 72px;
  accent-color: var(--accent);
}

.swatches-row {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  min-inline-size: 0;
  padding: 2px 0;
}

@supports not (scrollbar-width: none) {
  .swatches-row::-webkit-scrollbar {
    display: none;
  }
}

.color-swatch {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--control-border);
  cursor: pointer;
  flex-shrink: 0;
}

.color-swatch::after {
  content: '';
  position: absolute;
  inset: -4px;
}

.color-swatch.active {
  border: 2px solid var(--accent);
  transform: scale(1.1);
}

.custom-color-label {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #ff5e5e, #ffbe5e, #5eff8e, #5ecaff, #b85eff, #ff5e5e);
  display: inline-flex;
  cursor: pointer;
  flex-shrink: 0;
  border: 1.5px solid var(--control-border);
}

.custom-color-label:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.custom-color-label input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.fine-tune-toggle-btn,
.cover-bleed-btn {
  height: 26px;
  padding: 0 9px;
  border-radius: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}

.cover-bleed-btn.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent);
}

.cover-bleed-btn.active.all-bleed {
  background: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
  font-weight: 600;
}

/* Optional Fine-Tune View */
.theme-finetune-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.finetune-accent-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.finetune-row-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.segmented-pill-group {
  display: inline-flex;
  align-items: center;
  background: var(--bg);
  padding: 2px;
  border-radius: 6px;
  border: 1px solid var(--border-hairline);
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.segmented-pill {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  padding: 4px 8px;
  min-height: 24px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.segmented-pill.active,
.segmented-pill[aria-checked="true"],
.segmented-pill[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-text);
}

#btnFineTuneSurfaceTheme {
  background: var(--bg-elevated);
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
}

#btnFineTuneSurfaceTheme[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
}

.finetune-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px 10px;
  align-items: end;
}

.slider-control {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-secondary);
}

.mono-val {
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-size: 10px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.finetune-exif-card {
  margin-top: 6px;
  padding: 6px 8px;
  border-radius: 7px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.exif-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.exif-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.exif-toggle-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 13px;
  height: 13px;
  cursor: pointer;
}

.exif-toggle-title {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.exif-badge {
  font-family: var(--font-mono);
  font-size: 8px;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent-text);
  letter-spacing: 0.5px;
}

.exif-options-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 2px;
}

.exif-style-label {
  font-size: 9.5px;
  color: var(--text-secondary);
}

.exif-hint {
  font-size: 9px;
  color: var(--text-muted);
  line-height: 1.25;
}

/* STEP 4: EXPORT PANEL */
.export-step-layout {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.export-step-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.export-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.export-ready-title {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-primary);
}

.export-quality-pills {
  display: inline-flex;
  background: var(--bg);
  padding: 2px;
  border-radius: 6px;
  border: 1px solid var(--border-hairline);
}

.quality-pill {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.quality-pill.active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.export-main-btn {
  flex-shrink: 0;
  height: 40px;
  padding: 0 14px;
}

.export-step-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--border-hairline);
}

.export-mini-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  min-inline-size: 0;
  height: 58px;
}

@supports not (scrollbar-width: none) {
  .export-mini-strip::-webkit-scrollbar {
    display: none;
  }
}

.export-thumb-btn {
  position: relative;
  height: 54px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.export-thumb-btn img {
  height: 100%;
  width: auto;
  display: block;
}

.export-fallback-links {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

/* 4-Step Bottom Navigation Bar */
.dock-tab-bar {
  min-height: 50px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  border-top: 1px solid var(--border-hairline);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.dock-tab {
  position: relative;
  background: none;
  border: none;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease;
}

.step-num {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface-subtle);
  border: 1px solid var(--hairline);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dock-tab[aria-selected="true"],
.dock-tab.active {
  color: var(--text-primary);
}

.dock-tab[aria-selected="true"]::after {
  content: '';
  position: absolute;
  inset: 0 18% auto;
  border-block-start: 2px solid var(--accent);
}

.dock-tab[aria-selected="true"] .step-num,
.dock-tab.active .step-num {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-accent);
  font-weight: 600;
}

/* Responsive Compact Screen Safeguards */
@media (max-width: 390px) {
  .top-bar {
    padding: 0 8px;
    gap: 4px;
  }
  .top-bar-left {
    gap: 5px;
  }
  .logo-mark {
    font-size: 11.5px;
    letter-spacing: 0.1em;
  }
  .history-btn {
    width: 28px;
    height: 28px;
  }
  .view-mode-btn {
    padding: 4px 7px;
    font-size: 10.5px;
  }
  .top-add-btn {
    padding: 0 8px;
    font-size: 10.5px;
  }
  .btn-auto-story {
    padding: 2px 6px;
    font-size: 10.5px;
  }
}
