/* =========================================================================
   SPRUT — Mobile adaptation (≤ 768px)
   Desktop is NEVER touched: all rules are scoped inside this media query.
   ========================================================================= */

@media (max-width: 768px) {

  /* ---------- global ---------- */
  html, body { font-size: 15px; }
  .container { padding: 0 18px; }

  /* lock down section title scaling for narrow screens */
  .section-title { font-size: clamp(28px, 7.5vw, 38px); letter-spacing: -0.025em; }
  .section-sub  { font-size: 15px; margin-top: 14px; max-width: 100%; }
  .section-sub br { display: none; }

  /* shared section CTA — full-width stack */
  .section-cta { margin-top: 40px; flex-direction: column; gap: 10px; align-items: stretch; }
  .section-cta .btn { width: 100%; height: 48px; font-size: 14.5px; padding: 0 18px; }

  /* ---------- nav ---------- */
  .nav-inner { height: 56px; }
  .nav-logo { font-size: 16px; }
  .nav-logo .nav-logo-mark svg { width: 24px; height: 24px; }
  /* hide full link bar — keep only CTA on the right */
  .nav-links { display: none !important; }
  /* in the main nav we have two buttons; drop the ghost one, keep primary */
  .nav-cta { gap: 6px; }
  .nav-cta .btn-ghost { display: none; }
  .nav-cta .btn { height: 36px; padding: 0 14px; font-size: 13.5px; }

  /* ---------- hero ---------- */
  .hero {
    padding-top: 24px;
    padding-bottom: 40px;
    min-height: auto;
  }
  .hero-inner {
    grid-template-columns: 1fr !important;
    gap: 28px;
    min-height: auto;
    padding-top: 4px;
  }
  .hero h1 {
    font-size: clamp(36px, 9.5vw, 52px);
    margin-top: 18px;
    letter-spacing: -0.03em;
    line-height: 1.04;
  }
  .hero-sub {
    margin-top: 18px;
    font-size: 16px;
    line-height: 1.5;
    max-width: 100%;
  }
  .hero-sub br { display: none; }

  .hero-typewriter {
    margin-top: 22px;
    padding: 11px 14px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 46px;
    box-sizing: border-box;
  }
  .hero-typewriter .tw-text {
    font-size: clamp(10.5px, 3.2vw, 12.5px);
    min-width: 0;
  }
  .hero-typewriter .caret { height: 13px; }

  .hero-ctas {
    margin-top: 22px;
    gap: 10px;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
  }
  .hero-ctas .btn { width: 100%; height: 50px; min-width: 0; padding: 0 16px; flex: 0 0 auto; }

  /* 3D octopus — centered, no asymmetric offset */
  .hero-visual {
    min-height: 340px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .hero-visual .hero-canvas {
    top: -20px;
    bottom: -120px;
    left: 0;
    right: 0;
    width: 100%;
  }

  /* prevent grid track from being stretched by long monospace lines */
  .hero-copy { min-width: 0; }
  .hero-inner > * { min-width: 0; }

  .hero-meta-row {
    padding: 14px 16px;
    font-size: 12.5px;
    gap: 10px 14px;
    margin-top: 14px;
  }
  .hero-meta-row span { font-size: 12.5px; gap: 6px; }
  .hero-meta-row .check { width: 16px; height: 16px; }

  /* ---------- features ---------- */
  .features { padding: 60px 0; }
  .features-head {
    grid-template-columns: 1fr;
    gap: 18px;
    margin-bottom: 36px;
  }
  .features-grid { gap: 14px; }
  .feature { padding: 22px 20px; border-radius: 18px; }
  .feature h3 { font-size: 19px; margin-top: 16px; }
  .feature p { font-size: 14px; margin-top: 8px; }
  .feature-art { height: 150px; border-radius: 12px; }

  .feature--react { padding: 22px 20px; grid-template-columns: 1fr; gap: 18px; }
  .feature--react .feature-art--react { height: 220px; }
  .feature--react .feature-text h3 { margin-top: 0; font-size: 20px; }
  .feature--react .feature-text p { font-size: 14.5px; margin-top: 10px; }

  /* ---------- chat demo: tabs as horizontal scroll ON TOP, chat below ---------- */
  .demo { padding: 60px 0; }
  .demo-head { margin-bottom: 32px; }
  .demo-head .section-title { margin-top: 14px; }
  .demo-head .section-sub { margin-top: 12px; }

  .demo-layout {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }
  /* Tab strip — fully horizontal, swipeable */
  .demo-scenarios {
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 18px 10px;
    margin: 0 -18px;        /* bleed to viewport edge */
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .demo-scenarios::-webkit-scrollbar { display: none; }
  .scenario-tab {
    flex: 0 0 auto;
    min-width: 220px;
    padding: 12px 14px;
    font-size: 13.5px;
    scroll-snap-align: start;
  }
  .scenario-tab .st-num { font-size: 10.5px; }

  .chat-frame { min-height: 520px; border-radius: 18px; }
  .chat-top { height: 42px; padding: 0 14px; font-size: 12px; }
  .chat-top .ct-left, .chat-top .ct-right { gap: 8px; }
  .chat-body {
    padding: 14px 10px;
    gap: 12px;
    max-height: 460px;
  }
  .chat-msg-user, .chat-msg-ai { font-size: 14px; }
  .chat-msg-ai { width: 100%; min-width: 0; }
  .chat-msg-user { max-width: 88%; padding: 10px 14px; }
  .tool-step { font-size: 12px; padding: 7px 10px; }
  .chat-input-mock { margin: 0 14px 14px; padding: 10px 12px; }
  .chat-input-mock .ci-placeholder { font-size: 13px; }

  /* Tables inside chat — must fit fully on a 360px screen, no wraps, no scroll. */
  .result-table {
    font-size: 10.5px;
    border-radius: 10px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }
  .result-table .rt-top { padding: 7px 9px; }
  .result-table .rt-top .rt-btn { padding: 4px 7px; font-size: 10px; gap: 4px; }
  .result-table .rt-top .rt-copy { padding: 4px 7px; font-size: 10px; }
  .result-table table { width: 100%; table-layout: auto; }
  .result-table th, .result-table td {
    padding: 5px 4px;
    font-size: clamp(8.5px, 2.55vw, 10.5px);
    white-space: nowrap;
    line-height: 1.3;
    letter-spacing: -0.01em;
  }
  .result-table th {
    font-size: clamp(8px, 2.35vw, 9.5px);
    padding: 5px 4px;
  }
  .result-table td.mono,
  .result-table td.mono {
    font-size: clamp(7.5px, 2.15vw, 9.5px) !important;
    letter-spacing: -0.04em;
  }
  .result-table th:first-child,
  .result-table td:first-child { padding-left: 7px; }
  .result-table th:last-child,
  .result-table td:last-child { padding-right: 7px; }

  .bar-chart { padding: 10px; }
  .bar-row { grid-template-columns: 70px 1fr 42px; gap: 6px; font-size: 11px; }

  .result-success { padding: 11px 12px; font-size: 13px; }
  .result-success .rs-meta { font-size: 11.5px; }
  .confirm-action { padding: 10px 12px; font-size: 12.5px; gap: 10px; flex-wrap: wrap; }

  /* ---------- security ---------- */
  .security { padding: 60px 0; }
  .sec-grid { grid-template-columns: 1fr !important; gap: 32px; }
  .sec-cards { grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 24px; }
  .sec-card { padding: 16px 14px; border-radius: 12px; }
  .sec-card h4 { font-size: 14px; margin-top: 8px; }
  .sec-card p { font-size: 12.5px; margin-top: 4px; line-height: 1.45; }
  .sec-card--clean .sec-num { font-size: 10px; }

  .arch-diagram { padding: 20px 16px; border-radius: 18px; }
  .arch-diagram--v2 { padding: 18px 14px; }
  .arch-canvas { padding: 6px; border-radius: 10px; }
  .arch-head { margin-bottom: 12px; }
  .arch-eyebrow { font-size: 10px; }
  .arch-pulse { font-size: 10px; }
  .arch-note--v2 { font-size: 12px; margin-top: 10px; }

  /* ---------- roles ---------- */
  .roles { padding: 60px 0; }
  .roles-grid { grid-template-columns: 1fr !important; gap: 22px; margin-top: 36px; }
  .role-tabs {
    flex-direction: row !important;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 18px 6px;
    margin: 0 -18px;
    scrollbar-width: none;
  }
  .role-tabs::-webkit-scrollbar { display: none; }
  .role-tab {
    flex: 0 0 auto;
    padding: 10px 16px;
    font-size: 14px;
    border-radius: 999px;
    background: var(--bg-card);
    border-color: var(--line);
    white-space: nowrap;
  }
  .role-tab .arrow { display: none; }

  .role-panel { padding: 26px 22px; min-height: auto; border-radius: 22px; }
  .role-panel h3 { font-size: 24px; line-height: 1.15; }
  .role-panel .role-quote { font-size: 15px; margin-top: 14px; line-height: 1.45; }
  .role-tasks { grid-template-columns: 1fr !important; gap: 8px; margin-top: 22px; }
  .role-task { font-size: 13.5px; padding: 11px 13px; }
  .role-metric { gap: 22px; padding-top: 20px; margin-top: 24px; flex-wrap: wrap; }
  .role-metric .rm-val { font-size: 26px; }
  .role-metric .rm-label { font-size: 12px; }

  /* ---------- pricing / llm ---------- */
  .pricing { padding: 60px 0; }
  .llm-grid { grid-template-columns: 1fr !important; gap: 14px; margin-top: 36px; }
  .llm-card { padding: 26px 22px; border-radius: 22px; }
  .llm-card h3 { font-size: 24px; margin-top: 16px; }
  .llm-card .llm-sub { font-size: 14px; }
  .llm-list li { font-size: 13.5px; padding-left: 20px; }

  .sub-card {
    grid-template-columns: 1fr !important;
    gap: 14px;
    padding: 24px 20px;
    text-align: left;
    margin-top: 32px;
  }
  .sub-card h4 { font-size: 19px; }
  .sub-card p { font-size: 13.5px; }
  .sub-card .btn { width: 100%; justify-content: center; height: 48px; }

  /* unit-economics */
  .econ { padding: 24px 18px; margin-top: 36px; border-radius: 20px; }
  .econ-head { flex-direction: column; gap: 18px; }
  .econ-head-text { flex: 1 1 100%; }
  .econ-head h3 { font-size: 22px; margin-top: 12px; line-height: 1.2; }
  .econ-head .econ-lead { font-size: 14px; margin-top: 10px; }
  .econ-head .econ-lead br { display: none; }
  .econ-head-stat {
    width: 100%;
    padding: 18px 20px;
    min-width: 0;
    flex-direction: row;
    align-items: center;
    gap: 16px;
  }
  .econ-head-stat-eyebrow { flex: 1; font-size: 10.5px; }
  .econ-head-stat-eyebrow br { display: none; }
  .econ-head-stat-num { font-size: 38px; margin-top: 0; }
  .econ-head-stat-sub { display: none; }

  .econ-toggle { grid-template-columns: 1fr; margin-top: 20px; }
  .econ-toggle-btn { padding: 12px 14px; }
  .econ-toggle-label { font-size: 14px; }
  .econ-toggle-sub { font-size: 12px; }

  .econ-compare {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 22px;
  }
  .econ-vs {
    transform: none;
    padding: 0;
    margin: 0 auto;
    font-size: 16px;
    line-height: 1;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: #fff;
    border: 1px solid var(--line-2);
    color: var(--ink-3);
  }

  .econ-col { padding: 18px 18px 20px; border-radius: 14px; }
  .econ-col-tag { margin-bottom: 10px; font-size: 10px; }
  .econ-num { font-size: 34px; }
  .econ-num--save { font-size: 42px; }
  .econ-cap { font-size: 13.5px; margin-top: 8px; }
  .econ-sub { font-size: 12px; }

  /* Header stat (−95%) — green text on light wash instead of white-on-brand */
  .econ-head-stat {
    background: #ECF7F1;
    border: 1px solid #C8E6D5;
    color: var(--brand-2);
    box-shadow: none;
  }
  .econ-head-stat-eyebrow { color: var(--brand-2); opacity: 0.85; }
  .econ-head-stat-num { color: var(--brand-2); }
  .econ-head-stat-sub { color: var(--brand-2); opacity: 0.85; }

  .econ-calc { padding: 20px 16px; margin-top: 26px; border-radius: 16px; }
  .econ-calc-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .econ-calc-label { font-size: 15px; }
  .econ-calc-hint { font-size: 12px; }
  .econ-calc-volume { width: 100%; justify-content: space-between; padding: 8px 14px; }
  .econ-calc-volume input { width: 100%; font-size: 20px; }

  .econ-result { grid-template-columns: 1fr; gap: 10px; margin-top: 22px; }
  .econ-cell { padding: 16px 18px; border-radius: 12px; }
  .econ-cell-val { font-size: 26px; }
  .econ-cell--save .econ-cell-val { font-size: 30px; }
  .econ-cell-cap { font-size: 11px; }
  .econ-cell-sub { font-size: 12px; }

  .token-note { padding: 14px 16px; font-size: 13.5px; margin-top: 24px; }

  /* ---------- FAQ ---------- */
  .faq { padding: 60px 0; }
  .faq-grid { grid-template-columns: 1fr !important; gap: 22px; margin-top: 24px; }
  .faq-grid > div:first-child .btn { width: 100%; justify-content: center; }
  .faq-item { padding: 18px 0; }
  .faq-q { font-size: 15.5px; }
  .faq-a { font-size: 14px; }
  .faq-item.open .faq-a { max-height: 500px; padding-top: 12px; }

  /* ---------- CTA ---------- */
  .cta-section { padding: 60px 0; }
  .cta-box { padding: 50px 24px; border-radius: 22px; }
  .cta-box h2 { font-size: clamp(28px, 7.5vw, 40px); }
  .cta-box h2 br { display: none; }
  .cta-box p { font-size: 15px; margin-top: 14px; }
  .cta-actions { margin-top: 28px; flex-direction: column; gap: 10px; align-items: stretch; }
  .cta-actions .btn { width: 100%; height: 50px; padding: 0 18px; }

  /* ---------- footer ---------- */
  .footer { padding: 44px 0 28px; }
  .footer-top { grid-template-columns: 1fr !important; gap: 28px; margin-bottom: 32px; }
  .footer-brand { max-width: 100%; }
  .footer-bottom { flex-direction: column; align-items: flex-start; gap: 10px; padding-top: 18px; }
  .footer-bottom-links { flex-wrap: wrap; }

  /* =====================================================================
     PRICING.HTML
     ===================================================================== */
  .pricing-page { padding: 36px 0 64px; }

  .p-head { margin-bottom: 32px; }
  .p-head .eyebrow { margin-bottom: 18px; }
  .p-title { font-size: clamp(32px, 8.5vw, 46px); }
  .p-sub { font-size: 15px; margin-top: 16px; line-height: 1.5; }

  .billing-toggle { margin-top: 24px; padding: 4px; }
  .billing-toggle button { padding: 8px 14px; font-size: 13px; }
  .billing-toggle .save-badge { font-size: 10px; padding: 2px 6px; }

  .tariffs {
    grid-template-columns: 1fr !important;
    gap: 16px;
    /* keep some breathing room for the "Популярный" pill on the featured card */
    padding-top: 14px;
  }
  /* "Бизнес" наверху — featured first */
  .tariff.featured {
    order: -1 !important;
    transform: none !important;
    box-shadow: 0 18px 40px -12px rgba(15,138,94,0.35), 0 8px 20px rgba(15,138,94,0.12) !important;
  }
  .tariff.featured:hover { transform: none !important; }
  .tariff { padding: 28px 22px; border-radius: 22px; }
  .tariff h3 { font-size: 26px; margin-top: 12px; }
  .tariff .tariff-desc { font-size: 14px; min-height: 0; }

  .price-block { margin-top: 22px; padding-bottom: 22px; }
  .price-amount { font-size: 40px; }
  .price-amount .price-currency { font-size: 22px; }
  .price-old { font-size: 13px; }
  .price-hint { font-size: 11.5px; }

  .tariff-features { margin-top: 20px; gap: 10px; }
  .feat-row { font-size: 14px; }
  .feat-row .feat-muted { font-size: 12.5px; }

  .tariff-cta { height: 48px; font-size: 14.5px; margin-top: 20px; }

  .guarantees {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 18px 20px;
    margin-bottom: 32px;
    border-radius: 18px;
  }
  .g-item { white-space: normal; }
  .g-item > div { white-space: normal; }
  .g-item b { font-size: 13.5px; }

  /* ---- payment modal → bottom sheet ---- */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .modal {
    max-width: 100%;
    width: 100%;
    max-height: 92vh;
    border-radius: 22px 22px 0 0;
    transform: translateY(100%);
    transition: transform 280ms cubic-bezier(.2,.7,.2,1);
    box-shadow: 0 -20px 60px rgba(10,10,10,0.18);
  }
  .modal-overlay.open .modal { transform: translateY(0); }

  /* drag-handle indicator on top of the sheet */
  .modal::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 38px;
    height: 4px;
    border-radius: 999px;
    background: var(--line);
    z-index: 5;
  }

  .modal-head { padding: 22px 20px 0; gap: 12px; }
  .modal-head h3 { font-size: 19px; }
  .modal-head .modal-sub { font-size: 13px; margin-top: 4px; }
  .modal-close { width: 32px; height: 32px; }

  .modal-summary {
    margin: 16px 20px 0;
    padding: 14px 16px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .modal-summary .ms-tariff { font-size: 14px; }
  .modal-summary .ms-period { font-size: 12px; }
  .modal-summary .ms-price { font-size: 19px; }
  .modal-summary .ms-price small { font-size: 11.5px; }

  .user-counter { margin: 12px 20px 0; padding: 14px 16px; gap: 12px; }
  .user-counter .uc-title { font-size: 13.5px; }
  .user-counter .uc-hint { font-size: 12px; }

  .token-picker { margin: 10px 20px 0; padding: 16px; }
  .token-picker .tp-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .token-picker .tp-value-wrap { align-items: stretch; }
  .token-picker .tp-input { width: 100%; }
  .token-picker .tp-unit { text-align: right; }
  .token-picker .tp-presets { gap: 6px; }
  .token-picker .tp-preset { padding: 6px 10px; font-size: 12px; }

  .type-tabs { margin: 18px 20px 0; }
  .type-tab { padding: 9px 8px; font-size: 13px; gap: 6px; }

  .modal-form { padding: 18px 20px 18px; }
  .form-grid { grid-template-columns: 1fr !important; gap: 12px; }
  .field input, .field select, .field textarea { height: 44px; font-size: 14px; }
  .pay-methods { grid-template-columns: 1fr !important; gap: 8px; }
  .pay-method { padding: 12px; }
  .pay-method .pm-name { font-size: 13.5px; }
  .pay-method .pm-desc { font-size: 11px; }

  .modal-foot {
    padding: 14px 20px 22px;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px;
  }
  .foot-total { flex-direction: row; align-items: baseline; gap: 8px; justify-content: space-between; }
  .foot-total .label { font-size: 12.5px; }
  .foot-total .amount { font-size: 20px; }
  .modal-foot .pay-btn { width: 100% !important; justify-content: center !important; height: 50px; }

  .modal-success { padding: 36px 24px 28px; }
  .modal-success h3 { font-size: 21px; }
  .modal-success p { font-size: 14px; }
  .modal-success .ms-meta { padding: 14px; gap: 16px; flex-direction: column; }
  .modal-success .ms-actions { flex-direction: column; }
  .modal-success .ms-actions .btn { width: 100%; }

  /* =====================================================================
     PRIVACY.HTML
     ===================================================================== */
  .legal-page { padding: 36px 0 60px; }
  .legal-page h1 { font-size: clamp(28px, 7.5vw, 40px); line-height: 1.08; }
  .legal-page h1 br { display: none; }
  .legal-meta { font-size: 12px; }
  .legal-content { margin-top: 32px; font-size: 14.5px; line-height: 1.65; }
  .legal-content h2 {
    font-size: 18px;
    margin-top: 32px;
    margin-bottom: 12px;
    padding-top: 20px;
  }
  .legal-content ul { padding-left: 16px; }
  .legal-content ul li { font-size: 14px; }
  .legal-back { margin-top: 40px; }

  /* =====================================================================
     SOON.HTML
     ===================================================================== */
  .soon-page { min-height: calc(100vh - 56px); }
  .soon-inner { padding: 24px 18px 56px; }
  .soon-eyebrow { margin-bottom: 20px; }
  .soon-title { font-size: clamp(36px, 10vw, 56px); line-height: 1.04; }
  .soon-title br { display: none; }
  .soon-sub {
    margin-top: 18px;
    font-size: 15.5px;
    line-height: 1.5;
    max-width: 100%;
    text-wrap: pretty;
  }
  .soon-sub br { display: none; }
  .soon-contact {
    margin-top: 24px;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 14px 18px;
    width: 100%;
    text-align: left;
  }
  .soon-back { margin-top: 28px; }

} /* end @media */

/* Tiny phones — keep the layout from getting cramped */
@media (max-width: 380px) {
  .container { padding: 0 14px; }
  .hero h1 { font-size: 34px; }
  .section-title { font-size: 26px; }
  .price-amount { font-size: 36px; }
  .scenario-tab { min-width: 200px; }
  .role-panel { padding: 22px 18px; }
  .role-panel h3 { font-size: 22px; }
}
