/* ==========================================================================
   1. Custom properties
   ========================================================================== */
:root {
  --bg: #FAF9F6;
  --cream: #FFFFFF;
  --ink: #1B1B22;
  --ink-soft: #55555F;
  --accent: #E8622C;
  --accent-ink: #FFFFFF;
  --border: #E6E3DC;
  --border-strong: #D6D2C7;
  --success: #2E7D4F;
  --danger: #C4432B;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Fraunces", Georgia, serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --gutter: clamp(1.1rem, 4vw, 2.4rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17171B;
    --cream: #1F1F25;
    --ink: #F2F1EC;
    --ink-soft: #B3B2AC;
    --border: #33333B;
    --border-strong: #45454F;
  }
}

/* ==========================================================================
   2. Reset
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
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; }
input, select { font: inherit; color: inherit; }
p { text-wrap: pretty; }
h1, h2, h3 { font-family: var(--serif); text-wrap: balance; line-height: 1.1; letter-spacing: -0.01em; font-weight: 600; }
::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: var(--bg);
  z-index: 9999; border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 var(--gutter); }

/* ==========================================================================
   3. Header
   ========================================================================== */
.site-header { padding: 1.1rem 0; border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.05rem; }
.header-nav { display: none; gap: 1.6rem; font-weight: 600; font-size: .92rem; color: var(--ink-soft); }
.header-nav a:hover { color: var(--ink); }
@media (min-width: 720px) { .header-nav { display: flex; } }

/* ==========================================================================
   4. Hero
   ========================================================================== */
.hero { padding: clamp(1.8rem, 5vw, 3.2rem) 0 1.4rem; text-align: center; }
.hero h1 { font-size: clamp(1.7rem, 4vw, 2.7rem); max-width: 18ch; margin: 0 auto; }
.hero-sub { color: var(--ink-soft); max-width: 56ch; margin: .9rem auto 0; font-size: clamp(.98rem, 1.6vw, 1.1rem); }

/* Landing pages (use-case pages) */
.breadcrumb { font-size: .82rem; color: var(--ink-soft); padding-top: 1.2rem; }
.breadcrumb a { color: var(--ink-soft); }
.breadcrumb a:hover { color: var(--accent); }
.landing-cta-wrap { text-align: center; margin: 1.6rem 0; }
.landing-cta {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .9rem 1.9rem; border-radius: 999px; font-weight: 700; font-size: 1rem;
  background: var(--accent); color: var(--accent-ink); text-decoration: none;
  transition: transform .15s var(--ease-out);
}
.landing-cta:hover { transform: translateY(-1px); }
.related-links { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .6rem; }
.related-links a {
  border: 1px solid var(--border-strong); border-radius: 999px; padding: .5rem 1rem;
  font-size: .84rem; font-weight: 600; color: var(--ink);
}
.related-links a:hover { border-color: var(--accent); color: var(--accent); }

/* ==========================================================================
   5. Tool card
   ========================================================================== */
.tool-section { padding-bottom: 2.2rem; }
.tool-card, .threed-card {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(1.1rem, 3vw, 1.8rem);
  margin-bottom: 1.3rem;
}
.threed-title { font-size: 1.3rem; margin-bottom: 1rem; }

.tool-grid { display: grid; gap: 1.6rem; grid-template-columns: 1fr; }
@media (max-width: 859px) { .tool-preview { order: -1; } }
@media (min-width: 860px) { .tool-grid { grid-template-columns: 1fr 1fr; align-items: start; } }

.field-group { margin-bottom: 1.3rem; }
.field-group:last-child { margin-bottom: 0; }
.field-label { display: block; font-weight: 700; font-size: .88rem; margin-bottom: .5rem; }

.text-input {
  width: 100%; padding: .7rem .85rem; border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--bg); color: var(--ink);
  font-size: .96rem; transition: border-color .15s var(--ease-out);
}
.text-input:focus { border-color: var(--accent); }

.mode-tabs { display: inline-flex; gap: .3rem; padding: .25rem; background: var(--bg); border-radius: 999px; margin-bottom: .9rem; border: 1px solid var(--border); }
.mode-tab { padding: .45rem 1rem; border-radius: 999px; font-size: .85rem; font-weight: 700; color: var(--ink-soft); }
.mode-tab.is-active { background: var(--ink); color: var(--bg); }
.mode-panel.is-hidden { display: none; }
.wifi-grid { display: grid; gap: .7rem; }

.style-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
@media (min-width: 480px) { .style-grid { grid-template-columns: repeat(4, 1fr); } }
.style-opt {
  padding: .6rem .5rem; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: .85rem; font-weight: 700; text-align: center; transition: all .15s var(--ease-out);
}
.style-opt.is-active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }

.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.color-field { display: flex; align-items: center; justify-content: space-between; padding: .5rem .7rem; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); font-weight: 600; font-size: .88rem; }
.color-field input[type=color] { width: 36px; height: 36px; border: none; border-radius: 8px; padding: 0; background: none; cursor: pointer; }

.hint { font-size: .82rem; color: var(--ink-soft); margin-top: .5rem; }
.hint.warn { color: var(--danger); font-weight: 700; }
.hint.ok { color: var(--success); font-weight: 600; }

.emoji-grid { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .7rem; }
.emoji-opt {
  width: 40px; height: 40px; font-size: 1.25rem; display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); transition: all .15s var(--ease-out);
}
.emoji-opt.is-active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.logo-upload-row { display: flex; gap: .6rem; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .8rem 1.3rem; border-radius: 999px; font-weight: 700; font-size: .95rem;
  transition: transform .15s var(--ease-out), background .15s var(--ease-out);
}
.btn-primary { background: var(--accent); color: var(--accent-ink); width: 100%; }
.btn-primary:hover { transform: translateY(-1px); }
.btn-secondary { background: var(--ink); color: var(--bg); width: 100%; }
.btn-ghost { background: var(--bg); border: 1.5px solid var(--border-strong); }
.btn-small { padding: .5rem .9rem; font-size: .82rem; }
.btn-link { display: block; margin: .7rem auto 0; font-size: .84rem; font-weight: 700; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; }
.btn-link:hover { color: var(--accent); }

.tool-preview { display: flex; flex-direction: column; }
.preview-2d-wrap, .preview-3d-wrap {
  background: repeating-conic-gradient(var(--bg) 0% 25%, var(--cream) 0% 50%) 0 0 / 20px 20px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.preview-2d-wrap canvas { width: 100%; height: 100%; }
.preview-3d-wrap { position: relative; cursor: grab; touch-action: none; }
.preview-3d-wrap:active { cursor: grabbing; }
.viewer3d-placeholder { color: var(--ink-soft); font-size: .88rem; text-align: center; padding: 1rem; }
.preview-actions { margin-top: .9rem; display: grid; gap: .6rem; grid-template-columns: 1fr 1fr; }
.preview-actions .btn:only-child { grid-column: 1 / -1; }

.warnings { display: grid; gap: .5rem; }
.warning-line { font-size: .84rem; padding: .55rem .7rem; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--border); }
.warning-line.warn { border-color: var(--danger); color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--bg)); }
.warning-line.ok { border-color: var(--success); color: var(--success); background: color-mix(in srgb, var(--success) 8%, var(--bg)); }

.privacy-badge { margin-top: 1.2rem; font-size: .82rem; color: var(--ink-soft); text-align: center; }

/* ==========================================================================
   6. Ad slots
   ========================================================================== */
.ad-slot {
  margin: 1.6rem auto; min-height: 90px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; color: var(--ink-soft); font-size: .8rem;
}
.ad-slot-label { text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.ad-slot-leaderboard { max-width: 1080px; }
.ad-slot-incontent { max-width: 728px; }
.ad-slot-dialog { min-height: 220px; width: 100%; margin-top: .7rem; }

/* ==========================================================================
   7. Content sections
   ========================================================================== */
.content-section { padding: 2.4rem 0; }
.content-section h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); margin-bottom: 1.4rem; }

.steps-grid { display: grid; gap: 1.3rem; grid-template-columns: 1fr; margin-bottom: 2rem; }
@media (min-width: 720px) { .steps-grid { grid-template-columns: repeat(3, 1fr); } }
.step { padding: 1.3rem; border: 1px solid var(--border); border-radius: var(--radius-md); }
.step-icon { color: var(--accent); margin-bottom: .8rem; }
.step h3 { font-size: 1.05rem; margin-bottom: .4rem; }
.step p { color: var(--ink-soft); font-size: .92rem; }

.seo-text { max-width: 74ch; }
.seo-text h3 { font-size: 1.2rem; margin: 1.4rem 0 .6rem; }
.seo-text p { color: var(--ink-soft); margin-bottom: .9rem; }
.seo-text strong { color: var(--ink); }

.ideas-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .ideas-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 960px) { .ideas-grid { grid-template-columns: repeat(4, 1fr); } }
.idea-card { padding: 1.1rem; border: 1px solid var(--border); border-radius: var(--radius-md); }
.idea-emoji { font-size: 1.5rem; margin-bottom: .5rem; }
.idea-card h3 { font-size: .98rem; margin-bottom: .35rem; font-family: var(--sans); font-weight: 800; }
.idea-card h3 a { color: inherit; text-decoration: none; }
.idea-card h3 a:hover { color: var(--accent); text-decoration: underline; }
.idea-card p { color: var(--ink-soft); font-size: .86rem; }

.faq-list { display: grid; gap: .6rem; max-width: 74ch; }
.faq-item { border: 1px solid var(--border); border-radius: var(--radius-md); padding: .2rem .1rem; }
.faq-item summary { padding: .9rem 1rem; 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: "+"; color: var(--accent); font-size: 1.2rem; flex-shrink: 0; }
.faq-item[open] summary::after { content: "−"; }
.faq-item p { padding: 0 1rem 1rem; color: var(--ink-soft); font-size: .92rem; }

/* ==========================================================================
   8. Footer
   ========================================================================== */
.site-footer { border-top: 1px solid var(--border); padding: 1.6rem 0; margin-top: 1rem; }
.footer-inner { display: flex; flex-direction: column; gap: .6rem; font-size: .84rem; color: var(--ink-soft); }
@media (min-width: 640px) { .footer-inner { flex-direction: row; justify-content: space-between; } }
.footer-nav { display: flex; gap: 1rem; }
.footer-nav a:hover { color: var(--ink); }

/* ==========================================================================
   9. Corner toast + download dialog
   ========================================================================== */
.corner-toast {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 60;
  background: var(--cream); border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  padding: .8rem 2.2rem .8rem 1rem; min-width: 220px; min-height: 60px;
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
  font-size: .8rem; color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center;
}
.corner-toast[hidden] { display: none; }
.corner-toast-close {
  position: absolute; top: .35rem; right: .5rem; font-size: 1.1rem; line-height: 1; color: var(--ink-soft); padding: .2rem .4rem;
}
.corner-toast-close:hover { color: var(--ink); }

.download-dialog {
  border: none; border-radius: var(--radius-lg); padding: 0; max-width: 420px; width: calc(100% - 2rem);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.download-dialog::backdrop { background: rgba(0,0,0,.45); }
.dialog-body { padding: 1.4rem; position: relative; text-align: center; }
.dialog-close { position: absolute; top: .6rem; right: .8rem; font-size: 1.3rem; color: var(--ink-soft); padding: .3rem .5rem; }
.dialog-close:hover { color: var(--ink); }
.dialog-body .btn { margin-top: 1rem; }

/* ==========================================================================
   10. Reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn, .style-opt, .emoji-opt { transition: none; }
}
