/* ============================================================
   Letterly — стили
   Палитра: глубокий синий + чистый белый
   ============================================================ */

:root {
  --blue-50:  #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-300: #93c5fd;
  --blue-400: #60a5fa;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;
  --blue-900: #1e3a8a;

  --ink-900: #0b1220;
  --ink-700: #1f2937;
  --ink-500: #475569;
  --ink-400: #64748b;
  --ink-300: #94a3b8;
  --ink-200: #cbd5e1;
  --ink-100: #e2e8f0;
  --ink-50:  #f1f5f9;

  --white:   #ffffff;
  --bg:      #f7faff;
  --danger:  #dc2626;
  --success: #16a34a;

  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow:    0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 40px -12px rgba(30, 58, 138, 0.18), 0 8px 16px -8px rgba(30, 58, 138, 0.10);

  --tr: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-900);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ============================================================
   Header
   ============================================================ */
.header {
  background: var(--white);
  border-bottom: 1px solid var(--ink-100);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(180%) blur(8px);
  background-color: rgba(255, 255, 255, 0.85);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 68px;
}

.api-status {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--ink-50);
  color: var(--ink-500);
  white-space: nowrap;
}
.api-status.is-warn { background: #fef3c7; color: #92400e; }
.api-status.is-ok { background: #dcfce7; color: #166534; }

.alert {
  margin: 0 0 20px;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.5;
  border: 1px solid transparent;
}
.alert code {
  font-size: 12px;
  background: rgba(255, 255, 255, 0.6);
  padding: 2px 6px;
  border-radius: 4px;
}
.alert--warn {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #78350f;
}
.alert--info {
  background: var(--blue-50);
  border-color: var(--blue-200);
  color: var(--blue-900);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand__logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue-700), var(--blue-900));
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

.brand__logo svg {
  width: 22px;
  height: 22px;
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand__name {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--blue-900);
}

.brand__tagline {
  font-size: 12px;
  color: var(--ink-400);
  margin-top: 2px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--ink-100);
  background: var(--white);
  color: var(--ink-500);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--tr);
}

.icon-btn:hover {
  border-color: var(--blue-300);
  color: var(--blue-700);
  background: var(--blue-50);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* ============================================================
   Hero
   ============================================================ */
.main {
  padding: 48px 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hero {
  text-align: center;
  margin-bottom: 8px;
}

.hero__title {
  font-size: 38px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 800;
  color: var(--blue-900);
  margin: 0 0 12px;
}

.hero__subtitle {
  font-size: 16px;
  color: var(--ink-500);
  max-width: 580px;
  margin: 0 auto;
}

/* ============================================================
   Stepper
   ============================================================ */
.stepper {
  list-style: none;
  margin: 0 0 8px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--ink-100);
  box-shadow: var(--shadow-sm);
}

.stepper__item {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  position: relative;
  color: var(--ink-400);
  font-weight: 500;
  font-size: 14px;
}

.stepper__item:not(:last-child)::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--ink-100);
  margin: 0 8px;
}

.stepper__num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink-50);
  color: var(--ink-400);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  transition: all var(--tr);
}

.stepper__item.is-active .stepper__num {
  background: var(--blue-600);
  color: var(--white);
  box-shadow: 0 0 0 4px var(--blue-100);
}

.stepper__item.is-active {
  color: var(--blue-900);
}

.stepper__item.is-done .stepper__num {
  background: var(--blue-100);
  color: var(--blue-700);
}

.stepper__item.is-done {
  color: var(--blue-800);
}

/* ============================================================
   Card
   ============================================================ */
.card {
  background: var(--white);
  border: 1px solid var(--ink-100);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--tr), transform var(--tr);
}

.card:hover {
  box-shadow: var(--shadow);
}

.card__header {
  padding: 22px 24px 0;
}

.card__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--blue-900);
  margin: 0;
  letter-spacing: -0.01em;
}

.card__subtitle {
  font-size: 14px;
  color: var(--ink-500);
  margin: 6px 0 0;
}

.card__body {
  padding: 18px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 2px;
}

.card--settings {
  background: linear-gradient(180deg, var(--blue-50), var(--white));
}

.card--result {
  border-color: var(--blue-200);
  box-shadow: var(--shadow-lg);
}

/* ============================================================
   Badge
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--ink-50);
  color: var(--ink-500);
  border: 1px solid var(--ink-100);
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-300);
}

.badge.is-saved {
  background: var(--blue-50);
  color: var(--blue-800);
  border-color: var(--blue-200);
}

.badge.is-saved::before {
  background: var(--blue-600);
  box-shadow: 0 0 0 3px var(--blue-100);
}

/* ============================================================
   Dropzone
   ============================================================ */
.dropzone {
  border: 1.5px dashed var(--blue-200);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--blue-50);
  transition: all var(--tr);
}

.dropzone.is-dragover {
  border-color: var(--blue-600);
  background: var(--blue-100);
}

.dropzone__btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--white);
  border: 1px solid var(--blue-200);
  color: var(--blue-800);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--tr);
  box-shadow: var(--shadow-sm);
}

.dropzone__btn:hover {
  border-color: var(--blue-600);
  color: var(--blue-900);
  transform: translateY(-1px);
}

.dropzone__btn svg {
  width: 18px;
  height: 18px;
}

.dropzone__hint {
  font-size: 13px;
  color: var(--ink-500);
}

/* ============================================================
   Form fields
   ============================================================ */
.textarea,
input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--ink-200);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink-900);
  background: var(--white);
  transition: all var(--tr);
  resize: vertical;
}

.textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 4px var(--blue-100);
}

.textarea {
  min-height: 160px;
  line-height: 1.6;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-700);
}

.field__hint {
  font-size: 12px;
  color: var(--ink-400);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid--2col {
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 640px) {
  .form-grid,
  .form-grid--2col {
    grid-template-columns: 1fr;
  }
}

.advanced {
  border: 1px solid var(--ink-100);
  border-radius: 10px;
  background: var(--ink-50);
  padding: 12px 16px;
}

.advanced > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-700);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.advanced > summary::-webkit-details-marker { display: none; }

.advanced > summary::before {
  content: '+';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--white);
  color: var(--blue-700);
  font-weight: 700;
  border: 1px solid var(--ink-100);
  transition: transform var(--tr);
}

.advanced[open] > summary::before {
  content: '−';
}

.advanced__body {
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--tr);
  position: relative;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--blue-700);
  color: var(--white);
  box-shadow: 0 2px 6px rgba(29, 78, 216, 0.25);
}

.btn--primary:hover:not(:disabled) {
  background: var(--blue-800);
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(29, 78, 216, 0.3);
}

.btn--primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn--ghost {
  background: transparent;
  color: var(--ink-500);
  border-color: var(--ink-100);
}

.btn--ghost:hover:not(:disabled) {
  color: var(--blue-700);
  border-color: var(--blue-200);
  background: var(--blue-50);
}

.btn--cta {
  padding: 13px 24px;
  font-size: 15px;
  background: linear-gradient(135deg, var(--blue-700), var(--blue-900));
}

.btn--cta:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--blue-800), var(--blue-900));
}

.btn--small {
  padding: 6px 12px;
  font-size: 12px;
}

.btn__spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.btn.is-loading .btn__spinner {
  display: inline-block;
}

.btn.is-loading .btn__label::after {
  content: '...';
  margin-left: 2px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   Result
   ============================================================ */
.result {
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-700);
}

.result h1,
.result h2,
.result h3,
.result h4 {
  color: var(--blue-900);
  letter-spacing: -0.01em;
  margin: 24px 0 10px;
  line-height: 1.25;
}

.result h1 { font-size: 22px; font-weight: 800; }
.result h2 { font-size: 19px; font-weight: 700; border-bottom: 1px solid var(--blue-100); padding-bottom: 8px; }
.result h3 { font-size: 16px; font-weight: 700; color: var(--blue-800); }
.result h4 { font-size: 14px; font-weight: 600; color: var(--blue-700); text-transform: uppercase; letter-spacing: 0.05em; }

.result p { margin: 0 0 12px; }

.result ul, .result ol {
  padding-left: 22px;
  margin: 0 0 14px;
}

.result li { margin: 4px 0; }

.result strong { color: var(--ink-900); font-weight: 700; }

.result code {
  background: var(--blue-50);
  color: var(--blue-900);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 13px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
}

.result pre {
  background: var(--ink-900);
  color: var(--white);
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 13px;
  margin: 14px 0;
}

.result blockquote {
  margin: 14px 0;
  padding: 12px 18px;
  border-left: 3px solid var(--blue-600);
  background: var(--blue-50);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-700);
  font-style: normal;
}

.result blockquote p:last-child { margin-bottom: 0; }

.result table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 14px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--ink-100);
}

.result th, .result td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--ink-100);
}

.result th {
  background: var(--blue-50);
  color: var(--blue-900);
  font-weight: 600;
  font-size: 13px;
}

.result tr:last-child td { border-bottom: none; }

.result hr {
  border: none;
  border-top: 1px solid var(--ink-100);
  margin: 24px 0;
}

/* Кнопки копирования внутри блоков результата */
.copy-block {
  position: relative;
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 14px 0;
}

.copy-block__copy {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 6px 10px;
  background: var(--white);
  border: 1px solid var(--blue-200);
  border-radius: 6px;
  color: var(--blue-800);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--tr);
}

.copy-block__copy:hover {
  background: var(--blue-100);
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 20px;
  background: var(--ink-900);
  color: var(--white);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all var(--tr);
  z-index: 100;
  max-width: 90vw;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.is-error {
  background: var(--danger);
}

.toast.is-success {
  background: var(--success);
}

/* Turnstile */
.turnstile-wrap {
  margin: 16px 0 4px;
  min-height: 65px;
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
  border-top: 1px solid var(--ink-100);
  background: var(--white);
  padding: 20px 0;
  margin-top: 40px;
}

.footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--ink-500);
}

.footer__muted {
  color: var(--ink-400);
  font-size: 12px;
}

/* ============================================================
   Адаптив
   ============================================================ */
@media (max-width: 640px) {
  .hero__title { font-size: 28px; }
  .hero__subtitle { font-size: 15px; }
  .main { padding: 28px 16px 60px; }
  .container { padding: 0 16px; }
  .card__header, .card__body { padding-left: 18px; padding-right: 18px; }
  .stepper { padding: 10px 14px; flex-wrap: wrap; }
  .stepper__item:not(:last-child)::after { display: none; }
  .stepper__label { font-size: 13px; }
  .footer__inner { flex-direction: column; gap: 4px; text-align: center; }
}
