/* ===========================
   DESIGN TOKENS
   =========================== */
:root {
  --sage-dark: #4D7A52;
  --sage-light: #6a9e70;
  --terracotta: #C4714A;
  --charcoal: #2C2C2C;
  --cream: #FAF7F2;
  --gold: #C9A84C;

  --white: #ffffff;
  --gray-100: #f0ede8;
  --gray-200: #ddd9d3;
  --gray-400: #aaa69f;
  --gray-600: #666360;

  --shadow-sm: 0 1px 4px rgba(44,44,44,0.08);
  --shadow-md: 0 4px 20px rgba(44,44,44,0.12);
  --shadow-lg: 0 8px 32px rgba(44,44,44,0.16);

  --radius: 14px;
  --radius-sm: 8px;
  --radius-pill: 999px;

  --header-h: 60px;
  --nav-h: 64px;

  --font-title: 'Playfair Display', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  background: var(--cream);
  color: var(--charcoal);
  font-family: var(--font-body);
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

/* ===========================
   HEADER
   =========================== */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--charcoal);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  z-index: 200;
  box-shadow: var(--shadow-md);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.header-logo { font-size: 22px; }

/* Logo image in header */
.header-logo-img {
  width: 38px;
  height: 38px;
  object-fit: cover;
  object-position: 50% 30%;
  display: block;
  border-radius: 50%;
  background: white;
}

.header-title {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 700;
  color: var(--cream);
  letter-spacing: -0.3px;
  white-space: nowrap;
}

.header-title-ai {
  color: #6fcf79;
}

/* Desktop top tabs — hidden by default (mobile-first), shown on desktop */
.header-tabs {
  display: none;
  align-items: stretch;
  gap: 0;
  flex: 1;
  height: 100%;
}

.htab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: rgba(250,247,242,0.55);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  padding: 0 16px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  display: flex;
  align-items: center;
}

.htab:hover {
  color: rgba(250,247,242,0.85);
}

.htab.active {
  color: var(--cream);
  border-bottom-color: var(--sage-light);
}

.store-select {
  background: rgba(250,247,242,0.12);
  color: var(--cream);
  border: 1px solid rgba(250,247,242,0.25);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: var(--font-body);
  font-size: 13px;
  max-width: 160px;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  flex-shrink: 0;
}

.store-select option {
  background: var(--charcoal);
  color: var(--cream);
}

/* ===========================
   MAIN CONTENT (Desktop)
   =========================== */
.app-main {
  padding-top: var(--header-h);
  min-height: 100vh;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===========================
   CHAT HERO BANNER
   =========================== */
.chat-hero {
  background: linear-gradient(135deg, var(--sage-dark) 0%, var(--sage-light) 50%, #84b589 100%);
  color: var(--white);
  padding: 32px 24px 28px;
  text-align: center;
}

.chat-hero-mascot {
  width: 160px;
  height: auto;
  margin: 0 auto 12px;
  display: block;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,0.30));
}

.chat-hero h1 {
  font-family: var(--font-title);
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.2;
}

.chat-hero p {
  font-size: 15px;
  opacity: 0.88;
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.5;
}

/* ===========================
   CHAT LAYOUT (2-column)
   =========================== */
.chat-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  max-width: 1100px;
  margin: 28px auto;
  padding: 0 24px 40px;
}

/* ===========================
   CHAT AREA
   =========================== */
.chat-area {
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  min-height: 480px;
}

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 260px;
  max-height: 480px;
}

/* Bot message row */
.chat-msg--bot {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.bot-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  background: white;
}

.bot-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
  display: block;
}

.msg-bubble {
  background: var(--gray-100);
  border-radius: 4px var(--radius) var(--radius) var(--radius);
  padding: 14px 16px;
  max-width: 85%;
}

.msg-bubble p {
  font-size: 14px;
  line-height: 1.65;
  color: var(--charcoal);
  margin-bottom: 8px;
}
.msg-bubble p:last-child { margin-bottom: 0; }

.feature-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-bottom: 12px;
}
.feature-card {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--cream);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13px;
  font-weight: 500;
  color: var(--charcoal);
  line-height: 1.2;
}
.feature-card > span { flex: 1; }
.hero-question {
  font-weight: 600;
  font-size: 14px;
  color: var(--sage-dark);
  margin: 0 !important;
}

/* User message */
.chat-msg--user {
  display: flex;
  justify-content: flex-end;
}

.chat-msg--user .msg-bubble {
  background: var(--sage-dark);
  border-radius: var(--radius) 4px var(--radius) var(--radius);
}

.chat-msg--user .msg-bubble p {
  color: var(--white);
}

/* Match result inside chat */
.match-result-bubble {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 8px;
  width: 100%;
}

.match-result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--gray-100);
  font-size: 13px;
}

.match-result-row:first-child { border-top: none; }

.match-result-row--found { background: rgba(77,122,82,0.04); }
.match-result-row--not-found { background: rgba(196,113,74,0.04); }

.match-result-icon { flex-shrink: 0; font-size: 14px; }

.match-result-name {
  flex: 1;
  font-weight: 500;
  color: var(--charcoal);
}

.match-result-aisle {
  font-size: 12px;
  font-weight: 600;
  color: var(--sage-dark);
  background: rgba(77,122,82,0.1);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.match-result-miss {
  font-size: 12px;
  color: var(--terracotta);
}

/* ===========================
   IMAGE PREVIEW BAR
   =========================== */
.image-preview-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--gray-100);
  border-top: 1px solid var(--gray-200);
}

.image-thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.image-preview-label {
  font-size: 13px;
  color: var(--gray-600);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.image-remove-btn {
  background: none;
  border: none;
  color: var(--gray-600);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 6px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.15s;
}

.image-remove-btn:hover {
  background: var(--gray-200);
}

/* ===========================
   QUICK ACTION CHIPS
   =========================== */
.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--gray-200);
}

.chip {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--charcoal);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--sage-dark);
  color: var(--sage-dark);
  background: rgba(77,122,82,0.06);
}

.chip--skip {
  border-color: var(--gray-200);
  color: var(--gray-600);
}

/* ── Profile chip (highlighted) ── */
.chip--profile {
  background: var(--charcoal);
  border-color: var(--charcoal);
  color: var(--cream);
  font-weight: 600;
}
.chip--profile:hover {
  background: #444;
  border-color: #444;
  color: var(--cream);
}

/* ===========================
   CHAT INPUT BAR
   =========================== */
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--gray-200);
  background: var(--white);
}

.input-action-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  color: var(--charcoal);
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
  text-decoration: none;
}

.input-action-btn:hover {
  background: var(--gray-200);
}

.input-action-btn--listening {
  background: var(--terracotta);
  color: var(--white);
  animation: mic-pulse 1s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(196,113,74,0.4); }
  50%       { box-shadow: 0 0 0 8px rgba(196,113,74,0); }
}

.chat-text-input {
  flex: 1;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-pill);
  padding: 11px 18px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--charcoal);
  background: var(--gray-100);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  min-width: 0;
}

.chat-text-input:focus {
  border-color: var(--sage-dark);
  background: var(--white);
}

.chat-text-input::placeholder { color: var(--gray-400); }

.send-btn {
  background: var(--sage-dark);
  color: var(--white);
  border: none;
  border-radius: var(--radius-pill);
  padding: 11px 22px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}

.send-btn:active { background: #3d6342; }

/* ===========================
   SIDEBAR
   =========================== */
.chat-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-self: start;
  position: sticky;
  top: calc(var(--header-h) + 24px);
}

.sidebar-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.sidebar-card-title {
  font-family: var(--font-title);
  font-size: 15px;
  color: var(--charcoal);
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
}

/* ── Mi Lista collapsible card ── */
.mylist-card { overflow: visible; }

.mylist-toggle {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  gap: 8px;
}

.mylist-toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-title);
  font-size: 15px;
  color: var(--charcoal);
  font-weight: 700;
}

.mylist-icon { font-size: 16px; }

.mylist-count {
  background: var(--sage-dark);
  color: var(--white);
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  line-height: 1.4;
}

.mylist-chevron {
  font-size: 20px;
  font-weight: 300;
  color: var(--sage-dark);
  transition: transform 0.2s;
  line-height: 1;
  flex-shrink: 0;
}

.mylist-toggle[aria-expanded="true"] .mylist-chevron {
  transform: rotate(45deg);
}

.mylist-body {
  animation: slideDown 0.18s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sidebar-list-content {
  padding: 12px 16px;
  min-height: 52px;
}

.sidebar-empty {
  font-size: 13px;
  color: var(--gray-400);
}

.sidebar-add-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 10px;
  border-top: 1px solid var(--gray-100);
}

.sidebar-add-input {
  flex: 1;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-pill);
  padding: 7px 13px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--charcoal);
  background: var(--gray-100);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  min-width: 0;
}

.sidebar-add-input:focus {
  border-color: var(--sage-dark);
  background: var(--white);
}

.sidebar-add-input::placeholder { color: var(--gray-400); }

.sidebar-add-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--sage-dark);
  color: var(--white);
  font-size: 20px;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
  transition: background 0.15s;
}

.sidebar-add-btn:active { background: #3d6342; }

.sidebar-save-bar {
  padding: 8px 16px 14px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
}

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

.sidebar-item-name {
  flex: 1;
  font-weight: 500;
  color: var(--charcoal);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-item-aisle {
  font-size: 11px;
  color: var(--sage-dark);
  font-weight: 600;
  background: rgba(77,122,82,0.1);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

.sidebar-item-miss {
  font-size: 11px;
  color: var(--terracotta);
  flex-shrink: 0;
}

/* Assistant steps */
.assistant-steps {
  list-style: none;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--gray-400);
  padding: 7px 0;
  transition: color 0.2s;
}

.step::before {
  content: attr(data-step);
  width: 26px;
  height: 26px;
  background: var(--gray-200);
  color: var(--gray-600);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}

.step.active {
  color: var(--charcoal);
  font-weight: 600;
}

.step.active::before {
  background: var(--sage-dark);
  color: var(--white);
}

.step.done::before {
  background: var(--sage-dark);
  color: var(--white);
  content: '✓';
}

/* Lists in sidebar */
.lists-container-sidebar {
  padding: 8px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.list-card-sidebar {
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.list-card-sidebar-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--charcoal);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-card-sidebar-meta {
  font-size: 11px;
  color: var(--gray-600);
}

.list-card-sidebar-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.btn-list-action {
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  font-size: 11px;
  font-family: var(--font-body);
  cursor: pointer;
  color: var(--charcoal);
  transition: background 0.15s;
}

.btn-list-action:hover { background: var(--gray-200); }

.btn-list-delete {
  color: var(--terracotta);
  border-color: var(--terracotta);
}

.btn-list-delete:hover {
  background: var(--terracotta);
  color: var(--white);
}

/* ===========================
   SECTION HERO (tools)
   =========================== */
.section-hero {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 28px 24px;
  text-align: center;
}

.section-hero h2 {
  font-family: var(--font-title);
  font-size: 26px;
  color: var(--charcoal);
  margin-bottom: 6px;
}

.section-hero p {
  font-size: 14px;
  color: var(--gray-600);
}

/* ===========================
   TOOL LAYOUT (single column)
   =========================== */
.tool-layout {
  max-width: 720px;
  margin: 28px auto;
  padding: 0 24px 48px;
}

/* ===========================
   INPUT COMPONENTS
   =========================== */
.input-with-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-input {
  flex: 1;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 13px 16px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--charcoal);
  background: var(--white);
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}

.tool-input:focus { border-color: var(--sage-dark); }
.tool-input::placeholder { color: var(--gray-400); }

textarea {
  width: 100%;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 52px 14px 14px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--charcoal);
  background: var(--white);
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.5;
}

textarea:focus { border-color: var(--sage-dark); }
textarea::placeholder { color: var(--gray-400); }

.search-input-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.textarea-wrapper {
  position: relative;
}

.input-action-btn--corner {
  position: absolute;
  bottom: 10px;
  right: 10px;
}

.input-actions-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ===========================
   BUTTONS
   =========================== */
.btn-primary {
  width: 100%;
  background: var(--sage-dark);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  padding: 15px 20px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  letter-spacing: 0.1px;
}

.btn-primary:active { background: #3d6342; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  background: var(--white);
  color: var(--sage-dark);
  border: 1.5px solid var(--sage-dark);
  border-radius: var(--radius-pill);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  text-align: center;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.btn-secondary:active {
  background: var(--sage-dark);
  color: var(--white);
}

.btn-small {
  padding: 8px 16px;
  font-size: 13px;
}

/* ===========================
   RECIPE / PLANNER TABS
   =========================== */
.recipe-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.recipe-tab {
  flex: 1;
  background: var(--white);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 11px 10px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  text-align: center;
}

.recipe-tab.active {
  border-color: var(--sage-dark);
  color: var(--sage-dark);
  background: rgba(77,122,82,0.06);
}

.recipe-panel-body {
  margin-bottom: 20px;
}

/* ===========================
   UPLOAD ZONE
   =========================== */
.upload-zone {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  background: var(--gray-100);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: border-color 0.2s;
}

.upload-zone:hover { border-color: var(--sage-dark); }

.upload-zone-icon { font-size: 44px; }

.upload-zone-title {
  font-weight: 600;
  font-size: 16px;
  color: var(--charcoal);
}

.upload-zone-subtitle {
  font-size: 13px;
  color: var(--gray-600);
  max-width: 320px;
}

.upload-preview {
  margin-top: 4px;
}

.upload-preview-img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.image-file-name {
  font-size: 13px;
  color: var(--gray-600);
  word-break: break-all;
}

/* ===========================
   AISLE SEARCH RESULTS
   =========================== */
.aisle-search-results {
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.aisle-search-result {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.aisle-search-result--found { border-left: 4px solid var(--sage-dark); }
.aisle-search-result--not-found { border-left: 4px solid var(--gold); }

.asr-icon { font-size: 24px; flex-shrink: 0; }

.asr-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.asr-product {
  font-weight: 600;
  font-size: 15px;
  color: var(--charcoal);
  text-transform: capitalize;
}

.asr-category { font-size: 13px; color: var(--gray-600); }
.asr-aisle { font-size: 13px; font-weight: 700; color: var(--sage-dark); }
.asr-miss { font-size: 13px; color: var(--gray-600); }

/* Aisle image results */
.aisle-image-results {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 24px;
}

.aisle-image-results-title {
  background: var(--sage-dark);
  color: var(--white);
  font-size: 13px;
  font-weight: 700;
  padding: 10px 16px;
  letter-spacing: 0.4px;
}

/* ===========================
   AISLE SECTIONS GRID
   =========================== */
.aisle-sections-title {
  font-family: var(--font-title);
  font-size: 17px;
  font-weight: 700;
  color: var(--charcoal);
  margin-bottom: 14px;
}

.aisle-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}

.section-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  text-align: center;
  border: 2px solid transparent;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: default;
}

.section-card:hover { border-color: var(--sage-dark); }

.section-icon { font-size: 28px; line-height: 1; }

.section-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--charcoal);
  line-height: 1.3;
}

.section-aisle {
  font-size: 11px;
  color: var(--sage-dark);
  font-weight: 600;
}

/* ===========================
   PLANNER FORM
   =========================== */
.planner-form {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--charcoal);
}

.form-select,
.form-input {
  width: 100%;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--charcoal);
  background: var(--white);
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.form-select:focus,
.form-input:focus { border-color: var(--sage-dark); }

/* ===========================
   PLANNER DAY CARDS
   =========================== */
.planner-days {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 28px;
}

.day-card {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.day-card-header {
  background: var(--sage-dark);
  color: var(--white);
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 700;
  padding: 11px 16px;
  letter-spacing: 0.2px;
}

.day-meals { display: flex; flex-direction: column; }

.meal-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 16px;
  border-top: 1px solid var(--gray-100);
}

.meal-type {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  white-space: nowrap;
  min-width: 82px;
  padding-top: 1px;
}

.meal-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.meal-name { font-size: 14px; font-weight: 500; color: var(--charcoal); }
.meal-desc { font-size: 12px; color: var(--gray-600); }

/* ===========================
   PLANNER SHOPPING LIST
   =========================== */
.planner-shopping {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 28px;
}

.planner-shopping-title {
  font-family: var(--font-title);
  font-size: 18px;
  color: var(--charcoal);
  margin-bottom: 16px;
}

.shopping-category { margin-bottom: 16px; }

.shopping-category-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--sage-dark);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.shopping-category-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.shopping-category-items li {
  font-size: 14px;
  color: var(--charcoal);
  padding-left: 14px;
  position: relative;
}

.shopping-category-items li::before {
  content: '·';
  position: absolute;
  left: 4px;
  color: var(--sage-dark);
  font-weight: 700;
}

/* ===========================
   PROSE CONTENT (recipes result)
   =========================== */
.prose-content {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  line-height: 1.7;
}

.prose-content p {
  font-size: 14px;
  color: var(--charcoal);
  margin-bottom: 4px;
}

.prose-content .prose-gap { height: 12px; }

/* ===========================
   PLACEHOLDER
   =========================== */
.placeholder-text {
  color: var(--gray-400);
  font-size: 14px;
  text-align: center;
  padding: 40px 20px;
  grid-column: 1 / -1;
}

/* ===========================
   TOAST
   =========================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--charcoal);
  color: var(--white);
  padding: 11px 22px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  z-index: 500;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  pointer-events: none;
}

.toast--error   { background: var(--terracotta); }
.toast--success { background: var(--sage-dark); }

/* ===========================
   LOADING
   =========================== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(250,247,242,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  backdrop-filter: blur(3px);
}

.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--sage-dark);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

/* ===========================
   UTILITY
   =========================== */
.hidden { display: none !important; }

/* ===========================
   BOTTOM NAV — visible by default (mobile-first)
   =========================== */
.bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 4px;
  color: var(--gray-400);
  transition: color 0.15s;
}

.nav-item.active { color: var(--sage-dark); }
.nav-icon { font-size: 22px; line-height: 1; }

.nav-label {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 500;
}

/* ===========================
   BASE (mobile-first defaults)
   =========================== */
html, body {
  height: 100%;
  overflow: hidden;
}

.app-main {
  position: fixed;
  top: var(--header-h);
  bottom: var(--nav-h);
  left: 0; right: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: 0;
  min-height: unset;
}

/* Mobile chat: single column, no card borders */
.chat-layout {
  display: grid;
  grid-template-columns: 1fr;
  margin: 0;
  padding: 0 0 24px;
  gap: 0;
}

.chat-hero {
  background: linear-gradient(135deg, var(--sage-dark) 0%, var(--sage-light) 60%, #84b589 100%);
  color: var(--white);
  padding: 22px 16px;
  text-align: center;
}

.chat-hero h1 {
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 0;
  line-height: 1.2;
}

.chat-area {
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-radius: 0;
  box-shadow: none;
  min-height: unset;
}

.chat-messages {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
  max-height: 340px;
}

.chat-sidebar {
  padding: 16px;
  position: static;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-hero {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 20px 16px;
  text-align: left;
}

.section-hero h2 {
  font-family: var(--font-title);
  font-size: 22px;
  color: var(--charcoal);
  margin-bottom: 4px;
}

.section-hero p {
  font-size: 14px;
  color: var(--gray-600);
}

.tool-layout {
  max-width: 720px;
  margin: 16px auto;
  padding: 0 16px 32px;
}

.form-row { grid-template-columns: 1fr; }

.aisle-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--gray-200);
}

.chip {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--charcoal);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.chip:hover { border-color: var(--sage-dark); color: var(--sage-dark); }
.chip--skip { color: var(--gray-600); }

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--gray-200);
  background: var(--white);
}

.send-btn {
  background: var(--sage-dark);
  color: var(--white);
  border: none;
  border-radius: var(--radius-pill);
  padding: 10px 16px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}

.send-btn:active { background: #3d6342; }

.toast { bottom: calc(var(--nav-h) + 12px); }

/* ===========================
   DESKTOP (≥ 769px)
   =========================== */
@media (min-width: 769px) {

  html, body {
    height: auto;
    overflow: visible;
  }

  .app-main {
    position: static;
    padding-top: var(--header-h);
    min-height: 100vh;
    bottom: unset;
    overflow: visible;
  }

  /* Show top tabs, hide bottom nav */
  .header-tabs { display: flex; }
  .bottom-nav { display: none; }

  .toast { bottom: 24px; }

  /* Chat layout: 2 columns */
  .chat-layout {
    grid-template-columns: 1fr 300px;
    gap: 24px;
    max-width: 1100px;
    margin: 28px auto;
    padding: 0 24px 40px;
  }

  .chat-hero {
    padding: 36px 24px;
    text-align: center;
  }

  .chat-hero h1 { font-size: 30px; margin-bottom: 10px; }

  .chat-area {
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    min-height: 480px;
  }

  .chat-messages {
    padding: 20px;
    gap: 18px;
    min-height: 260px;
    max-height: 480px;
  }

  .chat-sidebar {
    padding: 0;
    position: sticky;
    top: calc(var(--header-h) + 24px);
    align-self: start;
    gap: 16px;
  }

  .section-hero {
    padding: 28px 24px;
    text-align: center;
  }

  .section-hero h2 { font-size: 26px; }

  .tool-layout {
    margin: 28px auto;
    padding: 0 24px 48px;
  }

  .form-row { grid-template-columns: 1fr 110px; }

  .aisle-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 32px;
  }

  .quick-chips {
    gap: 8px;
    padding: 12px 16px;
  }

  .chip {
    font-size: 13px;
    padding: 7px 14px;
  }

  .chat-input-bar {
    padding: 12px 16px;
    gap: 8px;
  }

  .send-btn {
    padding: 11px 22px;
    font-size: 14px;
  }
}

/* ===========================
   CART BUTTON (header logo)
   =========================== */
.cart-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
  color: inherit;
  flex-shrink: 0;
  -webkit-appearance: none;
  appearance: none;
}

.cart-btn:hover { background: rgba(250,247,242,0.12); }

.header-logo-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.cart-badge {
  position: absolute;
  top: -6px;
  right: -9px;
  background: var(--terracotta);
  color: var(--white);
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 2px solid var(--charcoal);
  pointer-events: none;
  animation: badge-pop 0.2s ease;
}

@keyframes badge-pop {
  0%   { transform: scale(0.5); }
  70%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ===========================
   SIDEBAR CHECKLIST
   =========================== */
.list-check {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: 50%;
  border: 2px solid var(--gray-200);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  flex-shrink: 0;
  background: var(--white);
}

.list-check:hover { border-color: var(--gold); }

.list-check:checked {
  background: var(--gold);
  border-color: var(--gold);
}

.list-check:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--white);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.sidebar-item-body {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.sidebar-item--done {
  text-decoration: line-through;
  color: var(--gray-400) !important;
}

/* ===========================
   CART DRAWER (bottom sheet)
   =========================== */
.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44,44,44,0.45);
  z-index: 290;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.cart-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.cart-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 78vh;
  background: var(--white);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -6px 32px rgba(44,44,44,0.18);
  z-index: 300;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 16px);
}

.cart-drawer.open { transform: translateY(0); }

.cart-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--gray-100);
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 1;
}

.cart-drawer-title {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 700;
  color: var(--charcoal);
}

.cart-drawer-close {
  background: var(--gray-100);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-600);
  transition: background 0.15s;
  flex-shrink: 0;
}

.cart-drawer-close:hover { background: var(--gray-200); }

.cart-drawer-items {
  padding: 8px 20px 16px;
  display: flex;
  flex-direction: column;
}

.cart-drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
}

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

.cart-drawer-item-check {
  font-size: 20px;
  flex-shrink: 0;
}

.cart-drawer-item-name {
  flex: 1;
  font-weight: 500;
  color: var(--charcoal);
  min-width: 0;
}

.cart-drawer-item-aisle {
  font-size: 12px;
  color: var(--sage-dark);
  font-weight: 600;
  background: rgba(77,122,82,0.1);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Aisles: Mi Lista panel ── */
.aisles-mylist {
  background: var(--white);
  border-bottom: 3px solid var(--sage-dark);
  padding: 0;
  margin-bottom: 0;
}

.aisles-mylist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 10px;
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 700;
  color: var(--charcoal);
}

.aisles-mylist-count {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--sage-dark);
}

.aisles-mylist-items {
  padding: 0 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.aisles-mylist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-top: 1px solid var(--gray-100);
  font-size: 14px;
}

.aisles-mylist-item:first-child { border-top: none; }

.aisles-mylist-item .list-check { width: 20px; height: 20px; min-width: 20px; }

.aisles-item-name {
  flex: 1;
  font-weight: 500;
  color: var(--charcoal);
  min-width: 0;
}

.aisles-item-name.done {
  text-decoration: line-through;
  color: var(--gray-400);
}

.aisles-item-aisle {
  font-size: 12px;
  font-weight: 700;
  color: var(--sage-dark);
  background: rgba(77,122,82,0.1);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  flex-shrink: 0;
}

.aisles-item-no-aisle {
  font-size: 12px;
  color: var(--gray-400);
  flex-shrink: 0;
}

.aisles-item-body {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.cart-drawer-item-body {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.cart-drawer-progress {
  font-size: 12px;
  font-weight: 600;
  color: var(--sage-dark);
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--gray-100);
  margin-bottom: 4px;
  text-align: center;
  letter-spacing: 0.2px;
}

.cart-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--gray-400);
  font-size: 14px;
  line-height: 1.6;
}

/* ============================================================
   PROFILE PANEL
   ============================================================ */

/* Header button */
.profile-hdr-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 20px;
  transition: background 0.15s;
  flex-shrink: 0;
}
.profile-hdr-btn:hover { background: rgba(255,255,255,0.15); }
.profile-hdr-icon { font-size: 20px; line-height: 1; }
.profile-hdr-pct {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(0,0,0,0.2);
  border-radius: 10px;
  padding: 1px 5px;
}

.logout-hdr-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 16px;
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}
.logout-hdr-btn:hover { background: rgba(255,255,255,0.22); }

.profile-sync-banner {
  margin-bottom: 10px;
}
.profile-sync-ok {
  font-size: 12px;
  color: var(--sage-dark);
  font-weight: 600;
  text-align: center;
  padding: 8px 12px;
  background: rgba(77,122,82,0.08);
  border-radius: 10px;
}
.profile-sync-cta {
  width: 100%;
  background: none;
  border: 1.5px dashed var(--sage-dark);
  border-radius: 10px;
  color: var(--sage-dark);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
  text-align: center;
  line-height: 1.4;
  transition: background 0.15s;
}
.profile-sync-cta:hover { background: rgba(77,122,82,0.07); }

/* Backdrop */
.profile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.profile-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

/* Panel — uses right-position animation instead of transform to avoid iOS input focus bug */
.profile-panel {
  position: fixed;
  top: 0;
  right: -101%;
  width: 100%;
  max-width: 480px;
  height: 100%;
  background: var(--cream);
  z-index: 301;
  display: flex;
  flex-direction: column;
  transition: right 0.3s ease;
}
.profile-panel.open { right: 0; }

/* Panel header */
.profile-panel-hdr {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
  background: var(--charcoal);
  color: white;
  flex-shrink: 0;
}
.profile-back {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px 4px 0;
  opacity: 0.85;
  transition: opacity 0.15s;
}
.profile-back:hover { opacity: 1; }
.profile-panel-title {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  font-weight: 600;
  flex: 1;
}
.profile-panel-pct {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
}

/* Progress bar */
.profile-panel-progress {
  height: 4px;
  background: rgba(255,255,255,0.15);
  flex-shrink: 0;
}
.profile-panel-bar {
  height: 100%;
  background: var(--gold);
  transition: width 0.4s ease;
}

/* Scrollable body */
.profile-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0 8px;
}

/* Footer */
.profile-panel-footer {
  flex-shrink: 0;
  padding: 12px 16px;
  background: white;
  border-top: 1px solid var(--gray-100, #eee);
}
#profile-continue {
  width: 100%;
  padding: 14px;
  background: var(--sage-dark);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
#profile-continue:hover { background: #3d6441; }

/* ── Profile blocks ── */
.profile-block {
  border-bottom: 1px solid var(--gray-100, #eee);
}
.profile-block-hdr {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  background: white;
  transition: background 0.12s;
  user-select: none;
}
.profile-block-hdr:hover { background: #f7f7f5; }

.pb-status {
  font-size: 16px;
  flex-shrink: 0;
}
.pb-right {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pb-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--charcoal);
}
.pb-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.pb-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.pb-tag--urgent  { background: #fde8e8; color: #c0392b; }
.pb-tag--high    { background: #fff3e0; color: #e67e22; }
.pb-tag--optional{ background: #e8f5e9; color: var(--sage-dark); }
.pb-tag--default { background: #f0f0f0; color: #666; }

.pb-est {
  font-size: 11px;
  color: #888;
}
.pb-chevron {
  font-size: 18px;
  color: #aaa;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.profile-block-hdr[aria-expanded="true"] .pb-chevron { transform: rotate(180deg); }

/* Block body */
.profile-block-body {
  padding: 0 16px 4px;
  background: white;
}
.profile-block-body.hidden { display: none; }

/* Block footer */
.profile-block-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 14px;
  background: white;
}
.profile-save-btn {
  flex: 1;
  padding: 11px;
  background: var(--sage-dark);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.profile-save-btn:hover { background: #3d6441; }
.profile-skip-btn {
  flex-shrink: 0;
  padding: 11px 16px;
  background: none;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  font-size: 14px;
  color: #888;
  cursor: pointer;
  transition: border-color 0.15s;
}
.profile-skip-btn:hover { border-color: #aaa; }
.profile-skip-confirm {
  font-size: 12px;
  color: #888;
  padding: 6px 16px 10px;
  line-height: 1.5;
}
.profile-skip-confirm-btn {
  display: inline-block;
  margin-top: 4px;
  padding: 6px 14px;
  background: #f0f0f0;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  color: var(--charcoal);
}

/* ── Question types ── */
.pq-wrap { padding: 12px 0 4px; }
.pq-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--charcoal);
  margin-bottom: 10px;
  line-height: 1.4;
}
.pq-max-note {
  font-size: 11px;
  color: #aaa;
  margin-bottom: 8px;
}

/* Multi / single options */
.pq-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pq-option {
  padding: 7px 13px;
  border: 1.5px solid #ddd;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  background: white;
  color: var(--charcoal);
  user-select: none;
}
.pq-option.active, .pq-option.selected {
  background: var(--sage-dark);
  border-color: var(--sage-dark);
  color: white;
}
.pq-option:hover:not(.active):not(.selected) {
  border-color: var(--sage-dark);
  color: var(--sage-dark);
}

/* Scale */
.pq-scale { display: flex; gap: 8px; align-items: center; }
.pq-scale-btn {
  width: 40px;
  height: 40px;
  border: 1.5px solid #ddd;
  border-radius: 50%;
  background: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pq-scale-btn.active, .pq-scale-btn.selected {
  background: var(--sage-dark);
  border-color: var(--sage-dark);
  color: white;
}
.pq-scale-btn:hover:not(.active):not(.selected) { border-color: var(--sage-dark); }
.pq-scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #888;
  margin-top: 4px;
}

/* Matrix */
.pq-list { display: flex; flex-direction: column; gap: 10px; }
.pq-mat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f5f5f5;
}
.pq-mat-row-label {
  font-size: 13px;
  color: var(--charcoal);
  flex: 1;
  min-width: 0;
}
.pq-mat-dots { display: flex; gap: 6px; }
.pq-mat-dot {
  width: 28px;
  height: 28px;
  border: 1.5px solid #ddd;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  color: #888;
  background: white;
}
.pq-mat-dot.active, .pq-mat-dot.selected {
  background: var(--sage-dark);
  border-color: var(--sage-dark);
  color: white;
}
.pq-mat-dot:hover:not(.active):not(.selected) { border-color: var(--sage-dark); }

/* Freq matrix columns header */
.pq-freq-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 0 6px;
  border-bottom: 1px solid #eee;
}
.pq-freq-header-label {
  flex: 1;
  font-size: 11px;
  color: #aaa;
  font-weight: 600;
}
.pq-freq-cols { display: flex; gap: 6px; }
.pq-freq-col-label {
  width: 28px;
  text-align: center;
  font-size: 10px;
  color: #aaa;
  font-weight: 600;
}

/* Text input */
.pq-text-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #ddd;
  border-radius: 10px;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.pq-text-input:focus { border-color: var(--sage-dark); }

/* Otro/Otra — campo de texto siempre visible, siempre editable */
.pq-otro-wrap { margin-top: 10px; }
.pq-otro-label {
  display: block;
  cursor: text;
}
.pq-otro-hint {
  display: block;
  font-size: 12px;
  color: var(--gray-600);
  font-weight: 500;
  margin-bottom: 5px;
}
.pq-otro-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #ccc;
  border-radius: 12px;
  font-size: 15px;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
  background: white;
  color: var(--charcoal);
  -webkit-appearance: none;
  appearance: none;
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
  cursor: text;
}
.pq-otro-input::placeholder { color: #bbb; }
.pq-otro-input:focus {
  border-color: var(--sage-dark);
  box-shadow: 0 0 0 3px rgba(77, 122, 82, 0.15);
}

/* ── In-chat profile open button ── */
.chat-open-profile-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 9px 18px;
  background: var(--sage-dark);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.chat-open-profile-btn:hover { background: #3d6441; }

/* ── Matrix / freq-matrix scrollable table ── */
.pq-matrix,
.pq-freq-matrix {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 8px;
}
.pq-matrix table,
.pq-freq-matrix table {
  border-collapse: collapse;
  min-width: 100%;
  font-size: 12px;
}
.pq-matrix th,
.pq-freq-matrix th {
  padding: 6px 8px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: #888;
  white-space: nowrap;
}
.pq-matrix td,
.pq-freq-matrix td {
  padding: 4px 6px;
  text-align: center;
}
.pq-matrix .pq-mat-row-label,
.pq-freq-matrix .pq-mat-row-label {
  text-align: left;
  font-size: 12px;
  color: var(--charcoal);
  white-space: nowrap;
  padding-right: 12px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   AUTH MODAL
   ============================================================ */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 400;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.auth-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.auth-modal {
  position: fixed;
  top: 8vh;
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  width: calc(100% - 32px);
  max-width: 400px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--white);
  border-radius: 20px;
  padding: 28px 24px 24px;
  z-index: 401;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.auth-modal.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) scale(1);
}

.auth-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--gray-100);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-600);
  transition: background 0.15s;
  flex-shrink: 0;
}
.auth-close:hover { background: var(--gray-200); }

.auth-logo {
  font-size: 36px;
  text-align: center;
  margin-bottom: 10px;
}

.auth-title {
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 700;
  color: var(--charcoal);
  text-align: center;
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--gray-600);
  text-align: center;
  line-height: 1.5;
  margin-bottom: 20px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.auth-label-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--charcoal);
}

.auth-input {
  width: 100%;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--charcoal);
  background: var(--gray-100);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}
.auth-input:focus {
  border-color: var(--sage-dark);
  background: var(--white);
}
.auth-input::placeholder { color: var(--gray-400); }

.auth-error {
  font-size: 13px;
  color: var(--terracotta);
  font-weight: 500;
  min-height: 18px;
  text-align: center;
}

.auth-submit-btn {
  width: 100%;
  background: var(--sage-dark);
  color: var(--white);
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 2px;
}
.auth-submit-btn:hover { background: #3d6441; }
.auth-submit-btn:disabled {
  background: var(--gray-400);
  cursor: not-allowed;
}

.auth-toggle {
  font-size: 13px;
  color: var(--gray-600);
  text-align: center;
  margin-top: 16px;
}

.auth-link {
  background: none;
  border: none;
  color: var(--sage-dark);
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-body);
  text-decoration: underline;
  padding: 0;
}
.auth-link:hover { color: #3d6441; }

/* ── Step body (interactive steps 1 & 2) ── */
.step { flex-wrap: wrap; align-items: flex-start; }
.step-label { flex: 1; min-width: 0; }
.step-body { width: calc(100% - 36px); margin-left: 36px; display: none; margin-top: 6px; }
.step.active .step-body,
.step.done .step-body { display: block; }
.step-body-btn {
  display: block; width: 100%;
  background: var(--sage-dark); color: var(--white);
  border: none; border-radius: 10px;
  padding: 8px 12px; font-size: 13px; font-weight: 600;
  font-family: var(--font-body); cursor: pointer;
  margin-bottom: 5px; text-align: left; transition: background 0.15s;
}
.step-body-btn:hover { background: #3d6441; }
.step-body-btn--secondary { background: var(--gray-100); color: var(--charcoal); }
.step-body-btn--secondary:hover { background: var(--gray-200); }
.step-body-link {
  background: none; border: none; color: var(--gray-400);
  font-size: 12px; font-family: var(--font-body);
  cursor: pointer; text-decoration: underline; padding: 0; display: block;
}
.step-body-ok { font-size: 12px; color: var(--sage-dark); font-weight: 600; margin-bottom: 6px; }
.step-body-hint { font-size: 11px; color: var(--gray-400); margin-top: 3px; }

/* ── Logout button in header ── */
.logout-hdr-btn {
  background: var(--charcoal); color: var(--cream);
  border: none; border-radius: var(--radius-pill);
  padding: 6px 14px; font-size: 13px; font-weight: 600;
  font-family: var(--font-body); cursor: pointer;
  white-space: nowrap; transition: background 0.15s; flex-shrink: 0;
}
.logout-hdr-btn:hover { background: #444; }
.logout-hdr-btn.hidden { display: none; }

/* ── Profile sync banner ── */
.profile-sync-banner { margin-bottom: 12px; min-height: 24px; }
.profile-sync-ok { font-size: 12px; color: var(--sage-dark); font-weight: 500; }
.profile-sync-cta {
  background: none; border: 1px solid var(--sage-dark);
  color: var(--sage-dark); border-radius: 10px; padding: 8px 12px;
  font-size: 12px; font-family: var(--font-body); cursor: pointer;
  width: 100%; text-align: left; font-weight: 500; line-height: 1.4;
}
.profile-sync-cta:hover { background: #f0f7f1; }
