:root {
  --bg: #f5efe0;
  --bg-2: #ebe2cb;
  --card: #fffdf7;
  --ink: #1f2b1c;
  --muted: #5f6b58;
  --line: #e1d7bd;
  --leaf: #3f7d2c;
  --leaf-2: #5ea043;
  --leaf-ink: #ffffff;
  --gold: #d79a2b;
  --err: #b3362b;
  --focus: #2f6fd6;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 8px 24px rgba(40, 30, 10, .07);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121a15; --bg-2: #18231c; --card: #1c2820; --ink: #eef2e6; --muted: #a3b09c;
    --line: #2d3b31; --leaf: #6fbf52; --leaf-2: #8fd472; --leaf-ink: #0f1a10; --gold: #e7b456;
    --err: #ff8a7a; --focus: #7fb0ff; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2 { font-family: Fraunces, Georgia, "Times New Roman", serif; margin: 0; letter-spacing: -.01em; }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }

/* Hero */
.hero { position: relative; background: linear-gradient(180deg, var(--bg-2), var(--bg)); padding: calc(40px + env(safe-area-inset-top)) 16px 56px; text-align: center; overflow: hidden; }
.hero-inner { max-width: 640px; margin: 0 auto; position: relative; z-index: 1; }
.hero h1 { font-size: clamp(34px, 7vw, 56px); font-weight: 800; line-height: 1.05; }
.hero h1 em { font-style: italic; font-weight: 600; color: var(--leaf); }
.hero p { margin: 12px auto 0; color: var(--muted); font-size: 17px; max-width: 460px; }
.badge { display: inline-block; margin-bottom: 12px; padding: 4px 10px; border-radius: 999px; background: var(--gold); color: #2a1d00; font-size: 12px; font-weight: 600; }
.vine { position: absolute; left: 0; right: 0; bottom: 8px; width: 100%; height: 48px; }
.vine path { fill: none; stroke: var(--leaf); stroke-width: 3; stroke-linecap: round; opacity: .35; }

main { max-width: 760px; margin: 0 auto; padding: 0 16px 48px; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.step-head h2 { font-size: 22px; font-weight: 600; }
.num { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--leaf); color: var(--leaf-ink); font-weight: 600; font-size: 14px; flex: none; }

/* Upload */
.drop { position: relative; border: 2px dashed var(--line); border-radius: 12px; min-height: 220px; display: grid; place-items: center; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; overflow: hidden; background: var(--bg); }
.drop:hover, .drop.over { border-color: var(--leaf-2); background: color-mix(in srgb, var(--leaf-2) 8%, var(--bg)); }
.drop.has-photo { border-style: solid; border-color: var(--leaf); }
.drop-icon { font-size: 40px; }
.drop-title { margin: 6px 0 2px; font-weight: 600; }
.drop p { margin: 0; }
#preview { width: 100%; max-height: 360px; object-fit: contain; display: block; }
.drop.has-photo .drop-empty { display: none; }
.pick-row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.pick-row .btn { flex: 1 1 140px; }
.tips { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 14px; }
.tips li::before { content: "✓ "; color: var(--leaf); font-weight: 600; }
@media (hover: hover) and (pointer: fine) { .only-touch { display: none; } }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 12px 18px; border-radius: 12px; font: 600 16px/1 Inter, system-ui, sans-serif; cursor: pointer; border: 1px solid transparent; -webkit-tap-highlight-color: transparent; transition: transform .05s, background .15s, opacity .15s; text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--leaf); color: var(--leaf-ink); width: 100%; font-size: 17px; }
.btn-primary:hover:not(:disabled) { background: var(--leaf-2); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--leaf-2); }

/* Styles */
.styles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.style-tile { position: relative; display: grid; gap: 2px; padding: 10px; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; transition: border-color .15s; }
.style-tile:has(input:checked) { border-color: var(--leaf); background: color-mix(in srgb, var(--leaf) 7%, var(--card)); }
.style-tile:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.style-tile input { position: absolute; opacity: 0; pointer-events: none; }
.swatch { height: 56px; border-radius: 8px; margin-bottom: 6px; }
.sw-storybook { background: radial-gradient(circle at 30% 40%, #f3c98b 0 18%, transparent 19%), radial-gradient(circle at 70% 60%, #9cc7a1 0 25%, transparent 26%), linear-gradient(135deg, #f7e7c6, #c9e0d0); }
.sw-3d { background: radial-gradient(circle at 35% 35%, #ffffff 0 6%, #7cc2ff 7% 30%, transparent 31%), linear-gradient(160deg, #ffb36b, #ff6f91); }
.sw-comic { background: radial-gradient(#0000 40%, #000 41% 48%, #0000 49%) 0 0/12px 12px, linear-gradient(135deg, #ffd23f, #ee4266); }
.sw-paper { background: linear-gradient(170deg, transparent 55%, #6a994e 56%), linear-gradient(190deg, transparent 45%, #a7c957 46%), #f2e8cf; }
.style-name { font-weight: 600; font-size: 15px; }
.style-desc { font-size: 12.5px; color: var(--muted); line-height: 1.3; }
@media (max-width: 600px) { .styles { grid-template-columns: repeat(2, 1fr); } }

.field { margin-top: 18px; }
.field-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: block; text-align: center; padding: 10px 6px; border-radius: 9px; cursor: pointer; font-weight: 500; }
.segmented input:checked + span { background: var(--card); box-shadow: var(--shadow); font-weight: 600; color: var(--leaf); }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); }

/* Scenes */
.scene-picks { display: grid; gap: 10px; }
.scene-pick { position: relative; display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; transition: border-color .15s, background .15s; }
.scene-pick:has(input:checked) { border-color: var(--leaf); background: color-mix(in srgb, var(--leaf) 7%, var(--card)); }
.scene-pick:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.scene-pick input { position: absolute; opacity: 0; pointer-events: none; }
.scene-num { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); font: 600 13px Inter, sans-serif; color: var(--muted); flex: none; margin-top: 2px; }
.scene-pick:has(input:checked) .scene-num { background: var(--leaf); border-color: var(--leaf); color: var(--leaf-ink); }
.scene-text strong { display: block; font-family: Fraunces, Georgia, serif; font-size: 18px; font-weight: 600; }
.scene-desc { display: block; color: var(--muted); font-size: 14.5px; margin-top: 2px; }

/* Submit */
.submit-bar { position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(180deg, transparent, var(--bg) 30%); z-index: 5; }
.error { color: var(--err); margin: 10px 0 0; font-weight: 500; text-align: center; }

/* Results */
#resultsWrap { margin-top: 24px; scroll-margin-top: 16px; }
.results-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.results-head h2 { font-size: 28px; }
.results { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.results:has(> :only-child) { grid-template-columns: minmax(0, 440px); justify-content: center; }
@media (max-width: 600px) { .results { grid-template-columns: 1fr; } }
.result { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.result .frame { aspect-ratio: 1 / 1; background: var(--bg-2); position: relative; }
.result img { width: 100%; height: 100%; object-fit: cover; display: block; animation: fade .5s ease; }
.result figcaption { flex: 1; padding: 14px 16px 6px; }
.result .cap-title { display: block; font-family: Fraunces, Georgia, serif; font-size: 19px; font-weight: 600; }
.result .cap-desc { display: block; margin-top: 4px; color: var(--muted); font-size: 15px; line-height: 1.45; }
.result .actions { padding: 8px 12px 14px; }
.result .actions .btn { width: 100%; min-height: 42px; font-size: 15px; }
.skeleton { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; background: linear-gradient(100deg, var(--bg-2) 30%, color-mix(in srgb, var(--card) 70%, var(--bg-2)) 50%, var(--bg-2) 70%) 0 0 / 300% 100%; animation: shimmer 1.6s linear infinite; }
.sprout { font-size: 44px; animation: grow 1.6s ease-in-out infinite alternate; transform-origin: bottom; }
.again { text-align: center; margin-top: 20px; }
@keyframes shimmer { to { background-position: -150% 0; } }
@keyframes grow { from { transform: scaleY(.7); } to { transform: scaleY(1.1); } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

footer { text-align: center; font-size: 13px; padding: 0 16px 32px; }
