:root {
  --ink: #14343c;
  --sea: #083746;
  --deep: #04242e;
  --lagoon: #0e7c8a;
  --foam: #e7f6f4;
  --paper: #fffdf8;
  --sand: #f3e2c4;
  --coral: #ff6a3d;
  --gold: #f0b429;
  --line: rgba(20, 52, 60, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }

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

body {
  font-family: "Nunito", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(240, 180, 41, 0.18), transparent 50%),
    radial-gradient(900px 500px at 110% 0%, rgba(255, 106, 61, 0.16), transparent 45%),
    linear-gradient(180deg, #e7f4f2 0%, #d5ebe8 40%, #c5e0dc 100%);
}

button, input { font: inherit; }

code {
  font-family: "Consolas", monospace;
  font-size: 0.92em;
}

.screen {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.home.screen {
  width: 100%;
  margin: 0;
  padding: 0;
  min-height: 100dvh;
}

.app-bar, .app-dock {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 30;
  background: rgba(255, 253, 248, 0.96);
  backdrop-filter: blur(14px);
}

.app-bar {
  top: 0;
  border-bottom: 1px solid var(--line);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}

.app-bar-inner {
  width: min(480px, 100%);
}

.app-bar-inner {
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-bar h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1;
  max-width: none;
}

.version {
  margin: 0;
  flex: none;
  text-align: right;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.25;
  white-space: nowrap;
  color: var(--sea);
}

.version span {
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--lagoon);
}

.app-scroll {
  width: min(480px, 100%);
  margin: 0 auto;
  padding: calc(68px + env(safe-area-inset-top)) 16px calc(112px + env(safe-area-inset-bottom));
}

.home-video {
  aspect-ratio: 16 / 9;
  border-radius: 22px;
  display: grid;
  place-items: center;
  overflow: hidden;
  margin-bottom: 14px;
  background:
    radial-gradient(140px 90px at 72% 58%, rgba(240, 180, 41, 0.38), transparent 70%),
    linear-gradient(160deg, #12899a 0%, #083746 72%);
  box-shadow: 0 14px 30px rgba(4, 36, 46, 0.16);
}

.home .hero-fish svg { width: 74%; }

.home .char-picker {
  flex-wrap: nowrap;
  overflow-x: auto;
  margin: 0 0 14px;
  padding-bottom: 4px;
}

.home .char-picker .char { flex: none; }

.home .steps {
  grid-template-columns: 1fr;
  margin: 0 0 16px;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.home-actions .btn { width: 100%; }

.demo-link {
  align-self: center;
  padding: 6px 8px;
}

.app-dock {
  bottom: 0;
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}

.ar-launch {
  width: min(448px, 100%);
  margin: 0 auto;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--coral);
  font-size: 1.05rem;
}

.qr-icon {
  width: 22px;
  height: 22px;
  display: block;
}

.home .brand {
  margin: 0 0 8px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--lagoon);
  font-size: 0.82rem;
}

.home h1, .topbar h1, .preview-card h2 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 560;
  letter-spacing: -0.03em;
}

.home h1 {
  margin: 0;
  flex: none;
  font-size: 1.4rem;
  line-height: 1;
  max-width: none;
  color: var(--deep);
}

.lead {
  max-width: 42rem;
  font-size: 1.12rem;
  line-height: 1.45;
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 12px;
  align-items: center;
}

.hero-fish {
  justify-self: center;
}

.hero-fish svg {
  width: min(280px, 70vw);
  overflow: visible;
}

.steps {
  list-style: none;
  padding: 0;
  margin: 8px 0 22px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.steps li {
  display: flex;
  gap: 12px;
  background: rgba(255, 253, 248, 0.86);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
}

.steps span {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--sea);
  color: white;
  font-weight: 800;
}

.steps p, .fine, .preview-card p, .status {
  margin: 4px 0 0;
  line-height: 1.4;
}

.steps strong { display: block; }

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

.char-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 18px;
}

.char-picker .char {
  background: white;
  color: var(--sea);
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(8, 55, 70, 0.08);
  cursor: pointer;
}

.char-picker .char.on {
  border-color: var(--coral);
  background: #fff4ee;
}

.unlock-pop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
}

.unlock-pop[hidden] { display: none; }

.unlock-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(4, 36, 46, 0.55);
}

.unlock-card {
  position: relative;
  z-index: 1;
  width: min(320px, 100%);
  background: var(--paper);
  border-radius: 24px;
  padding: 28px 22px;
  box-shadow: 0 20px 50px rgba(4, 36, 46, 0.28);
}

.btn.unlock-link {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--gold);
  color: var(--deep);
  text-decoration: none;
}

.lock-icon {
  width: 22px;
  height: 22px;
  display: block;
  flex: none;
}

.btn, .text-btn, .tool, .swatch {
  border: 0;
  cursor: pointer;
}

.btn {
  background: var(--sea);
  color: white;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 800;
}

.btn.primary { background: var(--coral); }
.btn.ghost { background: transparent; color: var(--sea); border: 2px solid var(--sea); }
.btn.small { padding: 8px 14px; }

.btn:hover, .tool:hover, .text-btn:hover { filter: brightness(1.08); }

.fine { color: #3e626c; max-width: 46rem; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.topbar h1 { margin: 0; font-size: 1.6rem; }

.text-btn {
  background: transparent;
  color: var(--sea);
  font-weight: 800;
  padding: 8px 0;
}

.text-btn.light { color: white; }

.sheet-wrap { width: min(210mm, 100%); margin: 0 auto; }
.sheet svg {
  width: 100%;
  height: auto;
  display: block;
  background: white;
  box-shadow: 0 16px 40px rgba(4, 36, 46, 0.16);
}

.studio-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
  align-items: start;
}

.paper-card, .preview-card {
  background: rgba(255, 253, 248, 0.92);
  border-radius: 24px;
  padding: 12px;
  border: 1px solid var(--line);
}

.paper-stack {
  position: relative;
  width: 100%;
  aspect-ratio: 780 / 744;
  background: var(--paper);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(20, 52, 60, 0.08);
}

.paper-stack canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.paper-stack .paint { cursor: crosshair; touch-action: none; }
.paper-stack .lines { pointer-events: none; }

.toolrow, .swatches, .ar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolrow, .swatches { margin-top: 10px; }

.tool {
  background: #e7f1f0;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
}

.tool.on, .swatch.on { outline: 3px solid var(--sea); }
.tool.accent { background: var(--gold); }

.size { font-weight: 800; font-size: 0.92rem; display: flex; gap: 8px; align-items: center; }

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.preview {
  width: 100%;
  height: min(68vh, 640px);
  display: block;
  border-radius: 16px;
  background: #08738f;
  touch-action: none;
}

.ar-screen {
  position: fixed;
  inset: 0;
  background: #02161d;
}

.ar-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.ar-stack { position: relative; }
.ar-stack canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.ar-debug { pointer-events: none; }

.ar-ui {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(2, 22, 29, 0.82));
  color: white;
}

.status {
  flex: 1;
  min-width: 180px;
  margin: 0;
  font-weight: 800;
}

.ar-ui .text-btn { position: absolute; top: auto; }
.ar-screen .text-btn.light {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: 16px;
  z-index: 2;
  background: rgba(2, 22, 29, 0.45);
  border-radius: 999px;
  padding: 8px 12px;
}

@media (max-width: 860px) {
  .hero, .steps, .studio-grid { grid-template-columns: 1fr; }
  .hero-fish { order: -1; }
  .preview { height: 320px; }
}

@media print {
  body { background: white; }
  .no-print { display: none !important; }
  .screen { width: auto; padding: 0; margin: 0; }
  .sheet-wrap { width: 210mm; }
  .sheet svg { width: 210mm; height: 297mm; box-shadow: none; }
  @page { size: A4 portrait; margin: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-fish animateTransform { display: none; }
}

.gallery.screen {
  width: 100%;
  margin: 0;
  padding: 0;
  min-height: 100dvh;
}

.gallery .app-scroll { padding-bottom: 28px; }

.gallery .app-bar h1 {
  font-size: 1.35rem;
  max-width: none;
}

.gallery-stage { margin-bottom: 16px; }

.gallery-view {
  width: 100%;
  height: 280px;
  display: block;
  border-radius: 22px;
  background: #08738f;
}

.gallery-name {
  margin: 12px 0 0;
  text-align: center;
  font-weight: 800;
  font-size: 1.15rem;
}

.gallery-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.gallery-actions .btn { flex: 1; }

.gallery-empty {
  margin: 28px 0;
  text-align: center;
  font-weight: 800;
  color: #3e626c;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.gallery-thumb {
  aspect-ratio: 1;
  padding: 6px;
  border: 3px solid transparent;
  border-radius: 16px;
  background: white;
  cursor: pointer;
}

.gallery-thumb.on { border-color: var(--coral); }

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.share-pop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(4, 36, 46, 0.72);
}

.share-pop[hidden] { display: none; }

.share-card {
  width: min(420px, 100%);
  max-height: 100%;
  overflow: auto;
  background: var(--paper);
  border-radius: 24px;
  padding: 12px;
}

.share-sheet {
  width: 100%;
  height: auto;
  display: block;
  background: white;
}

.catch { display: none; }
.catch.on { display: inline-flex; }
.btn.catch { background: var(--gold); color: var(--deep); }
