/* Grandma Online — большие шрифты, высокий контраст, простая навигация */

:root {
  --bg: #fffaf3;
  --bg-card: #ffffff;
  --bg-user: #2563eb;
  --bg-user-text: #ffffff;
  --bg-bot: #f1f5f9;
  --bg-bot-text: #1e293b;
  --bg-input: #ffffff;
  --bg-page: #fef9f1;
  --primary: #16a34a;
  --primary-hover: #15803d;
  --primary-active: #166534;
  --text: #1e293b;
  --text-soft: #64748b;
  --text-faint: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --warn: #d97706;
  --danger: #dc2626;
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
  --radius: 14px;
  --radius-lg: 22px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Atkinson Hyperlegible', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 18px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* === Header === */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-card);
  border-bottom: 2px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.header-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 22px;
}

.logo-icon { font-size: 28px; }

.header-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 17px;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--text);
  border: 2px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}

.header-btn:hover { background: var(--bg-bot); }
.header-btn span[aria-hidden] {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-weight: 700;
}

/* === Chat container === */
.chat-container {
  flex: 1;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 16px;
  display: flex;
  flex-direction: column;
}

/* === Welcome card === */
.welcome-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.welcome-emoji {
  font-size: 64px;
  margin-bottom: 8px;
  animation: wave 2.5s ease-in-out infinite;
  transform-origin: 70% 70%;
}

@keyframes wave {
  0%, 60%, 100% { transform: rotate(0deg); }
  10%, 30% { transform: rotate(14deg); }
  20% { transform: rotate(-8deg); }
  40% { transform: rotate(-4deg); }
}

.welcome-title {
  font-size: 32px;
  font-weight: 700;
  margin: 0 0 12px;
  line-height: 1.2;
}

.welcome-text {
  font-size: 19px;
  color: var(--text-soft);
  margin: 0 0 24px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.chip {
  padding: 12px 20px;
  background: var(--bg-card);
  border: 2px solid var(--border-strong);
  border-radius: 999px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.chip:hover {
  background: #ecfdf5;
  border-color: var(--primary);
  color: var(--primary-hover);
  transform: translateY(-1px);
}

.chip:active { transform: translateY(0); }

/* === Messages === */
.messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 85%;
  animation: fadeInUp 0.25s ease-out;
}

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

.message.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 2px solid var(--border);
}

.message.user .message-avatar { background: #dbeafe; }
.message.bot .message-avatar { background: #fef3c7; }

.message-bubble {
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 18px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.message.user .message-bubble {
  background: var(--bg-user);
  color: var(--bg-user-text);
  border-bottom-right-radius: 4px;
}

.message.bot .message-bubble {
  background: var(--bg-bot);
  color: var(--bg-bot-text);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}

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

.message-action {
  padding: 6px 12px;
  font-size: 14px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  color: var(--text-soft);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.message-action:hover {
  background: #ecfdf5;
  border-color: var(--primary);
  color: var(--primary-hover);
}

/* Typing indicator */
.typing {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.typing span {
  width: 10px;
  height: 10px;
  background: var(--text-faint);
  border-radius: 50%;
  animation: typingDot 1.4s ease-in-out infinite;
}

.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* === Input bar === */
.input-bar {
  position: sticky;
  bottom: 0;
  background: var(--bg-card);
  border-top: 2px solid var(--border);
  padding: 14px 20px 18px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.04);
}

.limit-pill {
  max-width: 800px;
  margin: 0 auto 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: #fef3c7;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: #92400e;
}

.limit-pill.low {
  background: #fee2e2;
  color: #991b1b;
}

.input-form {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.icon-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border-strong);
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: inherit;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg-bot);
  border-color: var(--primary);
}

.icon-btn.recording {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
  animation: pulse 1.5s ease-in-out infinite;
}

.icon-btn.call-btn {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e40af;
}

.icon-btn.call-btn:hover {
  background: #bfdbfe;
  border-color: var(--primary);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(220, 38, 38, 0); }
}

.message-input {
  flex: 1;
  padding: 14px 18px;
  font-size: 18px;
  font-family: inherit;
  background: var(--bg-input);
  border: 2px solid var(--border-strong);
  border-radius: 26px;
  resize: none;
  max-height: 160px;
  min-height: 52px;
  line-height: 1.4;
  color: var(--text);
}

.message-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.send-btn {
  height: 52px;
  padding: 0 24px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 26px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.send-btn:hover:not(:disabled) { background: var(--primary-hover); }
.send-btn:active:not(:disabled) { background: var(--primary-active); }
.send-btn:disabled {
  background: var(--text-faint);
  cursor: not-allowed;
}

.send-icon { font-size: 22px; }

@media (max-width: 540px) {
  .send-text { display: none; }
  .send-btn { padding: 0 18px; }
  .send-icon { font-size: 26px; }
  .welcome-title { font-size: 26px; }
  .welcome-text { font-size: 17px; }
  .message { max-width: 92%; }
  .message-bubble { font-size: 17px; padding: 12px 16px; }
  .message-input { font-size: 16px; }
}

/* На самых узких экранах прячем кнопку звонка — оставляем mic + send для места под плейсхолдер */
@media (max-width: 320px) {
  .call-btn { display: none; }
  .icon-btn { width: 46px; height: 46px; font-size: 22px; }
  .message-input { padding: 12px 14px; }
}

/* Перебиваем любой возможный кэш — call-btn явно синий */
.icon-btn.call-btn,
button.icon-btn.call-btn {
  background-color: #dbeafe !important;
  border-color: #93c5fd !important;
  color: #1e40af !important;
}

.icon-btn.call-btn:hover,
button.icon-btn.call-btn:hover {
  background-color: #bfdbfe !important;
  border-color: #2563eb !important;
}

.recording-indicator {
  max-width: 800px;
  margin: 8px auto 0;
  padding: 8px 16px;
  background: #fee2e2;
  color: #991b1b;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.recording-dot {
  width: 10px;
  height: 10px;
  background: var(--danger);
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}

/* === Modals === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

/* Атрибут hidden должен реально скрывать элемент (перебивает display:flex выше) */
[hidden] {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal h2 {
  margin: 0 0 16px;
  font-size: 26px;
}

.help-steps {
  margin: 0 0 16px;
  padding-left: 20px;
}

.help-steps li {
  margin-bottom: 12px;
  font-size: 17px;
  line-height: 1.5;
}

.help-tip {
  background: #fef3c7;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 16px;
  margin: 0 0 20px;
}

.modal-close {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  margin-top: 8px;
}

.modal-close:hover { background: var(--primary-hover); }

.modal-secondary {
  width: 100%;
  padding: 12px;
  background: var(--bg-card);
  color: var(--primary-hover);
  border: 2px solid var(--primary);
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  margin-top: 8px;
}

.modal-secondary:hover { background: #f0fdf4; }

/* Call form */
.call-form { margin-top: 12px; }

.form-label {
  display: block;
  margin-top: 14px;
  margin-bottom: 6px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 18px;
  font-family: inherit;
  background: var(--bg-card);
  border: 2px solid var(--border-strong);
  border-radius: 12px;
  color: var(--text);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.form-textarea {
  resize: vertical;
  min-height: 70px;
  max-height: 200px;
  line-height: 1.4;
}

.call-submit {
  background: #2563eb;
  margin-top: 20px;
}

.call-submit:hover { background: #1d4ed8; }

.call-success {
  text-align: center;
  padding: 16px 0;
}

.call-success h3 {
  font-size: 24px;
  margin: 12px 0 8px;
  color: var(--primary-hover);
}

.success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 36px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: successPop 0.4s ease-out;
}

@keyframes successPop {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Plan cards */
.plan-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}

@media (max-width: 420px) {
  .plan-cards { grid-template-columns: 1fr; }
}

.plan-card {
  position: relative;
  padding: 20px 16px;
  background: var(--bg-card);
  border: 2px solid var(--border-strong);
  border-radius: 16px;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
}

.plan-card:hover { border-color: var(--primary); background: #f0fdf4; }
.plan-card.popular { border-color: var(--primary); background: #f0fdf4; }

.plan-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  background: var(--primary);
  color: white;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.plan-name { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.plan-price { font-size: 28px; font-weight: 700; color: var(--primary-hover); margin-bottom: 4px; }
.plan-price span { font-size: 14px; font-weight: 400; color: var(--text-soft); }
.plan-detail { font-size: 14px; color: var(--text-soft); }

.demo-note {
  font-size: 14px;
  color: var(--text-soft);
  margin: 8px 0;
  text-align: center;
}

/* === Footer === */
.site-footer {
  text-align: center;
  padding: 20px;
  color: var(--text-faint);
  font-size: 14px;
}

/* === Accessibility === */
button:focus-visible,
.message-input:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

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