/* ===== Reset & base ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: #0f172a;
  background: #ffffff;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; }

:root {
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --accent: #f59e0b;
  --success: #10b981;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== Topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  display: flex; justify-content: space-between; align-items: center;
  height: 64px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 18px;
}
.brand__mark {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: white; border-radius: 8px;
  font-size: 18px;
}
.nav {
  display: flex; gap: 24px; align-items: center;
}
.nav a:not(.btn) {
  font-size: 14px; font-weight: 500;
  color: var(--text-muted);
  transition: color 0.2s;
}
.nav a:not(.btn):hover { color: var(--text); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600; font-size: 14px;
  transition: all 0.2s;
  border: 1px solid transparent;
}
.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--lg { padding: 14px 28px; font-size: 16px; }
.btn--primary {
  background: var(--primary); color: white;
}
.btn--primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn--secondary {
  background: var(--bg-alt); color: var(--text);
  border-color: var(--border);
}
.btn--secondary:hover { background: white; border-color: var(--border-strong); }
.btn--ghost {
  background: transparent; color: var(--primary);
  border-color: var(--border);
}

/* ===== Hero ===== */
.hero {
  padding: 80px 0 64px;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(79, 70, 229, 0.08), transparent 70%),
    var(--bg);
}
.hero__eyebrow {
  display: inline-block;
  padding: 6px 14px;
  background: rgba(79, 70, 229, 0.08);
  color: var(--primary);
  border-radius: 999px;
  font-size: 13px; font-weight: 500;
  margin-bottom: 24px;
}
.hero__title {
  font-size: clamp(36px, 6vw, 64px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}
.hero__sub {
  font-size: 18px;
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 auto 32px;
}
.hero__cta {
  display: flex; gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.hero__meta {
  display: flex; gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== Sections ===== */
.section { padding: 80px 0; }
.section--alt { background: var(--bg-alt); }
.section__title {
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.section__sub {
  font-size: 17px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 48px;
}

/* ===== Templates grid ===== */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.template-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  text-align: left;
  transition: all 0.2s;
  cursor: pointer;
  display: flex; flex-direction: column;
}
.template-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.template-card__emoji {
  font-size: 32px;
  margin-bottom: 12px;
}
.template-card__title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}
.template-card__desc {
  font-size: 14px;
  color: var(--text-muted);
  flex: 1;
  margin-bottom: 16px;
}
.template-card__price {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
}

/* ===== Modal / Runner ===== */
.modal {
  display: none;
  position: fixed; inset: 0;
  z-index: 100;
}
.modal[aria-hidden="false"] { display: block; }
.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
}
.modal__panel {
  position: relative;
  background: white;
  max-width: 560px;
  margin: 60px auto;
  border-radius: 20px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
  max-height: 80vh;
  overflow-y: auto;
}
.modal__close {
  position: absolute;
  top: 16px; right: 16px;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px;
  font-size: 24px;
  color: var(--text-muted);
}
.modal__close:hover { background: var(--bg-alt); }

.runner-form {
  display: flex; flex-direction: column;
  gap: 16px;
}
.runner-form label {
  display: flex; flex-direction: column;
  gap: 6px;
  font-size: 14px; font-weight: 500;
}
.runner-form input,
.runner-form textarea,
.runner-form select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
}
.runner-form input:focus,
.runner-form textarea:focus,
.runner-form select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.runner-form textarea { min-height: 80px; resize: vertical; }
.runner-form button[type="submit"] { margin-top: 8px; }

.runner-result {
  margin-top: 24px;
  padding: 20px;
  background: var(--bg-alt);
  border-radius: 12px;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.6;
  border: 1px solid var(--border);
}
.runner-result__meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.runner-error {
  margin-top: 16px;
  padding: 12px 16px;
  background: #fef2f2;
  color: #b91c1c;
  border-radius: 10px;
  font-size: 14px;
}
.runner-loading {
  margin-top: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ===== Steps ===== */
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 32px;
}
.step { text-align: center; }
.step__num {
  display: inline-grid; place-items: center;
  width: 48px; height: 48px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 20px; font-weight: 700;
  margin-bottom: 16px;
}
.step h3 {
  font-size: 18px; font-weight: 600;
  margin-bottom: 8px;
}
.step p { color: var(--text-muted); font-size: 15px; }

/* ===== Pricing ===== */
.pricing {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  max-width: 920px;
  margin: 0 auto;
}
.plan {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  position: relative;
  display: flex; flex-direction: column;
}
.plan--featured {
  border-color: var(--primary);
  border-width: 2px;
  transform: scale(1.02);
}
.plan__badge {
  position: absolute;
  top: -10px; right: 20px;
  background: var(--accent);
  color: white;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.plan h3 {
  font-size: 20px;
  margin-bottom: 12px;
}
.plan__price {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}
.plan__price span {
  font-size: 16px;
  font-weight: 400;
  color: var(--text-muted);
}
.plan__features {
  list-style: none;
  margin-bottom: 24px;
  flex: 1;
}
.plan__features li {
  padding: 8px 0;
  font-size: 14px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.plan__features li:last-child { border-bottom: none; }
.plan__features li::before {
  content: "✓ ";
  color: var(--success);
  font-weight: 700;
  margin-right: 4px;
}

/* ===== Footer ===== */
.footer {
  background: var(--bg-alt);
  padding: 48px 0 24px;
  border-top: 1px solid var(--border);
}
.footer__inner {
  display: flex; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.footer__tag {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 8px;
  max-width: 320px;
}
.footer__links {
  display: flex; gap: 24px; flex-wrap: wrap;
}
.footer__links a {
  color: var(--text-muted);
  font-size: 14px;
}
.footer__links a:hover { color: var(--text); }
.footer__bottom {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .nav a:not(.btn) { display: none; }
  .hero { padding: 56px 0; }
  .section { padding: 56px 0; }
  .modal__panel { margin: 24px 16px; padding: 24px; }
  .plan--featured { transform: none; }
}
/* ===== Nav active state ===== */
.nav a.nav--active {
  color: var(--text);
  font-weight: 600;
}

/* ===== Personas page ===== */
.personas-section {
  padding: 48px 0 96px;
}
.personas-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 32px;
  justify-content: center;
}
.tab {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all .15s;
}
.tab:hover { color: var(--text); border-color: var(--accent); }
.tab--active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.personas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.persona-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  transition: transform .15s, box-shadow .15s;
}
.persona-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}
.persona-card__avatar {
  font-size: 56px;
  margin-bottom: 12px;
}
.persona-card__name {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 8px;
}
.persona-card__desc {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 20px;
  min-height: 40px;
}
.btn--block { width: 100%; }

/* ===== Dialogs list ===== */
.dialogs-section {
  padding: 48px 0 96px;
}
.dialogs-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}
#usage-info {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
}
.dialog-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  text-decoration: none;
  color: inherit;
  transition: all .15s;
}
.dialog-row:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.dialog-row__avatar {
  font-size: 32px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 50%;
  flex-shrink: 0;
}
.dialog-row__main { flex: 1; min-width: 0; }
.dialog-row__title {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dialog-row__meta {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.dialog-row__chev {
  color: var(--text-muted);
  font-size: 20px;
}
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}
.empty-state p { margin-bottom: 16px; }

/* ===== Dialog page ===== */
.dialog-page { padding-bottom: 0; }
.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  margin-right: auto;
}
.back-link:hover { color: var(--text); }

.dialog-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  margin: 0 24px;
}
.dialog-persona-avatar {
  font-size: 32px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border-radius: 50%;
  flex-shrink: 0;
}
.dialog-title {
  font-weight: 600;
  font-size: 16px;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}
.dialog-meta {
  font-size: 12px;
  color: var(--text-muted);
}
.dialog-actions {
  display: flex;
  gap: 8px;
}
.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  transition: all .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.icon-btn--danger:hover { color: #b91c1c; border-color: #b91c1c; }

.dialog-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 20px 24px;
  min-height: calc(100vh - 200px);
}
.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.message {
  display: flex;
  width: 100%;
}
.message--user { justify-content: flex-end; }
.message--agent { justify-content: flex-start; }
.message__bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.message--user .message__bubble {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}
.message--agent .message__bubble {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.composer {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 16px 0;
}
.composer__inner {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  max-width: 800px;
  margin: 0 auto;
}
#input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 15px;
  resize: none;
  background: var(--surface);
  color: var(--text);
  max-height: 160px;
  outline: none;
}
#input:focus { border-color: var(--accent); }
#send-btn {
  padding: 12px 20px;
  font-size: 18px;
  line-height: 1;
}

@media (max-width: 640px) {
  .dialog-title-wrap { margin: 0 8px; }
  .dialog-title { font-size: 14px; max-width: 200px; }
  .dialog-persona-avatar { width: 32px; height: 32px; font-size: 24px; }
  .back-link { font-size: 12px; }
  .message__bubble { max-width: 85%; }
  .dialogs-header { flex-direction: column; align-items: flex-start; }
}

/* ===== Hamburger menu (mobile) ===== */
.burger {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 24px;
  height: 18px;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.burger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.nav--open .burger span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}
.nav--open .burger span:nth-child(2) { opacity: 0; }
.nav--open .burger span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 40;
  opacity: 0;
  transition: opacity .2s;
}
.nav-overlay--visible {
  display: block;
  opacity: 1;
}

@media (max-width: 768px) {
  .burger { display: flex; }
  .nav {
    position: fixed;
    top: 0; right: 0;
    width: 280px;
    max-width: 80vw;
    height: 100vh;
    background: var(--bg);
    border-left: 1px solid var(--border);
    padding: 80px 24px 24px;
    flex-direction: column;
    gap: 4px;
    align-items: stretch;
    transform: translateX(100%);
    transition: transform .25s;
    z-index: 60;
    box-shadow: -4px 0 16px rgba(0,0,0,0.06);
  }
  .nav--open {
    transform: translateX(0);
  }
  .nav a {
    padding: 12px 8px;
    border-radius: 8px;
    font-size: 16px;
  }
  .nav a:hover, .nav a.nav--active {
    background: var(--bg-alt);
  }
  .nav a.btn {
    margin-top: 16px;
    background: var(--primary);
    color: white !important;
    text-align: center;
    padding: 12px;
  }
  .nav a.btn:hover {
    background: var(--primary-dark);
  }
}

/* ===== Mobile responsive (universal) ===== */
@media (max-width: 768px) {
  .container { padding: 0 16px; }
  .hero { padding: 48px 0; }
  .hero__title { font-size: 32px; }
  .section { padding: 48px 0; }
  .section__title { font-size: 24px; }
  .hero__cta { flex-direction: column; align-items: stretch; }
  .hero__cta .btn { width: 100%; }
  .modal__panel { margin: 16px; padding: 20px; max-height: 90vh; overflow-y: auto; }
  .plan--featured { transform: none; }
  .templates-grid { grid-template-columns: 1fr; }
  .pricing { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .personas-grid { grid-template-columns: 1fr; }

  /* dialog page mobile */
  .dialog-title-wrap { margin: 0 8px; flex: 1; min-width: 0; }
  .dialog-title { font-size: 14px; max-width: 160px; }
  .dialog-persona-avatar { width: 32px; height: 32px; font-size: 24px; }
  .back-link { font-size: 12px; }
  .message__bubble { max-width: 85%; font-size: 14px; padding: 10px 14px; }
  .dialog-actions { gap: 4px; }
  .icon-btn { padding: 4px 8px; font-size: 14px; }

  /* dialog page header — гамбургер для диалога не нужен, там свой layout */
  .topbar--dialog { padding: 0; }
  .topbar__inner--dialog {
    flex-wrap: nowrap;
    gap: 8px;
    height: 60px;
  }

  /* forms */
  .form-group input, .form-group textarea, .form-group select {
    font-size: 16px; /* предотвращает zoom на iOS */
  }
}

@media (max-width: 480px) {
  .hero__title { font-size: 26px; }
  .hero__meta { flex-direction: column; align-items: flex-start; gap: 8px; }
  .btn--lg { padding: 14px 20px; font-size: 14px; }
}

/* Touch optimization */
@media (hover: none) {
  .btn:active, .nav a:active, .icon-btn:active {
    transform: scale(0.97);
  }
}
