:root {
  --ink: #1c1410;
  --muted: #6b574c;
  --paper: #f4ece3;
  --card: #fffaf4;
  --line: #e2d3c4;
  --accent: #8f2d2a;
  --accent-dark: #6f1f1d;
  --shadow: 0 18px 50px rgba(60, 32, 18, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Outfit, system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #fbe7d4 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #ead7c8 0%, transparent 50%),
    var(--paper);
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.hero h1,
.eyebrow {
  font-family: "Cormorant Garamond", Georgia, serif;
}

.eyebrow {
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--accent);
  margin: 0 0 8px;
}

.hero h1 {
  font-size: clamp(2.1rem, 5vw, 3.4rem);
  font-weight: 600;
  line-height: 1.05;
  margin: 0 0 12px;
}

.lede {
  max-width: 42rem;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
  margin: 0 0 28px;
}

.import-card,
.library,
.composer {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.import-card {
  position: relative;
  padding: 28px;
  display: grid;
  gap: 14px;
  cursor: pointer;
  border-style: dashed;
  border-width: 2px;
}

.import-card.dragover {
  background: #fff3e8;
  border-color: var(--accent);
}

.import-copy {
  display: grid;
  gap: 4px;
}

.import-copy span,
.hint,
#counts {
  color: var(--muted);
  font-size: 0.92rem;
}

.import-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.file-input {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.filename {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink);
  word-break: break-all;
}

.status {
  margin: 16px 0 0;
  color: var(--accent-dark);
  font-weight: 500;
}

.btn {
  font-family: inherit;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: var(--accent);
  color: #fffaf4;
}

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

.btn-ghost,
.btn-small {
  background: #efe4d8;
  color: var(--ink);
}

.btn-small {
  padding: 7px 12px;
  font-size: 0.85rem;
}

.workspace {
  margin-top: 28px;
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(0, 1.2fr);
  gap: 22px;
  align-items: start;
}

[hidden] {
  display: none !important;
}

.library,
.composer {
  padding: 18px;
}

.toolbar,
.select-row,
.composer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

select,
input[type="text"] {
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 140px;
}

input[type="text"] {
  min-width: 200px;
}

.check-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.check-label input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.custom-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.custom-colors input[type="color"],
input[type="color"] {
  width: 48px;
  height: 34px;
  padding: 2px;
  min-width: 48px;
  border-radius: 8px;
  cursor: pointer;
}

.slider-label input[type="range"] {
  width: 140px;
  min-width: 140px;
  accent-color: var(--accent);
}

.field-label {
  margin: 14px 0 8px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.bg-picks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.bg-swatch {
  aspect-ratio: 9 / 16;
  border: 0;
  padding: 0;
  border-radius: 10px;
  cursor: pointer;
  background: #efe4d8 center / cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  outline: 3px solid transparent;
  outline-offset: 2px;
  color: var(--ink);
  font: 600 0.65rem Outfit, sans-serif;
}

.bg-swatch.selected {
  outline-color: var(--accent);
}

.bg-swatch.solid {
  background: linear-gradient(180deg, #fffaf4, #e8d5c4);
}

.bg-swatch.upload {
  background: #f6eee8;
  box-shadow: inset 0 0 0 1px dashed rgba(58, 31, 36, 0.28);
  font-size: 0.62rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.bg-swatch.upload.has-photo {
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  color: #f4efe6;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
}

.select-row {
  margin: 14px 0;
  align-items: center;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 12px;
  max-height: 72vh;
  overflow: auto;
  padding-right: 4px;
}

.book-card {
  border: 0;
  padding: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.book-card .cover {
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  background: #ddd0c3;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  color: var(--muted);
  box-shadow: 0 8px 18px rgba(40, 20, 10, 0.12);
  outline: 3px solid transparent;
  outline-offset: 2px;
}

.book-card.selected .cover {
  outline-color: var(--accent);
}

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

.book-card .meta {
  margin-top: 6px;
}

.book-card .title {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
}

.book-card .author {
  font-size: 0.7rem;
  color: var(--muted);
}

.composer {
  position: sticky;
  top: 16px;
}

.composer-controls {
  margin-bottom: 12px;
}

.story-viewer {
  display: grid;
  grid-template-columns: auto minmax(0, 280px) auto;
  gap: 10px;
  align-items: center;
  justify-content: center;
}

.story-viewport {
  overflow: hidden;
  touch-action: pan-y;
  border-radius: 28px;
  cursor: grab;
}

.story-viewport.dragging {
  cursor: grabbing;
}

.story-track {
  display: flex;
  transition: transform 0.28s ease;
  will-change: transform;
}

.story-track.no-anim {
  transition: none;
}

.phone.is-post {
  flex-basis: 280px;
}

.phone {
  flex: 0 0 280px;
  width: 280px;
  background: #1a120f;
  border-radius: 28px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.phone canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 18px;
  background: #eee;
  pointer-events: none;
}

.phone-label {
  margin: 8px 0 0;
  text-align: center;
  font-size: 0.78rem;
  color: #f4efe6;
}

.story-nav {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: #efe4d8;
  color: var(--ink);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.story-nav:disabled {
  opacity: 0.35;
  cursor: default;
}

.preview-hint {
  text-align: center;
  margin: 4px 0 0;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .composer {
    position: static;
  }
}
