/* ============================================================
   AI WeightLoss Mini App — Styles
   3D, modern, minimalist, beautiful
   ============================================================ */

:root {
  --bg: #0a0f0d;
  --bg-2: #0d1512;
  --surface: rgba(14, 23, 18, 0.7);
  --surface-2: rgba(18, 29, 23, 0.8);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --text: #f4f7f5;
  --muted: #94a59c;
  --accent: #9be15d;
  --accent-2: #4ade80;
  --accent-glow: rgba(155, 225, 93, 0.3);
  --danger: #ff6b6b;
  --warning: #ffb86b;
  --info: #8ab4ff;
  --radius: 20px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(155, 225, 93, 0.15);
  --font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ---------- 3D Background ---------- */
#bg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ---------- Screens ---------- */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  padding-top: 60px;
  padding-bottom: 100px;
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1), transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  will-change: transform, opacity;
}

.screen.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.screen.exit {
  opacity: 0;
  transform: translateX(-40px);
  pointer-events: none;
}

/* ---------- Glass Cards ---------- */
.glass {
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
}

.glass:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow), var(--shadow-glow);
}

/* ---------- Typography ---------- */
h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 8px;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 8px;
}

p {
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.95rem;
}

.grad {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: 100px;
  font-weight: 700;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  font-family: var(--font);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0a1408;
  box-shadow: 0 8px 24px rgba(155, 225, 93, 0.25);
}

.btn-primary:hover, .btn-primary:active {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(155, 225, 93, 0.35);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-ghost:hover, .btn-ghost:active {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 10px 20px;
  font-size: 0.85rem;
}

.btn-danger {
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.3);
}

/* ---------- Form Elements ---------- */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  width: 100%;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(155, 225, 93, 0.15);
}

.form-input::placeholder {
  color: var(--muted);
  opacity: 0.5;
}

/* ---------- Widgets (Product Selection) ---------- */
.widget-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 4px;
}

.widget-grid::-webkit-scrollbar {
  width: 4px;
}

.widget-grid::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 2px;
}

.widget-grid::-webkit-scrollbar-thumb {
  background: rgba(155, 225, 93, 0.3);
  border-radius: 2px;
}

@media (max-width: 360px) {
  .widget-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.widget {
  padding: 12px 8px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.widget:hover {
  transform: translateY(-3px) scale(1.02);
  border-color: rgba(155, 225, 93, 0.4);
}

.widget.selected {
  background: rgba(155, 225, 93, 0.12);
  border-color: var(--accent);
  box-shadow: 0 0 15px rgba(155, 225, 93, 0.15);
  animation: pulse 0.3s ease;
}

.widget__icon {
  font-size: 1.8rem;
  margin-bottom: 6px;
  display: block;
  transition: transform 0.3s ease;
}

.widget:hover .widget__icon {
  transform: scale(1.15);
}

.widget__name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.widget__desc {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.2;
}

.widget {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.widget:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.widget.selected {
  background: rgba(155, 225, 93, 0.1);
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(155, 225, 93, 0.1);
}

.widget__icon {
  font-size: 2rem;
  margin-bottom: 8px;
  display: block;
}

.widget__name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.widget__desc {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ---------- Difficulty Selector ---------- */
.difficulty-options {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.difficulty-option {
  flex: 1;
  padding: 14px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.85rem;
  font-weight: 600;
}

.difficulty-option.selected {
  background: rgba(155, 225, 93, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}

.difficulty-option__icon {
  font-size: 1.5rem;
  margin-bottom: 6px;
  display: block;
}

/* ---------- Meal Plan ---------- */
.meal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  margin-bottom: 14px;
  transition: transform var(--transition);
}

.meal-card:hover {
  transform: translateY(-2px);
}

.meal-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.meal-card__title {
  font-weight: 700;
  font-size: 1rem;
}

.meal-card__calories {
  background: rgba(155, 225, 93, 0.1);
  color: var(--accent);
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 700;
}

.meal-card__items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meal-card__item {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.meal-card__item:last-child {
  border-bottom: none;
}

.meal-card__item-name {
  color: var(--text);
  font-weight: 500;
}

.meal-card__macros {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--muted);
}

.meal-card__macros span {
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 10px;
  border-radius: 100px;
}

.meal-card__recipe {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.meal-card__recipe summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  transition: color 0.2s ease;
}

.meal-card__recipe summary:hover {
  color: var(--accent-2);
}

.meal-card__recipe summary::-webkit-details-marker {
  display: none;
}

.meal-card__recipe summary::before {
  content: "▶";
  font-size: 0.7rem;
  transition: transform 0.2s ease;
}

.meal-card__recipe[open] summary::before {
  transform: rotate(90deg);
}

.meal-card__recipe-text {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.7;
  padding: 8px 0;
  white-space: pre-line;
}

.meal-total {
  background: linear-gradient(135deg, rgba(155, 225, 93, 0.1), rgba(74, 222, 128, 0.05));
  border: 1px solid rgba(155, 225, 93, 0.2);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  margin-bottom: 20px;
}

.meal-total__value {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.03em;
}

.meal-total__label {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ---------- Weight Tracker ---------- */
.weight-input-group {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}

.weight-input {
  flex: 1;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: border-color var(--transition);
}

.weight-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(155, 225, 93, 0.15);
}

.chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  height: 280px;
  position: relative;
}

.ai-message {
  background: linear-gradient(135deg, rgba(155, 225, 93, 0.08), rgba(74, 222, 128, 0.04));
  border: 1px solid rgba(155, 225, 93, 0.2);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.6;
}

.ai-message__icon {
  font-size: 1.2rem;
  margin-right: 8px;
}

.weight-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.weight-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 0.9rem;
}

.weight-entry__date {
  color: var(--muted);
}

.weight-entry__value {
  font-weight: 700;
  color: var(--accent);
}

.weight-entry__change {
  font-size: 0.8rem;
  font-weight: 600;
}

.weight-entry__change.down {
  color: var(--accent);
}

.weight-entry__change.up {
  color: var(--danger);
}

/* ---------- Header ---------- */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(10, 15, 13, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.app-header__title {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.app-header__title span {
  color: var(--accent);
}

.app-header__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  color: #0a1408;
  font-weight: 800;
}

/* ---------- Bottom Nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-around;
  padding: 10px 16px 16px;
  background: rgba(10, 15, 13, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}

.bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.bottom-nav__item.active {
  color: var(--accent);
  background: rgba(155, 225, 93, 0.08);
}

.bottom-nav__item__icon {
  font-size: 1.3rem;
}

/* ---------- Agreement ---------- */
.agreement-content {
  max-height: 50vh;
  overflow-y: auto;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.7;
}

.agreement-content h3 {
  color: var(--text);
  margin-top: 12px;
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.agreement-checkbox {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text);
}

.agreement-checkbox input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---------- Allergy Tags ---------- */
.allergy-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.allergy-tag {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.allergy-tag.selected {
  background: rgba(255, 107, 107, 0.1);
  border-color: var(--danger);
  color: var(--danger);
}

/* ---------- Loading ---------- */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 16px;
}

.loading__spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(155, 225, 93, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading__text {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 20px rgba(155, 225, 93, 0.1); }
  50% { box-shadow: 0 0 40px rgba(155, 225, 93, 0.3); }
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  33% { transform: translateY(-10px) rotate(2deg); }
  66% { transform: translateY(5px) rotate(-2deg); }
}

.animate-in {
  animation: fadeIn 0.5s ease forwards;
}

.animate-slide {
  animation: slideUp 0.6s ease forwards;
}

.animate-bounce {
  animation: bounce 2s ease-in-out infinite;
}

.animate-glow {
  animation: glow 3s ease-in-out infinite;
}

.animate-float {
  animation: float 6s ease-in-out infinite;
}

.widget {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.widget.selected {
  animation: pulse 0.3s ease;
}

.meal-card {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: fadeIn 0.4s ease forwards;
}

.meal-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 20px rgba(155, 225, 93, 0.1);
}

.btn {
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:active {
  transform: scale(0.97);
}

.screen {
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.glass {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .widget-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.3rem; }
  
  .screen {
    padding: 16px;
    padding-top: 56px;
    padding-bottom: 90px;
  }
}

/* ============================================================
   UNIVERSAL DEVICE OPTIMIZATION
   Safe areas, tablets, landscape, large phones, foldables
   ============================================================ */

/* Safe-area insets for notched devices (iPhone X+, Dynamic Island) */
@supports (padding: env(safe-area-inset-top)) {
  .screen {
    padding-top: calc(60px + env(safe-area-inset-top));
    padding-left: calc(20px + env(safe-area-inset-left));
    padding-right: calc(20px + env(safe-area-inset-right));
    padding-bottom: calc(100px + env(safe-area-inset-bottom));
  }
  .bottom-nav {
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .support-btn { top: calc(14px + env(safe-area-inset-top)); right: calc(14px + env(safe-area-inset-right)); }
  .splash__skip { right: calc(18px + env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom)); }
}

/* Large phones (max-width 430px) — comfortable spacing */
@media (max-width: 430px) and (min-width: 361px) {
  .screen { padding-left: 18px; padding-right: 18px; }
  .widget { padding: 10px 6px; }
  .widget__icon { font-size: 1.6rem; }
}

/* Small phones (max-width 360px) */
@media (max-width: 360px) {
  .screen { padding: 14px; padding-top: 54px; padding-bottom: 96px; }
  .widget-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .widget { padding: 10px 5px; }
  .widget__icon { font-size: 1.5rem; }
  .widget__name { font-size: 0.68rem; }
  .widget__desc { font-size: 0.58rem; }
  h1 { font-size: 1.45rem; }
  .btn { padding: 12px 16px; font-size: 0.85rem; }
  .bottom-nav { padding: 8px 8px 12px; }
  .bottom-nav__item { padding: 6px 8px; font-size: 0.62rem; }
  .bottom-nav__item__icon { font-size: 1.15rem; }
  .support-btn { width: 38px; height: 38px; top: 10px; right: 10px; }
  .support-btn__icon { font-size: 1.1rem; }
  .chat-msg { font-size: 0.82rem; max-width: 88%; }
}

/* Tablets and larger (min-width 600px) — center content, larger UI */
@media (min-width: 600px) {
  .screen { padding-top: 80px; }
  .glass { padding: 28px; }
  .widget-grid { grid-template-columns: repeat(4, 1fr); }
  .bottom-nav { max-width: 600px; left: 50%; right: auto; transform: translateX(-50%); border-radius: 20px 20px 0 0; }
  .support-btn { width: 48px; height: 48px; top: 20px; right: max(20px, calc(50vw - 300px + 20px)); }
  .chart-container { height: 320px; }
}

/* Desktop / large screens (min-width 1024px) */
@media (min-width: 1024px) {
  .screen { padding-top: 40px; padding-bottom: 60px; }
  .glass { max-width: 560px !important; padding: 36px 40px; }
  .widget-grid { grid-template-columns: repeat(5, 1fr); }
  .bottom-nav { max-width: 560px; bottom: 20px; border-radius: 20px; border: 1px solid var(--border); }
  .support-btn { top: 28px; right: max(28px, calc(50vw - 280px + 24px)); }
  h1 { font-size: 2.1rem; }
}

/* Landscape phones / short viewport */
@media (max-height: 500px) and (orientation: landscape) {
  .screen { padding-top: 44px; padding-bottom: 70px; }
  .bottom-nav { padding-top: 5px; padding-bottom: 6px; }
  .bottom-nav__item { padding: 4px 10px; flex-direction: row; gap: 6px; }
  .bottom-nav__item__icon { font-size: 1rem; }
  .agreement-content { max-height: 40vh; }
  .splash__logo { width: 72px; height: 72px; font-size: 2rem; margin-bottom: 12px; }
  .splash__status { margin-top: 18px; }
}

/* Foldables / very wide small-height */
@media (min-width: 600px) and (max-height: 500px) {
  .glass { max-width: 700px !important; }
  .widget-grid { grid-template-columns: repeat(6, 1fr); }
}

/* Reduced motion — respect accessibility settings */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .splash__progress-fill { animation: none; width: 100%; }
}

/* High-contrast / large text accessibility */
@media (prefers-contrast: more) {
  :root { --border: rgba(255,255,255,0.3); --muted: #c8d5cd; --text: #ffffff; }
}

/* Touch targets — minimum 44px for accessibility */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .chat-send { width: 48px; height: 48px; }
  .support-btn { width: 46px; height: 46px; }
  .difficulty-option, .allergy-tag { min-height: 40px; }
}

/* ---------- Utility ---------- */
.text-center { text-align: center; }
.text-accent { color: var(--accent); }
.text-muted { color: var(--muted); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-2 { gap: 16px; }
.w-full { width: 100%; }

/* ============================================================
   SPLASH / WELCOME PREVIEW
   ============================================================ */
.splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #050a07;
  transition: opacity 0.7s ease, transform 0.7s ease;
  overflow: hidden;
}
.splash.hide {
  opacity: 0;
  transform: scale(1.06);
  pointer-events: none;
}
.splash::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 45%, rgba(220,235,225,0.14) 0%, rgba(80,110,90,0.05) 30%, transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgba(155,225,93,0.08) 0%, transparent 50%),
    linear-gradient(180deg, #020604 0%, #050a07 60%, #020604 100%);
}
.splash__ray {
  position: absolute;
  top: -30%;
  left: 50%;
  width: 70vw;
  height: 160vh;
  background: linear-gradient(180deg, rgba(220,240,225,0.09) 0%, rgba(220,240,225,0.02) 50%, transparent 100%);
  transform: translateX(-50%) rotate(-12deg);
  filter: blur(40px);
  animation: ray-sway 12s ease-in-out infinite alternate;
}
.splash__ray--2 {
  transform: translateX(-50%) rotate(10deg);
  opacity: 0.45;
  animation-delay: -6s;
}
@keyframes ray-sway {
  from { transform: translateX(-50%) rotate(-12deg) scale(1); opacity: 0.65; }
  to   { transform: translateX(-50%) rotate(-6deg) scale(1.1); opacity: 1; }
}
.splash__particles { position: absolute; inset: 0; }
.splash__particles i {
  position: absolute;
  width: 2px; height: 2px;
  border-radius: 50%;
  background: rgba(255,255,255,0.7);
  animation: drift linear infinite;
}
@keyframes drift {
  0%   { transform: translateY(-10vh) translateX(0); opacity: 0; }
  10%  { opacity: 0.8; }
  90%  { opacity: 0.6; }
  100% { transform: translateY(110vh) translateX(40px); opacity: 0; }
}
.splash__content {
  position: relative;
  z-index: 2;
  text-align: center;
  animation: slideUp 1s ease both;
}
.splash__logo {
  width: 104px; height: 104px;
  margin: 0 auto 24px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 3rem;
  background: radial-gradient(circle at 35% 30%, rgba(155,225,93,0.4), rgba(10,25,15,0.7) 70%);
  border: 1px solid rgba(155,225,93,0.5);
  box-shadow: 0 0 80px rgba(155,225,93,0.35), inset 0 0 40px rgba(155,225,93,0.25);
  animation: float 5s ease-in-out infinite;
}
.splash__title { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; color: #fff; text-shadow: 0 2px 30px rgba(0,0,0,0.9), 0 0 40px rgba(155,225,93,0.25); }
.splash__title .grad { color: #b6f07d; text-shadow: 0 0 30px rgba(155,225,93,0.5); }
.splash__subtitle { color: rgba(230,245,235,0.85); font-size: 0.8rem; letter-spacing: 0.08em; margin-top: 10px; }
.splash__status {
  margin-top: 40px;
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: rgba(155,225,93,0.7);
}
.splash__progress {
  width: 180px; height: 2px;
  margin: 14px auto 0;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.splash__progress-fill {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent), #d6ffa8);
  box-shadow: 0 0 10px rgba(155,225,93,0.6);
  animation: splash-fill 5s linear forwards;
}
@keyframes splash-fill { from { width: 0%; } to { width: 100%; } }
.splash__skip {
  position: absolute;
  right: 18px; bottom: 18px;
  z-index: 5;
  padding: 10px 16px;
  border-radius: 100px;
  border: 1px solid rgba(155,225,93,0.3);
  background: rgba(10,20,14,0.6);
  backdrop-filter: blur(10px);
  color: var(--accent);
  font-family: var(--font);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.25s ease;
}
.splash__skip:hover { background: rgba(155,225,93,0.15); border-color: var(--accent); }

/* ============================================================
   AI CHAT
   ============================================================ */
.chat-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100% - 20px);
  max-width: 480px;
  margin: 0 auto;
}
.chat-header { text-align: center; margin-bottom: 12px; flex-shrink: 0; }
.chat-header__icon {
  font-size: 2.2rem;
  display: inline-block;
  animation: float 3s ease-in-out infinite;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.chat-msg {
  max-width: 85%;
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.5;
  animation: slideUp 0.3s ease both;
  word-break: break-word;
  white-space: pre-wrap;
}
.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0a1408;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.chat-msg.ai {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-msg.ai::before {
  content: "🤖 ";
}
.chat-typing {
  align-self: flex-start;
  padding: 12px 16px;
  background: var(--surface-2);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}
.chat-typing span {
  display: inline-block;
  width: 6px; height: 6px; margin: 0 2px;
  border-radius: 50%; background: var(--muted);
  animation: bounce 1.2s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
.chat-suggestions {
  display: flex; gap: 8px; overflow-x: auto; padding: 8px 0; flex-shrink: 0;
  scrollbar-width: none;
}
.chat-suggestions::-webkit-scrollbar { display: none; }
.chat-chip {
  flex-shrink: 0;
  padding: 8px 12px;
  border-radius: 100px;
  border: 1px solid var(--border-strong);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}
.chat-chip:hover { border-color: var(--accent); color: var(--accent); }
.chat-input-row {
  display: flex; gap: 8px; padding-top: 10px; flex-shrink: 0;
  border-top: 1px solid var(--border);
}
.chat-input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 100px;
  border: 1px solid var(--border-strong);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  outline: none;
}
.chat-input:focus { border-color: var(--accent); }
.chat-send {
  width: 46px; height: 46px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none; color: #0a1408; font-size: 1.2rem;
  cursor: pointer; display: grid; place-items: center;
  transition: transform 0.2s ease;
}
.chat-send:active { transform: scale(0.92); }

/* Detailed recipe */
.recipe-detail { font-size: 0.85rem; color: var(--muted); line-height: 1.7; padding: 8px 0; white-space: pre-wrap; }
.recipe-detail b { color: var(--accent); }

/* Analysis block */
.analysis-block {
  background: rgba(155,225,93,0.06);
  border: 1px solid rgba(155,225,93,0.2);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 12px;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* Cross-links */
.cross-links { display: flex; gap: 10px; margin-top: 16px; }
.cross-links .btn { flex: 1; font-size: 0.8rem; }

/* Support button (top-right) */
.support-btn {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 150;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(155,225,93,0.35);
  background: rgba(10,20,14,0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 0 16px rgba(155,225,93,0.15);
  transition: all var(--transition);
}
.support-btn:hover { background: rgba(155,225,93,0.18); border-color: var(--accent); transform: scale(1.08); }
.support-btn:active { transform: scale(0.94); }
.support-btn__icon { font-size: 1.25rem; line-height: 1; }

/* Support sheet */
.support-sheet { position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-end; justify-content: center; }
.support-sheet__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.65); backdrop-filter: blur(4px); }
.support-sheet__card {
  position: relative;
  width: 100%;
  max-width: 480px;
  padding: 26px 20px 30px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -20px 60px rgba(0,0,0,0.6);
  animation: slideUp 0.35s ease both;
}
.support-sheet__close {
  position: absolute; top: 14px; right: 14px;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--border); background: rgba(255,255,255,0.05);
  color: var(--muted); cursor: pointer; font-size: 0.9rem;
}
.support-sheet__close:hover { color: var(--text); border-color: var(--border-strong); }