:root {
      --bg: #0e0e10;
      --surface: #15171b;
      --surface-2: #1c1f25;
      --surface-3: #22262d;
      --text: #e8e8e8;
      --text-secondary: #9ca3af;
      --text-muted: #6b7280;
      --border: #2b3038;
      --accent: #3b82f6;
      --accent-hover: #60a5fa;
      --accent-soft: rgba(59, 130, 246, 0.13);
      --header-bg: rgba(14, 14, 16, 0.94);
      --user-message: #253044;
      --assistant-message: #181b20;
      --danger: #fca5a5;
      --danger-bg: #351719;
      --success: #86efac;
      --success-bg: #14271b;
      --shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
      --overlay: rgba(0, 0, 0, 0.68);
    }

    [data-theme="light"] {
      --bg: #f7f7f7;
      --surface: #ffffff;
      --surface-2: #f5f7fa;
      --surface-3: #eef1f5;
      --text: #1a1a1a;
      --text-secondary: #6b7280;
      --text-muted: #8a919d;
      --border: #e1e5ea;
      --accent: #3b82f6;
      --accent-hover: #2563eb;
      --accent-soft: rgba(59, 130, 246, 0.09);
      --header-bg: rgba(247, 247, 247, 0.94);
      --user-message: #1a2332;
      --assistant-message: #ffffff;
      --danger: #b91c1c;
      --danger-bg: #fef2f2;
      --success: #166534;
      --success-bg: #f0fdf4;
      --shadow: 0 12px 35px rgba(26, 35, 50, 0.09);
      --overlay: rgba(15, 23, 42, 0.48);
    }

    * {
      box-sizing: border-box;
    }

    html {
      min-width: 320px;
      min-height: 100%;
      overflow-x: hidden;
      overflow-y: auto;
      scroll-behavior: smooth;
    }

    body {
      margin: 0;
      min-width: 320px;
      min-height: 100vh;
      overflow-x: hidden;
      overflow-y: auto;
      position: static;
      color: var(--text);
      background: var(--bg);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, Helvetica, Arial, sans-serif;
      font-size: 16px;
      line-height: 1.5;
      transition:
        color 0.2s ease,
        background-color 0.2s ease;
    }

    button,
    input,
    textarea,
    select {
      font: inherit;
    }

    button {
      cursor: pointer;
    }

    button:disabled {
      cursor: not-allowed;
      opacity: 0.55;
    }

    a {
      color: var(--accent);
    }

    .app {
      min-height: 100vh;
      display: flex;
      flex-direction: column;
    }

    /* HEADER */

    .header {
      position: sticky;
      top: 0;
      z-index: 20;
      background: var(--header-bg);
      border-bottom: 1px solid var(--border);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
    }

    .header-inner {
      width: min(1180px, calc(100% - 28px));
      min-height: 64px;
      margin: 0 auto;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 9px;
      flex-shrink: 0;
      color: var(--text);
      font-size: 14px;
      font-weight: 750;
      letter-spacing: 0.07em;
      text-transform: uppercase;
    }

    .brand-mark {
      width: 27px;
      height: 27px;
      display: grid;
      place-items: center;
      border: 2px solid var(--text);
      border-radius: 8px;
    }

    .brand-mark span {
      width: 9px;
      height: 9px;
      border: 2px solid var(--text);
      transform: rotate(45deg);
    }

    .header-actions {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 7px;
    }

    .limit {
      display: none;
      padding: 6px 10px;
      color: var(--text-secondary);
      background: var(--surface-2);
      border-radius: 8px;
      font-size: 12px;
      white-space: nowrap;
    }

    .limit strong {
      color: var(--text);
    }

    .header-btn,
    .theme-btn,
    .language-btn {
      min-height: 42px;
      padding: 8px 11px;
      color: var(--text);
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 9px;
      font-size: 13px;
      font-weight: 650;
      white-space: nowrap;
      transition:
        color 0.2s ease,
        background 0.2s ease,
        border-color 0.2s ease;
    }

    .header-btn:hover,
    .theme-btn:hover,
    .language-btn:hover {
      color: var(--accent);
      border-color: var(--accent);
    }

    .theme-btn {
      width: 42px;
      padding: 0;
      display: grid;
      place-items: center;
      font-size: 18px;
    }

    .language-wrap {
      position: relative;
    }

    .language-btn {
      min-width: 76px;
    }

    .language-menu {
      position: absolute;
      top: calc(100% + 7px);
      right: 0;
      z-index: 50;
      min-width: 145px;
      padding: 5px;
      display: none;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      box-shadow: var(--shadow);
    }

    .language-menu.visible {
      display: block;
    }

    .language-option {
      width: 100%;
      min-height: 42px;
      padding: 8px 10px;
      color: var(--text);
      background: transparent;
      border: 0;
      border-radius: 7px;
      text-align: left;
      font-size: 14px;
    }

    .language-option:hover,
    .language-option.active {
      background: var(--accent-soft);
      color: var(--accent);
    }

    /* BANNERS */

    .banner {
      display: none;
      width: min(900px, calc(100% - 28px));
      margin: 12px auto 0;
      padding: 12px 15px;
      border-radius: 10px;
      font-size: 14px;
    }

    .banner.visible {
      display: block;
    }

    .banner.error {
      color: var(--danger);
      background: var(--danger-bg);
      border: 1px solid var(--border);
    }

    .banner.success {
      color: var(--success);
      background: var(--success-bg);
      border: 1px solid var(--border);
    }

    /* MAIN */

    .main {
      width: 100%;
      flex: 1;
      display: flex;
      flex-direction: column;
    }

    /* LANDING */

    .landing {
      width: min(1100px, calc(100% - 28px));
      margin: 0 auto;
      padding: 48px 0 36px;
    }

    .landing.hidden {
      display: none;
    }

    .hero {
      max-width: 780px;
      margin: 0 auto 38px;
      text-align: center;
    }

    .hero h1 {
      margin: 0 0 16px;
      color: var(--text);
      font-size: clamp(32px, 6vw, 52px);
      line-height: 1.08;
      letter-spacing: -0.035em;
    }

    .hero p {
      max-width: 650px;
      margin: 0 auto;
      color: var(--text-secondary);
      font-size: 17px;
      line-height: 1.6;
    }

    .personas {
      display: grid;
      grid-template-columns: 1fr;
      gap: 14px;
    }

    .persona {
      display: flex;
      flex-direction: column;
      min-height: 270px;
      padding: 22px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 16px;
      transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.2s ease,
        opacity 0.2s ease;
    }

    .persona:hover {
      border-color: var(--accent);
      box-shadow: var(--shadow);
      transform: translateY(-2px);
    }

    .persona.selected {
      border-color: var(--accent);
      box-shadow: 0 0 0 3px var(--accent-soft);
    }

    .persona.dimmed {
      opacity: 0.45;
    }

    .persona-icon {
      width: 48px;
      height: 48px;
      display: grid;
      place-items: center;
      margin-bottom: 18px;
      color: var(--text);
      background: var(--surface-2);
      border-radius: 13px;
    }

    .persona-icon svg {
      width: 27px;
      height: 27px;
      fill: none;
      stroke: currentColor;
      stroke-width: 1.8;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .persona h2 {
      margin: 0 0 3px;
      color: var(--text);
      font-size: 20px;
      line-height: 1.2;
    }

    .persona-role {
      margin-bottom: 10px;
      color: var(--accent);
      font-size: 13px;
      font-weight: 700;
    }

    .persona p {
      margin: 0 0 20px;
      color: var(--text-secondary);
      font-size: 14px;
      line-height: 1.5;
    }

    .persona-btn {
      width: 100%;
      min-height: 44px;
      margin-top: auto;
      color: var(--text);
      background: transparent;
      border: 1px solid var(--border);
      border-radius: 9px;
      font-weight: 650;
    }

    .persona-btn:hover {
      border-color: var(--accent);
      color: var(--accent);
    }

    .persona.selected .persona-btn {
      color: #ffffff;
      background: var(--accent);
      border-color: var(--accent);
    }

    /* CHAT */

    .chat {
      width: min(900px, calc(100% - 28px));
      flex: 1;
      margin: 0 auto;
      display: none;
      flex-direction: column;
      min-height: 0;
    }

    .chat.visible {
      display: flex;
    }

    .chat-header {
      padding: 20px 0 12px;
    }

    .chat-title {
      margin: 0;
      color: var(--text);
      font-size: 20px;
      font-weight: 700;
    }

    .chat-subtitle {
      margin: 3px 0 0;
      color: var(--text-secondary);
      font-size: 13px;
    }

    .messages {
      min-height: 180px;
      max-height: 58vh;
      overflow-y: auto;
      overflow-x: hidden;
      padding: 12px 3px 24px;
      overscroll-behavior: contain;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: thin;
      scrollbar-color: var(--border) transparent;
    }

    .message-row {
      display: flex;
      margin-bottom: 16px;
    }

    .message-row.user {
      justify-content: flex-end;
    }

    .message-row.assistant {
      justify-content: flex-start;
    }

    .message {
      max-width: min(82%, 720px);
      padding: 13px 16px;
      border-radius: 15px;
      overflow-wrap: anywhere;
    }

    .message.user {
      color: #ffffff;
      background: var(--user-message);
      border-bottom-right-radius: 5px;
    }

    .message.assistant {
      color: var(--text);
      background: var(--assistant-message);
      border: 1px solid var(--border);
      border-bottom-left-radius: 5px;
    }

    .message p {
      margin: 0 0 10px;
    }

    .message p:last-child {
      margin-bottom: 0;
    }

    .message ul,
    .message ol {
      margin: 8px 0;
      padding-left: 22px;
    }

    .message li {
      margin: 4px 0;
    }

    .message strong {
      font-weight: 750;
    }

    .message code {
      padding: 2px 5px;
      color: var(--text);
      background: var(--surface-3);
      border-radius: 4px;
      font-size: 0.9em;
    }

    .message pre {
      max-width: 100%;
      overflow-x: auto;
      padding: 12px;
      background: var(--surface-3);
      border-radius: 8px;
    }

    .message pre code {
      padding: 0;
      background: transparent;
    }

    .message h1,
    .message h2,
    .message h3 {
      margin: 14px 0 7px;
      line-height: 1.25;
    }

    .message h1 {
      font-size: 22px;
    }

    .message h2 {
      font-size: 19px;
    }

    .message h3 {
      font-size: 17px;
    }

    .typing {
      display: none;
      align-items: center;
      gap: 9px;
      margin: 0 0 14px;
      color: var(--text-secondary);
      font-size: 13px;
    }

    .typing.visible {
      display: flex;
    }

    .typing-dots {
      display: flex;
      gap: 4px;
    }

    .typing-dots span {
      width: 6px;
      height: 6px;
      background: var(--text-secondary);
      border-radius: 50%;
      animation: typing 1.1s infinite ease-in-out;
    }

    .typing-dots span:nth-child(2) {
      animation-delay: 0.15s;
    }

    .typing-dots span:nth-child(3) {
      animation-delay: 0.3s;
    }

    @keyframes typing {
      0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
      }

      30% {
        opacity: 1;
        transform: translateY(-3px);
      }
    }

    /* COMPOSER */

    .composer-wrap {
      position: sticky;
      bottom: 0;
      z-index: 10;
      padding: 10px 0 16px;
      background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0),
        var(--bg) 18%
      );
    }

    .composer {
      padding: 9px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 15px;
      box-shadow: var(--shadow);
    }

    .persona-select-row {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 2px 3px 8px;
    }

    .persona-select-label {
      color: var(--text-secondary);
      font-size: 12px;
      white-space: nowrap;
    }

    .persona-select {
      min-height: 38px;
      flex: 1;
      padding: 5px 8px;
      color: var(--text);
      background: var(--surface-2);
      border: 1px solid transparent;
      border-radius: 8px;
      outline: none;
      font-size: 13px;
    }

    .persona-select:focus {
      border-color: var(--accent);
    }

    .composer-row {
      display: flex;
      align-items: flex-end;
      gap: 8px;
    }

    .question-input {
      flex: 1;
      width: 100%;
      min-height: 48px;
      max-height: 180px;
      resize: none;
      padding: 12px 13px;
      color: var(--text);
      background: var(--surface-2);
      border: 1px solid transparent;
      border-radius: 11px;
      outline: none;
      font-size: 16px;
      line-height: 1.45;
    }

    .question-input::placeholder {
      color: var(--text-muted);
    }

    .question-input:focus {
      border-color: var(--accent);
      background: var(--surface);
      box-shadow: 0 0 0 2px var(--accent-soft);
    }

    .ask-button {
      min-width: 105px;
      min-height: 48px;
      padding: 10px 16px;
      color: #ffffff;
      background: var(--accent);
      border: 0;
      border-radius: 11px;
      font-weight: 700;
    }

    .ask-button:hover:not(:disabled) {
      background: var(--accent-hover);
    }

    .composer-note {
      margin: 6px 3px 0;
      color: var(--text-muted);
      font-size: 11px;
    }

    /* MODAL */

    .modal-overlay {
      position: fixed;
      inset: 0;
      z-index: 100;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 18px;
      background: var(--overlay);
      backdrop-filter: blur(4px);
      -webkit-backdrop-filter: blur(4px);
    }

    .modal-overlay.visible {
      display: flex;
    }

    .modal {
      width: min(440px, 100%);
      max-height: calc(100vh - 36px);
      overflow-y: auto;
      padding: 25px;
      color: var(--text);
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 18px;
      box-shadow: var(--shadow);
    }

    .modal h2 {
      margin: 0 0 8px;
      color: var(--text);
      font-size: 22px;
      line-height: 1.25;
    }

    .modal-description {
      margin: 0 0 20px;
      color: var(--text-secondary);
      font-size: 14px;
      line-height: 1.5;
    }

    .modal-close {
      float: right;
      width: 40px;
      height: 40px;
      margin: -7px -7px 0 10px;
      color: var(--text-secondary);
      background: transparent;
      border: 0;
      border-radius: 8px;
      font-size: 23px;
    }

    .modal-close:hover {
      color: var(--text);
      background: var(--surface-2);
    }

    .field {
      margin-bottom: 14px;
    }

    .field label {
      display: block;
      margin-bottom: 6px;
      color: var(--text);
      font-size: 13px;
      font-weight: 650;
    }

    .field input {
      width: 100%;
      min-height: 46px;
      padding: 10px 12px;
      color: var(--text);
      background: var(--surface-2);
      border: 1px solid var(--border);
      border-radius: 9px;
      outline: none;
      font-size: 16px;
    }

    .field input:focus {
      border-color: var(--accent);
      box-shadow: 0 0 0 3px var(--accent-soft);
    }

    .modal-submit {
      width: 100%;
      min-height: 48px;
      margin-top: 5px;
      color: #ffffff;
      background: var(--accent);
      border: 0;
      border-radius: 10px;
      font-weight: 700;
    }

    .modal-submit:hover:not(:disabled) {
      background: var(--accent-hover);
    }

    .modal-error {
      display: none;
      margin-bottom: 13px;
      padding: 10px 12px;
      color: var(--danger);
      background: var(--danger-bg);
      border: 1px solid var(--border);
      border-radius: 8px;
      font-size: 13px;
    }

    .modal-error.visible {
      display: block;
    }

    /* PAYMENT */

    .payment-modal {
      text-align: center;
    }

    .payment-icon {
      width: 54px;
      height: 54px;
      display: grid;
      place-items: center;
      margin: 0 auto 18px;
      color: var(--accent);
      background: var(--accent-soft);
      border-radius: 14px;
    }

    .payment-icon svg {
      width: 28px;
      height: 28px;
      fill: none;
      stroke: currentColor;
      stroke-width: 1.8;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    .payment-text {
      margin: 0 0 20px;
      color: var(--text-secondary);
      font-size: 15px;
    }

    .payment-btn {
      display: flex;
      min-height: 48px;
      align-items: center;
      justify-content: center;
      width: 100%;
      color: #ffffff;
      background: var(--accent);
      border-radius: 10px;
      text-decoration: none;
      font-weight: 700;
    }

    .payment-btn:hover {
      background: var(--accent-hover);
    }

    .payment-note {
      margin: 14px 0 0;
      color: var(--text-secondary);
      font-size: 12px;
    }

    /* FOOTER */

    footer {
      padding: 20px 14px 25px;
      color: var(--text-muted);
      text-align: center;
      font-size: 11px;
      line-height: 1.5;
    }


    /* NAVIGATION MENU */

    .site-header-left {
      display: flex;
      align-items: center;
      gap: 9px;
      flex-shrink: 0;
    }

    .menu-wrap {
      position: relative;
      flex-shrink: 0;
    }

    .menu-button {
      width: 42px;
      height: 42px;
      padding: 0;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 5px;
      color: var(--text);
      background: transparent;
      border: 0;
      border-radius: 8px;
    }

    .menu-button:hover {
      color: var(--accent);
      background: var(--accent-soft);
    }

    .menu-button span {
      display: block;
      width: 19px;
      height: 1px;
      background: currentColor;
    }

    .site-menu {
      position: absolute;
      top: calc(100% + 7px);
      left: 0;
      z-index: 50;
      min-width: 150px;
      padding: 5px 0;
      display: none;
      background: var(--surface);
      border-radius: 8px;
    }

    .site-menu.visible {
      display: block;
    }

    .site-menu a {
      display: block;
      padding: 9px 12px;
      color: var(--text);
      background: transparent;
      text-decoration: none;
      font-size: 14px;
      line-height: 1.4;
    }

    .site-menu a:hover {
      color: var(--accent);
      background: var(--accent-soft);
    }

    /* RESPONSIVE */

    @media (min-width: 650px) {
      .header-inner {
        width: min(1180px, calc(100% - 42px));
      }

      .limit {
        display: block;
      }

      .landing {
        width: min(1100px, calc(100% - 42px));
        padding-top: 60px;
      }

      .personas {
        grid-template-columns: repeat(2, 1fr);
      }

      .chat {
        width: min(900px, calc(100% - 42px));
      }

      .message {
        max-width: 76%;
      }
    }

    @media (min-width: 980px) {
      .personas {
        grid-template-columns: repeat(4, 1fr);
      }

      .persona {
        min-height: 300px;
      }
    }

    @media (max-width: 520px) {
      .header-inner {
        min-height: 58px;
      }

      .brand {
        font-size: 12px;
      }

      .brand-mark {
        width: 24px;
        height: 24px;
      }

      .header-actions {
        gap: 4px;
      }

      .header-btn,
      .language-btn {
        padding: 7px 8px;
        font-size: 12px;
      }

      .theme-btn {
        width: 40px;
      }

      .limit {
        display: none !important;
      }

      .landing {
        padding-top: 35px;
      }

      .hero {
        margin-bottom: 30px;
      }

      .message {
        max-width: 90%;
      }

      .messages {
        max-height: 52vh;
      }

      .composer-row {
        align-items: stretch;
      }

      .ask-button {
        min-width: 82px;
        padding: 8px 11px;
      }

      .composer-note {
        display: none;
      }

      .modal {
        padding: 21px;
      }
    }

    @media (prefers-reduced-motion: reduce) {
      *,
      *::before,
      *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
      }
    }


/* AUXILIARY PAGES */

.aux-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.aux-main {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 72px 24px 80px;
  box-sizing: border-box;
}

.aux-content {
  max-width: 720px;
}

.aux-content h1 {
  margin: 0 0 18px;
  font-size: 32px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text);
}

.aux-content p {
  margin: 0 0 14px;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.7;
}

@media (max-width: 640px) {
  .aux-main {
    padding: 48px 20px 60px;
  }

  .aux-content h1 {
    font-size: 28px;
  }
}
