:root {
  --paper: #f3eee5;
  --paper-deep: #e9e0d2;
  --ink: #342e29;
  --terracotta: #a5482e;
  --terracotta-dark: #823521;
  --olive: #5d6137;
  --line: rgba(52, 46, 41, 0.16);
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Montserrat", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 10%, rgba(165,72,46,.08), transparent 24rem),
    radial-gradient(circle at 96% 90%, rgba(93,97,55,.09), transparent 22rem),
    var(--paper);
  font-family: var(--sans);
  font-size: 16px;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.shell { width: min(100%, 34rem); margin: 0 auto; padding: max(2rem, env(safe-area-inset-top)) 1.25rem max(2rem, env(safe-area-inset-bottom)); }
.brand { text-align: center; margin-bottom: 1.5rem; }
.brand h1 { margin: .1rem 0; font: 600 clamp(3.4rem, 18vw, 5rem)/.95 var(--serif); letter-spacing: .06em; color: var(--terracotta); }
.brand h1 span { color: var(--olive); font-weight: 500; }
.brand > p:last-child { margin: .7rem auto 0; font: 500 1.15rem/1.4 var(--serif); }
.eyebrow, .section-heading span { margin: 0; color: var(--olive); font-size: .72rem; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; }

.panel { position: relative; padding: 1.4rem; border: 1px solid var(--line); border-radius: 1.75rem 1.75rem .55rem .55rem; background: rgba(255,255,255,.42); box-shadow: 0 1.25rem 3rem rgba(62,43,31,.08); backdrop-filter: blur(12px); }
.start-panel { text-align: center; padding: 2rem 1.4rem 1.5rem; overflow: hidden; }
.start-panel::before, .start-panel::after { content: ""; position: absolute; width: 5rem; height: 8rem; border: 1px solid rgba(93,97,55,.24); border-radius: 100%; transform: rotate(35deg); pointer-events: none; }
.start-panel::before { left: -3.8rem; top: -4.5rem; }
.start-panel::after { right: -4rem; bottom: -5rem; }
.botanical { color: var(--olive); font: 2.2rem/1 var(--serif); transform: rotate(-18deg); }
h2 { margin: .35rem 0 .45rem; font: 600 2rem/1.05 var(--serif); color: var(--terracotta-dark); }
.start-panel > p:not(.privacy-note) { max-width: 24rem; margin: .8rem auto 1.4rem; line-height: 1.6; }
.action-stack { display: grid; gap: .75rem; }
.button { min-height: 3.45rem; width: 100%; border: 1px solid transparent; border-radius: 999px; padding: .8rem 1.2rem; font-size: .82rem; font-weight: 600; letter-spacing: .11em; text-transform: uppercase; cursor: pointer; transition: transform .18s, background .18s, color .18s; }
.button:active { transform: scale(.985); }
.button:focus-visible, .text-button:focus-visible, .icon-button:focus-visible { outline: 3px solid rgba(165,72,46,.32); outline-offset: 3px; }
.button-primary { color: #fffaf4; background: var(--terracotta); }
.button-primary:hover { background: var(--terracotta-dark); }
.button-secondary { color: var(--olive); background: transparent; border-color: var(--olive); }
.button-ghost { color: var(--terracotta-dark); background: rgba(165,72,46,.08); }
.text-button { margin: 1rem auto 0; padding: .5rem; border: 0; background: none; color: var(--terracotta-dark); text-decoration: underline; text-underline-offset: .3em; cursor: pointer; }
.privacy-note { margin: 1rem 0 0; color: #6d655e; font-size: .75rem; line-height: 1.5; }

.section-heading { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.section-heading h2 { margin-top: .15rem; }
.section-heading.centered { display: block; text-align: center; }
.icon-button { flex: 0 0 auto; width: 2.8rem; height: 2.8rem; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.5); color: var(--ink); font-size: 1.25rem; cursor: pointer; }
.stage { position: relative; width: min(100%, 21rem); aspect-ratio: 9/16; margin: 0 auto; overflow: hidden; border-radius: .4rem; background: #cdc5b9; box-shadow: 0 .8rem 2.5rem rgba(37,29,24,.18); touch-action: none; user-select: none; }
.stage canvas { display: block; width: 100%; height: 100%; }
.gesture-hint { position: absolute; left: 50%; bottom: .85rem; transform: translateX(-50%); width: max-content; padding: .42rem .75rem; border-radius: 999px; background: rgba(38,31,26,.72); color: white; font-size: .68rem; letter-spacing: .04em; opacity: 1; transition: opacity .5s; pointer-events: none; }
.stage.touched .gesture-hint { opacity: 0; }
.zoom-row { display: grid; grid-template-columns: auto 1fr auto; gap: .65rem; align-items: center; margin: 1.2rem .3rem 1rem; color: var(--olive); }
.zoom-row input { width: 100%; accent-color: var(--terracotta); }
.editor-panel .button, .result-panel .button { margin-top: .2rem; }

.result-image { display: block; width: min(74%, 17rem); aspect-ratio: 9/16; object-fit: cover; margin: 1rem auto 1.3rem; border-radius: .3rem; box-shadow: 0 1rem 2.7rem rgba(37,29,24,.2); background: var(--paper-deep); }
.share-hint { margin: -.15rem .25rem .35rem; color: #625d56; font-size: .82rem; line-height: 1.55; text-align: center; }
.gallery-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .65rem; }
.gallery-grid img { display: block; width: 100%; aspect-ratio: 9/16; object-fit: cover; border-radius: .3rem; }
.empty-state { margin: 2rem 0 1rem; padding: 1.2rem; border: 1px dashed rgba(93,97,55,.4); border-radius: 1rem; color: #625d56; text-align: center; line-height: 1.6; }

dialog { width: min(calc(100% - 2rem), 27rem); border: 1px solid var(--line); border-radius: 1.5rem; padding: 2rem; color: var(--ink); background: var(--paper); box-shadow: 0 2rem 5rem rgba(30,23,18,.32); text-align: center; }
dialog::backdrop { background: rgba(39,32,27,.58); backdrop-filter: blur(4px); }
dialog p:not(.eyebrow) { line-height: 1.6; }
.dialog-close { position: absolute; right: .75rem; top: .65rem; border: 0; background: none; color: var(--ink); font-size: 1.6rem; cursor: pointer; }
.toast { position: fixed; left: 50%; bottom: max(1.5rem, env(safe-area-inset-bottom)); z-index: 10; transform: translate(-50%, 1rem); max-width: calc(100% - 2rem); padding: .75rem 1rem; border-radius: 999px; background: #332b25; color: white; font-size: .82rem; opacity: 0; pointer-events: none; transition: .25s; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 48rem) {
  .shell { width: min(100%, 68rem); }
  .brand { margin-bottom: 1.8rem; }
  .panel { width: min(100%, 31rem); margin-inline: auto; }
  .editor-panel { width: min(100%, 32rem); }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
