:root {
  --bg: #eef2ef;
  --grid: rgba(20, 32, 26, 0.04);
  --surface: #ffffff;
  --text: #121a16;
  --muted: #5a6a61;
  --line: #d7e0da;
  --accent: #0f766e;
  --accent-2: #12a594;
  --accent-soft: #d7f3ee;
  --cta: #c8f06c;
  --cta-text: #14201a;
  --spark: #c45c26;
  --spark-soft: #fce8dc;
  --danger: #b42318;
  --radius: 20px;
  --shadow: 0 20px 60px rgba(18, 26, 22, 0.08);
  --font: "Manrope", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

/* display:flex/grid на .field/.result-view иначе перебивает атрибут hidden */
[hidden] { display: none !important; }

body.app-body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 20px;
  padding: 14px 24px;
  background: rgba(238, 242, 239, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--text);
  letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.top-nav { display: flex; gap: 16px; flex: 1; }
.top-nav a { color: var(--muted); font-weight: 500; font-size: 0.92rem; }
.top-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-email { color: var(--muted); font-size: 0.85rem; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sparks-pill {
  display: inline-flex; gap: 4px; align-items: center;
  padding: 6px 12px; border-radius: 999px;
  background: var(--spark-soft); color: var(--spark); font-weight: 700;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 14px; padding: 12px 18px;
  font-weight: 700; cursor: pointer;
  transition: transform .15s, background .15s, box-shadow .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-sm { padding: 8px 14px; font-size: 0.88rem; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-accent {
  background: var(--cta); color: var(--cta-text);
  box-shadow: 0 10px 28px rgba(200, 240, 108, 0.35);
}
.btn-accent:hover:not(:disabled) { transform: translateY(-1px); }
.btn-ghost {
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
}
.cost-badge {
  display: inline-flex; padding: 2px 8px; border-radius: 999px;
  background: rgba(20,32,26,.08); font-size: 0.85rem;
}

.intro {
  text-align: center;
  padding: 28px 20px 8px;
  max-width: 720px;
  margin: 0 auto;
}
.intro-brand {
  font-family: var(--display);
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  margin: 0 0 6px;
  letter-spacing: -0.03em;
}
.intro h1 {
  margin: 0 0 10px;
  font-size: clamp(1.15rem, 2.5vw, 1.45rem);
  font-weight: 600;
  color: var(--muted);
}
.intro-lead { margin: 0; color: var(--muted); }

.studio {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 18px;
  padding: 18px 20px 40px;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-left { padding: 18px; display: flex; flex-direction: column; gap: 22px; }
.panel-right {
  min-height: 640px;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.92), rgba(255,255,255,.88)),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: auto, 28px 28px, 28px 28px;
}

.step-label {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; margin-bottom: 12px;
}
.step-label span {
  color: #9aaba1; font-size: 1.4rem; letter-spacing: 0.04em;
}
.step-num { color: #9aaba1; font-size: 1.6rem; font-weight: 800; }

.dropzone {
  display: block;
  border: 1.5px dashed #b7c7be;
  border-radius: 16px;
  background: linear-gradient(180deg, #fbfdfc, #f3f7f4);
  min-height: 180px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-drag {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone-empty {
  min-height: 180px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; text-align: center; padding: 18px; color: var(--muted);
}
.dropzone-empty strong { color: var(--text); }
.dropzone-empty em { font-style: normal; font-size: 0.8rem; opacity: .85; }
.dz-icon {
  width: 44px; height: 44px; border-radius: 12px; margin-bottom: 6px;
  display: grid; place-items: center;
  background: #fff; border: 1px solid var(--line); font-size: 1.2rem;
}
.dropzone-filled { padding: 12px; text-align: center; }
.dropzone-filled img {
  width: 100%; max-height: 220px; object-fit: contain; border-radius: 12px; background: #fff;
}
.detect-bar {
  margin-top: 10px; padding: 10px 12px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent); font-weight: 650; font-size: 0.9rem;
}

.seg {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  background: #f1f5f2; padding: 5px; border-radius: 14px; margin-bottom: 8px;
}
.seg-sm { grid-template-columns: 1fr 1fr; }
.seg-btn {
  border: none; background: transparent; border-radius: 11px;
  padding: 10px 8px; font-weight: 700; color: var(--muted); cursor: pointer;
}
.seg-btn.is-active { background: #1c2520; color: #fff; }
.hint { margin: 0 0 12px; color: var(--muted); font-size: 0.88rem; }

.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.field > span, .field-row span { font-weight: 700; font-size: 0.9rem; color: var(--muted); }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field select, .field input, .field textarea, .quiz-custom {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 12px; background: #fff; color: var(--text);
}
.field textarea { resize: vertical; min-height: 110px; line-height: 1.45; }
.counter { text-align: right; color: var(--muted); font-size: 0.8rem; margin-top: -6px; }

.chip-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 6px 10px; font-weight: 700; font-size: 0.82rem; cursor: pointer; color: var(--text);
}
.chip-btn:hover { border-color: var(--accent); background: var(--accent-soft); }

.concept-list { display: flex; flex-direction: column; gap: 8px; }
.concept-card {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  border: 1px solid var(--line); background: #fafcfb; border-radius: 14px;
  padding: 12px 14px; cursor: pointer; font: inherit;
}
.concept-card strong { color: var(--text); }
.concept-card span { color: var(--muted); font-size: 0.82rem; }
.concept-card.is-active { border-color: var(--accent); background: var(--accent-soft); }

.adv {
  border: 1px solid var(--line); border-radius: 14px; padding: 0 12px; margin-bottom: 14px; background: #f7faf8;
}
.adv summary {
  cursor: pointer; font-weight: 750; padding: 12px 0; list-style: none;
}
.adv summary::-webkit-details-marker { display: none; }
.adv-body { padding-bottom: 14px; }
.adv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.mini-upload {
  border: 1.5px dashed #b7c7be; border-radius: 12px; min-height: 88px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.82rem; background: #fff;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 12px;
  padding: 9px 12px; cursor: pointer; font-weight: 700; color: var(--text);
}
.chip i { font-style: normal; color: var(--accent-2); margin-left: 4px; }
.chip.is-active { background: #1c2520; color: #fff; border-color: #1c2520; }
.chip.is-active i { color: var(--cta); }

.premium-toggle {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px;
  background: #fff; cursor: pointer; font-weight: 700;
}
.premium-toggle input { width: 18px; height: 18px; accent-color: var(--cta); }
.premium-toggle .price { margin-left: auto; color: var(--accent-2); font-weight: 600; font-size: 0.85rem; }
.premium-hint { margin: 8px 0 0; font-size: 0.78rem; line-height: 1.35; }

.variant-row {
  display: flex; gap: 10px; width: 100%; margin-bottom: 12px; overflow-x: auto;
  padding-bottom: 4px;
}
.variant-chip {
  flex: 0 0 auto; width: 96px; border: 2px solid var(--line); border-radius: 12px;
  background: #fff; padding: 4px; cursor: pointer; text-align: center;
}
.variant-chip img {
  display: block; width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 8px;
}
.variant-chip span {
  display: block; margin-top: 4px; font-size: 0.72rem; font-weight: 700; color: var(--muted);
}
.variant-chip.is-active { border-color: var(--cta); }
.variant-chip.is-active span { color: var(--text); }

.warn-list {
  margin: 0; padding-left: 1.1rem; color: #8a4b00; font-size: 0.82rem; line-height: 1.45;
}
.warn-list li { margin-bottom: 4px; }
#warningsBlock { background: #fff8e8; border-radius: 12px; padding: 10px 12px; }

.meta-line, .status-line { margin: 8px 0 0; color: var(--muted); font-size: 0.85rem; }
.status-line.is-error { color: var(--danger); }

.results-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.results-head h2 { margin: 0; font-size: 1.2rem; }
.results-canvas {
  min-height: 520px; border-radius: 16px; position: relative;
  display: grid; place-items: center;
}
.results-empty { color: var(--muted); text-align: center; }
.gen-progress {
  text-align: center; width: min(320px, 90%);
}
.spark-mark {
  width: 48px; height: 48px; margin: 0 auto 10px; border-radius: 14px;
  display: grid; place-items: center; background: var(--cta); font-size: 1.3rem;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
.bar {
  height: 8px; border-radius: 999px; background: #e3ebe6; overflow: hidden; margin: 12px 0 8px;
}
.bar i {
  display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--cta));
  transition: width .25s linear;
}
.result-view {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(240px, 1.2fr) minmax(220px, 0.9fr);
  gap: 16px;
  align-items: start;
}
.result-media {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.result-media img {
  width: 100%;
  display: block;
  background: #f4f7f5;
  max-height: 520px;
  object-fit: contain;
}
.result-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
}
.icon-btn {
  width: 42px; height: 42px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  font-size: 1.05rem;
}
.icon-btn.is-good { border-color: #86c96a; }
.btn-download {
  flex: 1;
  min-height: 44px;
  font-size: 1rem;
}
.result-side {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow);
}
.result-actions-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.btn-dark {
  background: #1c2520;
  color: #fff;
}
.btn-dark:hover:not(:disabled) { background: #111814; }
.meta-block h4 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}
.meta-block p { margin: 0; color: var(--text); font-size: 0.92rem; line-height: 1.45; }
.wishes-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.wishes-clamp.is-open {
  display: block;
  -webkit-line-clamp: unset;
}
.improve-block input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  margin-bottom: 8px;
  background: #f7faf8;
}
.version-chip {
  display: inline-flex;
  padding: 6px 12px;
  border-radius: 999px;
  background: #1c2520;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 6px;
}
@media (max-width: 960px) {
  .result-view { grid-template-columns: 1fr; }
}

.marketing { padding: 48px 20px; }
.marketing .container { max-width: 1000px; margin: 0 auto; text-align: center; }
.marketing h2 { margin: 0 0 18px; font-size: 1.8rem; }
.marketing .lead { color: var(--muted); margin: -8px 0 22px; }
.m-grid, .price-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; text-align: left;
}
.m-grid article, .price-row article {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px;
}
.m-grid strong { color: #9aaba1; font-size: 1.3rem; }
.m-grid h3, .price-row h3 { margin: 8px 0; }
.m-grid p, .price-row p { margin: 0; color: var(--muted); }
.price-row .amt { font-size: 1.8rem; font-weight: 800; }
.price-row .hi { border-color: var(--accent); background: linear-gradient(180deg, #fff, #f1faf8); }
.price-row .pack-buy { margin-top: 14px; width: 100%; }

.site-footer {
  border-top: 1px solid var(--line); padding: 24px; text-align: center; color: var(--muted);
}

.modal {
  border: none; padding: 0; background: transparent;
  width: min(440px, calc(100vw - 28px));
}
.modal::backdrop { background: rgba(18, 26, 22, 0.48); backdrop-filter: blur(4px); }
.modal-card {
  background: #fff; border-radius: 22px; padding: 22px;
  border: 1px solid var(--line); box-shadow: var(--shadow);
  position: relative; display: flex; flex-direction: column; gap: 12px;
}
.modal-card h2 { margin: 0; font-size: 1.35rem; }
.modal-x {
  position: absolute; top: 14px; right: 14px;
  width: 34px; height: 34px; border-radius: 999px; border: none;
  background: #1c2520; color: #fff; font-size: 1.2rem; cursor: pointer; line-height: 1;
}
.muted { color: var(--muted); margin: 0; }
.center { text-align: center; }
.linkish {
  background: none; border: none; color: var(--accent); font-weight: 700;
  cursor: pointer; padding: 0; text-align: left; text-decoration: underline;
}
.quiz-progress { color: var(--muted); font-size: 0.88rem; margin: 0; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-opt {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 12px 16px; cursor: pointer; font-weight: 600; text-align: center;
}
.quiz-opt:hover, .quiz-opt.is-active { border-color: var(--accent); background: var(--accent-soft); }
.quiz-custom { margin-top: 4px; }
.auth-error { color: var(--danger); margin: 0; font-size: 0.88rem; }
.legal-mini { font-size: 0.75rem; color: var(--muted); margin: 0; }
.legal-mini a { color: var(--accent); }
.consent-row {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 0.82rem; line-height: 1.35; color: var(--text); margin: 4px 0 8px;
}
.consent-row input { margin-top: 3px; accent-color: var(--cta); }
.consent-row a { color: var(--accent); }
.legal-page {
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 12% -8%, rgba(200, 240, 108, 0.16), transparent 55%),
    radial-gradient(700px 360px at 100% 0%, rgba(15, 118, 110, 0.07), transparent 50%),
    var(--bg);
}
.legal-wrap {
  display: flex;
  justify-content: center;
  padding: 40px 20px 72px;
}
.legal-card {
  width: 100%;
  max-width: 760px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 36px 40px 28px;
  box-shadow: var(--shadow);
}
.legal-meta {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 20px !important;
  line-height: 1.5;
}
.legal-content h3 {
  margin: 16px 0 8px;
  font-size: 0.98rem;
  font-weight: 800;
}
.legal-page h1 {
  margin: 0 0 18px;
  font-family: var(--display);
  font-size: clamp(1.45rem, 2.4vw, 1.85rem);
  letter-spacing: -0.02em;
  line-height: 1.25;
  text-align: center;
}
.legal-content {
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.65;
}
.legal-content p { margin: 0 0 14px; }
.legal-content h2 {
  margin: 22px 0 10px;
  font-size: 1.05rem;
  font-weight: 800;
}
.legal-content ul {
  margin: 0 0 14px;
  padding-left: 1.15rem;
}
.legal-content li { margin: 6px 0; }
.legal-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
  font-weight: 600;
}
.legal-links a { color: var(--accent); }
.site-footer a { color: var(--accent); text-decoration: none; font-weight: 600; }
@media (max-width: 640px) {
  .legal-card { padding: 26px 18px 22px; }
  .legal-page .top-nav { display: none; }
}
.oauth-stack { display: flex; flex-direction: column; gap: 8px; }
.btn-oauth {
  font-weight: 700;
  border-radius: 999px;
  min-height: 46px;
  text-decoration: none;
}
.btn-oauth:hover:not(:disabled) { text-decoration: none; transform: translateY(-1px); }
.btn-yandex { background: #000; color: #fff; }
.btn-yandex:disabled { background: #444; color: #bbb; }
.btn-vk { background: #0077ff; color: #fff; }
.btn-vk:disabled { background: #6aa8f0; color: #e8f1ff; }
.auth-divider {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted); font-size: 0.82rem; margin: 4px 0;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}
.emoji { font-size: 1.6rem; margin: 0; }
.promo-box {
  border: 1.5px dashed var(--accent); background: var(--accent-soft);
  border-radius: 14px; padding: 14px; text-align: center;
}
.promo-box span { display: block; font-size: 0.75rem; color: var(--accent); font-weight: 800; letter-spacing: .04em; }
.promo-box strong { display: block; font-size: 1.5rem; color: var(--accent); margin: 4px 0; }
.promo-box em { font-style: normal; color: var(--muted); }

@media (max-width: 960px) {
  .studio { grid-template-columns: 1fr; }
  .top-nav { display: none; }
  .user-email { display: none; }
  .m-grid, .price-row { grid-template-columns: 1fr; }
  .panel-right { min-height: 420px; }
}
