:root {
  --bg: #0f1115;
  --surface: #1a1d23;
  --surface2: #242830;
  --border: #2e333b;
  --text: #e4e6ea;
  --text-dim: #9ba1ab;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --success: #22c55e;
  --danger: #ef4444;
  --info: #3b82f6;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }

/* Header */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
header .container { display: flex; align-items: center; justify-content: space-between; }
.logo { font-size: 1.5rem; font-weight: 700; color: var(--accent); text-decoration: none; }
nav { display: flex; gap: 0.25rem; }
nav button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s;
}
nav button:hover, nav button.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* AI status LED */
.ai-led {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.ai-led.green { background: #22c55e; box-shadow: 0 0 6px #22c55e88; }
.ai-led.red { background: #ef4444; box-shadow: 0 0 6px #ef444488; }
.ai-led.grey { background: #555; }

/* Search bar */
.search-bar {
  display: flex;
  gap: 0.5rem;
  margin: 1.5rem 0;
}
.search-bar input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
}
.search-bar input:focus { border-color: var(--accent); }
.search-bar button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

/* Filters */
.filters {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.filters select, .filters button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
}
.filters button.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* Recipe grid */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.recipe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}
.recipe-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.recipe-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}
.recipe-card .card-body { padding: 1rem; }
.recipe-card h3 { font-size: 1.1rem; margin-bottom: 0.25rem; }
.recipe-card .meta { color: var(--text-dim); font-size: 0.8rem; }
.recipe-card .tags { display: flex; gap: 0.25rem; margin-top: 0.5rem; flex-wrap: wrap; }
.tag {
  background: var(--surface2);
  color: var(--text-dim);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
}
.tag.ai { background: #7c3aed33; color: #a78bfa; }
.tag.makeable { background: #22c55e22; color: var(--success); }

/* Favorite button on card */
.recipe-card { position: relative; }
.fav-btn {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,0.5); border: none;
  color: #888; font-size: 1.3rem; width: 32px; height: 32px;
  border-radius: 50%; cursor: pointer; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.2s, background 0.2s;
}
.fav-btn:hover { background: rgba(0,0,0,0.7); color: #ef4444; }
.fav-btn.active { color: #ef4444; }

/* Modal favorite + rating */
.modal-actions { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.fav-btn-lg {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-dim); padding: 0.4rem 0.8rem;
  border-radius: 6px; cursor: pointer; font-size: 0.9rem;
  transition: all 0.2s;
}
.fav-btn-lg:hover { border-color: #ef4444; color: #ef4444; }
.fav-btn-lg.active { background: #ef444422; border-color: #ef4444; color: #ef4444; }

/* Star rating */
.star-rating { display: flex; gap: 0.15rem; }
.star { font-size: 1.4rem; color: #444; cursor: pointer; transition: color 0.15s; }
.star:hover { color: var(--accent); }
.star.active { color: var(--accent); }

/* Substitution button + results */
.sub-btn {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  font-size: 0.7rem; padding: 0.1rem 0.4rem; border-radius: 4px;
  cursor: pointer; margin-left: 0.5rem; vertical-align: middle;
}
.sub-btn:hover { border-color: var(--accent); color: var(--accent); }
.sub-results { margin-top: 0.4rem; padding-left: 0.5rem; border-left: 2px solid var(--accent); }
.sub-item { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 0.3rem; }
.sub-item strong { color: var(--text); }
.sub-item em { color: var(--text-dim); font-size: 0.75rem; }

/* Recipe detail modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 650px; width: 100%;
  max-height: 85vh; overflow-y: auto;
  padding: 2rem;
}
.modal h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.modal .close-btn {
  float: right;
  background: none; border: none;
  color: var(--text-dim); font-size: 1.5rem;
  cursor: pointer;
}
.modal img { width: 100%; border-radius: 8px; margin: 1rem 0; }
.modal h4 { color: var(--accent); margin-top: 1rem; margin-bottom: 0.5rem; }
.modal ul { padding-left: 1.25rem; }
.modal li { margin-bottom: 0.25rem; }
.modal p { margin-bottom: 0.5rem; }

/* Inventory page */
.category-group { margin-bottom: 1.25rem; }
.category-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}
.category-header:hover { color: var(--accent); }
.category-header .collapse-icon {
  transition: transform 0.2s;
  font-size: 0.75rem;
  color: var(--text-dim);
}
.category-group.collapsed .collapse-icon { transform: rotate(-90deg); }
.category-group.collapsed .category-items { display: none; }
.category-header .cat-name { font-weight: 600; font-size: 1rem; }
.category-header .cat-count { color: var(--text-dim); font-size: 0.8rem; }

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-bottom: 2rem;
}
.inventory-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.inventory-item .name { font-size: 0.9rem; }
.inventory-item .category { color: var(--text-dim); font-size: 0.75rem; }
.toggle-btn {
  width: 44px; height: 24px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-btn.on { background: var(--success); }
.toggle-btn.off { background: var(--border); }
.toggle-btn::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: white;
  top: 3px;
  transition: left 0.2s;
}
.toggle-btn.on::after { left: 22px; }
.toggle-btn.off::after { left: 4px; }

.cost-row { display: flex; align-items: center; gap: 2px; margin-top: 2px; }
.cost-input {
  width: 55px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.75rem;
}
.cost-row span { color: var(--text-dim); font-size: 0.75rem; }

.remove-btn {
  background: none; border: none; color: var(--text-dim);
  font-size: 1rem; cursor: pointer; padding: 0 0.25rem;
  opacity: 0.4; transition: opacity 0.2s, color 0.2s;
  line-height: 1;
}
.remove-btn:hover { opacity: 1; color: var(--danger); }

.add-ing-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0.5rem; border-bottom: 1px solid var(--border);
}
.add-ing-row .ing-name { font-size: 0.9rem; }
.add-ing-row .ing-cat { color: var(--text-dim); font-size: 0.75rem; }
.add-ing-row.in-bar { opacity: 0.4; }
.add-ing-row.in-bar .btn-primary { pointer-events: none; }
.cost-estimate {
  text-align: center;
  margin: 0.75rem 0;
  padding: 0.5rem;
  background: rgba(245,158,11,0.08);
  border-radius: 6px;
  font-size: 0.9rem;
}

.toggle-label { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; font-size: 0.9rem; color: var(--text-dim); }
.toggle-label input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

/* Context settings */
.context-settings { margin: 0.75rem 0; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem 1rem; }
.context-settings summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; color: var(--text); user-select: none; }
.context-settings summary::-webkit-details-marker { color: var(--accent); }
.context-toggles { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; margin: 0.75rem 0; }
.custom-context-row { margin-top: 0.5rem; }
.custom-context-row input { width: 100%; padding: 0.5rem 0.75rem; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 0.9rem; }
.custom-context-row input::placeholder { color: var(--text-dim); }
.vibe-preview { margin-top: 0.75rem; padding: 0.6rem 0.8rem; background: rgba(255,140,0,0.08); border-left: 3px solid var(--accent); border-radius: 4px; font-size: 0.85rem; color: var(--text-dim); min-height: 1.5rem; }
.vibe-preview:empty { display: none; }
.vibe-banner { margin-bottom: 1rem; padding: 0.6rem 0.8rem; background: rgba(255,140,0,0.08); border-left: 3px solid var(--accent); border-radius: 4px; font-size: 0.85rem; color: var(--text-dim); }

/* History / Journal */
.history-entry {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.75rem 1rem; margin-bottom: 0.5rem;
}
.history-main { display: flex; justify-content: space-between; align-items: center; }
.history-name { color: var(--accent); cursor: pointer; font-weight: 600; }
.history-name:hover { text-decoration: underline; }
.history-date { color: var(--text-dim); font-size: 0.8rem; }
.history-notes { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.25rem; font-style: italic; }

/* AI panel */
.ai-panel {
  max-width: 800px;
  margin: 0 auto;
}
.ai-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  position: sticky;
  top: 60px;
  z-index: 50;
}
.ai-form textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 1rem;
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}
.ai-form textarea:focus { outline: none; border-color: var(--accent); }
.ai-form .form-row { display: flex; gap: 0.5rem; margin-top: 0.75rem; align-items: center; flex-wrap: wrap; }
.ai-form select, .ai-form input[type="number"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem;
  border-radius: 6px;
  font-size: 0.875rem;
}
.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 0.625rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.625rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.session-item:hover { border-color: var(--accent) !important; }

.ai-results { margin-top: 1rem; }
.ai-recipe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.ai-recipe-card h3 { color: var(--accent); margin-bottom: 0.5rem; }
.ai-recipe-top { display: flex; gap: 1.25rem; align-items: flex-start; }
.ai-recipe-left { flex-shrink: 0; }
.ai-recipe-img { width: 130px; height: 150px; border-radius: 8px; display: block; }
.ai-recipe-right { flex: 1; min-width: 0; }
.ai-recipe-bottom { margin-top: 0.75rem; }
.ai-recipe-card .reasoning {
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}
/* What to Expect section (replaces Why This Works) */
.what-to-expect {
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.15);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.what-to-expect .wte-header {
  font-weight: 700;
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.what-to-expect .wte-header::before {
  content: '\1F9EA';
  font-size: 1rem;
}
.what-to-expect .wte-body {
  line-height: 1.6;
  margin-bottom: 0.5rem;
}
.what-to-expect .wte-issues {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.4rem;
}
.what-to-expect .wte-issues span {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
}

/* Chemistry badge */
.chem-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.chem-badge.safe {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.25);
}
.chem-badge.warn {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 0.5rem;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-msg {
  text-align: center;
  padding: 3rem;
  color: var(--text-dim);
}

.empty-msg {
  text-align: center;
  padding: 3rem;
  color: var(--text-dim);
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 1.5rem 0;
}
.pagination button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
}
.pagination button.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Seed button */
.admin-bar {
  display: flex;
  justify-content: flex-end;
  padding: 0.5rem 0;
}

/* Section headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.section-header h2 { font-size: 1.25rem; }

/* Toast notification */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Party Mode */
.party-panel { max-width: 800px; margin: 0 auto; }
.party-controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
}
.party-search-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.party-search-row input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
}
.party-search-results {
  margin-bottom: 1rem;
  max-height: 200px;
  overflow-y: auto;
}
.party-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.party-selected-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.party-selected-header h3 { font-size: 1rem; }
.party-guest-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}
.party-guest-row input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem;
  border-radius: 6px;
  font-size: 0.875rem;
}
.party-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 40px;
}
.party-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.3rem 0.5rem 0.3rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}
.party-chip button {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}
.party-chip button:hover { color: var(--danger); }
.shopping-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  margin-top: 1rem;
}
.shopping-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.5rem;
}
.shopping-item {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.shopping-item.need { border-left: 3px solid var(--danger); }
.shopping-item.have { border-left: 3px solid var(--success); }
.shopping-measures { color: var(--text-dim); font-size: 0.8rem; margin-top: 0.25rem; }

/* Step-by-step mode overlay */
.step-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.step-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
  max-width: 520px;
  width: 90%;
  text-align: center;
}
.step-header {
  margin-bottom: 1.5rem;
}
.step-name {
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 700;
}
.step-progress {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}
.step-text {
  font-size: 1.2rem;
  line-height: 1.5;
  margin-bottom: 1rem;
  min-height: 60px;
}
.step-detail {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  white-space: pre-line;
  text-align: left;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.step-nav {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1rem;
}
.step-nav button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 0.625rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
}
.step-nav button:hover { background: var(--accent-hover); }
.step-nav button:disabled { opacity: 0.3; cursor: not-allowed; }
.step-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
}
.step-close:hover { color: var(--text); }

/* Login Wall */
.login-wall {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-logo {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.25rem;
}
.login-subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}
.login-card input {
  display: block;
  width: 100%;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card .btn-primary {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem;
  font-size: 1rem;
}
.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.75rem;
  min-height: 1.2em;
}

/* Logout button */
.logout-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s;
}
.logout-btn:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 1rem 0;
  margin-top: 2rem;
}
.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.footer-version { opacity: 0.6; }
.footer-powered a {
  color: var(--accent);
  text-decoration: none;
}
.footer-powered a:hover { text-decoration: underline; }

/* Modal scroll lock */
body.modal-open { overflow: hidden; }

/* Bottom nav (hidden on desktop) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: none;
  justify-content: space-around;
  align-items: stretch;
  z-index: 100;
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
  overflow: visible;
}
.bnav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 58px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  padding: 8px 4px;
  transition: color 0.2s;
  overflow: visible;
  white-space: nowrap;
}
.bnav-tab svg { stroke: var(--text-dim); transition: stroke 0.2s; }
.bnav-tab.active,
.bnav-tab.active svg { color: var(--accent); stroke: var(--accent); }
.bnav-ai-label { display: flex; align-items: center; gap: 3px; }

/* Voice mic button */
.ai-voice-row {
  margin-top: 0.5rem;
  display: flex;
}
.mic-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.mic-btn:hover { border-color: var(--accent); color: var(--text); }
.mic-btn.recording {
  border-color: var(--danger);
  color: var(--danger);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.3);
  animation: mic-pulse 1.5s ease-in-out infinite;
}
.mic-btn.processing {
  border-color: var(--accent);
  color: var(--accent);
}
.mic-btn.processing svg { display: none; }
.mic-btn.processing::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 4px rgba(239, 68, 68, 0.2); }
  50% { box-shadow: 0 0 12px rgba(239, 68, 68, 0.5); }
}

/* AI Bar (mobile only — hidden on desktop) */
.ai-bar {
  display: none;
}

/* More menu slide-up (mobile only) */
.more-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
  display: flex;
  align-items: flex-end;
}
.more-menu-overlay.hidden { display: none; }
.more-menu {
  width: 100%;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 0.5rem 0 env(safe-area-inset-bottom, 0.5rem);
  animation: slideUp 0.2s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.more-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem 0.5rem;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
}
.more-menu-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-dim);
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.more-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.9rem 1.25rem;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.more-menu-item:active { background: var(--surface2); }
.more-menu-item svg { stroke: var(--text-dim); flex-shrink: 0; }
.more-menu-logout { color: var(--danger); }
.more-menu-logout svg { stroke: var(--danger); }

/* Mobile-only Create Cocktails button (hidden on desktop) */
.ai-mobile-create { display: none; }

/* Hamburger button (hidden on desktop) */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 101;
}
.hamburger-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.hamburger-btn.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Logout icon button (hidden on desktop) */
.logout-icon-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 0;
}
.logout-icon-btn:hover { border-color: var(--danger); color: var(--danger); }

/* ==================== TABLET: 768px ==================== */
@media (max-width: 768px) {
  /* Hide header nav on mobile — bottom nav + More menu handles it */
  header nav { display: none; }
  .logout-icon-btn { display: block; }

  /* AI Bar — sticky collapsible bar at top */
  .ai-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, var(--surface2), var(--surface));
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.7rem 1rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
  }
  .ai-bar:active { background: var(--surface2); }
  .ai-bar-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
  }
  .ai-bar-chevron {
    transition: transform 0.2s;
    color: var(--text-dim);
  }
  .ai-bar.expanded .ai-bar-chevron {
    transform: rotate(180deg);
  }
  .ai-bar.expanded {
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(124,58,237,0.08), var(--surface));
  }

  /* Bottom nav visible */
  .bottom-nav { display: flex !important; }
  body { padding-bottom: 64px; }

  /* Recipe grid: 2-col */
  .recipe-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

  /* Wrap section headers and form rows */
  .section-header { flex-wrap: wrap; gap: 0.5rem; }
  .party-search-row { flex-wrap: wrap; }
  .ai-form .form-row { flex-wrap: wrap; }

  /* Disable sticky AI form on mobile */
  .ai-form { position: relative; top: auto; }

  /* Show mobile Create button right below textarea */
  .ai-mobile-create {
    display: block;
    margin-top: 0.75rem;
  }
  .ai-mobile-create .btn-primary {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
  }

  /* Toast above bottom nav */
  .toast { bottom: 5rem; }

  /* Touch targets */
  .toggle-btn { min-height: 44px; min-width: 44px; height: 28px; }
  .pagination button { min-height: 44px; min-width: 44px; }
  .category-header { min-height: 44px; }
  .star { font-size: 1.6rem; padding: 4px; }
  .party-chip { min-height: 44px; }
  .context-toggles .toggle-label { min-height: 44px; }
  .filters select, .filters button { min-height: 44px; }

  /* Filters: give each item room to breathe */
  .filters {
    gap: 0.4rem;
  }
  .filters select, .filters button {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.85rem;
  }
}

/* ==================== PHONE: 480px ==================== */
@media (max-width: 480px) {
  /* Tighter container */
  .container { padding: 0 0.5rem; }

  /* Single-column grids */
  .recipe-grid { grid-template-columns: 1fr; }
  .inventory-grid { grid-template-columns: 1fr; }
  .shopping-items { grid-template-columns: 1fr; }

  /* Search bar: wrap Import below */
  .search-bar { flex-wrap: wrap; }
  .search-bar .btn-secondary { width: 100%; }

  /* Filters: 2-per-row so text is readable */
  .filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }
  .filters select, .filters button {
    width: 100%;
    font-size: 0.85rem;
  }

  /* AI form row stacked — hide desktop Create btn (mobile version shown above) */
  .ai-form .form-row { flex-direction: column; }
  .ai-form .form-row #ai-create-btn { display: none; }
  .ai-form .form-row .btn-secondary { width: 100%; }

  /* Party search stacked */
  .party-search-row { flex-direction: column; }
  .party-search-row button { width: 100%; }

  /* Full-screen modals */
  .modal-overlay { padding: 0; }
  .modal {
    max-width: 100%;
    max-height: 100%;
    height: 100%;
    border-radius: 0;
    padding: 1rem;
    padding-top: 3rem;
  }
  .modal .close-btn {
    position: fixed;
    top: 0.5rem;
    right: 0.75rem;
    z-index: 210;
    font-size: 2rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: 50%;
  }

  /* Step overlay fills screen */
  .step-container {
    max-width: 100%;
    width: 100%;
    border-radius: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  /* Login card full width */
  .login-card { max-width: 100%; border-radius: 0; }

  /* Horizontal recipe cards on mobile: image left, info right */
  .recipe-card { display: flex; flex-direction: row; }
  .recipe-card img { width: 70px; height: 70px; object-fit: cover; border-radius: 10px 0 0 10px; flex-shrink: 0; }
  .recipe-card .card-body { padding: 0.5rem 0.6rem; min-width: 0; flex: 1; }
  .recipe-card h3 { font-size: 0.95rem; margin-bottom: 0.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .recipe-card .meta { font-size: 0.75rem; }
  .recipe-card .tags { margin-top: 0.25rem; }

  /* Cap modal image on mobile */
  .modal img { max-height: 150px; object-fit: contain; }

  /* Modal actions: wrap and bigger touch targets */
  .modal-actions { flex-wrap: wrap; gap: 0.5rem; }
  .modal-actions .fav-btn-lg { min-height: 44px; padding: 0.5rem 1rem; font-size: 1rem; }
  .modal-actions .star { font-size: 1.6rem; padding: 4px; }
  .modal-actions .btn-secondary { min-height: 44px; }

  /* Reposition fav button for horizontal card */
  .fav-btn { width: 28px; height: 28px; font-size: 1rem; top: 4px; right: 4px; }

  /* AI recipe card responsive */
  .ai-recipe-img { width: 70px; height: 85px; }
  .ai-recipe-top { gap: 0.75rem; }
  .ai-recipe-left h3 { font-size: 1rem; }
}
