@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ═══════════════ Design tokens ═══════════════ */
:root {
  --bg-primary: #0B0F19;
  --bg-surface: #121824;
  --bg-card: #1B2336;
  --bg-elevated: #242F47;
  --accent: #8B5CF6;
  --accent-soft: #A78BFA;
  --accent-deep: #7C3AED;
  --accent-dim: rgba(139, 92, 246, 0.15);
  --accent-glow: rgba(139, 92, 246, 0.25);
  --text-primary: #FAFAFA;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --border: #334155;
  --border-soft: #1E293B;
  --success: #34D399;
  --warning: #FBBF24;
  --danger: #F87171;
  --info: #38BDF8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow: 0 10px 30px rgba(0,0,0,0.4);
  --shadow-lg: 0 20px 50px rgba(0,0,0,0.5);
  --radius-card: 20px;
  --radius-input: 14px;
  --radius-btn: 12px;
  --sidebar-width: 260px;
  --content-max: 1200px;
  --topbar-h: 56px;
  --tabbar-h: 68px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 200ms var(--ease);
}

/* ═══════════════ Reset ═══════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', sans-serif;
  background: radial-gradient(circle at 80% 20%, #1c123c 0%, transparent 50%),
              radial-gradient(circle at 20% 80%, #0d091e 0%, transparent 60%),
              linear-gradient(135deg, #090614 0%, #0c081d 50%, #06040d 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; font-family: inherit; color: inherit; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; display: block; }

/* ═══════════════ Icons (line, stroke-based) ═══════════════ */
svg.ic, svg.nav-ic, svg.mobile-tab-ic, .stat-ic svg, .search-ic, .search-clear svg,
.goal-card-icon svg, .empty-icon svg, .food-add-btn svg, .log-row-del svg,
.chat-send-btn svg, .chat-avatar svg, .scan-upload-icon svg, .logo-mark svg,
.page-date svg, .toast-ic svg, .food-card svg, .scan-result svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
svg.ic { width: 18px; height: 18px; display: inline-block; vertical-align: middle; flex-shrink: 0; }

/* ═══════════════ App shell ═══════════════ */
.app-shell { display: flex; min-height: 100vh; }

/* ── Sidebar (desktop only) ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  height: 100vh;
  z-index: 100;
  padding-bottom: 20px;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.logo-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: #09090B;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-mark svg { width: 20px; height: 20px; stroke-width: 2.4; }
.sidebar-logo h1 { font-size: 17px; font-weight: 800; letter-spacing: -0.4px; line-height: 1; }
.sidebar-logo span { font-size: 11px; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border: none; background: none; width: 100%; text-align: left;
  border-radius: var(--radius-btn);
  color: var(--text-secondary);
  font-size: 14px; font-weight: 500;
  position: relative;
  transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 50%;
  width: 3px; height: 20px; background: var(--accent);
  border-radius: 0 3px 3px 0; transform: translateY(-50%);
}
.nav-ic { width: 19px; height: 19px; flex-shrink: 0; }

/* ── Mobile top bar ── */
.mobile-topbar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  align-items: center; gap: 10px;
  padding: 0 16px;
  background: rgba(9,9,11,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 90;
}
.mobile-topbar .logo-mark { width: 30px; height: 30px; border-radius: 8px; }
.mobile-topbar .logo-mark svg { width: 17px; height: 17px; }
.mobile-topbar-title { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }

/* ── Main ── */
.main-content { margin-left: var(--sidebar-width); flex: 1; min-height: 100vh; }

/* ═══════════════ Sections ═══════════════ */
.section { display: none; }
.section.active { display: block; animation: sectionIn 0.32s var(--ease); }
.section-wide { max-width: var(--content-max); margin: 0 auto; padding: 36px 40px; }

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

/* ── Page header ── */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; margin-bottom: 26px;
}
.page-title { font-size: 28px; font-weight: 800; letter-spacing: -0.8px; line-height: 1.1; }
.page-subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 6px; }
.page-head-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.page-date {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
  padding: 9px 13px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-btn);
  white-space: nowrap;
}
.page-date svg { width: 15px; height: 15px; color: var(--text-muted); }

/* ═══════════════ Buttons ═══════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border: none; border-radius: var(--radius-btn);
  font-size: 14px; font-weight: 600;
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #09090B; }
.btn-primary:hover { background: var(--accent-soft); }
.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: #3A3A40; }
.btn-block { width: 100%; margin-top: 18px; padding: 13px; }
.btn-quick { box-shadow: 0 0 0 1px var(--accent-deep), 0 6px 18px var(--accent-glow); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn .ic { width: 16px; height: 16px; }

/* ═══════════════ Panels / cards ═══════════════ */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
}
.card-title { font-size: 14px; font-weight: 700; margin-bottom: 16px; letter-spacing: -0.2px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-title { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }
.panel-badge {
  font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 600;
  color: var(--accent); background: var(--accent-dim);
  padding: 4px 10px; border-radius: 20px;
}

/* Card entrance animation */
.anim-card { opacity: 0; animation: cardIn 0.5s var(--ease) forwards; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.section.active .anim-card:nth-child(1) { animation-delay: 0.02s; }
.section.active .anim-card:nth-child(2) { animation-delay: 0.08s; }
.section.active .anim-card:nth-child(3) { animation-delay: 0.14s; }
.section.active .anim-card:nth-child(4) { animation-delay: 0.20s; }
.section.active .anim-card:nth-child(5) { animation-delay: 0.26s; }
.stat-row .anim-card:nth-child(1) { animation-delay: 0.02s; }
.stat-row .anim-card:nth-child(2) { animation-delay: 0.07s; }
.stat-row .anim-card:nth-child(3) { animation-delay: 0.12s; }
.stat-row .anim-card:nth-child(4) { animation-delay: 0.17s; }
.stat-row .anim-card:nth-child(5) { animation-delay: 0.22s; }

/* ═══════════════ Forms ═══════════════ */
.profile-layout { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; align-items: start; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-label {
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  letter-spacing: 0.3px; text-transform: uppercase;
  display: flex; align-items: center; justify-content: space-between;
}
.label-val { font-family: 'JetBrains Mono', monospace; color: var(--accent); font-size: 13px; text-transform: none; }
.form-input, .form-select {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-input); padding: 12px 14px;
  color: var(--text-primary); font-size: 15px; width: 100%; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus, .form-select:focus { border-color: var(--accent-deep); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-input::placeholder { color: var(--text-muted); }
.form-select {
  appearance: none; cursor: pointer; padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23A1A1AA' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.form-select option { background: var(--bg-card); }

/* Slider */
.form-slider {
  -webkit-appearance: none; appearance: none;
  height: 5px; background: var(--bg-elevated); border-radius: 3px; outline: none; width: 100%;
}
.form-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 3px solid var(--bg-card);
  box-shadow: 0 0 0 1px var(--accent-deep); transition: transform var(--transition);
}
.form-slider::-webkit-slider-thumb:active { transform: scale(1.15); }
.form-slider::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 3px solid var(--bg-card); cursor: pointer; }

/* Radio */
.radio-group { display: flex; gap: 10px; }
.radio-item { display: none; }
.radio-label {
  flex: 1; text-align: center; padding: 11px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-input);
  cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text-secondary);
  transition: all var(--transition); user-select: none;
}
.radio-item:checked + .radio-label { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

/* Goal cards */
.goal-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.goal-card-input { display: none; }
.goal-card-label {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 18px 10px; border: 1px solid var(--border); border-radius: var(--radius-input);
  cursor: pointer; text-align: center; transition: all var(--transition);
}
.goal-card-label:hover { border-color: #3A3A40; transform: translateY(-2px); }
.goal-card-icon {
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--bg-elevated); color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.goal-card-icon svg { width: 20px; height: 20px; }
.goal-card-text { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.goal-card-input:checked + .goal-card-label { border-color: var(--accent); background: var(--accent-dim); }
.goal-card-input:checked + .goal-card-label .goal-card-icon { background: var(--accent); color: #09090B; }
.goal-card-input:checked + .goal-card-label .goal-card-text { color: var(--accent); }

/* Result card */
.result-card { position: sticky; top: 20px; background: radial-gradient(120% 100% at 0 0, rgba(163,230,53,0.07), transparent 55%), var(--bg-card); }
.result-card-title { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 16px; }
.result-target { text-align: center; padding: 18px; background: var(--accent-dim); border-radius: var(--radius-input); margin-bottom: 16px; }
.result-target-value { font-family: 'JetBrains Mono', monospace; font-size: 40px; font-weight: 700; color: var(--accent); letter-spacing: -1.5px; line-height: 1; }
.result-target-label { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.result-stat { text-align: center; padding: 12px 4px; background: var(--bg-surface); border-radius: var(--radius-input); }
.result-stat-value { font-family: 'JetBrains Mono', monospace; font-size: 19px; font-weight: 700; color: var(--text-primary); }
.result-stat-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.result-macros { display: flex; gap: 8px; }
.macro-chip { flex: 1; text-align: center; padding: 10px 4px; background: var(--bg-surface); border-radius: 10px; }
.macro-chip .macro-val { display: block; font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: 14px; }
.macro-chip .macro-name { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ═══════════════ Stat cards (Kaloriya) ═══════════════ */
.stat-row { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr 1fr; gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 11px;
  transition: border-color var(--transition), transform var(--transition);
}
.stat-card:hover { border-color: #34343A; transform: translateY(-2px); }
.stat-card-head { display: flex; align-items: center; justify-content: space-between; }
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.stat-ic { width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; background: var(--bg-elevated); }
.stat-ic svg { width: 16px; height: 16px; }
.stat-ic-accent  { color: var(--accent);  background: var(--accent-dim); }
.stat-ic-protein { color: var(--info);    background: rgba(96,165,250,0.12); }
.stat-ic-carbs   { color: var(--accent);  background: var(--accent-dim); }
.stat-ic-fat     { color: var(--warning); background: rgba(251,191,36,0.12); }
.stat-ic-water   { color: #38BDF8;        background: rgba(56,189,248,0.12); }
.stat-value { font-family: 'JetBrains Mono', monospace; font-size: 26px; font-weight: 700; letter-spacing: -1px; line-height: 1; display: flex; align-items: baseline; gap: 4px; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--text-muted); letter-spacing: 0; }
.stat-sub { font-size: 12px; color: var(--text-muted); }
.stat-sub span { color: var(--text-secondary); font-weight: 600; }
.stat-bar { height: 5px; background: var(--bg-elevated); border-radius: 3px; overflow: hidden; }
.stat-bar-fill { height: 100%; width: 0%; border-radius: 3px; transition: width 0.7s var(--ease); }
.stat-bar-fill.protein { background: var(--info); }
.stat-bar-fill.carbs { background: var(--accent); }
.stat-bar-fill.fat { background: var(--warning); }

.stat-hero { background: radial-gradient(120% 120% at 0 0, rgba(163,230,53,0.08), transparent 55%), var(--bg-card); }
.stat-hero-body { display: flex; align-items: center; gap: 16px; }
.stat-ring-wrap { position: relative; width: 72px; height: 72px; flex-shrink: 0; }
.stat-ring { width: 72px; height: 72px; transform: rotate(-90deg); }
.stat-ring-bg { fill: none; stroke: var(--bg-elevated); stroke-width: 6; }
.stat-ring-fg { fill: none; stroke: var(--accent); stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset 0.8s var(--ease), stroke 0.3s; }
.stat-ring-pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 700; }
.stat-hero-nums .stat-value { font-size: 30px; }

/* Water */
.water-dots { display: flex; gap: 5px; flex-wrap: wrap; }
.water-dot { width: 15px; height: 15px; border-radius: 5px; background: var(--bg-elevated); border: 1px solid var(--border); transition: all var(--transition); cursor: pointer; }
.water-dot.filled { background: #38BDF8; border-color: #38BDF8; transform: scale(1.05); }
.water-add-btn { background: none; border: none; color: #38BDF8; font-size: 12px; font-weight: 600; padding: 0; text-align: left; transition: opacity var(--transition); }
.water-add-btn:hover { opacity: 0.75; }

/* ═══════════════ Workspace ═══════════════ */
.cal-workspace { display: grid; grid-template-columns: 1.7fr 1fr; gap: 18px; align-items: start; }

/* Search */
.search-wrapper { position: relative; margin-bottom: 16px; }
.search-ic { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-muted); pointer-events: none; }
.search-field {
  width: 100%; background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-input); padding: 13px 42px 13px 44px;
  color: var(--text-primary); font-size: 15px; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-field::placeholder { color: var(--text-muted); }
.search-field:focus { border-color: var(--accent-deep); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-clear { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; border-radius: 7px; border: none; background: var(--bg-elevated); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; }
.search-clear svg { width: 14px; height: 14px; }

/* Chips */
.chip-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip-row-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.food-chip {
  padding: 7px 14px; background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 20px; font-size: 13px; font-weight: 500; color: var(--text-secondary);
  transition: all var(--transition);
}
.food-chip:hover { border-color: var(--accent-deep); color: var(--accent); background: var(--accent-dim); transform: translateY(-1px); }
.food-chip:active { transform: scale(0.96); }

/* Food grid */
.food-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; min-height: 260px; align-content: start; }
.food-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-input); padding: 14px; display: flex; flex-direction: column; gap: 12px; transition: border-color var(--transition), transform var(--transition); animation: cardIn 0.35s var(--ease) both; }
.food-card:hover { border-color: #34343A; transform: translateY(-2px); }
.food-card-top { display: flex; gap: 12px; align-items: center; }
.food-thumb { width: 44px; height: 44px; border-radius: 11px; background: var(--accent-dim); color: var(--accent); display: flex; align-items: center; justify-content: center; font-family: 'JetBrains Mono', monospace; font-size: 15px; font-weight: 700; flex-shrink: 0; text-transform: uppercase; }
.food-card-name { font-size: 14px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.food-card-kcal { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--accent); font-weight: 600; margin-top: 2px; }
.food-macros-mini { display: flex; gap: 6px; }
.macro-pill { flex: 1; text-align: center; background: var(--bg-elevated); border-radius: 7px; padding: 6px 4px; }
.macro-pill .mp-val { display: block; font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 600; }
.macro-pill .mp-key { display: block; font-size: 10px; color: var(--text-muted); margin-top: 1px; }
.food-card-foot { display: flex; align-items: center; gap: 8px; }
.food-gram-input { width: 100%; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; color: var(--text-primary); font-family: 'JetBrains Mono', monospace; font-size: 13px; text-align: center; outline: none; }
.food-gram-input:focus { border-color: var(--accent-deep); }
.food-add-btn { flex-shrink: 0; width: 40px; height: 38px; border-radius: 9px; border: none; background: var(--accent); color: #09090B; display: flex; align-items: center; justify-content: center; transition: all var(--transition); }
.food-add-btn svg { width: 18px; height: 18px; }
.food-add-btn:hover { background: var(--accent-soft); }
.food-add-btn:active { transform: scale(0.9); }

/* Empty / skeleton */
.empty-premium { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 44px 24px; gap: 6px; }
.empty-icon { width: 54px; height: 54px; border-radius: 15px; background: var(--bg-surface); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--text-muted); margin-bottom: 8px; }
.empty-icon svg { width: 24px; height: 24px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text-secondary); }
.empty-desc { font-size: 13px; color: var(--text-muted); max-width: 280px; line-height: 1.5; }
.skeleton { background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-elevated) 50%, var(--bg-surface) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius-input); }
.food-skeleton { height: 132px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Meal sections */
.meal-sections { display: flex; flex-direction: column; gap: 6px; }
.meal-group-head { display: flex; align-items: center; gap: 10px; padding: 10px 4px; }
.meal-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.meal-dot.breakfast { background: var(--warning); }
.meal-dot.lunch { background: var(--accent); }
.meal-dot.dinner { background: var(--info); }
.meal-dot.snack { background: #C084FC; }
.meal-name { font-size: 13px; font-weight: 600; }
.meal-kcal { margin-left: auto; font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-secondary); }
.meal-items { display: flex; flex-direction: column; gap: 6px; }
.log-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg-surface); border: 1px solid var(--border-soft); border-radius: 10px; transition: border-color var(--transition); animation: rowIn 0.3s var(--ease) both; }
.log-row:hover { border-color: var(--border); }
@keyframes rowIn { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: translateX(0); } }
.log-row-info { flex: 1; min-width: 0; }
.log-row-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-row-meta { font-size: 11px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.log-row-kcal { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 600; color: var(--accent); }
.log-row-del { width: 26px; height: 26px; border-radius: 7px; border: none; background: transparent; color: var(--text-muted); display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all var(--transition); }
.log-row-del svg { width: 14px; height: 14px; }
.log-row-del:hover { background: rgba(248,113,113,0.12); color: var(--danger); }
.meal-empty { font-size: 12px; color: var(--text-muted); padding: 10px 12px; border: 1px dashed var(--border); border-radius: 10px; text-align: center; }

/* ═══════════════ Scanner ═══════════════ */
.scan-upload-zone { border: 2px dashed var(--border); border-radius: var(--radius-card); padding: 36px 20px; text-align: center; transition: border-color var(--transition), background var(--transition); }
.scan-upload-zone.dragover { border-color: var(--accent); background: var(--accent-dim); }
.scan-upload-icon { width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 16px; background: var(--bg-elevated); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.scan-upload-icon svg { width: 28px; height: 28px; }
.scan-upload-text { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.scan-upload-hint { font-size: 13px; color: var(--text-muted); margin-bottom: 18px; }
.scan-btn-row { display: flex; gap: 10px; justify-content: center; }
#scan-video { width: 100%; max-width: 380px; border-radius: var(--radius-input); margin: 16px auto 0; }
#scan-camera-controls { margin-top: 12px; display: flex; gap: 8px; justify-content: center; }
.image-preview { width: 100%; max-height: 320px; object-fit: contain; border-radius: var(--radius-input); background: var(--bg-surface); display: none; margin-top: 16px; }
.image-preview.visible { display: block; animation: cardIn 0.3s var(--ease); }
.scan-action-row { margin-top: 16px; display: none; }
.scan-action-row.visible { display: block; }
.scan-result { display: none; margin-top: 18px; }
.scan-result.visible { display: block; animation: cardIn 0.35s var(--ease); }
.scan-result-card { background: radial-gradient(120% 100% at 0 0, rgba(163,230,53,0.06), transparent 55%), var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 20px; }
.scan-result-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
.scan-food-item { padding: 14px; background: var(--bg-card); border-radius: var(--radius-input); margin-bottom: 10px; }
.scan-food-name { font-size: 15px; font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.scan-food-macros { display: flex; gap: 14px; font-size: 13px; font-family: 'JetBrains Mono', monospace; flex-wrap: wrap; }
.scan-food-macros .kcal { color: var(--accent); font-weight: 700; }
.scan-food-macros .macro { color: var(--text-muted); }
.scan-notes { font-size: 13px; color: var(--text-secondary); margin: 12px 0; padding: 12px 14px; background: var(--bg-card); border-radius: 10px; border-left: 3px solid var(--accent); }
.confidence-badge { padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.confidence-badge.high { background: rgba(74,222,128,0.15); color: var(--success); }
.confidence-badge.medium { background: rgba(251,191,36,0.15); color: var(--warning); }
.confidence-badge.low { background: rgba(248,113,113,0.15); color: var(--danger); }
.scan-total { padding: 14px; background: var(--accent-dim); border-radius: var(--radius-input); margin-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.scan-total-label { font-size: 12px; color: var(--text-muted); }
.scan-total-val { font-family: 'JetBrains Mono', monospace; font-size: 24px; font-weight: 700; color: var(--accent); }
.scan-total-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ═══════════════ Chat ═══════════════ */
.chat-container { display: flex; flex-direction: column; height: calc(100vh - 220px); max-height: 720px; min-height: 460px; }
.chat-header { display: flex; align-items: center; gap: 12px; padding: 14px 18px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-card) var(--radius-card) 0 0; }
.chat-avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--accent-dim); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.chat-avatar svg { width: 22px; height: 22px; }
.chat-name { font-size: 15px; font-weight: 700; }
.chat-status { font-size: 12px; color: var(--success); display: flex; align-items: center; gap: 6px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(74,222,128,0.5); } 50% { box-shadow: 0 0 0 4px rgba(74,222,128,0); } }
.chat-messages { flex: 1; overflow-y: auto; padding: 18px; background: var(--bg-surface); border-left: 1px solid var(--border); border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.chat-message { max-width: 80%; animation: msgIn 0.3s var(--ease); }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.chat-message.user { align-self: flex-end; }
.chat-message.assistant { align-self: flex-start; }
.message-bubble { padding: 12px 15px; border-radius: 16px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.chat-message.user .message-bubble { background: var(--accent); color: #09090B; border-radius: 16px 16px 4px 16px; font-weight: 500; }
.chat-message.assistant .message-bubble { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px 16px 16px 4px; }
.message-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; padding: 0 4px; }
.chat-message.user .message-time { text-align: right; }
.typing-indicator { display: none; align-items: center; gap: 4px; padding: 14px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px 16px 16px 4px; width: fit-content; }
.typing-indicator.visible { display: flex; }
.typing-dot { width: 7px; height: 7px; background: var(--text-muted); border-radius: 50%; animation: typingBounce 1.2s infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce { 0%,60%,100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-6px); opacity: 1; } }
.quick-chips { display: flex; gap: 8px; padding: 12px 16px; background: var(--bg-surface); border-left: 1px solid var(--border); border-right: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.quick-chips::-webkit-scrollbar { display: none; }
.quick-chip { padding: 7px 14px; border: 1px solid var(--border); border-radius: 20px; font-size: 12px; color: var(--text-secondary); background: var(--bg-card); white-space: nowrap; flex-shrink: 0; transition: all var(--transition); }
.quick-chip:hover { border-color: var(--accent-deep); color: var(--accent); }
.quick-chip:active { transform: scale(0.96); }
.chat-input-row { display: flex; gap: 10px; padding: 14px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 0 0 var(--radius-card) var(--radius-card); }
.chat-input { flex: 1; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 22px; padding: 11px 18px; color: var(--text-primary); font-size: 14px; outline: none; resize: none; max-height: 100px; line-height: 1.4; transition: border-color var(--transition); }
.chat-input:focus { border-color: var(--accent-deep); }
.chat-send-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #09090B; border: none; display: flex; align-items: center; justify-content: center; align-self: flex-end; flex-shrink: 0; transition: all var(--transition); }
.chat-send-btn svg { width: 19px; height: 19px; }
.chat-send-btn:hover { background: var(--accent-soft); transform: scale(1.05); }
.chat-send-btn:active { transform: scale(0.92); }

/* ═══════════════ Dashboard ═══════════════ */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.dashboard-full { grid-column: 1 / -1; }
.ring-chart-wrapper { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.ring-wrapper { position: relative; }
.ring-chart-svg { transform: rotate(-90deg); }
.ring-center-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-val { font-family: 'JetBrains Mono', monospace; font-size: 28px; font-weight: 800; letter-spacing: -1px; }
.ring-sub { font-size: 12px; color: var(--text-muted); }
.ring-pct-row { display: flex; flex-direction: column; align-items: center; }
.ring-pct-label { font-size: 13px; color: var(--text-muted); }
.ring-pct-val { font-size: 22px; font-weight: 800; font-family: 'JetBrains Mono', monospace; color: var(--accent); }
.bar-chart { width: 100%; height: 160px; }
.bar-chart rect { transition: height 0.6s var(--ease), y 0.6s var(--ease); }
.bar-chart-labels { display: flex; justify-content: space-between; margin-top: 8px; }
.bar-chart-label { font-size: 11px; color: var(--text-muted); text-align: center; flex: 1; }
.macro-bars { display: flex; flex-direction: column; gap: 14px; }
.macro-bar-row { display: flex; align-items: center; gap: 12px; }
.macro-bar-name { font-size: 13px; color: var(--text-secondary); min-width: 72px; }
.macro-bar-track { flex: 1; height: 8px; background: var(--bg-elevated); border-radius: 4px; overflow: hidden; }
.macro-bar-fill { height: 100%; width: 0%; border-radius: 4px; transition: width 0.7s var(--ease); }
.macro-bar-fill.protein { background: var(--info); }
.macro-bar-fill.fat { background: var(--warning); }
.macro-bar-fill.carbs { background: var(--accent); }
.macro-bar-val { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-muted); min-width: 64px; text-align: right; }
.bmi-display { text-align: center; padding: 12px 0 16px; }
.bmi-value { font-family: 'JetBrains Mono', monospace; font-size: 44px; font-weight: 800; color: var(--accent); letter-spacing: -2px; }
.bmi-category { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-top: 2px; }
.bmi-scale-wrap { position: relative; }
.bmi-scale { display: flex; border-radius: 4px; overflow: hidden; height: 6px; }
.bmi-scale-seg { flex: 1; }
.bmi-scale-seg:nth-child(1) { background: var(--info); }
.bmi-scale-seg:nth-child(2) { background: var(--success); }
.bmi-scale-seg:nth-child(3) { background: var(--warning); }
.bmi-scale-seg:nth-child(4) { background: var(--danger); }
.bmi-indicator { position: absolute; top: -3px; width: 12px; height: 12px; background: var(--text-primary); border-radius: 50%; transform: translateX(-50%); border: 2px solid var(--bg-card); transition: left 0.6s var(--ease); }
.bmi-legend { display: flex; justify-content: space-between; margin-top: 8px; font-size: 11px; color: var(--text-muted); }

/* ═══════════════ Mobile bottom tab bar ═══════════════ */
.mobile-tabbar { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: rgba(9,9,11,0.9); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--border); z-index: 100; padding-bottom: env(safe-area-inset-bottom); }
.mobile-tabs { display: flex; justify-content: space-around; height: var(--tabbar-h); }
.mobile-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: none; background: none; color: var(--text-muted); font-size: 10px; font-weight: 500; flex: 1; position: relative; transition: color var(--transition); }
.mobile-tab-ic { width: 22px; height: 22px; transition: transform var(--transition); }
.mobile-tab.active { color: var(--accent); }
.mobile-tab.active .mobile-tab-ic { transform: translateY(-1px) scale(1.08); }
.mobile-tab.active::after { content: ''; position: absolute; top: 0; width: 28px; height: 3px; background: var(--accent); border-radius: 0 0 3px 3px; }

/* ═══════════════ Toasts ═══════════════ */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 11px; padding: 13px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-input); box-shadow: var(--shadow); font-size: 14px; min-width: 240px; max-width: 360px; pointer-events: auto; animation: toastIn 0.25s var(--ease), toastOut 0.3s var(--ease) 2.7s forwards; }
@keyframes toastIn { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }
.toast-ic { width: 20px; height: 20px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.toast-ic svg { width: 18px; height: 18px; }
.toast.success .toast-ic { color: var(--success); }
.toast.error .toast-ic { color: var(--danger); }
.toast.info .toast-ic { color: var(--accent); }

/* Spinner */
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 32px; color: var(--text-secondary); font-size: 14px; }

/* ═══════════════ Scrollbars ═══════════════ */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ═══════════════ Responsive — tablet ═══════════════ */
@media (max-width: 1100px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .stat-hero { grid-column: 1 / -1; }
  .cal-workspace { grid-template-columns: 1fr; }
  .profile-layout { grid-template-columns: 1fr; }
  .result-card { position: static; }
}

/* ═══════════════ Responsive — phone (primary target) ═══════════════ */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .mobile-topbar { display: flex; }
  .mobile-tabbar { display: block; }
  .main-content { margin-left: 0; padding-top: var(--topbar-h); padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 50px); }

  .section-wide { padding: 18px 16px 28px; }

  .page-head { flex-direction: column; gap: 14px; margin-bottom: 18px; }
  .page-title { font-size: 23px; }
  .page-subtitle { font-size: 13px; }
  .page-head-right { width: 100%; }
  .page-head-right .page-date { flex: 1; justify-content: center; }
  .btn-quick { flex: 1.4; }

  /* Single-column stat stack, but keep macros 2-up for density */
  .stat-row { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
  .stat-hero { grid-column: 1 / -1; }
  .stat-value { font-size: 22px; }
  .stat-hero-nums .stat-value { font-size: 26px; }

  .food-grid { grid-template-columns: 1fr; min-height: 200px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-input, .form-select, .search-field { font-size: 16px; } /* prevent iOS zoom */
  .chat-input { font-size: 16px; }
  .goal-cards { grid-template-columns: repeat(3, 1fr); }
  .goal-card-label { padding: 14px 6px; }
  .goal-card-text { font-size: 11px; }

  .dashboard-grid { grid-template-columns: 1fr; }
  .result-target-value { font-size: 34px; }

  .chat-container { height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - 110px); min-height: 250px; }

  .toast-container { bottom: calc(var(--tabbar-h) + 16px); right: 12px; left: 12px; }
  .toast { min-width: 0; width: 100%; }
}

@media (max-width: 380px) {
  .stat-row { grid-template-columns: 1fr; }
  .scan-btn-row { flex-direction: column; }
}

/* ─── Landing Page & Auth Overlay ─── */
body.auth-mode {
  background: radial-gradient(circle at top, rgba(163,230,53,0.1), transparent 60%), #09090B;
}

.landing-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 24px 20px;
  max-width: 800px;
  margin: 0 auto;
  gap: 40px;
}

.landing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
}

.landing-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.landing-logo h2 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.4px;
}

.landing-logo h2 span {
  color: var(--accent);
}

.landing-lang {
  display: flex;
  gap: 6px;
}

.landing-lang .lang-btn {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
}

.landing-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 36px;
  flex: 1;
  justify-content: center;
}

.landing-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 600px;
}

.landing-hero-img {
  width: 100%;
  max-width: 540px;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-card);
  margin-bottom: 16px;
  filter: drop-shadow(0 0 20px rgba(163, 230, 53, 0.25));
  animation: floatHero 4s ease-in-out infinite;
}

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

.landing-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.8px;
  line-height: 1.15;
}

.landing-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.landing-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
}

.landing-feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease);
}

.landing-feature-card:hover {
  transform: translateY(-3px);
  border-color: rgba(163,230,53,0.3);
}

.landing-feature-card .feature-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.landing-feature-card .feature-icon svg {
  width: 18px;
  height: 18px;
}

.landing-feature-card h3 {
  font-size: 14px;
  font-weight: 700;
}

.landing-feature-card p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.landing-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 400px;
}

.btn-landing {
  flex: 1;
  padding: 13px;
}

/* Auth Modal Overlay & Forms */
.auth-modal {
  width: 90%;
  max-width: 440px;
  border-radius: var(--radius-card);
  align-self: center;
  margin-bottom: 0;
  box-shadow: var(--shadow-lg);
  animation: authModalIn 0.3s var(--ease) forwards;
}

@keyframes authModalIn {
  from { transform: scale(0.95) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

@media (max-width: 768px) {
  .landing-page {
    gap: 30px;
  }
  .landing-title {
    font-size: 24px;
  }
  .landing-features {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .landing-actions {
    flex-direction: column;
    width: 100%;
  }
}

/* ═══════════════ NEW: settings, activity, modal, chat tools ═══════════════ */

/* Topbar settings button */
.mobile-topbar { justify-content: flex-start; }
.topbar-settings { margin-left: auto; width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; }
.topbar-settings svg { width: 18px; height: 18px; }

/* Small buttons */
.btn-sm { padding: 8px 12px; font-size: 12px; }
.btn-block-sm { width: 100%; margin-top: 12px; padding: 10px; font-size: 13px; }
.btn-accent-outline { background: transparent; color: var(--accent); border: 1px solid var(--accent-deep); }
.btn-accent-outline:hover { background: var(--accent-dim); }

/* Clickable meal header */
.meal-group-head { cursor: pointer; border-radius: 10px; transition: background var(--transition); }
.meal-group-head:hover { background: var(--bg-surface); }
.meal-add { width: 22px; height: 22px; border-radius: 6px; background: var(--accent-dim); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.meal-add svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }

/* Activity */
.panel-badge.burn { color: var(--warning); background: rgba(251,191,36,0.12); }
.log-row-kcal.burn { color: var(--warning); }
.activity-steps { margin-bottom: 12px; }
.act-row { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--bg-surface); border: 1px solid var(--border-soft); border-radius: 10px; }
.act-ic { width: 34px; height: 34px; border-radius: 9px; background: rgba(56,189,248,0.12); color: #38BDF8; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.act-ic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.act-info { flex: 1; min-width: 0; }
.act-label { font-size: 13px; font-weight: 600; }
.act-sub { font-size: 11px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }
.act-input { width: 72px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 8px; color: var(--text-primary); font-family: 'JetBrains Mono', monospace; font-size: 13px; text-align: center; outline: none; }
.act-input:focus { border-color: var(--accent-deep); }
.exercise-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }

/* Recommendation */
.rec-panel { border-color: rgba(163,230,53,0.25); background: radial-gradient(120% 100% at 0 0, rgba(163,230,53,0.06), transparent 55%), var(--bg-card); }
.rec-note { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; line-height: 1.5; }
.rec-note strong { color: var(--accent); font-family: 'JetBrains Mono', monospace; }
.rec-list { display: flex; flex-direction: column; gap: 6px; }
.rec-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--bg-surface); border: 1px solid var(--border-soft); border-radius: 10px; }
.rec-item-name { font-size: 13px; font-weight: 600; }
.rec-item-meta { font-size: 11px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }

/* Settings */
.settings-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.settings-row-left { display: flex; align-items: center; gap: 14px; }
.settings-ic { width: 40px; height: 40px; border-radius: 11px; background: var(--accent-dim); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.settings-ic svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.settings-title { font-size: 15px; font-weight: 700; }
.settings-desc { font-size: 12px; color: var(--text-muted); }
.lang-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.lang-btn { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-input); background: var(--bg-surface); color: var(--text-secondary); font-size: 14px; font-weight: 600; transition: all var(--transition); }
.lang-btn:hover { border-color: #3A3A40; transform: translateY(-2px); }
.lang-btn.active { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; z-index: 9000; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: flex; align-items: flex-end; justify-content: center; opacity: 0; pointer-events: none; visibility: hidden; transition: opacity 0.2s var(--ease), visibility 0.2s var(--ease); }
.modal-overlay.open { opacity: 1; pointer-events: auto; visibility: visible; }
.modal { width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-card) var(--radius-card) 0 0; transform: translateY(24px); transition: transform 0.26s var(--ease); }
.modal-overlay.open .modal { transform: translateY(0); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-card); z-index: 1; }
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close { width: 32px; height: 32px; border-radius: 9px; border: none; background: var(--bg-elevated); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; }
.modal-close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.modal-img-preview { display: none; width: 100%; max-height: 200px; object-fit: cover; border-radius: var(--radius-input); }
.modal-img-preview.visible { display: block; }
.modal-photo-row { display: flex; gap: 10px; }
.modal-photo-row .btn { flex: 1; }
.modal-hint { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.modal-foot { display: flex; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--bg-card); }
.modal-foot .btn { flex: 1; }

/* Chat tools */
.chat-tool-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; align-self: flex-end; flex-shrink: 0; transition: all var(--transition); }
.chat-tool-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chat-tool-btn:hover { border-color: var(--accent-deep); color: var(--accent); }
.chat-tool-btn.recording { background: var(--danger); color: #fff; border-color: var(--danger); animation: pulse 1.2s infinite; }
.chat-image-preview { display: none; max-width: 140px; max-height: 110px; object-fit: cover; border-radius: 12px; margin: 0 16px 8px; border: 1px solid var(--border); }
.chat-image-preview.visible { display: block; }
.chat-msg-img { width: 100%; max-width: 220px; border-radius: 12px; margin-bottom: 8px; }

body.modal-open { overflow: hidden; }

/* Real-time username check positioning */
.check-ok, .check-err {
  position: absolute;
  right: 12px;
  top: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px; /* matches input text alignment vertical center */
}

/* Auth visibility toggling via body class */
body.auth-mode .app-shell {
  display: none !important;
}
body.auth-mode .landing-page {
  display: flex !important;
}
body:not(.auth-mode) .landing-page {
  display: none !important;
}
body:not(.auth-mode) .app-shell {
  display: flex !important;
}

@media (max-width: 768px) {
  /* Viewport Locking Strategy (only active when logged in) */
  html, body {
    height: 100dvh !important;
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
  }
  
  /* Allow natural scrolling on the landing / auth modals screen */
  body.auth-mode, body.auth-mode html {
    height: auto !important;
    overflow: auto !important;
    position: static !important;
  }
  
  .app-shell {
    height: 100dvh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }
  
  .main-content {
    flex: 1 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    margin-left: 0 !important;
    padding-top: var(--topbar-h) !important;
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 50px) !important;
  }

  .modal { max-width: 100%; max-height: 88vh; }
  .modal-body { padding-bottom: 16px; }
  .modal-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .lang-options { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr; }

  /* 7-tab menu styling for S23 Ultra */
  .mobile-tabs {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 4px;
  }

  .mobile-tab {
    font-size: 8px !important;
    gap: 2px !important;
    padding: 6px 0 !important;
    flex: 1 !important;
    min-width: 0;
  }

  .mobile-tab-ic {
    width: 18px !important;
    height: 18px !important;
  }

  .mobile-tab.active::after {
    width: 22px !important;
  }

  /* Compact Landing Page layout for mobile viewports */
  .landing-page {
    gap: 12px !important;
    padding: 12px 14px !important;
    justify-content: flex-start !important;
  }
  
  .landing-hero {
    gap: 8px !important;
  }
  
  .landing-hero-img {
    max-height: 150px !important;
    border-radius: 12px !important;
    margin-bottom: 4px !important;
  }
  
  .landing-title {
    font-size: 20px !important;
    line-height: 1.2 !important;
  }
  
  .landing-subtitle {
    font-size: 12px !important;
    line-height: 1.4 !important;
  }
  
  .landing-features {
    display: none !important;
  }
  
  .landing-actions {
    gap: 8px !important;
    margin-top: 8px !important;
  }
  
  .btn-landing {
    padding: 10px !important;
    font-size: 13px !important;
  }

  /* Compact Chat Layout */
  #section-chat.active {
    position: fixed !important;
    top: var(--topbar-h) !important;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px) !important;
    left: 0 !important;
    right: 0 !important;
    height: auto !important;
    z-index: 100 !important;
    background: var(--bg-surface) !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  #section-chat .page-head {
    display: none !important;
  }

  .chat-container {
    height: 100% !important;
    max-height: none !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    border-radius: 0 !important;
    border: none !important;
    margin: 0 !important;
    width: 100% !important;
  }

  .chat-header {
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
  }

  .chat-messages {
    padding: 10px !important;
    gap: 8px !important;
    border-left: none !important;
    border-right: none !important;
    flex: 1 !important;
    overflow-y: auto !important;
  }

  .message-bubble {
    padding: 8px 12px !important;
    font-size: 13px !important;
    border-radius: 12px !important;
  }

  .chat-message.user .message-bubble {
    border-radius: 12px 12px 4px 12px !important;
  }

  .chat-message.assistant .message-bubble {
    border-radius: 12px 12px 12px 4px !important;
  }

  .chat-input-row {
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom)) !important;
    gap: 6px !important;
  }

  .chat-input {
    padding: 8px 14px !important;
    font-size: 13px !important;
    border-radius: 18px !important;
  }

  .chat-send-btn {
    width: 38px !important;
    height: 38px !important;
  }

  .chat-send-btn svg {
    width: 16px !important;
    height: 16px !important;
  }

  .chat-tool-btn {
    width: 38px !important;
    height: 38px !important;
  }

  .chat-tool-btn svg {
    width: 16px !important;
    height: 16px !important;
  }

  .quick-chips {
    padding: 8px !important;
    gap: 6px !important;
    border-left: none !important;
    border-right: none !important;
  }

  .quick-chip {
    padding: 5px 10px !important;
    font-size: 11px !important;
  }

  /* Compact Meals (Taomlarim) Layout */
  .cal-workspace {
    gap: 10px !important;
  }

  .search-wrapper {
    padding: 8px !important;
  }

  .search-field {
    font-size: 14px !important;
  }

  .food-grid {
    gap: 8px !important;
  }

  .food-card {
    padding: 8px 10px !important;
    gap: 8px !important;
  }

  .food-card-top {
    gap: 8px !important;
  }

  .food-thumb {
    width: 32px !important;
    height: 32px !important;
    font-size: 11px !important;
    border-radius: 8px !important;
  }

  .food-card-name {
    font-size: 13px !important;
  }

  .food-card-kcal {
    font-size: 11px !important;
  }

  .food-macros-mini {
    gap: 4px !important;
  }

  .macro-pill {
    padding: 2px 6px !important;
    font-size: 10px !important;
  }

  .food-card-foot {
    margin-top: 4px !important;
  }

  .food-gram-input {
    width: 54px !important;
    font-size: 12px !important;
    padding: 4px 6px !important;
  }

  .food-add-btn {
    width: 26px !important;
    height: 26px !important;
  }

  .log-row {
    padding: 8px 10px !important;
    gap: 8px !important;
  }

  .log-row-name {
    font-size: 12px !important;
  }

  .log-row-meta {
    font-size: 10px !important;
  }

  .log-row-kcal {
    font-size: 12px !important;
  }

  .log-row-del {
    width: 24px !important;
    height: 24px !important;
  }
}

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

#m-ai-info {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ═══════════════ Calio Custom Redesign Styles ═══════════════ */
.week-calendar {
  width: 100%;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
}
.week-calendar::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}
.calendar-day-card {
  box-shadow: var(--shadow-sm);
}
.calendar-day-card:hover {
  transform: translateY(-2px);
  border-color: rgba(139, 92, 246, 0.4) !important;
}
.calendar-day-card.active {
  box-shadow: 0 4px 12px var(--accent-glow) !important;
}

/* Options Bottom Sheet */
.plus-opt-btn {
  border: 1px solid var(--border) !important;
  color: var(--text-primary) !important;
  transition: transform 0.2s, background-color 0.2s, border-color 0.2s;
}
.plus-opt-btn:hover {
  background: var(--bg-card) !important;
  border-color: var(--accent) !important;
  transform: translateY(-2px);
}
.plus-opt-btn:active {
  transform: scale(0.96);
}

/* Modals animations */
.modal-overlay {
  transition: opacity 0.2s var(--ease);
}
.modal-overlay.open {
  opacity: 1 !important;
}
.modal {
  transition: transform 0.2s var(--ease);
}
.modal-overlay.open .modal {
  transform: scale(1) !important;
}

/* Circular Gauge Glowing & Aesthetics */
.circular-gauge-wrap {
  filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.15));
  transition: transform 0.2s;
}
.circular-gauge-wrap:hover {
  transform: scale(1.02);
}

/* Soft Shadows & Spacing for Macro Cards */
.macro-card {
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
}
.macro-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent) !important;
  box-shadow: 0 6px 20px var(--accent-glow);
}

/* Clean Spacing for Flat Logs */
.log-row {
  margin-bottom: 10px;
  transition: border-color 0.2s, background-color 0.2s;
}
.log-row:hover {
  border-color: var(--accent) !important;
  background-color: var(--bg-card) !important;
}
