/* ===== RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f0f0e;
  --surface: #1a1a18;
  --card: #222220;
  --border: #2e2e2b;
  --accent: #c8e6a0;
  --accent2: #f0d080;
  --text: #f0ede8;
  --muted: #7a7870;
  --pill-bg: #252522;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --danger: #e57373;
}

html, body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ===== APP LAYOUT ===== */
.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  max-width: 100%;
}

/* ===== APP HEADER ===== */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  flex-shrink: 0;
  z-index: 10;
}

.app-header .logo {
  font-family: 'DM Serif Display', serif;
  font-size: 18px;
  color: var(--accent);
  letter-spacing: -0.3px;
}

/* ===== APP BODY ===== */
.app-body {
  flex: 1;
  overflow: hidden;
  position: relative;
  min-height: 0; /* critical for flex children to shrink */
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  padding-bottom: var(--safe-b);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  transition: color 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.nav-item .icon {
  font-size: 20px;
  line-height: 1;
}

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

/* ===== SECTIONS ===== */
.section {
  display: none;
  height: 100%;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.section.active {
  display: flex;
}

/* Chat section: input bar must stay at bottom */
#sectionChat {
  overflow: hidden;
}

#sectionChat .chat-header {
  flex-shrink: 0;
}

#sectionChat .chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#sectionChat .chat-input-bar {
  flex-shrink: 0;
}

/* Bottom nav always visible */

/* ===== LOGIN ===== */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px 24px;
  background: var(--bg);
}

.login-logo {
  font-size: 64px;
  margin-bottom: 12px;
  line-height: 1;
}

.login-title {
  font-family: 'DM Serif Display', serif;
  font-size: 28px;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 32px;
  letter-spacing: -0.5px;
}

.login-form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== INPUT FIELD ===== */
.input-field {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  padding: 13px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.input-field::placeholder {
  color: var(--muted);
}

.input-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200, 230, 160, 0.12);
}

.input-field option {
  background: var(--surface);
  color: var(--text);
}

/* ===== ERROR MESSAGE ===== */
.error-msg {
  display: none;
  color: var(--danger);
  font-size: 13px;
  padding: 8px 10px;
  background: rgba(229, 115, 115, 0.1);
  border: 1px solid rgba(229, 115, 115, 0.25);
  border-radius: 8px;
}

.error-msg.visible {
  display: block;
}

.forgot-password {
  display: block;
  text-align: center;
  margin-top: 12px;
  color: #888;
  font-size: 13px;
  text-decoration: none;
}

.forgot-password:hover {
  color: #aaa;
  text-decoration: underline;
}

/* ===== BUTTONS ===== */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 12px 20px;
  background: var(--accent);
  color: #0f0f0e;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn-primary:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 12px 20px;
  background: var(--surface);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn-secondary:active {
  transform: scale(0.98);
  background: var(--card);
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-danger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 12px 20px;
  background: rgba(229, 115, 115, 0.15);
  color: var(--danger);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid rgba(229, 115, 115, 0.3);
  border-radius: 12px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn-danger:active {
  transform: scale(0.98);
  opacity: 0.85;
}

.btn-danger:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-outline {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 12px 20px;
  background: transparent;
  color: var(--accent);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 500;
  border: 1px solid var(--accent);
  border-radius: 12px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn-outline:active {
  transform: scale(0.98);
  background: rgba(200, 230, 160, 0.08);
}

.btn-outline:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ===== QUIZ ===== */
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.quiz-container {
  padding: 20px 16px 32px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.quiz-step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.quiz-back-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.quiz-back-btn:active {
  color: var(--text);
  border-color: var(--muted);
}

.progress-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  flex: 1;
}

.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s, transform 0.2s;
}

.progress-dot.done {
  background: var(--muted);
}

.progress-dot.active {
  background: var(--accent);
  transform: scale(1.35);
}

.quiz-card {
  animation: fadeSlideIn 0.3s ease forwards;
}

.quiz-title {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.3;
  letter-spacing: -0.3px;
}

.quiz-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 20px;
  line-height: 1.5;
}

.plan-options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.plan-option-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s;
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
}

.plan-option-card:active {
  border-color: var(--accent);
}

.plan-option-title {
  font-size: 14px;
  font-weight: 500;
}

.plan-option-macros {
  font-size: 12px;
  color: var(--muted);
}

.recipe-source-chip {
  display: inline-block;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.recipe-source-chip.source-plan {
  background: rgba(200, 230, 160, 0.15);
  color: var(--accent);
}

.recipe-source-chip.source-user {
  background: rgba(240, 208, 128, 0.15);
  color: var(--accent2);
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  min-height: 72px;
  width: 100%;
  text-align: left;
}

.quiz-option:active {
  transform: scale(0.99);
}

.quiz-option.selected,
.quiz-option.active {
  border-color: var(--accent);
  background: rgba(200, 230, 160, 0.08);
}

.quiz-option .emoji {
  font-size: 28px;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}

.quiz-option .label {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
}

.quiz-option .sublabel {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.3;
}

.meal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.meal-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-align: center;
}

.meal-btn .emoji {
  font-size: 24px;
}

.meal-btn.selected {
  border-color: var(--accent);
  background: rgba(200, 230, 160, 0.08);
  color: var(--accent);
}

.meal-btn:disabled,
.meal-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.fridge-textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  padding: 13px 14px;
  outline: none;
  resize: vertical;
  min-height: 120px;
  transition: border-color 0.15s, box-shadow 0.15s;
  margin-bottom: 16px;
}

.fridge-textarea::placeholder {
  color: var(--muted);
}

.fridge-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200, 230, 160, 0.12);
}

/* Home Google-style */
.home-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
  padding: 20px 24px;
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
}
.home-emoji {
  font-size: 48px;
  margin-bottom: 8px;
}
.home-title {
  font-family: 'DM Serif Display', serif;
  font-size: 24px;
  color: var(--text);
  margin-bottom: 24px;
}
.home-input-wrapper {
  position: relative;
  width: 100%;
}
.home-textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  padding: 16px 48px 16px 18px;
  outline: none;
  resize: none;
  min-height: 56px;
  max-height: 120px;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}
.home-textarea::placeholder {
  color: var(--muted);
  transition: opacity 0.3s ease;
}
.home-textarea.placeholder-fade::placeholder {
  opacity: 0;
}
.home-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200, 230, 160, 0.12);
}
.home-send-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  border: none;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, transform 0.1s;
}
.home-send-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.home-send-btn:active:not(:disabled) {
  transform: scale(0.95);
}
.home-plan-status {
  margin-top: 16px;
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.3px;
}

.no-plan-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 20px;
}

.no-plan-card .emoji {
  font-size: 40px;
  margin-bottom: 10px;
}

.no-plan-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 16px;
}

/* ===== CHAT ===== */
.chat-header {
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: var(--pill-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.chip:hover,
.chip.active {
  border-color: var(--accent);
  color: var(--accent);
}

.quick-reply-group {
  margin: 8px 0;
}

.quick-reply-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.quick-reply-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-reply-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  background: var(--pill-bg);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.quick-reply-chip:hover {
  border-color: var(--accent);
}

.quick-reply-chip.selected {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(76, 175, 80, 0.1);
}

.quick-reply-chip.dimmed {
  opacity: 0.4;
  pointer-events: none;
}

.quick-reply-chip.default {
  border-color: var(--accent);
  border-style: dashed;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.message {
  display: flex;
  gap: 8px;
  max-width: 100%;
}

.message.user {
  flex-direction: row-reverse;
  align-self: flex-end;
  max-width: 82%;
}

.message.assistant {
  flex-direction: row;
  align-self: flex-start;
  max-width: 88%;
}

/* Wrapper inside message: stack bubble + save button vertically */
.message-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  max-width: 100%;
}

.message-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--pill-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.message-bubble {
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  word-break: break-word;
}

.message.user .message-bubble {
  background: var(--accent);
  color: #0f0f0e;
  border-radius: 18px 18px 4px 18px;
  font-weight: 500;
}

.message.assistant .message-bubble {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px 18px 18px 4px;
}

.save-recipe-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding: 6px 12px;
  background: rgba(200, 230, 160, 0.1);
  border: 1px solid rgba(200, 230, 160, 0.25);
  border-radius: 20px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.save-recipe-btn:hover {
  background: rgba(200, 230, 160, 0.18);
}

.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + var(--safe-b));
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 60px;
  max-width: 100%;
  overflow: hidden;
}

.chat-textarea {
  flex: 1;
  min-width: 0; /* prevent flex item from overflowing */
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  padding: 10px 14px;
  outline: none;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.4;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.chat-textarea::placeholder {
  color: var(--muted);
}

.chat-textarea:focus {
  border-color: var(--accent);
}

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #0f0f0e;
  border: none;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.send-btn:active {
  transform: scale(0.92);
}

.send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* ===== RECIPES ===== */
.recipes-container {
  padding: 16px 16px 32px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

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

.recipes-header h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.3px;
}

.recipe-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.recipe-card:active {
  transform: scale(0.99);
  border-color: var(--accent);
}

.recipe-type-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.recipe-type-chip.almoco {
  background: rgba(200, 230, 160, 0.15);
  color: var(--accent);
}

.recipe-type-chip.cafe {
  background: rgba(240, 208, 128, 0.15);
  color: var(--accent2);
}

.recipe-type-chip.lanche {
  background: rgba(147, 197, 253, 0.15);
  color: #93c5fd;
}

.recipe-type-chip.jantar {
  background: rgba(196, 181, 253, 0.15);
  color: #c4b5fd;
}

.recipe-type-chip.pre-treino {
  background: rgba(251, 191, 146, 0.15);
  color: #fbbf92;
}

.recipe-type-chip.ceia {
  background: rgba(167, 139, 250, 0.15);
  color: #a78bfa;
}

/* Recipe filter chips */
.recipe-filters {
  margin-bottom: 16px;
  position: relative;
}

.recipe-filters::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: calc(100% - 4px);
  background: linear-gradient(to right, transparent, var(--bg));
  pointer-events: none;
  z-index: 1;
}

.recipe-filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  padding-right: 24px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.recipe-filter-row::-webkit-scrollbar {
  display: none;
}

.recipe-filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid var(--border);
  color: var(--muted);
  background: transparent;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.recipe-filter-chip.active {
  background: var(--accent);
  color: #1a1a18;
  border-color: var(--accent);
  font-weight: 600;
}

.recipe-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.3;
}

.recipe-preview {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 10px;
}

.macros {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.macro-pill {
  padding: 3px 9px;
  background: var(--pill-bg);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.recipe-date {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.empty-state .emoji {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 15px;
  line-height: 1.5;
}

/* ===== PROFILE ===== */
.profile-container {
  padding: 24px 16px 48px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--pill-bg);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin: 0 auto 12px;
}

.profile-name {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  font-weight: 400;
  color: var(--text);
  text-align: center;
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.profile-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}

.profile-card h4 {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
}

.profile-card p {
  font-size: 15px;
  color: var(--text);
  line-height: 1.5;
}

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

/* ===== MODALS ===== */
@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(20px + var(--safe-b));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slideUp 0.28s cubic-bezier(0.32, 0.72, 0, 1) forwards;
}

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

.modal-header h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 20px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.3px;
}

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--pill-bg);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.modal-close:hover {
  background: var(--card);
  color: var(--text);
}

/* ===== LOADING DOTS ===== */
@keyframes loadingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
}

.loading-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
  animation: loadingBounce 1.2s infinite ease-in-out;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ===== CONFIRM ACTIONS ===== */
#confirmDialog.active {
  z-index: 200;
}
.confirm-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.confirm-actions .btn-secondary,
.confirm-actions .btn-primary {
  flex: 1;
}

/* ===== ANALYTICS ===== */
.analytics-container {
  padding: 16px 16px 32px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.analytics-header {
  margin-bottom: 16px;
}

.analytics-header h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.3px;
}

.period-selector {
  display: flex;
  gap: 4px;
  background: var(--pill-bg);
  border-radius: 20px;
  padding: 3px;
  margin-bottom: 20px;
}

.period-btn {
  flex: 1;
  text-align: center;
  padding: 8px;
  border-radius: 18px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.period-btn.active {
  background: var(--accent);
  color: #0f0f0e;
  font-weight: 600;
}

/* Progress Rings */
.rings-row {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 16px;
}

.ring-item {
  text-align: center;
}

.ring-svg {
  width: 72px;
  height: 72px;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--pill-bg);
  stroke-width: 6;
}

.ring-fg {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}

.ring-fg.protein { stroke: #81c784; }
.ring-fg.carbs { stroke: #81d4fa; }
.ring-fg.fat { stroke: #f0d080; }

.ring-label {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.ring-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* Calorie total */
.calorie-total {
  text-align: center;
  margin-bottom: 20px;
}

.calorie-total .big-number {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
}

.calorie-total .goal-number {
  font-size: 15px;
  color: var(--muted);
}

/* Chart container */
.chart-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

.chart-container canvas {
  max-height: 200px;
}

/* Meal timeline */
.meal-timeline {
  margin-top: 16px;
}

.meal-timeline-title {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 10px;
}

.timeline-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.timeline-item:last-child {
  border-bottom: none;
}

.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.timeline-dot.cafe { background: var(--accent2); }
.timeline-dot.almoco { background: var(--accent); }
.timeline-dot.lanche { background: #93c5fd; }
.timeline-dot.jantar { background: #c4b5fd; }

.timeline-info {
  flex: 1;
  min-width: 0;
}

.timeline-meal-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.timeline-meal-title {
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.timeline-kcal {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}
.timeline-btns { display: flex; gap: 4px; }
.timeline-btn { background: none; border: none; cursor: pointer; font-size: 14px; padding: 2px 4px; opacity: 0.5; transition: opacity 0.2s; }
.timeline-btn:hover { opacity: 1; }
.timeline-macros { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Summary cards */
.summary-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.summary-card .summary-title {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 8px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.summary-item {
  text-align: center;
  flex: 1;
}

.summary-item .value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.summary-item .label {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

.summary-item .value.calories { color: var(--accent); }
.summary-item .value.protein { color: #81c784; }
.summary-item .value.carbs-val { color: #81d4fa; }
.summary-item .value.fat-val { color: #f0d080; }

/* Macro toggle buttons (month view) */
.macro-toggle {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 10px;
}

.macro-toggle-btn {
  padding: 5px 12px;
  border-radius: 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.macro-toggle-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(200, 230, 160, 0.1);
}

/* Log Meal Modal */
.log-meal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.portion-selector {
  display: flex;
  gap: 8px;
}

.portion-btn {
  flex: 1;
  padding: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.portion-btn.active {
  border-color: var(--accent);
  background: rgba(200, 230, 160, 0.1);
  color: var(--accent);
}

.log-macro-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 0;
}

.log-macro-preview .macro-pill {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}

.log-macro-preview .macro-pill.protein { color: #81c784; }
.log-macro-preview .macro-pill.carb { color: #81d4fa; }
.log-macro-preview .macro-pill.fat { color: #f0d080; }
.log-macro-preview .macro-pill.kcal { color: var(--accent); }

/* "Comer" button in chat — same size as save-recipe-btn but gold */
.log-meal-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding: 6px 12px;
  background: rgba(240, 208, 128, 0.1);
  border: 1px solid rgba(240, 208, 128, 0.25);
  border-radius: 20px;
  color: var(--accent2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.log-meal-btn:hover {
  background: rgba(240, 208, 128, 0.18);
}

/* Chat recipe buttons row */
.recipe-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  width: 100%;
  align-self: stretch;
}

.recipe-actions .save-recipe-btn,
.recipe-actions .log-meal-btn {
  margin-top: 0;
  flex: 1;
  justify-content: center;
}

/* Empty state for analytics */
.analytics-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.analytics-empty .emoji {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

.analytics-empty p {
  font-size: 15px;
  line-height: 1.5;
}

/* ===== DESKTOP ===== */
@media (min-width: 768px) {
  .app {
    max-width: 480px;
    margin: 0 auto;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    left: 50%;
    transform: translateX(-50%);
    right: auto;
    width: 480px;
  }

  .modal-overlay {
    align-items: center;
  }

  .modal {
    border-radius: 20px;
    margin-bottom: 0;
    max-height: 85vh;
  }
}

/* Nutri Virtual */
.nv-consultation { display: flex; flex-direction: column; height: calc(100vh - 120px); }
.nv-header { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--surface); }
.nv-checklist { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--surface); }
.nv-badge { padding: 3px 8px; border-radius: 10px; font-size: 11px; }
.nv-badge-done { background: #1b3a1b; color: #4CAF50; }
.nv-badge-pending { background: var(--surface); color: var(--muted); }
.nv-messages { flex: 1; overflow-y: auto; padding: 16px; }
.nv-msg { display: flex; gap: 8px; margin-bottom: 14px; }
.nv-msg-user { justify-content: flex-end; }
.nv-msg-avatar { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.nv-msg-agent .nv-msg-avatar { background: var(--accent); }
.nv-msg-user .nv-msg-avatar { background: var(--surface); order: 1; }
.nv-msg-bubble { padding: 10px 14px; border-radius: 12px; font-size: 14px; max-width: 80%; line-height: 1.4; }
.nv-msg-agent .nv-msg-bubble { background: #1a2a1a; border-top-left-radius: 4px; }
.nv-msg-user .nv-msg-bubble { background: #1a1a2a; border-top-right-radius: 4px; }
.nv-interim { padding: 0 16px; font-size: 13px; color: var(--muted); font-style: italic; min-height: 20px; }
.nv-controls { text-align: center; padding: 16px; }
.nv-mic-btn { width: 64px; height: 64px; border-radius: 50%; background: var(--surface); border: 2px solid var(--muted); font-size: 28px; cursor: pointer; transition: all 0.2s; }
.nv-mic-btn-small { width: 42px; height: 42px; border-radius: 50%; background: var(--surface); border: 2px solid var(--muted); font-size: 18px; cursor: pointer; transition: all 0.2s; flex-shrink: 0; }
.nv-mic-btn.nv-mic-active, .nv-mic-btn-small.nv-mic-active { background: #e53935; border-color: #e53935; box-shadow: 0 0 20px rgba(229,57,53,0.3); animation: nv-pulse 1.5s infinite; }
.nv-mic-label { font-size: 12px; color: var(--muted); margin-top: 6px; text-align: center; }
.nv-audio-level { width: 120px; height: 6px; background: var(--surface); border-radius: 3px; margin: 0 auto 12px; overflow: hidden; }
.nv-audio-bar { height: 100%; background: #4CAF50; border-radius: 3px; width: 0%; transition: width 0.05s; }
@keyframes nv-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

/* ===== SPINNER ===== */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0,0,0,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== PLAN SUMMARY CHIPS ===== */
.plan-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}
.plan-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
}
.plan-details {
  margin-top: 8px;
}
.plan-details summary {
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  list-style: none;
}
.plan-details summary::before {
  content: '▸ ';
}
.plan-details[open] summary::before {
  content: '▾ ';
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
  position: fixed;
  bottom: calc(72px + var(--safe-b));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  max-width: 320px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #2e7d32; }
.toast.error { background: #c62828; }
.toast.info { background: #1565c0; }
