/* ===== RESET ===== */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{scroll-behavior:smooth}
body{
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Inter,sans-serif;
  background:#fafafa;color:#171717;line-height:1.55;-webkit-font-smoothing:antialiased;
}
a{color:inherit;text-decoration:none}
button{font-family:inherit;cursor:pointer;border:none;background:none}
input{font-family:inherit}
.hidden{display:none !important}
.container{max-width:1120px;margin:0 auto;padding:0 20px}

/* ===== BUTTONS ===== */
.btn{display:inline-flex;align-items:center;gap:6px;padding:10px 18px;border-radius:12px;font-size:14px;font-weight:500;transition:all .15s ease}
.btn-sm{padding:6px 12px;font-size:12px;border-radius:8px}
.btn-lg{padding:14px 24px;font-size:15px}
.btn-primary{background:#171717;color:#fff}
.btn-primary:hover{background:#333}
.btn-primary:disabled{opacity:.4;cursor:not-allowed}
.btn-outline{background:transparent;border:1px solid #d4d4d4;color:#404040}
.btn-outline:hover{background:#f5f5f5}
.btn-ghost{color:#525252}
.btn-ghost:hover{background:#f5f5f5}
.btn-danger{background:#ef4444;color:#fff}
.btn-danger:hover{background:#dc2626}
.icon-btn{width:32px;height:32px;display:flex;align-items:center;justify-content:center;border-radius:8px;color:#737373;font-size:14px}
.icon-btn:hover{background:#f5f5f5}

/* ===== HEADER ===== */
.header{position:sticky;top:0;z-index:40;background:rgba(255,255,255,.85);backdrop-filter:blur(10px);border-bottom:1px solid #e5e5e5}
.header-inner{display:flex;align-items:center;justify-content:space-between;padding:14px 20px}
.logo{display:flex;align-items:center;gap:8px}
.logo-mark{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:10px;background:#171717;color:#fff;font-size:12px;font-weight:700}
.logo-text{font-size:17px;font-weight:600;letter-spacing:-.01em}
.nav{display:flex;gap:24px}
.nav a{font-size:14px;color:#525252;transition:color .15s}
.nav a:hover{color:#171717}
.header-actions{display:flex;gap:8px}
.burger{display:none;flex-direction:column;gap:5px;padding:8px}
.burger span{display:block;width:20px;height:2px;background:#171717}
.mobile-menu{display:none;flex-direction:column;gap:14px;padding:16px 20px;border-top:1px solid #e5e5e5;background:#fff}
.mobile-menu a{font-size:14px;color:#404040}
.mobile-menu.open{display:flex}

/* ===== HERO ===== */
.hero{padding:80px 0 100px}
.hero-grid{display:grid;grid-template-columns:1fr 1fr;gap:56px;align-items:center}
.pill{display:inline-flex;align-items:center;gap:8px;padding:5px 12px;border:1px solid #e5e5e5;border-radius:999px;background:#fff;font-size:12px;color:#525252;margin-bottom:20px}
.dot{width:6px;height:6px;border-radius:50%;background:#22c55e}
.hero h1{font-size:52px;line-height:1.05;letter-spacing:-.02em;font-weight:700;margin-bottom:20px}
.hero h1 span{color:#a3a3a3}
.lead{font-size:17px;color:#525252;max-width:520px;margin-bottom:28px}
.hero-actions{display:flex;gap:12px;flex-wrap:wrap}
.hero-visual{position:relative}
.mock-chat{background:#fff;border:1px solid #e5e5e5;border-radius:18px;box-shadow:0 8px 30px rgba(0,0,0,.05);padding:16px}
.mock-head{display:flex;align-items:center;gap:6px;margin-bottom:12px}
.mock-head .dot{width:10px;height:10px}
.dot.red{background:#f87171}.dot.yellow{background:#fbbf24}.dot.green{background:#4ade80}
.mock-title{margin-left:8px;font-size:12px;color:#a3a3a3}
.mock-body{display:flex;flex-direction:column;gap:10px}
.bubble{max-width:80%;padding:10px 14px;font-size:13.5px;border-radius:14px}
.bubble.user{align-self:flex-end;background:#171717;color:#fff;border-bottom-right-radius:4px}
.bubble.ai{align-self:flex-start;background:#f5f5f5;color:#262626;border-bottom-left-radius:4px}
.bubble.ai p{color:#737373;margin-top:4px}
.bubble.typing{display:flex;gap:4px;padding:12px 14px}
.bubble.typing span{width:6px;height:6px;border-radius:50%;background:#a3a3a3;animation:bounce 1s infinite}
.bubble.typing span:nth-child(2){animation-delay:.15s}
.bubble.typing span:nth-child(3){animation-delay:.3s}
@keyframes bounce{0%,80%,100%{transform:translateY(0)}40%{transform:translateY(-4px)}}
.float-card{position:absolute;background:#fff;border:1px solid #e5e5e5;border-radius:12px;padding:10px 14px;font-size:12px;color:#525252;box-shadow:0 4px 16px rgba(0,0,0,.05)}
.float-card.top{top:-16px;right:-16px}
.float-card.bottom{bottom:-16px;left:-16px}
.float-card b{color:#171717;font-size:13px}

/* ===== SECTIONS ===== */
.section{padding:80px 0}
.section-alt{background:#fff;border-top:1px solid #e5e5e5;border-bottom:1px solid #e5e5e5}
.section-head{text-align:center;margin-bottom:44px}
.section-head h2{font-size:34px;letter-spacing:-.02em;font-weight:700}
.section-head p{margin-top:10px;color:#525252}

/* ===== FILTERS ===== */
.filters{display:flex;gap:16px;justify-content:space-between;align-items:center;flex-wrap:wrap;margin-bottom:32px}
.search-wrap{position:relative;flex:1;max-width:380px}
.search-icon{position:absolute;left:12px;top:50%;transform:translateY(-50%);font-size:14px;opacity:.5}
.search-wrap input{width:100%;padding:10px 14px 10px 36px;border:1px solid #e5e5e5;border-radius:12px;background:#fff;font-size:14px;outline:none;transition:border-color .15s}
.search-wrap input:focus{border-color:#a3a3a3}
.categories{display:flex;gap:8px;flex-wrap:wrap}
.cat-btn{padding:7px 12px;border-radius:8px;font-size:12px;font-weight:500;background:#f5f5f5;color:#525252;transition:all .15s}
.cat-btn:hover{background:#e5e5e5}
.cat-btn.active{background:#171717;color:#fff}

/* ===== TOOLS ===== */
.tools-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:20px}
.tool-card{display:flex;flex-direction:column;background:#fff;border:1px solid #e5e5e5;border-radius:16px;padding:24px;transition:all .2s ease}
.tool-card:hover{border-color:#d4d4d4;box-shadow:0 4px 20px rgba(0,0,0,.05);transform:translateY(-2px)}
.tool-head{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:16px}
.tool-icon{font-size:28px}
.tool-cat{padding:3px 10px;border-radius:999px;background:#f5f5f5;font-size:11px;color:#737373;font-weight:500}
.tool-card h3{font-size:17px;font-weight:600;margin-bottom:8px}
.tool-desc{font-size:13.5px;color:#525252;flex:1;line-height:1.5}
.tool-examples{display:flex;flex-wrap:wrap;gap:6px;margin-top:14px}
.tool-example{padding:4px 8px;border-radius:6px;background:#fafafa;font-size:11.5px;color:#737373}
.tool-card .btn{width:100%;justify-content:center;margin-top:18px}
.empty-state{text-align:center;padding:80px 0;color:#737373}
.empty-state p{font-size:17px;font-weight:500;color:#404040}
.empty-state span{display:block;margin-top:6px;font-size:13.5px}

/* ===== STEPS ===== */
.steps{display:grid;grid-template-columns:repeat(3,1fr);gap:32px}
.step{text-align:center}
.step-num{display:inline-flex;align-items:center;justify-content:center;width:48px;height:48px;border-radius:12px;background:#171717;color:#fff;font-size:13px;font-weight:700}
.step h3{font-size:17px;font-weight:600;margin:16px 0 8px}
.step p{font-size:13.5px;color:#525252}

/* ===== CTA ===== */
.cta{text-align:center}
.cta-inner{max-width:640px}
.cta h2{font-size:34px;letter-spacing:-.02em}
.cta p{margin:16px 0 32px;color:#525252}

/* ===== FOOTER ===== */
.footer{border-top:1px solid #e5e5e5;background:#fff;padding:56px 0 0}
.footer-grid{display:grid;grid-template-columns:2fr 1fr 1fr;gap:40px;padding-bottom:40px}
.footer-desc{margin-top:16px;font-size:13.5px;color:#737373;max-width:340px;line-height:1.6}
.footer h4{font-size:13.5px;font-weight:600;margin-bottom:12px}
.footer ul{list-style:none;display:flex;flex-direction:column;gap:8px}
.footer ul a{font-size:13.5px;color:#737373}
.footer ul a:hover{color:#171717}
.footer-bottom{border-top:1px solid #f5f5f5;padding:20px 0;text-align:center;font-size:12px;color:#a3a3a3}

/* ===== MODAL / CHAT ===== */
.modal{position:fixed;inset:0;z-index:100;display:flex;align-items:center;justify-content:center;padding:16px}
.modal-backdrop{position:absolute;inset:0;background:rgba(0,0,0,.4);backdrop-filter:blur(4px)}
.chat{position:relative;display:flex;flex-direction:column;width:100%;max-width:760px;height:92vh;background:#fff;border-radius:18px;box-shadow:0 20px 60px rgba(0,0,0,.2);overflow:hidden}
.chat-head{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;border-bottom:1px solid #e5e5e5}
.chat-title-wrap{display:flex;align-items:center;gap:12px}
.chat-icon{font-size:26px}
.chat-head h3{font-size:15px;font-weight:600}
.chat-head p{font-size:12px;color:#737373;margin-top:2px;max-width:500px}
.chat-head-actions{display:flex;align-items:center;gap:4px}

/* ===== TIMER BAR ===== */
.timer-bar{display:flex;align-items:center;gap:8px;padding:10px 20px;border-bottom:1px solid #e5e5e5;background:#fafafa;flex-wrap:wrap}
.timer-display{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:18px;font-weight:600;color:#171717;min-width:64px;letter-spacing:.02em}
.timer-display.warn{color:#dc2626}
.timer-actions{margin-left:auto;display:flex;gap:6px;flex-wrap:wrap}

/* ===== CHAT BODY ===== */
.chat-body{flex:1;overflow-y:auto;padding:20px;display:flex;flex-direction:column;gap:14px}
.msg{display:flex;animation:fadeInUp .25s ease-out}
.msg.user{justify-content:flex-end}
.msg-ai{max-width:85%;padding:12px 16px;border-radius:16px;background:#f5f5f5;color:#262626;font-size:14px;line-height:1.55;border-bottom-left-radius:4px}
.msg-user{max-width:85%;padding:12px 16px;border-radius:16px;background:#171717;color:#fff;font-size:14px;line-height:1.55;border-bottom-right-radius:4px}
.msg-ai h3,.msg-ai h4{font-size:14px;font-weight:600;margin:8px 0 4px}
.msg-ai ul{margin:4px 0 4px 20px}
.msg-ai li{margin:2px 0}
.msg-ai pre{background:#171717;color:#86efac;border-radius:8px;padding:12px;overflow-x:auto;margin:8px 0;font-size:12.5px}
.msg-ai p{min-height:1.4em}
.msg-error{padding:12px 16px;border-radius:12px;background:#fef2f2;border:1px solid #fecaca;color:#b91c1c;font-size:13.5px}
.typing-dots{display:flex;gap:4px;padding:14px 16px;background:#f5f5f5;border-radius:16px;align-self:flex-start}
.typing-dots span{width:6px;height:6px;border-radius:50%;background:#a3a3a3;animation:bounce 1s infinite}
.typing-dots span:nth-child(2){animation-delay:.15s}
.typing-dots span:nth-child(3){animation-delay:.3s}

@keyframes fadeInUp{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}

/* ===== EXAMPLES ===== */
.chat-examples{padding:12px 20px;border-top:1px solid #f5f5f5}
.chat-examples-title{font-size:11.5px;font-weight:500;color:#a3a3a3;margin-bottom:8px}
.chat-examples-list{display:flex;flex-wrap:wrap;gap:8px}
.example-chip{padding:6px 12px;border:1px solid #e5e5e5;border-radius:8px;background:#fff;font-size:12px;color:#525252;transition:all .15s}
.example-chip:hover{border-color:#d4d4d4;background:#fafafa}

/* ===== FORM ===== */
.chat-form{display:flex;gap:12px;padding:16px 20px;border-top:1px solid #e5e5e5}
.chat-form input{flex:1;padding:11px 16px;border:1px solid #e5e5e5;border-radius:12px;background:#fafafa;font-size:14px;outline:none;transition:border-color .15s}
.chat-form input:focus{border-color:#a3a3a3}
.chat-form input:disabled{opacity:.6}

/* ===== ЭКРАН ВХОДА ===== */
.gate-body{display:flex;align-items:center;justify-content:center;min-height:100vh;padding:20px;background:#fafafa}
.gate-card{width:100%;max-width:400px;background:#fff;border:1px solid #e5e5e5;border-radius:20px;padding:40px 32px 32px;box-shadow:0 10px 40px rgba(0,0,0,.06);text-align:center}
.gate-logo{display:flex;justify-content:center;margin-bottom:20px}
.gate-logo .logo-mark{display:inline-flex;align-items:center;justify-content:center;width:56px;height:56px;border-radius:16px;background:#171717;color:#fff;font-size:18px;font-weight:700}
.gate-title{font-size:22px;font-weight:700;letter-spacing:-.01em;margin-bottom:8px;color:#171717}
.gate-sub{font-size:14px;color:#737373;margin-bottom:24px}
.gate-error{padding:10px 14px;border-radius:10px;background:#fef2f2;border:1px solid #fecaca;color:#b91c1c;font-size:13.5px;margin-bottom:16px}
.gate-form{display:flex;flex-direction:column;gap:12px}
.gate-form input{width:100%;padding:12px 16px;border:1px solid #e5e5e5;border-radius:12px;background:#fafafa;font-size:15px;outline:none;transition:border-color .15s,background .15s;text-align:center;letter-spacing:.05em}
.gate-form input:focus{border-color:#171717;background:#fff}
.gate-form .btn{justify-content:center;padding:12px 18px;font-size:14.5px}
.gate-hint{margin-top:20px;font-size:12px;color:#a3a3a3}

/* ============================================================
   MOBILE: ЧАТ КАК ПРИЛОЖЕНИЕ
   ============================================================ */
@media (max-width:880px){

  /* --- Лендинг --- */
  .nav, .header-actions { display: none }
  .burger { display: flex }
  .hero-grid { grid-template-columns: 1fr; gap: 40px }
  .hero h1 { font-size: 38px }
  .hero-visual { display: none }
  .steps { grid-template-columns: 1fr; gap: 24px }
  .footer-grid { grid-template-columns: 1fr; gap: 28px }
  .filters { flex-direction: column; align-items: stretch }
  .search-wrap { max-width: none }

  /* --- Модалка = экран приложения --- */
  body.chat-open {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  .modal {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
    inset: 0;
  }

  .modal-backdrop {
    display: none; /* на мобиле фон не нужен — чат занимает весь экран */
  }

  .chat {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  /* Верхняя панель чата — как app-bar */
  .chat-head {
    padding: 14px 16px;
    padding-top: calc(14px + env(safe-area-inset-top));
    background: #fff;
    border-bottom: 1px solid #e5e5e5;
    position: sticky;
    top: 0;
    z-index: 5;
  }
  .chat-head h3 { font-size: 16px }
  .chat-head p {
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Лента сообщений */
  .chat-body {
    padding: 16px;
    padding-bottom: 12px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .msg-ai, .msg-user { max-width: 88%; font-size: 15px }

  /* Примеры запросов */
  .chat-examples { padding: 10px 16px }
  .example-chip { font-size: 12.5px; padding: 7px 12px }

  /* Панель таймера */
  .timer-bar {
    padding: 8px 12px;
    gap: 6px;
    position: sticky;
    top: 0;
    z-index: 4;
  }
  .timer-display { font-size: 16px; min-width: 56px }
  .timer-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
    overflow-x: auto;
  }

  /* Поле ввода — фиксировано снизу, с учётом safe-area */
  .chat-form {
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid #e5e5e5;
    gap: 8px;
  }
  .chat-form input {
    padding: 12px 14px;
    font-size: 16px;   /* 16px — чтобы iOS не делал зум при фокусе */
    border-radius: 22px;
    background: #f5f5f5;
    border: 1px solid #e5e5e5;
  }
  .chat-form input:focus { background: #fff }
  .chat-form .btn {
    padding: 12px 18px;
    border-radius: 22px;
    font-size: 14px;
    flex-shrink: 0;
  }

  /* Кнопки в шапке — крупнее для тапа */
  .chat-head-actions .btn { padding: 8px 12px; font-size: 13px }
  .chat-head-actions .icon-btn { width: 40px; height: 40px; font-size: 16px }

  #newDialog { padding: 8px 10px }
}