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

:root {
  --bg: #1a1a1a;
  --card-bg: #242424;
  --card-active: #2c2c2c;
  --text: #f5f0eb;
  --text-muted: #a09888;
  --accent: #c9a96e;
  --accent-dim: rgba(201, 169, 110, 0.08);
  --allergen-red: #8b3a3a;
  --allergen-yellow: #8b7a3a;
  --safe-green: #3a6b4a;
  --border: #333333;
  --border-subtle: #444444;
  --highlight: rgba(201, 169, 110, 0.2);
  --radius: 6px;
  --header-height: 0px;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 300;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ---- Header ---- */

#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
}

/* ---- Search ---- */

.search-container {
  position: relative;
  margin-bottom: 10px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

#search {
  width: 100%;
  padding: 12px 48px 12px 44px;
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 300;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

#search:focus {
  border-color: var(--accent);
}

#search::placeholder {
  color: var(--text-muted);
}

.search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  display: none;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.search-clear.visible {
  display: flex;
}

/* ---- Filter Section ---- */

.filter-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-mode {
  display: flex;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.mode-btn {
  flex: 1;
  padding: 8px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.03em;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  min-height: 44px;
  touch-action: manipulation;
  position: relative;
}

.mode-btn.active[data-mode="contains"] {
  color: #c07070;
  background: rgba(139, 58, 58, 0.12);
}

.mode-btn.active[data-mode="contains"]::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 16px;
  height: 2px;
  background: #8b3a3a;
}

.mode-btn.active[data-mode="safe"] {
  color: #6bab7b;
  background: rgba(58, 107, 74, 0.12);
}

.mode-btn.active[data-mode="safe"]::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 16px;
  height: 2px;
  background: #3a6b4a;
}

/* ---- Allergen Toggles ---- */

.allergen-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.allergen-btn {
  padding: 6px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 400;
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  min-height: 36px;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.allergen-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
}

/* ---- Search Disclaimer ---- */

.search-disclaimer {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  z-index: 99;
  top: var(--header-height);
  padding: 8px 16px 8px 14px;
  background: #2a2420;
  border-left: 3px solid var(--accent);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 300;
  color: var(--text);
  line-height: 1.4;
}

.search-disclaimer.visible {
  display: block;
}

/* ---- Main Content ---- */

#main {
  padding: 16px;
  padding-top: calc(var(--header-height) + 16px);
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

/* ---- Results Info ---- */

.results-info {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin-bottom: 16px;
  min-height: 20px;
}

/* ---- Category Groups ---- */

.category-group {
  margin-bottom: 36px;
}

.category-title {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ---- Dish Card ---- */

.dish-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
  border-left: 3px solid transparent;
}

.dish-card.expanded {
  border-left-color: var(--accent);
}

.dish-header {
  padding: 16px 20px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.dish-header:active {
  background: var(--card-active);
}

.dish-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.dish-talk {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 300;
  color: var(--text-muted);
  line-height: 1.5;
}

.dish-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

/* ---- Allergen Badges ---- */

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-major {
  background: rgba(139, 58, 58, 0.2);
  color: #c07070;
  border: 1px solid rgba(139, 58, 58, 0.3);
}

.badge-sensitivity {
  background: rgba(139, 122, 58, 0.2);
  color: #bfa86b;
  border: 1px solid rgba(139, 122, 58, 0.3);
}

.badge-none {
  background: rgba(58, 107, 74, 0.2);
  color: #6bab7b;
  border: 1px solid rgba(58, 107, 74, 0.3);
}

/* ---- Dish Detail (Expanded) ---- */

.dish-detail {
  display: none;
  padding: 0 20px 20px;
  border-top: 1px solid var(--border);
}

.dish-card.expanded .dish-detail {
  display: block;
}

.detail-section {
  margin-top: 16px;
}

.detail-label {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 6px;
}

.detail-text {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 300;
  color: var(--text);
  line-height: 1.6;
}

.detail-text.muted {
  color: var(--text-muted);
  font-style: italic;
}

.ingredients-list {
  list-style: none;
  padding: 0;
}

.ingredients-list li {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 300;
  color: var(--text);
  padding: 4px 0;
  padding-left: 16px;
  position: relative;
  line-height: 1.5;
}

.ingredients-list li::before {
  content: '\00B7';
  position: absolute;
  left: 4px;
  color: var(--accent);
  font-weight: bold;
  font-size: 18px;
}

.flag-warning {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: #bfa86b;
  font-style: italic;
  padding: 10px 14px;
  background: rgba(139, 122, 58, 0.1);
  border-radius: var(--radius);
  border: 1px solid rgba(139, 122, 58, 0.2);
}

/* ---- Search Highlight ---- */

mark {
  background: var(--highlight);
  color: var(--text);
  border-radius: 2px;
  padding: 0 2px;
}

/* ---- Empty State ---- */

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

.empty-state-text {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 300;
  margin-top: 8px;
}

/* ---- Footer ---- */

.app-footer {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 300;
  color: #a09888;
  text-align: center;
  padding: 16px;
  border-top: 1px solid #333333;
}

/* ---- Utilities ---- */

::selection {
  background: var(--accent);
  color: var(--bg);
}

*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ---- Tablet+ ---- */

@media (min-width: 600px) {
  #header {
    padding: 16px 24px;
  }

  #main {
    padding: 24px;
    padding-top: calc(var(--header-height) + 24px);
    max-width: 680px;
    margin: 0 auto;
  }
}
