:root {
  --bg-canvas: #0b0e14;
  --bg-surface: #131722;
  --bg-elevated: #1b2130;
  --border-subtle: rgba(241, 245, 249, 0.09);
  --text-primary: #f8fafc;
  --text-secondary: #b6c2d6;
  --text-muted: #7e8da6;
  --accent: #f43f5e;
  --accent-hover: #e11d48;
  --accent-soft: rgba(244, 63, 94, 0.14);
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-soft: 0 12px 32px rgba(0, 0, 0, 0.35);
}

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

::selection {
  background: var(--accent);
  color: #ffffff;
}

*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100dvh;
  width: 100%;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(248, 250, 252, 0.16);
  border-radius: 999px;
}

.hidden {
  display: none !important;
}

/* Экран авторизации */
.auth-screen {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 0%, rgba(244, 63, 94, 0.12), transparent 55%), var(--bg-canvas);
}

.auth-panel {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-soft);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.auth-brand img {
  width: 48px;
  height: 48px;
  border-radius: 14px;
}

.auth-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  margin: 4px 0 0;
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 16px 0 8px;
}

.text-input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-size: 1rem;
  caret-color: var(--accent);
}

.btn-primary {
  width: 100%;
  margin-top: 16px;
  padding: 13px 16px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.96rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease;
}

.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-primary:active {
  transform: scale(0.99);
}
.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
}

.auth-error {
  margin-top: 12px;
  font-size: 0.86rem;
  color: #fda4af;
}

.auth-hint {
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Основной макет приложения */
.app-shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 760px;
  margin: 0 auto;
  background: var(--bg-canvas);
}

.topbar {
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.topbar-name {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
}

.topbar-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.tier-pill {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(244, 63, 94, 0.35);
  background: var(--accent-soft);
  color: #fecdd3;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

/* Баннер установки PWA */
.pwa-banner {
  margin: 10px 14px 0;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pwa-banner-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.pwa-banner-text strong {
  color: var(--text-primary);
  display: block;
  margin-bottom: 2px;
}

/* Вкладки */
.tab-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Чат */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 84%;
}

.msg-row.user {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-row.model {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-bubble {
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-row.user .msg-bubble {
  background: var(--accent);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.msg-row.model .msg-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.msg-audio {
  margin-top: 6px;
  width: 240px;
  max-width: 100%;
  height: 36px;
}

.msg-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.msg-thumbs img {
  width: 68px;
  height: 68px;
  object-fit: cover;
  border-radius: 10px;
}

.chips-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 14px 4px;
  scrollbar-width: none;
}
.chips-bar::-webkit-scrollbar {
  display: none;
}

.chip-btn {
  flex-shrink: 0;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
}

.preview-strip {
  display: flex;
  gap: 8px;
  padding: 6px 14px;
  overflow-x: auto;
}

.preview-item {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}

.preview-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: none;
  background: #0b0e14;
  color: #ffffff;
  font-size: 12px;
  cursor: pointer;
}

.composer {
  padding: 8px 12px 10px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.composer textarea {
  flex: 1;
  min-height: 40px;
  max-height: 110px;
  resize: none;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.35;
}

.composer-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

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

.composer-btn.recording {
  background: #dc2626;
  border-color: #dc2626;
  animation: pulseRec 1.1s infinite;
}

@keyframes pulseRec {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Нижняя навигация */
.bottom-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-tab {
  padding: 10px 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
}

.nav-tab.active {
  color: var(--accent);
}

/* Модальные окна (Тарифы, Профиль, iOS установка) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 11, 0.78);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
  padding: 16px;
}

@media (min-width: 600px) {
  .modal-backdrop {
    align-items: center;
  }
}

.modal-sheet {
  width: 100%;
  max-width: 460px;
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-soft);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.plan-row {
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-canvas);
  margin-bottom: 10px;
}

.plan-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.plan-name {
  font-weight: 600;
  font-size: 1rem;
}

.plan-price {
  font-weight: 700;
  color: #fecdd3;
}

.plan-features {
  margin: 0 0 10px;
  padding-left: 18px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Вкладка звонка внутри app-shell */
.call-pane {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
