:root {
  --bg: #f3f0e9;
  --bg-deep: #eae5db;
  --paper: #fbf8f1;
  --ink: #1b1b18;
  --ink-soft: #383832;
  --muted: #78736a;
  --muted-light: #a29c91;
  --line: rgba(27, 27, 24, 0.11);
  --line-strong: rgba(27, 27, 24, 0.2);
  --accent: #ff6138;
  --accent-soft: #f3b398;
  --dark: #141412;
  --cream: #f6f2e9;
  --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --ease-out: cubic-bezier(0.22, 0.8, 0.24, 1);
}

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

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(110% 68% at 82% -8%, rgba(255, 255, 255, 0.95), transparent 56%),
    radial-gradient(70% 52% at -12% 104%, rgba(221, 120, 79, 0.11), transparent 68%),
    linear-gradient(180deg, #f5f2ec 0%, var(--bg) 60%, #efebe2 100%);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, transparent calc(50% - 0.5px), rgba(27, 27, 24, 0.035) 50%, transparent calc(50% + 0.5px));
  content: "";
  pointer-events: none;
}

body.is-preview-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

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

h1,
h2,
h3,
p,
ul,
figure {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

img {
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.page-grain {
  position: fixed;
  inset: 0;
  z-index: 500;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

.app {
  position: relative;
  z-index: 2;
}

/* ---------------------------------- Top bar --------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 35;
  display: flex;
  width: 100%;
  padding: max(26px, env(safe-area-inset-top)) max(28px, calc((100vw - 836px) / 2 + 28px)) 12px;
  align-items: center;
  justify-content: space-between;
}

.topbar::before {
  position: absolute;
  inset: 0;
  border-bottom: 1px solid transparent;
  background: rgba(243, 240, 233, 0.72);
  content: "";
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.25s ease,
    border-color 0.25s ease;
  -webkit-backdrop-filter: blur(18px) saturate(1.08);
  backdrop-filter: blur(18px) saturate(1.08);
}

.topbar.is-scrolled::before {
  border-bottom-color: rgba(27, 27, 24, 0.08);
  opacity: 1;
}

.topbar > * {
  position: relative;
  z-index: 1;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  user-select: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  color: var(--cream);
  background: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 11px;
  box-shadow: 0 7px 16px -10px rgba(27, 27, 24, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.13);
  place-items: center;
}

.brand-mark svg {
  width: 29px;
  height: 29px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1;
}

.brand-tagline {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.23em;
  line-height: 1.3;
}

.icon-button {
  position: relative;
  display: grid;
  width: 46px;
  height: 46px;
  padding: 0;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.54);
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: 0 10px 28px -22px rgba(27, 27, 24, 0.7);
  transition:
    color 0.25s ease,
    background-color 0.25s ease,
    border-color 0.25s ease,
    transform 0.25s var(--ease-out),
    opacity 0.25s ease;
  place-items: center;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.icon-button svg {
  width: 21px;
  height: 21px;
}

.icon-button:not(:disabled):hover {
  color: var(--cream);
  background: var(--ink);
  border-color: var(--ink);
  transform: translateY(-2px);
}

.icon-button:not(:disabled):active {
  transform: scale(0.94);
}

.icon-button:disabled {
  opacity: 0.34;
  cursor: not-allowed;
}

.icon-button:not(:disabled)::after {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--bg);
  content: "";
}

/* ---------------------------------- Layout ---------------------------------- */

.main {
  width: min(100%, 836px);
  margin: 0 auto;
  padding: 56px 28px 170px;
}

.hero {
  margin-bottom: 56px;
}

.kicker {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  line-height: 1.4;
}

.kicker-dot {
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255, 97, 56, 0.1);
}

.hero h1 {
  margin: 20px 0 20px;
  font-size: clamp(44px, 7.1vw, 74px);
  font-weight: 600;
  letter-spacing: -0.06em;
  line-height: 1.07;
}

.hero h1 .serif {
  font-family: var(--font-serif);
  font-weight: 500;
  letter-spacing: -0.055em;
}

.hero-desc {
  max-width: 33em;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.005em;
  line-height: 1.85;
}

.feature-row {
  display: flex;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  align-items: center;
  gap: 25px;
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  line-height: 1.4;
}

.feature-row li {
  display: flex;
  align-items: center;
  gap: 7px;
}

.feature-row span {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.03em;
}

/* --------------------------------- Workspace -------------------------------- */

.workspace {
  position: relative;
  padding: 22px;
  scroll-margin-top: 96px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(27, 27, 24, 0.1);
  border-radius: 30px;
  box-shadow:
    0 44px 90px -66px rgba(27, 27, 24, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.75);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.workspace-head {
  display: flex;
  margin-bottom: 18px;
  padding: 0 3px 16px;
  border-bottom: 1px solid var(--line);
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.workspace-title-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.workspace-head h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.025em;
  line-height: 1;
}

.count-badge {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  color: var(--cream);
  background: var(--ink);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  place-items: center;
  transition: transform 0.25s var(--ease-out);
}

.count-badge.is-bumping {
  animation: badgeBump 0.36s var(--ease-out);
}

.output-meta {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.015em;
  line-height: 1.5;
  text-align: right;
  white-space: nowrap;
}

.output-meta.is-calculating {
  color: var(--accent);
}

/* --------------------------------- Empty state ------------------------------ */

.empty-state {
  padding: 46px 18px 40px;
  text-align: center;
}

.empty-art {
  position: relative;
  width: 198px;
  height: 198px;
  margin: 0 auto 20px;
}

.empty-card {
  position: absolute;
  width: 108px;
  height: 142px;
  background: var(--paper);
  border: 7px solid var(--paper);
  border-radius: 13px;
  box-shadow:
    0 20px 34px -26px rgba(27, 27, 24, 0.7),
    0 2px 5px rgba(27, 27, 24, 0.05);
  overflow: hidden;
}

.empty-card-back {
  top: 37px;
  left: 18px;
  background: linear-gradient(155deg, #d3dad4 0%, #a2b2aa 48%, #768e84 100%);
  border-color: #f8f5ee;
  transform: rotate(-14deg);
}

.empty-card-back::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 34%;
  background: linear-gradient(180deg, rgba(59, 81, 72, 0), rgba(48, 68, 60, 0.55));
  content: "";
}

.empty-sun {
  position: absolute;
  top: 17px;
  right: 17px;
  width: 18px;
  height: 18px;
  background: #f1c7a4;
  border-radius: 50%;
  opacity: 0.9;
}

.empty-card-mid {
  top: 27px;
  right: 15px;
  background: linear-gradient(150deg, #f2c9a7 0%, #e29b73 55%, #c87353 100%);
  border-color: #f8f5ee;
  transform: rotate(11deg);
}

.empty-arch {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 46px;
  height: 76px;
  background: rgba(255, 250, 242, 0.54);
  border-radius: 999px 999px 0 0;
  transform: translateX(-50%);
}

.empty-card-front {
  top: 45px;
  left: 50%;
  z-index: 3;
  width: 118px;
  height: 150px;
  padding: 0;
  background: linear-gradient(180deg, #d9e3df 0%, #c6d4cd 53%, #9bafa4 53%, #778f82 100%);
  border: 7px solid #fffdf8;
  transform: translateX(-50%) rotate(-2.5deg);
}

.empty-photo {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.empty-photo-sun {
  position: absolute;
  top: 22px;
  left: 21px;
  width: 22px;
  height: 22px;
  background: #f7c088;
  border-radius: 50%;
  box-shadow: 0 0 24px rgba(247, 192, 136, 0.55);
}

.empty-photo-ridge {
  position: absolute;
  right: -10px;
  bottom: -4px;
  left: -10px;
  height: 67%;
  background: #667d72;
  clip-path: polygon(0 70%, 24% 47%, 40% 61%, 63% 29%, 82% 55%, 100% 38%, 100% 100%, 0 100%);
}

.empty-photo-ridge.second {
  height: 42%;
  background: #4f675c;
  clip-path: polygon(0 63%, 19% 43%, 43% 74%, 59% 48%, 78% 66%, 100% 45%, 100% 100%, 0 100%);
}

.empty-shadow {
  position: absolute;
  bottom: 4px;
  left: 50%;
  width: 150px;
  height: 18px;
  background: rgba(27, 27, 24, 0.17);
  border-radius: 50%;
  filter: blur(10px);
  transform: translateX(-50%);
}

.empty-state h3 {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.3;
}

.empty-state p {
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.01em;
  line-height: 1.8;
}

/* --------------------------------- Photo grid ------------------------------- */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

.photo-card {
  position: relative;
  aspect-ratio: 4 / 5;
  background: var(--bg-deep);
  border: 1px solid rgba(27, 27, 24, 0.08);
  border-radius: 17px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
  overflow: hidden;
}

.photo-card.is-new {
  animation: cardIn 0.58s var(--ease-out) both;
  animation-delay: calc(var(--enter-index, 0) * 55ms);
}

.photo-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s var(--ease-out), filter 0.4s ease;
  -webkit-user-drag: none;
}

@media (hover: hover) {
  .photo-card:hover img {
    transform: scale(1.035);
  }
}

.photo-index {
  position: absolute;
  top: 9px;
  left: 9px;
  display: inline-grid;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  color: #fff;
  background: rgba(18, 18, 16, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  place-items: center;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.photo-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  box-shadow: 0 5px 12px -7px rgba(0, 0, 0, 0.6);
  transition:
    background-color 0.2s ease,
    transform 0.2s var(--ease-out);
  place-items: center;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.photo-remove svg {
  width: 12px;
  height: 12px;
}

.photo-remove:hover {
  background: #fff;
  transform: scale(1.08);
}

.photo-remove:active {
  transform: scale(0.92);
}

.photo-meta {
  position: absolute;
  bottom: 9px;
  left: 9px;
  padding: 4px 7px;
  color: rgba(255, 255, 255, 0.88);
  background: rgba(18, 18, 16, 0.48);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  line-height: 1;
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}

/* ----------------------------------- Dock ----------------------------------- */

.dock {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  display: flex;
  padding: 26px 20px calc(20px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(243, 240, 233, 0) 0%, rgba(243, 240, 233, 0.82) 48%, var(--bg) 82%);
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}

.dock-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  pointer-events: auto;
}

.add-button {
  position: relative;
  display: grid;
  width: 66px;
  height: 66px;
  padding: 0;
  color: var(--cream);
  background: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  box-shadow:
    0 22px 42px -16px rgba(27, 27, 24, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition:
    transform 0.25s var(--ease-out),
    background-color 0.25s ease,
    opacity 0.25s ease;
  place-items: center;
}

.add-button::before {
  position: absolute;
  inset: -7px;
  border: 1px solid rgba(27, 27, 24, 0.12);
  border-radius: 50%;
  content: "";
  transition: transform 0.25s var(--ease-out), border-color 0.25s ease;
}

.plus-icon {
  width: 25px;
  height: 25px;
  transition: opacity 0.15s ease, transform 0.25s var(--ease-out);
}

@media (hover: hover) {
  .add-button:hover {
    background: #050504;
    transform: translateY(-2px);
  }

  .add-button:hover::before {
    border-color: rgba(27, 27, 24, 0.25);
    transform: scale(1.04);
  }
}

.add-button:active {
  transform: scale(0.94);
}

.add-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.dock-label {
  padding: 4px 9px;
  color: var(--muted);
  background: rgba(243, 240, 233, 0.72);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.1em;
  line-height: 1.4;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.add-spinner {
  position: absolute;
  display: none;
  width: 21px;
  height: 21px;
  border: 1.8px solid rgba(255, 255, 255, 0.22);
  border-top-color: var(--cream);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.add-button.is-loading .plus-icon {
  opacity: 0;
  transform: scale(0.6);
}

.add-button.is-loading .add-spinner {
  display: block;
}

/* ---------------------------------- Preview --------------------------------- */

.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  color: var(--cream);
  background:
    radial-gradient(90% 46% at 50% -6%, rgba(255, 255, 255, 0.08), transparent 58%),
    radial-gradient(60% 60% at 50% 110%, rgba(255, 97, 56, 0.06), transparent 65%),
    var(--dark);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.preview-overlay::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0.028;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  content: "";
  pointer-events: none;
}

.preview-overlay.is-open {
  opacity: 1;
}

.preview-bar {
  position: relative;
  z-index: 3;
  display: grid;
  flex: 0 0 auto;
  min-height: 72px;
  padding: max(14px, env(safe-area-inset-top)) 22px 14px;
  background: rgba(20, 20, 18, 0.7);
  border-bottom: 1px solid rgba(246, 242, 233, 0.075);
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
}

.preview-back {
  display: inline-flex;
  justify-self: start;
  padding: 8px 11px 8px 5px;
  color: rgba(246, 242, 233, 0.7);
  border-radius: 10px;
  align-items: center;
  gap: 1px;
  font-size: 11.5px;
  letter-spacing: 0.025em;
  line-height: 1;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.preview-back svg {
  width: 20px;
  height: 20px;
}

.preview-back:hover {
  color: var(--cream);
  background: rgba(255, 255, 255, 0.07);
}

.preview-back:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.preview-heading {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.preview-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.preview-subtitle {
  max-width: 46vw;
  color: rgba(246, 242, 233, 0.43);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.025em;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-button {
  position: relative;
  display: inline-flex;
  min-width: 76px;
  height: 39px;
  padding: 0 20px;
  justify-self: end;
  color: #171715;
  background: var(--cream);
  border-radius: 999px;
  box-shadow: 0 6px 20px -12px rgba(0, 0, 0, 0.8);
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
  transition:
    background-color 0.2s ease,
    transform 0.2s var(--ease-out),
    opacity 0.2s ease;
}

.save-button:not(:disabled):hover {
  background: #fffdf8;
  transform: translateY(-1px);
}

.save-button:not(:disabled):active {
  transform: scale(0.96);
}

.save-button:disabled {
  opacity: 0.36;
  cursor: default;
}

.save-button.is-saving {
  background: var(--cream);
  opacity: 1;
  pointer-events: none;
}

.save-button.is-saving .save-text {
  visibility: hidden;
}

.save-spinner {
  position: absolute;
  display: none;
  width: 15px;
  height: 15px;
  border: 1.6px solid rgba(23, 23, 21, 0.18);
  border-top-color: #171715;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.save-button.is-saving .save-spinner {
  display: block;
}

.preview-scroller {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(246, 242, 233, 0.22) transparent;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.preview-scroller::-webkit-scrollbar {
  width: 8px;
}

.preview-scroller::-webkit-scrollbar-track {
  background: transparent;
}

.preview-scroller::-webkit-scrollbar-thumb {
  background: rgba(246, 242, 233, 0.18);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

.preview-stage {
  display: flex;
  min-height: 100%;
  padding: 34px 22px calc(72px + env(safe-area-inset-bottom));
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.preview-loading {
  display: flex;
  width: 100%;
  min-height: 52vh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: rgba(246, 242, 233, 0.82);
  text-align: center;
}

.preview-loading p {
  font-size: 13px;
  letter-spacing: 0.02em;
}

.preview-loading small {
  color: rgba(246, 242, 233, 0.37);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.025em;
}

.preview-loader {
  width: 34px;
  height: 34px;
  border: 1.8px solid rgba(246, 242, 233, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.preview-figure {
  width: min(88vw, 540px);
  margin: 0;
  animation: sheetIn 0.5s var(--ease-out) both;
}

.preview-image {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  border-radius: 2px;
  box-shadow:
    0 40px 100px -30px rgba(0, 0, 0, 0.72),
    0 0 0 1px rgba(255, 255, 255, 0.11);
}

.preview-caption {
  display: flex;
  margin-top: 20px;
  color: rgba(246, 242, 233, 0.43);
  font-family: var(--font-mono);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  line-height: 1.4;
  align-items: center;
  justify-content: center;
  gap: 11px;
}

.caption-sep {
  width: 1px;
  height: 10px;
  background: rgba(246, 242, 233, 0.19);
}

/* ----------------------------------- Toast ---------------------------------- */

.toast {
  position: fixed;
  bottom: calc(112px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 300;
  max-width: calc(100vw - 36px);
  padding: 11px 17px;
  color: var(--cream);
  background: rgba(27, 27, 24, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  box-shadow: 0 14px 36px -16px rgba(0, 0, 0, 0.55);
  font-size: 11.5px;
  letter-spacing: 0.015em;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 10px);
  transition:
    opacity 0.25s ease,
    transform 0.3s var(--ease-out),
    visibility 0.25s ease;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.toast.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

/* -------------------------------- Animations -------------------------------- */

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes badgeBump {
  0%,
  100% {
    transform: scale(1);
  }
  42% {
    transform: scale(1.18);
  }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(13px) scale(0.975);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes sheetIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.992);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* -------------------------------- Responsive -------------------------------- */

@media (min-width: 620px) {
  .photo-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }
}

@media (min-width: 561px) {
  .dock {
    padding-right: max(40px, calc((100vw - 836px) / 2 + 40px));
    background: none;
    justify-content: flex-end;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: max(16px, env(safe-area-inset-top)) 18px 10px;
  }

  .brand-mark {
    width: 35px;
    height: 35px;
    border-radius: 10px;
  }

  .brand-mark svg {
    width: 27px;
    height: 27px;
  }

  .brand-name {
    font-size: 16px;
  }

  .icon-button {
    width: 43px;
    height: 43px;
  }

  .icon-button svg {
    width: 20px;
    height: 20px;
  }

  .main {
    padding: 30px 16px 154px;
  }

  .workspace {
    scroll-margin-top: 80px;
  }

  .hero {
    margin-bottom: 34px;
  }

  .hero h1 {
    margin: 16px 0 16px;
    font-size: clamp(37px, 10.9vw, 47px);
    letter-spacing: -0.065em;
    line-height: 1.09;
  }

  .hero-desc {
    font-size: 12.5px;
    line-height: 1.8;
  }

  .feature-row {
    margin-top: 21px;
    padding-top: 14px;
    gap: 15px;
    font-size: 9.5px;
    letter-spacing: 0.02em;
  }

  .feature-row span {
    font-size: 8px;
  }

  .workspace {
    padding: 15px;
    border-radius: 24px;
  }

  .workspace-head {
    margin-bottom: 14px;
    padding: 2px 2px 13px;
    align-items: center;
    gap: 10px;
  }

  .workspace-head h2 {
    font-size: 12px;
  }

  .count-badge {
    min-width: 21px;
    height: 21px;
    font-size: 9.5px;
  }

  .output-meta {
    font-size: 8.5px;
    white-space: normal;
  }

  .empty-state {
    padding: 31px 8px 27px;
  }

  .empty-art {
    width: 172px;
    height: 172px;
    margin-bottom: 15px;
    transform: scale(0.93);
  }

  .empty-state h3 {
    font-size: 17px;
  }

  .empty-state p {
    margin-top: 7px;
    font-size: 11px;
    line-height: 1.75;
  }

  .photo-grid {
    gap: 9px;
  }

  .photo-card {
    border-radius: 14px;
  }

  .photo-index {
    top: 7px;
    left: 7px;
    min-width: 22px;
    height: 22px;
    font-size: 8.5px;
  }

  .photo-remove {
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
  }

  .photo-meta {
    bottom: 7px;
    left: 7px;
    padding: 3px 6px;
    font-size: 8px;
  }

  .dock {
    padding: 22px 16px calc(15px + env(safe-area-inset-bottom));
  }

  .add-button {
    width: 62px;
    height: 62px;
  }

  .plus-icon {
    width: 24px;
    height: 24px;
  }

  .preview-bar {
    min-height: 66px;
    padding: max(12px, env(safe-area-inset-top)) 13px 12px;
    gap: 6px;
  }

  .preview-back {
    padding-right: 6px;
  }

  .preview-back span {
    display: none;
  }

  .preview-title {
    font-size: 11.5px;
  }

  .preview-subtitle {
    max-width: 45vw;
    font-size: 8px;
  }

  .save-button {
    min-width: 70px;
    height: 37px;
    padding: 0 17px;
    font-size: 12px;
  }

  .preview-stage {
    padding: 24px 12px calc(62px + env(safe-area-inset-bottom));
  }

  .preview-figure {
    width: min(92vw, 540px);
  }

  .preview-caption {
    margin-top: 16px;
    font-size: 8.5px;
  }

  .toast {
    bottom: calc(102px + env(safe-area-inset-bottom));
  }
}

@media (max-height: 840px) and (max-width: 560px) {
  .main {
    padding-top: 20px;
  }

  .hero {
    margin-bottom: 22px;
  }

  .hero h1 {
    margin: 10px 0 0;
    font-size: clamp(32px, 9vw, 39px);
    line-height: 1.08;
  }

  .hero-desc,
  .feature-row {
    display: none;
  }

  .empty-art {
    width: 190px;
    height: 110px;
    margin: -4px auto 8px;
    transform: scale(0.56);
    transform-origin: center top;
  }

  .empty-state {
    padding: 18px 8px 22px;
  }
}

@media (max-height: 600px) and (max-width: 560px) {
  .topbar {
    padding-top: max(13px, env(safe-area-inset-top));
    padding-bottom: 8px;
  }

  .main {
    padding-top: 15px;
  }

  .hero {
    margin-bottom: 18px;
  }

  .hero h1 {
    font-size: clamp(28px, 8.8vw, 34px);
  }

  .empty-art {
    display: none;
  }

  .empty-state {
    padding-top: 15px;
    padding-bottom: 18px;
  }

  .workspace-head {
    margin-bottom: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
