:root {
  /* Палитра: белый фон + вариации зелёного */
  --primary: #16A34A;
  --primary-light: #4ADE80;
  --primary-dark: #15803D;
  --primary-container: #DCFCE7;
  --primary-soft: #F0FDF4;
  --on-primary-container: #166534;

  --surface: #FFFFFF;
  --surface-glass: rgba(255, 255, 255, 0.74);
  --surface-variant: #F1F5F9;
  --background: #FFFFFF;

  --on-primary: #FFFFFF;
  --on-surface: #0F172A;
  --on-surface-variant: #64748B;
  --outline: #DCE6E0;
  --error: #EF4444;
  --success: #16A34A;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 999px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.1);
  --shadow-glow: 0 0 24px color-mix(in srgb, var(--primary) 20%, transparent);

  --header-height: 64px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface: #13211A;
    --surface-glass: rgba(19, 33, 26, 0.78);
    --surface-variant: #1C2E24;
    --background: #0B140F;
    --on-surface: #E7F0EB;
    --on-surface-variant: #9FB3A8;
    --outline: #2A3D33;
    --primary-container: #14532D;
    --primary-soft: #052E16;
    --on-primary-container: #BBF7D0;
  }
}

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

html, body {
  font-family: 'Inter', 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
  color: var(--on-surface);
  min-height: 100%;
  overflow-x: hidden;
  background:
    radial-gradient(1100px 700px at 85% -10%, color-mix(in srgb, var(--primary-light) 14%, transparent), transparent 60%),
    radial-gradient(900px 600px at -10% 90%, color-mix(in srgb, var(--primary) 10%, transparent), transparent 60%),
    radial-gradient(700px 500px at 60% 120%, color-mix(in srgb, #22C55E 8%, transparent), transparent 60%),
    var(--background);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* ====== СКРОЛЛБАР ====== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--outline); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--on-surface-variant); }

/* ====== ЭКРАНЫ ====== */
.screen {
  min-height: 100vh;
  padding: 16px;
  animation: fadeIn 0.4s ease;
}

.hidden { display: none !important; }

/* ====== КАРТОЧКИ (Glassmorphism) ====== */
.card {
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  min-width: 0;
  overflow-wrap: break-word;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.45s ease both;
  transition: var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

/* ====== ЛОГИН ====== */
.login-card {
  max-width: 420px;
  margin: 8vh auto;
  text-align: center;
  padding: 40px 36px 36px;
}

.login-logo {
  width: 84px;
  height: 84px;
  margin: 0 auto 22px;
  border-radius: 28px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: var(--on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  box-shadow: var(--shadow-glow);
  animation: float 3s ease-in-out infinite;
}

/* ====== ПРИВЕТСТВИЕ ====== */
.welcome-card {
  max-width: 480px;
  text-align: center;
}
.welcome-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 22px 0 26px;
  text-align: left;
}
.welcome-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px;
  background: var(--primary-soft);
  border: 1px solid color-mix(in srgb, var(--primary) 15%, transparent);
  border-radius: var(--radius-md);
  animation: slideUp 0.35s ease both;
}
.welcome-item:nth-child(2) { animation-delay: 0.1s; }
.welcome-item:nth-child(3) { animation-delay: 0.2s; }
.welcome-icon { font-size: 1.4rem; line-height: 1.3; flex-shrink: 0; }
.welcome-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--on-surface-variant);
  margin-bottom: 4px;
}
.welcome-text {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--on-surface);
}

h1.app-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
  background: linear-gradient(135deg, var(--on-surface), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--on-surface);
  display: flex;
  align-items: center;
  gap: 10px;
}
h2::before {
  content: '';
  width: 5px;
  height: 22px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--primary), var(--primary-light));
}

.subtitle {
  color: var(--on-surface-variant);
  margin-bottom: 28px;
  font-size: 0.95rem;
}
.hint {
  font-size: 0.85rem;
  color: var(--on-surface-variant);
  margin-bottom: 14px;
  line-height: 1.5;
}
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--outline), transparent);
  margin: 20px 0;
}
.field-label {
  display: block;
  font-size: 0.8rem;
  color: var(--on-surface-variant);
  margin-bottom: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ====== ПОЛЯ ВВОДА ====== */
.field { margin-bottom: 18px; text-align: left; }
.field label {
  display: block;
  font-size: 0.8rem;
  color: var(--on-surface-variant);
  margin-bottom: 6px;
  font-weight: 600;
}
.field input,
.field textarea,
.custom-input-row input,
.chat-input-row input {
  width: 100%;
  padding: 14px 18px;
  border: 1.5px solid var(--outline);
  border-radius: var(--radius-md);
  font-size: 1rem;
  background: var(--surface);
  color: var(--on-surface);
  font-family: inherit;
  transition: var(--transition);
}
.field input:focus,
.field textarea:focus,
.custom-input-row input:focus,
.chat-input-row input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 12%, transparent);
}
.field textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
}

/* ====== КНОПКИ ====== */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: var(--on-primary);
  border: none;
  padding: 14px 28px;
  border-radius: var(--radius-xl);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--primary) 30%, transparent);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px color-mix(in srgb, var(--primary) 40%, transparent);
}
.btn-primary:hover::after { opacity: 1; }
.btn-primary:active { transform: scale(0.97); }
.btn-block { width: 100%; }
.btn-small { padding: 12px 20px; font-size: 0.85rem; }

.btn-icon {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: var(--on-primary);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  backdrop-filter: blur(4px);
}
.btn-icon:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}
.btn-icon:active { transform: scale(0.92); }

.error {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 12px;
  min-height: 1.2em;
  font-weight: 500;
}
.status {
  color: var(--success);
  font-size: 0.85rem;
  margin-top: 12px;
  min-height: 1.2em;
  font-weight: 600;
}

/* ====== ШАПКА ====== */
.app-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: var(--on-primary);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  position: sticky;
  top: 16px;
  z-index: 100;
  backdrop-filter: blur(12px);
}
.app-bar .app-title {
  color: var(--on-primary);
  font-size: 1.2rem;
  margin: 0;
  -webkit-text-fill-color: var(--on-primary);
}
.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.app-date {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--on-primary);
  white-space: nowrap;
}
.user-chip .avatar {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9);
}

/* ====== АВАТАРКИ ====== */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  user-select: none;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.7), 0 4px 12px rgba(15, 23, 42, 0.15);
  transition: var(--transition);
}
.avatar:hover {
  transform: scale(1.1) rotate(-5deg);
}

/* ====== СЕТКА: карточки адаптируются к ширине экрана ====== */
.content {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
  align-content: start;
}

/* Главный экран — на всю высоту вьюпорта, контент скроллится внутри */
#main-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
#main-screen .app-bar {
  position: static;
  flex-shrink: 0;
}
#main-screen .content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* ====== НАПИТКИ ====== */
.drink-cat {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--on-surface-variant);
  margin: 20px 0 12px;
}
.drink-cat:first-of-type { margin-top: 0; }

/* Вертикальный список напитков: строка = напиток, справа единицы и степпер */
.drinks-list { display: flex; flex-direction: column; gap: 10px; }

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface-variant);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}
.row:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--primary) 25%, transparent);
  box-shadow: var(--shadow-sm);
}
.row.selected {
  background: var(--primary-container);
  border-color: var(--primary);
  box-shadow: 0 3px 12px color-mix(in srgb, var(--primary) 16%, transparent);
}
.row input {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}
.row .name {
  font-size: 0.95rem;
  font-weight: 500;
  flex: 1;
  min-width: 96px;
}
.row.selected .name { font-weight: 600; color: var(--on-primary-container); }

.row .controls {
  display: none;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.row.selected .controls { display: flex; animation: qtyIn 0.2s ease; }

.unit-toggle {
  display: flex;
  background: var(--surface);
  border: 1.5px solid var(--outline);
  border-radius: var(--radius-xl);
  padding: 3px;
  gap: 2px;
}
.unit-opt {
  border: none;
  background: none;
  padding: 4px 12px;
  border-radius: var(--radius-xl);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--on-surface-variant);
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}
.unit-opt.active {
  background: var(--primary);
  color: var(--on-primary);
}
.unit-opt:active { transform: scale(0.94); }

.qty-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--outline);
  background: var(--surface);
  color: var(--primary-dark);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-family: inherit;
  padding: 0;
  flex-shrink: 0;
}
.qty-btn:hover { border-color: var(--primary); background: var(--primary-soft); }
.qty-btn:active { transform: scale(0.88); }

.qty-value {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  background: var(--surface);
  border: 1.5px solid var(--outline);
  border-radius: var(--radius-xl);
  transition: var(--transition);
}
.qty-value:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
}
.qty-input {
  width: 48px;
  border: none;
  background: none;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  font-family: inherit;
  color: var(--on-surface);
  padding: 0;
  -moz-appearance: textfield;
  appearance: textfield;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-input:focus { outline: none; }
.qty-unit {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--on-surface-variant);
  min-width: 1em;
}

.custom-input-row {
  margin-bottom: 14px;
}
#add-custom-drink {
  margin-bottom: 14px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 36px;
}
.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 8px 16px;
  background: var(--primary-container);
  color: var(--on-primary-container);
  border-radius: var(--radius-xl);
  font-size: 0.88rem;
  font-weight: 500;
  animation: popIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid color-mix(in srgb, var(--primary) 15%, transparent);
  transition: var(--transition);
}
.chip:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.chip-x {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--on-primary-container);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.chip-x:hover {
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  transform: rotate(90deg);
}

/* ====== ЕДА ====== */
.food-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.sugg-chip {
  padding: 8px 16px;
  background: var(--surface-variant);
  border: 1.5px solid var(--outline);
  border-radius: var(--radius-xl);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.sugg-chip::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--primary-soft), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}
.sugg-chip:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  color: var(--on-primary-container);
  box-shadow: var(--shadow-sm);
}
.sugg-chip:hover::after { opacity: 1; }
.sugg-chip:active { transform: scale(0.95); }
.sugg-chip.used {
  background: var(--primary-container);
  border-color: var(--primary);
  color: var(--on-primary-container);
  font-weight: 600;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 12%, transparent);
}
.sugg-chip.static {
  cursor: default;
  background: var(--primary-container);
  border-color: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--on-primary-container);
}
.sugg-chip.static:hover {
  transform: none;
  box-shadow: none;
  border-color: color-mix(in srgb, var(--primary) 15%, transparent);
}
.sugg-chip.static::after { display: none; }

/* ====== УЧАСТНИКИ ====== */
.others-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.other-user {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  background: var(--surface-variant);
  border-radius: var(--radius-md);
  border: 1px solid rgba(0, 0, 0, 0.03);
  transition: var(--transition);
  animation: slideUp 0.35s ease both;
}
.other-user:nth-child(1) { animation-delay: 0.05s; }
.other-user:nth-child(2) { animation-delay: 0.1s; }
.other-user:nth-child(3) { animation-delay: 0.15s; }
.other-user:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--primary) 10%, transparent);
}
.other-user .info { flex: 1; min-width: 0; }
.other-user .name { font-weight: 700; font-size: 0.95rem; margin-bottom: 4px; }
.other-user .meta {
  font-size: 0.82rem;
  color: var(--on-surface-variant);
  line-height: 1.5;
}
.other-user .meta span { display: block; word-break: break-word; }

/* ====== ЧАТ ====== */
.chat-card {
  display: flex;
  flex-direction: column;
  align-self: start;
}
.chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
  padding: 6px;
}
.chat-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: slideUp 0.3s ease;
}
.chat-msg .msg-content {
  background: var(--surface-variant);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border-top-left-radius: 4px;
  max-width: 78%;
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: var(--transition);
}
.chat-msg .msg-content:hover {
  box-shadow: var(--shadow-md);
}
.chat-msg .msg-author {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--on-primary-container);
  margin-bottom: 4px;
}
.chat-msg .msg-text {
  font-size: 0.92rem;
  word-break: break-word;
  line-height: 1.45;
}
.chat-msg.own { flex-direction: row-reverse; }
.chat-msg.own .msg-content {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: var(--on-primary);
  border-radius: var(--radius-md);
  border-top-right-radius: 4px;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--primary) 25%, transparent);
}
.chat-msg.own .msg-author {
  color: rgba(255, 255, 255, 0.85);
  text-align: right;
}

.chat-input-row {
  display: flex;
  gap: 10px;
}
.chat-input-row input { flex: 1; min-width: 0; }
.chat-input-row button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.2rem;
}

/* ====== КАРТОЧКА «ПОЛЬЗОВАТЕЛИ» ====== */
.people-card { display: flex; flex-direction: column; align-self: start; }
.people-card .others-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* ====== ТОСТ ====== */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--on-surface);
  color: var(--surface);
  padding: 14px 26px;
  border-radius: var(--radius-xl);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  z-index: 1000;
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 90vw;
  text-align: center;
  backdrop-filter: blur(12px);
}

/* ====== МОДАЛЬНОЕ ОКНО СМЕНЫ ПАРОЛЯ ====== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 900;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: fadeIn 0.25s ease both;
}
.modal-card h3 { margin: 0 0 6px; font-size: 1.15rem; }
.modal-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--outline);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--on-surface);
  font-family: inherit;
  margin-bottom: 8px;
}
.modal-card input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 12%, transparent);
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}
.btn-ghost {
  background: transparent;
  border: 1.5px solid var(--outline);
  color: var(--on-surface-variant);
  padding: 12px 20px;
  border-radius: var(--radius-xl);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}
.btn-ghost:hover { background: var(--surface-variant); }

/* ====== АНИМАЦИИ ====== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
  from { transform: scale(0.85); opacity: 0.5; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes qtyIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 20px) scale(0.95); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ====== REDUCED MOTION ====== */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ====== МОБИЛЬНАЯ АДАПТАЦИЯ ====== */

/* Нижняя навигация — видна только на мобильных */
.bottom-nav { display: none; }

@media (max-width: 1500px) {
  .content { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .content { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .content {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    align-items: stretch;
  }
  /* Видимая карточка (кроме напитков) занимает весь экран, внутренние блоки скроллятся */
  .content > .card:not(.card-hidden):not([data-tab="drinks"]) {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }
  /* На мобиле .content — flex-колонка, align-self управляет шириной:
     возвращаем растяжение на всю ширину (на ПК оно отвечает за высоту) */
  .people-card, .chat-card { align-self: stretch; }

  /* Кнопки-действия на мобиле растягиваем на всю ширину и делаем повыше
     для тача (иначе они остаются узкими inline-кнопками вне flex-карточки напитков) */
  #save-food, #add-custom-drink {
    width: 100%;
    min-height: 54px;
    padding: 15px 24px;
    font-size: 1rem;
  }

  /* Вкладки: на мобильных показываем только активную карточку */
  .content [data-tab].card-hidden { display: none !important; }

  .screen { padding: 10px; padding-bottom: 96px; }

  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    justify-content: space-around;
    background: var(--surface-glass);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    border-top: 1px solid var(--outline);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    z-index: 200;
    box-shadow: 0 -6px 24px rgba(15, 23, 42, 0.08);
  }
  .nav-btn {
    flex: 1;
    min-width: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 7px 4px;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 1.25rem;
    color: var(--on-surface-variant);
    border-radius: 16px;
    transition: var(--transition);
  }
  .nav-btn span {
    font-size: 0.68rem;
    font-weight: 600;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .nav-btn.active {
    color: var(--primary-dark);
    background: var(--primary-container);
  }
  .nav-btn:active { transform: scale(0.94); }
  .nav-btn .badge {
    position: absolute;
    top: 2px;
    left: calc(50% + 8px);
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--error);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    display: none;
  }
  .nav-btn .badge.show { display: block; }

  /* Шапка компактнее */
  .app-bar {
    top: 8px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
  }
  .app-bar .app-title { font-size: 1.05rem; }
  .card { padding: 18px; margin-bottom: 14px; }
  .card:hover { transform: none; }
  .other-user:hover { transform: none; }

  /* Напитки — список, на мобильных компактнее */
  .row { padding: 11px 14px; gap: 10px; }
  .row .controls { gap: 6px; }

  /* «Пользователи» и «Чат» — заполняют экран, внутренний список скроллится */
  .people-card, .chat-card { max-height: none; }
  .chat-card .chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }
  .people-card .others-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
  }

  .login-card, .welcome-card {
    margin: 6vh auto;
    padding: 30px 24px;
  }

  h2 { font-size: 1rem; }
  .btn-primary { padding: 14px 24px; }
  .chat-input-row button { width: 50px; height: 50px; }
}

@media (max-width: 480px) {
  #my-name { display: none; }
  .screen { padding: 8px; padding-bottom: 90px; }
  .welcome-block { gap: 10px; }
  .welcome-item { padding: 13px; }
  .custom-input-row { flex-direction: column; }
  .custom-input-row .btn-small { width: 100%; }
}
