/* Pobrendu demo — чистый минимализм на акценте #6C5CE7.
   Нейтрали с лёгким фиолетовым уклоном, чтобы серый не выглядел случайным.
   Обе темы описаны токенами: системная тема + ручной data-theme. */

:root {
  --accent:        #6C5CE7;
  --accent-hover:  #5A4AD4;
  --accent-soft:   #EEEBFC;
  --accent-ring:   rgba(108, 92, 231, .32);

  --ground:  #F7F6FB;
  --surface: #FFFFFF;
  --line:    #E4E1F0;
  --ink:     #16151F;
  --muted:   #6B6880;

  --ok:    #157F5B;
  --error: #C3352B;

  --radius:    14px;
  --radius-sm: 10px;
  --shadow:    0 1px 2px rgba(22, 21, 31, .05), 0 12px 32px rgba(22, 21, 31, .06);

  --step-0: 0.9375rem;
  --step-1: 1.0625rem;
  --step-2: 1.375rem;
  --step-3: 1.875rem;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent:       #8B7CF0;
    --accent-hover: #9C90F5;
    --accent-soft:  #241F3D;
    --accent-ring:  rgba(139, 124, 240, .38);

    --ground:  #100F16;
    --surface: #1A1924;
    --line:    #2C2A3A;
    --ink:     #F1F0F7;
    --muted:   #9A97AE;

    --ok:    #4BC49A;
    --error: #F2857C;

    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .32);

    color-scheme: dark;
  }
}

/* Ручное переключение темы должно побеждать медиазапрос в обе стороны. */
:root[data-theme="dark"] {
  --accent: #8B7CF0; --accent-hover: #9C90F5; --accent-soft: #241F3D;
  --accent-ring: rgba(139, 124, 240, .38);
  --ground: #100F16; --surface: #1A1924; --line: #2C2A3A;
  --ink: #F1F0F7; --muted: #9A97AE;
  --ok: #4BC49A; --error: #F2857C;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .32);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --accent: #6C5CE7; --accent-hover: #5A4AD4; --accent-soft: #EEEBFC;
  --accent-ring: rgba(108, 92, 231, .32);
  --ground: #F7F6FB; --surface: #FFFFFF; --line: #E4E1F0;
  --ink: #16151F; --muted: #6B6880;
  --ok: #157F5B; --error: #C3352B;
  --shadow: 0 1px 2px rgba(22, 21, 31, .05), 0 12px 32px rgba(22, 21, 31, .06);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

/* Атрибут hidden обязан побеждать классы с display (.btn, .stage img,
   .stage__loader), иначе «скрытые» узлы остаются на экране. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 var(--step-0)/1.55 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.shell { width: min(1180px, 100% - 2.5rem); margin-inline: auto; }

/* --- Шапка ---------------------------------------------------------- */

.topbar { border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar__inner {
  display: flex; align-items: center; gap: 1rem;
  flex-wrap: wrap; padding: 1rem 0;
}
.wordmark {
  display: inline-flex; align-items: center; gap: .55rem;
  font-weight: 700; font-size: var(--step-1); letter-spacing: -.01em;
  color: var(--ink); text-decoration: none;
}
.wordmark__mark {
  width: 20px; height: 20px; border-radius: 6px;
  background: var(--accent);
  box-shadow: inset 0 0 0 4px var(--surface), inset 0 0 0 7px var(--accent);
}
.topbar__tag { margin: 0; color: var(--muted); font-size: var(--step-0); }

/* --- Раскладка ------------------------------------------------------ */

.layout {
  display: grid; gap: 1.5rem; align-items: start;
  padding: 2rem 0 3rem;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
}
@media (min-width: 901px) {
  .panel--preview { position: sticky; top: 1.5rem; }
}

.panel__title {
  margin: 0 0 .5rem;
  font-size: var(--step-3); line-height: 1.2; letter-spacing: -.02em;
  text-wrap: balance;
}
.panel__title--sm { font-size: var(--step-2); margin: 0; }
.panel__lead { margin: 0 0 1.75rem; color: var(--muted); max-width: 52ch; }

/* --- Поля формы ------------------------------------------------------ */

.field { margin-bottom: 1.25rem; }
.field-group { border: 0; padding: 0; margin: 0 0 1.25rem; }
.field-group__legend {
  padding: 0; margin-bottom: .6rem;
  font-size: .75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
}

.label {
  display: block; margin-bottom: .35rem;
  font-size: .8125rem; font-weight: 600; color: var(--ink);
}
.label__opt { font-weight: 400; color: var(--muted); }

.hint { margin: .35rem 0 0; font-size: .75rem; color: var(--muted); }

.control {
  width: 100%; padding: .625rem .75rem;
  font: inherit; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.control:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
select.control { cursor: pointer; }

.colors { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .875rem; }
@media (max-width: 560px) { .colors { grid-template-columns: 1fr; } }

.color__row { display: flex; gap: .5rem; align-items: center; }
input[type="color"] {
  width: 42px; height: 42px; flex: none; padding: 0; cursor: pointer;
  background: none; border: 1px solid var(--line); border-radius: var(--radius-sm);
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 6px; }

.hex {
  width: 100%; min-width: 0; padding: .5rem .55rem;
  font: 500 .8125rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: uppercase; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.hex[aria-invalid="true"] { border-color: var(--error); }

/* --- Загрузка логотипа ----------------------------------------------- */

.upload { display: flex; align-items: center; gap: .625rem; flex-wrap: wrap; }
.upload__input {
  position: absolute; width: 1px; height: 1px;
  clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden;
}
.upload__input:focus-visible + .btn { outline: 2px solid var(--accent); outline-offset: 2px; }
.upload__state { font-size: .75rem; color: var(--muted); }
.upload__clear {
  padding: 0; font: inherit; font-size: .75rem;
  color: var(--accent); background: none; border: 0; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}

/* --- Кнопки ---------------------------------------------------------- */

.actions { display: flex; gap: .625rem; flex-wrap: wrap; margin-top: 1.5rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .625rem 1.125rem;
  font: 600 var(--step-0)/1.2 inherit;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; text-decoration: none;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn--ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn--ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

:where(a, button, input, select, [tabindex]):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* --- Статусы --------------------------------------------------------- */

.status { margin: .875rem 0 0; font-size: .8125rem; min-height: 1.2em; color: var(--muted); }
.status[data-kind="error"] { color: var(--error); }
.status[data-kind="ok"] { color: var(--ok); }

/* --- Превью ---------------------------------------------------------- */

.preview__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1rem;
}

.stage {
  position: relative;
  display: grid; place-items: center;
  aspect-ratio: 3 / 4;
  /* Карточка 3:4 на ноутбуке выше экрана — держим её целиком в поле зрения,
     object-fit: contain оставляет поля по бокам вместо обрезки. */
  max-height: calc(100vh - 15rem);
  background: var(--ground);
  border: 1px dashed var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.stage[data-state="ready"] { border-style: solid; border-color: var(--line); }
.stage img { width: 100%; height: 100%; object-fit: contain; display: block; }

.stage__empty { text-align: center; color: var(--muted); padding: 1.5rem; }
.stage__empty p { margin: .75rem 0 0; font-size: .8125rem; max-width: 24ch; margin-inline: auto; }
.stage__ratio {
  display: inline-block; padding: .25rem .5rem;
  font: 600 .6875rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .08em; color: var(--accent);
  background: var(--accent-soft); border-radius: 6px;
}

.stage__loader { position: absolute; display: flex; gap: .375rem; }
.stage__loader span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); animation: pulse 1.1s ease-in-out infinite;
}
.stage__loader span:nth-child(2) { animation-delay: .16s; }
.stage__loader span:nth-child(3) { animation-delay: .32s; }
@keyframes pulse { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.stage[data-state="loading"] img { opacity: .35; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
      transition-duration: .01ms !important; }
}

/* --- Лидогенерация ---------------------------------------------------- */

.lead {
  position: relative;
  margin-top: 1.5rem; padding: 1.25rem;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: var(--radius);
}
.lead__close {
  position: absolute; top: .5rem; right: .5rem;
  width: 28px; height: 28px; display: grid; place-items: center;
  font-size: 1.125rem; line-height: 1;
  color: var(--muted); background: none; border: 0; border-radius: 8px;
  cursor: pointer;
}
.lead__close:hover { color: var(--ink); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.lead__title { margin: 0 0 .35rem; font-size: var(--step-1); letter-spacing: -.01em; }
.lead__text { margin: 0 0 1.125rem; font-size: .8125rem; color: var(--muted); max-width: 54ch; }
.lead__form .field { margin-bottom: .875rem; }
.lead[data-done="true"] .lead__form { display: none; }

/* --- Подвал ----------------------------------------------------------- */

.footer { border-top: 1px solid var(--line); background: var(--surface); }
.footer__inner {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 1.25rem 0; font-size: .8125rem; color: var(--muted);
}
.footer p { margin: 0; }
