*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary-dark: #1c2d41;
  --primary-dark-alt: #1a2b3e;
  --primary-accent: #fab24d;
  --primary-light: #f6f7f7;
  --primary-gray: #ced2d7;
  --max-blue: #0066dd;
  --text-dark: #000000;
  --text-light: #4a5568;
  --white: #ffffff;
  --success-green: #218838;
  --error-red: #dc3545;
  --warning-orange: #ffc107;
  --info-blue: #17a2b8;
  --help-purple: #8a2be2;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 15px 40px rgba(0, 0, 0, 0.12);
  --radius: 16px;
  --transition: all 0.3s ease;
  --msg-user-bg: linear-gradient(135deg, #E8F0FE 0%, #D4E4FC 100%);
  --msg-assistant-bg: var(--white);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--primary-light);
  color: var(--text-dark);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Шапка */
.nav {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-dark-alt) 100%);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}
.nav-brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--white);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-brand img {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 2px solid var(--white);
}
.nav-btn {
  padding: 10px 24px;
  border-radius: 50px;
  border: 2px solid var(--white);
  background: transparent;
  color: var(--white);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.9rem;
  transition: var(--transition);
}
.nav-btn:hover { background: var(--white); color: var(--primary-dark); }
.nav-btn.ghost {
  border: none;
  color: rgba(255,255,255,0.85);
}
.nav-btn.ghost:hover { background: rgba(255,255,255,0.1); color: var(--white); }

/* Кнопки */
.btn {
  display: inline-block;
  padding: 16px 32px;
  border-radius: 50px;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  text-align: center;
}
.btn-primary {
  background-color: var(--primary-accent);
  color: var(--primary-dark);
}
.btn-primary:hover {
  background-color: #ff9c1a;
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(250, 178, 77, 0.3);
}
.btn-secondary {
  background-color: transparent;
  color: var(--white);
  border: 2px solid var(--white);
}
.btn-secondary:hover {
  background-color: var(--white);
  color: var(--primary-dark);
}
.btn-outline {
  background: var(--white);
  border: 1px solid var(--primary-gray);
  color: var(--text-dark);
}
.btn-outline:hover { background: var(--primary-light); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:active { transform: scale(0.98); }

/* Ввод */
.input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--primary-gray);
  border-radius: 12px;
  font-size: 1rem;
  background: var(--white);
  outline: none;
  transition: border 0.2s;
}
.input:focus { border-color: var(--max-blue); }

/* === ЛЕНДИНГ === */
header.landing-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-dark-alt) 100%);
  color: var(--white);
  padding: 40px 20px;
  text-align: center;
}
.header-content {
  max-width: 800px;
  margin: 0 auto;
}
.logo {
  width: 120px;
  height: 120px;
  margin: 0 auto 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border: 6px solid white;
  border-radius: 12px;
}
header.landing-header h1 {
  font-size: 2.8rem;
  font-weight: 800;
  margin-bottom: 20px;
  line-height: 1.2;
}
header.landing-header p {
  font-size: 1.2rem;
  max-width: 700px;
  margin: 0 auto 40px;
  opacity: 0.9;
  font-weight: 300;
}
.cta-buttons {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 30px;
  padding: 60px 0;
}
.feature-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 40px 30px;
  box-shadow: var(--shadow);
  text-align: center;
  border-top: 5px solid var(--max-blue);
  transition: var(--transition);
}
.feature-card:nth-child(2) { border-top-color: var(--success-green); }
.feature-card:nth-child(3) { border-top-color: var(--primary-accent); }
.feature-card:nth-child(4) { border-top-color: var(--help-purple); }
.feature-card:hover {
  transform: translateY(-10px);
  box-shadow: var(--shadow-hover);
}
.feature-icon { font-size: 3rem; margin-bottom: 20px; display: block; }
.feature-card h3 { font-size: 1.5rem; margin-bottom: 12px; color: var(--primary-dark); }
.feature-card p { color: var(--text-dark); font-size: 1rem; }

/* Футер */
footer {
  background-color: var(--primary-dark);
  color: var(--white);
  padding: 60px 20px 40px;
}
.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 40px;
  margin-bottom: 40px;
}
.footer-logo img {
  width: 50px;
  height: 50px;
  border: 6px solid white;
  border-radius: 12px;
}
.footer-links h3 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: var(--primary-accent);
}
.footer-links ul { list-style: none; }
.footer-links li { margin-bottom: 10px; }
.footer-links a {
  color: #e2e8f0;
  text-decoration: none;
  transition: var(--transition);
}
.footer-links a:hover { color: var(--primary-accent); padding-left: 6px; }
.copyright {
  text-align: center;
  padding-top: 40px;
  border-top: 1px solid rgba(255,255,255,0.1);
  color: var(--primary-gray);
  font-size: 0.85rem;
}

/* === АВТОРИЗАЦИЯ === */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 40px 28px;
  box-shadow: var(--shadow);
}
.auth-card h2 {
  text-align: center;
  margin-bottom: 24px;
  color: var(--primary-dark);
  font-size: 1.5rem;
}
.auth-card .btn {
  width: 100%;
  margin-top: 8px;
}
.form-group { margin-bottom: 16px; }
.form-label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.9rem; color: var(--text-dark); }
.form-error { color: var(--error-red); font-size: 0.8rem; margin-top: 4px; }
.form-hint { color: var(--text-light); font-size: 0.85rem; text-align: center; margin-bottom: 12px; }
.link-btn {
  background: none;
  border: none;
  color: var(--max-blue);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
}

/* === ЧАТ === */
.chat-wrapper {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 53px);
  max-width: 1140px;
  margin: 0 auto;
  width: 100%;
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 20px;
  padding-bottom: 20px;
}
.message {
  margin-bottom: 10px;
  max-width: 95%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.95rem;
  word-wrap: break-word;
  line-height: 1.5;
}
.message.user {
  background: var(--msg-user-bg);
  color: var(--text-dark);
  margin-left: auto;
  border-radius: 14px;
  /* border: 1px solid #C5D9F5; */
}
.message.assistant {
  background: var(--msg-assistant-bg);
  /* border: 1px solid var(--primary-gray); */
  /* border-bottom-left-radius: 4px; */
  color: var(--text-dark);
}
.message.system {
  text-align: center;
  color: var(--text-light);
  font-size: 0.85rem;
  max-width: 100%;
  background: none;
  padding: 6px;
  margin: 6px 0;
}
.message ul, .message ol { padding-left: 20px; margin: 6px 0; }
.message li { margin-bottom: 4px; }
.message h1, .message h2, .message h3, .message h4 { font-size: 1rem; margin: 8px 0 4px; }
.message strong { font-weight: 700; }
.message p { margin: 4px 0; }

/* Меню */
.menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 16px;
  background: var(--white);
  border-top: 1px solid var(--primary-gray);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.04);
}
.menu-btn {
  padding: 10px 6px;
  border-radius: 12px;
  border: 1px solid var(--primary-gray);
  background: var(--white);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
  color: var(--text-dark);
}
.menu-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary-accent);
}
.menu-btn.active {
  background: var(--primary-accent);
  color: var(--primary-dark);
  border-color: var(--primary-accent);
}

/* Блоки в чате */
.attach-btn {
  display: inline-block;
  padding: 12px 20px;
  border-radius: 12px;
  border: 1px solid var(--primary-gray);
  background: var(--white);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-dark);
  transition: var(--transition);
}
.attach-btn:hover { background: var(--primary-light); border-color: var(--primary-accent); }
.attach-btn input { display: none; }

.file-chip {
  background: rgba(0, 102, 221, 0.08);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  display: inline-block;
  margin: 2px;
  color: var(--max-blue);
  font-weight: 500;
}

.chat-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* Адаптив */
@media (max-width: 768px) {
  .features { grid-template-columns: 1fr; }
  header.landing-header h1 { font-size: 2rem; }
  .message { max-width: 92%; }
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--primary-gray);
  border-top: 2px solid var(--primary-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}