/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #faf8fc;
  --bg-alt: #f1edf9;
  --surface: #ffffff;
  --ink: #1c1526;
  --ink-soft: #564d68;
  --border: #e4dff0;
  --accent: #6c4cf1;
  --accent-dark: #5636d6;
  --accent-soft: #efe9fd;
  --coral: #ff5b77;
  --success: #17a673;
  --cream: #ffffff;
  --shadow: 0 12px 32px -12px rgba(28, 21, 38, 0.18);
  --radius: 18px;
  --radius-sm: 10px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --safe-line: rgba(255, 91, 119, 0.9);
  --safe-fill: rgba(255, 91, 119, 0.12);
  --cut-line: rgba(28, 21, 38, 0.55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #150f1e;
    --bg-alt: #1b1428;
    --surface: #201933;
    --ink: #f3eefc;
    --ink-soft: #b7abcf;
    --border: #362b4c;
    --accent: #9c85ff;
    --accent-dark: #7a5cf0;
    --accent-soft: #2a2140;
    --cream: #201933;
    --shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.55);
  }
}
:root[data-theme="dark"] {
  --bg: #150f1e;
  --bg-alt: #1b1428;
  --surface: #201933;
  --ink: #f3eefc;
  --ink-soft: #b7abcf;
  --border: #362b4c;
  --accent: #9c85ff;
  --accent-dark: #7a5cf0;
  --accent-soft: #2a2140;
  --cream: #201933;
  --shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.55);
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; overflow-x: clip; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
}
img, svg, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { font-family: "Sora", "Inter", system-ui, sans-serif; text-wrap: balance; line-height: 1.1; letter-spacing: -0.01em; color: var(--ink); }
::selection { background: var(--accent); color: #fff; }

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

.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--ink); color: #fff;
  z-index: 9999; border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

.container { max-width: 1080px; margin-inline: auto; padding-inline: 1.25rem; }

/* =============================================================
   3. Header
   ============================================================= */
.site-header { padding-block: 1.1rem; border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.logo { display: flex; align-items: center; gap: .55rem; font-family: "Sora", sans-serif; font-weight: 700; font-size: 1.1rem; color: var(--accent-dark); }
.header-tag { font-size: .82rem; color: var(--ink-soft); display: none; }
@media (min-width: 720px) { .header-tag { display: block; } }

/* =============================================================
   4. Hero + tool
   ============================================================= */
.hero { padding-block: 2.4rem 1.5rem; text-align: center; }
.hero-title { font-size: clamp(1.7rem, 4.6vw, 2.7rem); max-width: 20ch; margin-inline: auto; }
.hero-sub { margin: .85rem auto 0; max-width: 56ch; color: var(--ink-soft); font-size: 1.05rem; }

.tool-card {
  margin-top: 1.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem;
  text-align: left;
}
@media (min-width: 720px) { .tool-card { padding: 2rem; } }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .6rem; text-align: center; padding: 3rem 1.5rem;
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  color: var(--accent-dark); cursor: pointer;
  transition: border-color .2s var(--ease-out), background-color .2s var(--ease-out);
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-title { font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.dropzone-hint { font-size: .88rem; color: var(--ink-soft); }
.tool-error {
  margin-top: .9rem; padding: .75rem 1rem; border-radius: var(--radius-sm);
  background: #ffe9ec; color: #a3123a; font-size: .9rem; font-weight: 600;
}

.mode-tabs { display: flex; flex-wrap: wrap; gap: .5rem; }
.mode-tab {
  display: flex; align-items: center; gap: .45rem;
  padding: .6rem 1rem; border-radius: 999px; border: 1px solid var(--border);
  font-weight: 600; font-size: .92rem; color: var(--ink-soft);
  transition: all .18s var(--ease-out);
}
.mode-tab:hover { color: var(--ink); }
.mode-tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.mode-desc { margin-top: .7rem; color: var(--ink-soft); font-size: .92rem; }

.editor-grid { display: grid; gap: 1.4rem; margin-top: 1.2rem; }
@media (min-width: 960px) { .editor-grid { grid-template-columns: 1.4fr 1fr; align-items: start; } }

.canvas-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .9rem; margin-bottom: .7rem; }
.zoom-control { display: flex; align-items: center; gap: .5rem; color: var(--ink-soft); flex: 1 1 160px; }
.zoom-control input[type="range"] { flex: 1; accent-color: var(--accent); }
.safe-toggle { display: flex; align-items: center; gap: .4rem; font-size: .88rem; color: var(--ink-soft); font-weight: 600; }
.safe-toggle input { accent-color: var(--coral); width: 16px; height: 16px; }

.btn-ghost {
  padding: .45rem .9rem; border-radius: 999px; border: 1px solid var(--border);
  font-weight: 600; font-size: .85rem; color: var(--ink-soft);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-dark); }

.canvas-frame {
  position: relative; width: 100%; background: repeating-conic-gradient(var(--bg-alt) 0% 25%, var(--surface) 0% 50%) 0 0/20px 20px;
  border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border);
  touch-action: none;
}
#preview-canvas { display: block; width: 100%; height: auto; cursor: grab; }
#preview-canvas:active { cursor: grabbing; }
.canvas-hint { margin-top: .55rem; font-size: .82rem; color: var(--ink-soft); }

.control-group { border: 0; padding: 0; margin: 0 0 1.1rem; }
.control-group legend { font-weight: 700; font-size: .9rem; margin-bottom: .55rem; padding: 0; }
.range-row { display: flex; align-items: center; gap: .8rem; }
.range-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.range-row output { font-weight: 700; min-width: 1.6em; text-align: center; background: var(--accent-soft); color: var(--accent-dark); border-radius: 999px; padding: .15rem .5rem; }

.pill-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.pill {
  padding: .55rem .85rem; border-radius: var(--radius-sm); border: 1px solid var(--border);
  font-weight: 600; font-size: .85rem; color: var(--ink-soft); display: flex; flex-direction: column; gap: .1rem; text-align: left;
  transition: all .18s var(--ease-out);
}
.pill span { font-weight: 500; font-size: .75rem; color: var(--ink-soft); opacity: .8; }
.pill:hover { border-color: var(--accent); }
.pill.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); }
.pill.is-active span { color: var(--accent-dark); }

.control-note { font-size: .82rem; color: var(--ink-soft); background: var(--bg-alt); border-radius: var(--radius-sm); padding: .7rem .85rem; }

/* Preview simulation */
.preview-tabs { display: flex; gap: .5rem; margin-top: 1.6rem; border-bottom: 1px solid var(--border); }
.preview-tab { padding: .6rem 1rem; font-weight: 700; font-size: .9rem; color: var(--ink-soft); border-bottom: 2px solid transparent; }
.preview-tab.is-active { color: var(--accent-dark); border-color: var(--accent); }

.preview-sim { padding-block: 1.4rem; display: flex; justify-content: center; }
.sim-panel { display: flex; flex-direction: column; align-items: center; gap: .8rem; max-width: 100%; }
.sim-hint { font-size: .82rem; color: var(--ink-soft); text-align: center; max-width: 42ch; }

.phone-mock {
  width: 260px; background: var(--ink); border-radius: 34px; padding: 10px;
  box-shadow: var(--shadow);
}
.phone-notch { width: 70px; height: 16px; background: var(--ink); border-radius: 0 0 10px 10px; margin: 0 auto 6px; }
.phone-header { display: flex; align-items: center; gap: .5rem; background: var(--surface); padding: .5rem .6rem; border-radius: 12px 12px 0 0; }
.phone-avatar { width: 26px; height: 26px; border-radius: 50%; background: linear-gradient(135deg, var(--coral), var(--accent)); flex-shrink: 0; }
.phone-lines { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.phone-lines span { height: 6px; border-radius: 4px; background: var(--border); }
.phone-lines span:first-child { width: 70%; }
.phone-lines span:last-child { width: 40%; }
.phone-track {
  width: 100%; aspect-ratio: 1/1; background: var(--bg-alt); overflow-x: auto; overflow-y: hidden;
  display: flex; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; cursor: grab;
  scrollbar-width: none;
}
.phone-track::-webkit-scrollbar { display: none; }
.phone-track.is-dragging { cursor: grabbing; scroll-snap-type: none; }
.phone-track img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: cover; scroll-snap-align: start; pointer-events: none; user-select: none; }
.phone-actions { display: flex; align-items: center; gap: .7rem; background: var(--surface); padding: .55rem .6rem; color: var(--ink); }
.phone-save { margin-left: auto; }
.phone-caption { background: var(--surface); padding: 0 .6rem .6rem; border-radius: 0 0 12px 12px; font-size: .78rem; color: var(--ink-soft); }
.phone-caption b { color: var(--ink); }

.grid-mock-wrap { width: 100%; max-width: 320px; }
.grid-mock { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.grid-cell { aspect-ratio: 1/1; background: var(--bg-alt); position: relative; overflow: hidden; }
.grid-cell img { width: 100%; height: 100%; object-fit: cover; }
.grid-cell.is-placeholder { background: repeating-linear-gradient(45deg, var(--bg-alt), var(--bg-alt) 8px, var(--border) 8px, var(--border) 9px); }
.grid-cell-badge {
  position: absolute; top: 4px; left: 4px; background: rgba(28,21,38,.72); color: #fff;
  font-size: .62rem; font-weight: 700; padding: .1rem .35rem; border-radius: 4px;
}

/* Thumbnails + results */
.result-block { margin-top: 1.8rem; border-top: 1px solid var(--border); padding-top: 1.4rem; }
.thumbs-row { display: flex; flex-wrap: wrap; gap: .7rem; }
.thumb {
  position: relative; width: 84px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border);
  background: var(--bg-alt); flex-shrink: 0;
}
.thumb canvas, .thumb img { width: 100%; display: block; }
.thumb-order {
  position: absolute; top: 4px; left: 4px; background: var(--accent); color: #fff;
  font-size: .68rem; font-weight: 800; padding: .05rem .4rem; border-radius: 999px;
}
.thumb-dl {
  position: absolute; bottom: 0; right: 0; left: 0; background: rgba(28,21,38,.72); color: #fff;
  font-size: .68rem; font-weight: 700; text-align: center; padding: .25rem 0;
  opacity: 0; transition: opacity .15s var(--ease-out);
}
.thumb:hover .thumb-dl, .thumb:focus-within .thumb-dl { opacity: 1; }

.result-actions { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 1.2rem; align-items: center; }
.btn-primary, .btn-secondary, .btn-text {
  border-radius: 999px; font-weight: 700; padding: .8rem 1.4rem; font-size: .95rem;
  display: inline-flex; align-items: center; gap: .5rem; transition: transform .15s var(--ease-out), box-shadow .15s var(--ease-out);
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 10px 24px -10px rgba(108,76,241,.6); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 14px 28px -10px rgba(108,76,241,.7); }
.btn-secondary { background: var(--accent-soft); color: var(--accent-dark); }
.btn-secondary:hover { transform: translateY(-1px); }
.btn-text { color: var(--ink-soft); text-decoration: underline; padding-inline: .3rem; }

.privacy-badge { margin-top: 1.3rem; font-size: .88rem; color: var(--success); font-weight: 600; }
.limits-note { margin-top: .35rem; font-size: .82rem; color: var(--ink-soft); }

/* =============================================================
   5. Ad slots
   ============================================================= */
.ad-slot {
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  color: var(--ink-soft); font-weight: 700; font-size: .78rem; letter-spacing: .08em;
  background: var(--bg-alt);
}
.ad-leaderboard { min-height: 90px; margin-block: 2rem; }
.ad-incontent { min-height: 250px; margin-block: 2rem; max-width: 336px; margin-inline: auto; }
.ad-popup { min-height: 200px; margin-bottom: 1rem; }
.ad-corner { min-height: 100px; width: 260px; }

.download-dialog {
  border: 0; border-radius: var(--radius); padding: 1.4rem; max-width: 340px; width: calc(100% - 2.5rem);
  box-shadow: var(--shadow); background: var(--surface); color: var(--ink);
}
.download-dialog::backdrop { background: rgba(20, 14, 30, .55); }
.dialog-close { position: absolute; top: .7rem; right: .8rem; font-size: 1rem; color: var(--ink-soft); }
.dialog-caption { text-align: center; font-weight: 600; margin-bottom: 1rem; }
.download-dialog .btn-secondary { width: 100%; justify-content: center; }

.corner-ad {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 500;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: .6rem;
}
.corner-ad-close {
  position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: .65rem; display: flex; align-items: center; justify-content: center;
}
@media (max-width: 539px) { .corner-ad { left: 1rem; right: 1rem; } .ad-corner { width: 100%; } }

/* =============================================================
   6. Content sections
   ============================================================= */
.section { padding-block: 2.2rem; }
.section h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); margin-bottom: 1.2rem; text-align: center; }

.steps-grid { display: grid; gap: 1.1rem; }
@media (min-width: 720px) { .steps-grid { grid-template-columns: repeat(3, 1fr); } }
.step-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem; }
.step-num {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent-dark); font-weight: 800; margin-bottom: .8rem;
}
.step-card h3 { font-size: 1.05rem; margin-bottom: .4rem; }
.step-card p { color: var(--ink-soft); font-size: .92rem; }

.seo-copy { max-width: 760px; }
.seo-copy h2 { text-align: left; }
.seo-copy p { color: var(--ink-soft); margin-bottom: 1rem; }
.seo-copy strong { color: var(--ink); }

.ideas-grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) { .ideas-grid { grid-template-columns: repeat(4, 1fr); } }
.idea-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; }
.idea-icon { color: var(--accent); margin-bottom: .7rem; }
.idea-card h3 { font-size: .95rem; margin-bottom: .4rem; }
.idea-card p { font-size: .84rem; color: var(--ink-soft); }

.faq-list { max-width: 760px; margin-inline: auto; display: flex; flex-direction: column; gap: .6rem; }
.faq-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .9rem 1.1rem; }
.faq-item summary { font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 1.2rem; color: var(--accent); flex-shrink: 0; }
.faq-item[open] summary::after { content: "–"; }
.faq-item p { margin-top: .7rem; color: var(--ink-soft); font-size: .92rem; }

/* =============================================================
   7. Footer
   ============================================================= */
.site-footer { border-top: 1px solid var(--border); padding-block: 1.6rem; margin-top: 1rem; }
.footer-inner { display: flex; flex-direction: column; gap: .6rem; align-items: center; text-align: center; color: var(--ink-soft); font-size: .85rem; }
.footer-links { display: flex; gap: 1rem; }
.footer-links a:hover { color: var(--accent-dark); }
.footer-disclaimer { font-size: .75rem; opacity: .75; max-width: 50ch; }

/* =============================================================
   8. Legal pages
   ============================================================= */
.legal-page { max-width: 720px; margin-inline: auto; padding: 2.4rem 1.25rem 3rem; }
.legal-page h1 { font-size: 1.8rem; margin-bottom: 1rem; }
.legal-page h2 { font-size: 1.15rem; margin-top: 1.6rem; margin-bottom: .5rem; }
.legal-page p, .legal-page li { color: var(--ink-soft); margin-bottom: .7rem; }
.legal-page a { color: var(--accent-dark); text-decoration: underline; }

/* =============================================================
   9. Reduced motion — only intrusive effects
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .phone-track { scroll-behavior: auto; }
}

/* =============================================================
   10. No-JS fallback
   ============================================================= */
.no-js-note { display: none; }
html.no-js .tool-drop { display: none; }
html.no-js .no-js-note { display: block; padding: 1.4rem; text-align: center; color: var(--ink-soft); background: var(--bg-alt); border-radius: var(--radius-sm); }
