/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f7f7fb;
  --surface: #ffffff;
  --surface-2: #f0f0f7;
  --border: #e2e2ee;
  --text: #16161f;
  --text-soft: #55566b;
  --text-faint: #85869c;
  --accent: #4338ca;
  --accent-2: #6d5ef1;
  --accent-soft: #ece9fd;
  --ok: #12876b;
  --warn: #b6560f;
  --danger: #c62b3a;
  --cream: #fdfcf9;

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --display: "Manrope", var(--sans);
  --mono: "JetBrains Mono", "IBM Plex Mono", monospace;

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 40, .06), 0 1px 1px rgba(20,20,40,.04);
  --shadow-md: 0 8px 24px rgba(20, 20, 40, .10);
  --shadow-lg: 0 20px 50px rgba(20, 20, 40, .16);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f16;
    --surface: #17171f;
    --surface-2: #1e1e29;
    --border: #2b2b3a;
    --text: #f1f1f7;
    --text-soft: #b6b6c8;
    --text-faint: #7d7e92;
    --accent: #7c72f4;
    --accent-2: #9b8ffb;
    --accent-soft: #24213f;
    --cream: #17171f;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0f16;
  --surface: #17171f;
  --surface-2: #1e1e29;
  --border: #2b2b3a;
  --text: #f1f1f7;
  --text-soft: #b6b6c8;
  --text-faint: #7d7e92;
  --accent: #7c72f4;
  --accent-2: #9b8ffb;
  --accent-soft: #24213f;
  --cream: #17171f;
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; overflow-x: clip; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  overscroll-behavior-y: none;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
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 { text-wrap: balance; line-height: 1.1; letter-spacing: -0.01em; font-family: var(--display); }
ul { list-style: none; padding: 0; }
::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(--text); color: var(--bg);
  z-index: 9999; border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: 1160px; margin-inline: auto; padding-inline: clamp(1rem, 4vw, 2rem); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.section { padding-block: clamp(2.6rem, 6vw, 4.5rem); }
.section-head { max-width: 640px; margin-bottom: clamp(1.6rem, 4vw, 2.4rem); }
.section-head .kicker { display: block; font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: .5rem; }
.section-head h2 { font-size: clamp(1.6rem, 3.2vw, 2.3rem); margin-bottom: .5rem; }
.section-head p { color: var(--text-soft); font-size: 1.02rem; }
.badge {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .35rem .7rem; border-radius: 100px;
  background: var(--accent-soft); color: var(--accent);
  font-size: .82rem; font-weight: 600;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .8rem 1.3rem; border-radius: 100px;
  font-weight: 700; font-size: .96rem;
  transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out), background .2s var(--ease-out);
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-2); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface); border-color: var(--accent); }
.btn-ghost { color: var(--accent); }
.btn-ghost:hover { text-decoration: underline; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }
.btn svg { width: 1.1em; height: 1.1em; flex-shrink: 0; }
.btn-block { width: 100%; }

/* =============================================================
   4. Header / Footer
   ============================================================= */
.site-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem clamp(1rem, 4vw, 2rem);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
@supports not (backdrop-filter: blur(1px)) { .site-header { background: var(--bg); } }
.logo { display: flex; align-items: center; gap: .55rem; font-family: var(--display); font-weight: 800; font-size: 1.15rem; }
.logo .logo-mark { width: 30px; height: 30px; color: var(--accent); }
.header-nav { display: flex; align-items: center; gap: 1.4rem; }
.header-nav a { font-size: .92rem; font-weight: 600; color: var(--text-soft); }
.header-nav a:hover { color: var(--accent); }
.header-nav a.btn-primary { color: #fff; }

.site-footer { border-top: 1px solid var(--border); padding-block: 2.4rem; color: var(--text-soft); font-size: .88rem; }
.footer-grid { display: flex; flex-wrap: wrap; gap: 1.5rem; justify-content: space-between; align-items: center; }
.footer-links { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.footer-links a:hover { color: var(--accent); }
.footer-credits { margin-top: 1rem; font-size: .78rem; color: var(--text-faint); }

/* =============================================================
   5. Hero + Tool card
   ============================================================= */
.hero { padding-block: clamp(1.8rem, 5vw, 3rem) clamp(1.2rem, 3vw, 2rem); text-align: center; }
.hero h1 { font-size: clamp(1.9rem, 4.4vw, 3rem); max-width: 20ch; margin-inline: auto; margin-bottom: .7rem; }
.hero .subtitle { color: var(--text-soft); font-size: clamp(1rem, 1.6vw, 1.18rem); max-width: 46ch; margin-inline: auto; }
.hero .hero-badges { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; margin-top: 1rem; }

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: clamp(1rem, 3vw, 1.8rem);
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.4rem;
}
@media (min-width: 960px) {
  .tool-card { grid-template-columns: 1fr 1fr; align-items: stretch; }
}

.tool-panel { display: flex; flex-direction: column; gap: 1.1rem; min-width: 0; }
.field { display: flex; flex-direction: column; gap: .4rem; }
.field label, .field legend { font-size: .82rem; font-weight: 700; color: var(--text-soft); padding: 0; }
.field input[type="text"], .field input[type="url"], .field input[type="password"], .field textarea {
  width: 100%; padding: .7rem .85rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: .96rem; font-family: var(--sans);
  transition: border-color .2s var(--ease-out), background .2s var(--ease-out);
}
.field input:focus, .field textarea:focus { border-color: var(--accent); background: var(--surface); outline: none; }
.field .hint { font-size: .78rem; color: var(--text-faint); }

.tabs { display: flex; gap: .4rem; padding: .25rem; background: var(--surface-2); border-radius: 100px; border: 1px solid var(--border); }
.tabs button {
  flex: 1; padding: .5rem .6rem; border-radius: 100px; font-size: .84rem; font-weight: 700;
  color: var(--text-soft); transition: background .2s var(--ease-out), color .2s var(--ease-out);
}
.tabs button[aria-selected="true"] { background: var(--accent); color: #fff; }

.tab-panel[hidden] { display: none; }

.swatch-row { display: flex; flex-wrap: wrap; gap: .55rem; }
.swatch-row.style-row { gap: .5rem; }
.style-opt {
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  padding: .5rem .3rem; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--surface-2); font-size: .74rem; font-weight: 600; color: var(--text-soft);
  width: 78px; transition: border-color .15s var(--ease-out), background .15s var(--ease-out);
}
.style-opt svg { width: 30px; height: 30px; }
.style-opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.style-opt:hover { border-color: var(--accent-2); }

.color-field { display: flex; align-items: center; gap: .7rem; }
.color-field input[type="color"] {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--border);
  padding: 0; cursor: pointer; background: none;
}
.color-field .swatch-label { font-size: .84rem; color: var(--text-soft); font-family: var(--mono); }
.color-pair { display: flex; gap: 1.2rem; flex-wrap: wrap; }

.emoji-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.emoji-btn {
  width: 42px; height: 42px; display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--surface-2); transition: border-color .15s var(--ease-out);
}
.emoji-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.upload-row { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.upload-row .file-label {
  display: inline-flex; align-items: center; gap: .4rem; padding: .55rem .9rem;
  border-radius: var(--radius-sm); border: 1.5px dashed var(--border); font-size: .84rem;
  font-weight: 600; color: var(--text-soft); cursor: pointer;
}
.upload-row .file-label:hover { border-color: var(--accent); color: var(--accent); }
.upload-row input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.center-clear { font-size: .8rem; color: var(--accent); font-weight: 600; }

/* result / preview column */
.preview-col { display: flex; flex-direction: column; gap: .9rem; min-width: 0; }
.preview-col::after { content: ""; flex: 1; }
.preview-2d {
  background: var(--surface-2); border-radius: var(--radius); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; padding: 1.2rem; min-height: 240px;
}
.preview-2d canvas, .preview-2d svg, .preview-2d img { max-width: 220px; max-height: 220px; border-radius: 6px; }

.warnings { display: flex; flex-direction: column; gap: .4rem; }
.warning-line {
  display: flex; gap: .5rem; align-items: flex-start; font-size: .82rem;
  padding: .55rem .7rem; border-radius: var(--radius-sm); background: var(--surface-2);
  color: var(--text-soft); border: 1px solid var(--border);
}
.warning-line svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: .12rem; }
.warning-line.is-bad { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.warning-line.is-warn { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); }
.warning-line.is-ok { background: color-mix(in srgb, var(--ok) 10%, var(--surface)); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, var(--border)); }

.dl-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.dl-row .btn { padding: .7rem .9rem; font-size: .88rem; }
.dl-row-secondary { display: flex; justify-content: space-between; align-items: center; gap: .6rem; font-size: .82rem; color: var(--text-faint); flex-wrap: wrap; }

.privacy-badge {
  display: flex; align-items: center; gap: .5rem; font-size: .82rem; color: var(--text-soft);
  padding: .6rem .8rem; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.privacy-badge svg { width: 18px; height: 18px; color: var(--ok); flex-shrink: 0; }
.limits-note { font-size: .78rem; color: var(--text-faint); }

/* =============================================================
   6. 3D panel
   ============================================================= */
.tool-3d { grid-column: 1 / -1; border-top: 1px solid var(--border); padding-top: 1.2rem; margin-top: .2rem; }
.tool-3d-grid { display: grid; grid-template-columns: 1fr; gap: 1.3rem; }
@media (min-width: 960px) { .tool-3d-grid { grid-template-columns: 1.05fr 1fr; } }
.tool-3d h3 { font-size: 1.15rem; margin-bottom: .3rem; }
.tool-3d .sub { color: var(--text-soft); font-size: .9rem; margin-bottom: .9rem; }

.format-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.format-opt {
  flex: 1 1 100px; display: flex; flex-direction: column; align-items: center; gap: .4rem;
  padding: .7rem .5rem; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--surface-2); font-size: .8rem; font-weight: 700; color: var(--text-soft);
}
.format-opt svg { width: 34px; height: 34px; }
.format-opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.viewer-wrap {
  position: relative; border-radius: var(--radius); overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border);
  aspect-ratio: 4 / 3; min-height: 260px;
}
.viewer-wrap canvas { width: 100% !important; height: 100% !important; display: block; }
.viewer-status {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .6rem; text-align: center; padding: 1rem; font-size: .86rem; color: var(--text-soft);
  background: var(--surface-2); transition: opacity .25s var(--ease-out);
}
.viewer-wrap[data-viewer-state="ready"] .viewer-status { opacity: 0; pointer-events: none; }
.viewer-hint { position: absolute; bottom: .6rem; left: 0; right: 0; text-align: center; font-size: .74rem; color: var(--text-faint); pointer-events: none; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border);
  border-top-color: var(--accent); animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================================
   7. Ad slots
   ============================================================= */
.ad-slot {
  display: flex; align-items: center; justify-content: center;
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  color: var(--text-faint); font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 10px, var(--surface) 10px 20px);
}
.ad-slot-banner { min-height: 90px; margin-block: 1rem; }
.ad-slot-incontent { min-height: 250px; margin-block: 1rem; max-width: 728px; margin-inline: auto; }
.ad-slot-square { min-height: 200px; }

.ad-popup {
  border: none; border-radius: var(--radius-lg); padding: 0; max-width: 380px; width: min(90vw, 380px);
  box-shadow: var(--shadow-lg); background: var(--surface); color: var(--text);
}
.ad-popup::backdrop { background: rgba(10,10,20,.55); backdrop-filter: blur(2px); }
.ad-popup-inner { padding: 1.3rem; display: flex; flex-direction: column; gap: .8rem; }
.ad-popup-head { display: flex; justify-content: space-between; align-items: center; }
.ad-popup-head span { font-size: .78rem; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; }
.ad-popup-close { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 1rem; }
.ad-popup-close:hover { background: var(--border); }
.ad-popup .ad-slot { min-height: 220px; }
.ad-popup-foot { display: flex; justify-content: flex-end; }

.corner-toast {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 200;
  max-width: 260px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .8rem .9rem;
  display: flex; gap: .6rem; align-items: flex-start;
  transition: transform .3s var(--ease-out), opacity .3s var(--ease-out);
}
.corner-toast[hidden] { display: flex; opacity: 0; transform: translateY(12px); pointer-events: none; }
.corner-toast .toast-label { font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); }
.corner-toast .toast-body { font-size: .82rem; color: var(--text-soft); }
.corner-toast button.toast-close { flex-shrink: 0; font-size: 1rem; color: var(--text-faint); line-height: 1; }

/* =============================================================
   8. How it works / usos / faq / more
   ============================================================= */
.steps { display: grid; grid-template-columns: 1fr; gap: 1.2rem; }
@media (min-width: 720px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.step { padding: 1.3rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.step .step-num {
  width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 800; margin-bottom: .8rem;
}
.step h3 { font-size: 1.05rem; margin-bottom: .4rem; }
.step p { color: var(--text-soft); font-size: .92rem; }

.usos-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 720px) { .usos-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .usos-grid { grid-template-columns: repeat(3, 1fr); } }
.uso-card { display: flex; gap: .9rem; padding: 1.1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.uso-card .uso-icon {
  width: 42px; height: 42px; flex-shrink: 0; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.uso-card .uso-icon svg { width: 22px; height: 22px; }
.uso-card h3 { font-size: 1rem; margin-bottom: .25rem; }
.uso-card p { font-size: .88rem; color: var(--text-soft); }

.seo-copy { max-width: 720px; color: var(--text-soft); }
.seo-copy p { margin-bottom: 1rem; }
.seo-copy h2 { color: var(--text); font-size: clamp(1.4rem, 3vw, 1.9rem); margin-bottom: .8rem; }

.faq-list { max-width: 760px; display: flex; flex-direction: column; gap: .6rem; }
.faq-item { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.faq-item summary {
  padding: 1rem 1.2rem; font-weight: 700; cursor: pointer; list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 1.3rem; color: var(--accent); flex-shrink: 0; transition: transform .2s var(--ease-out); }
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item .faq-a { padding: 0 1.2rem 1.1rem; color: var(--text-soft); font-size: .93rem; }

.more-tools-note { padding: 1.4rem; border-radius: var(--radius); background: var(--surface-2); border: 1px dashed var(--border); color: var(--text-soft); font-size: .9rem; }

.js-off-note { display: none; padding: 1.2rem; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); text-align: center; color: var(--text-soft); }
html.no-js .js-off-note { display: block; }
html.no-js .tool-panel, html.no-js .preview-col, html.no-js .tool-3d { display: none; }

/* =============================================================
   9. Reduced motion (only intrusive)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .corner-toast { transition: none; }
}

/* =============================================================
   10. Responsive helpers
   ============================================================= */
@media (max-width: 539px) {
  .dl-row { grid-template-columns: 1fr; }
  .header-nav a:not(.btn-primary) { display: none; }
  .format-row { flex-direction: column; }
  .format-opt { flex-direction: row; justify-content: flex-start; }
}
