:root {
  --terracotta: #b34830;
  --terracotta-dark: #a8412c;
  --mustard: #e0a458;
  --green: #3d6b50;
  --cream: #fdf6ec;
  --cream-2: #f5ead7;
  --ink: #3a2a22;
  --muted: #7a6a5e;
  --shadow: 0 4px 14px rgba(58,42,34,0.12);
  --radius: 16px;
}

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

/* Splash screen (random artwork, fades on ready / tap to skip) */
.splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: opacity .5s ease;
  cursor: pointer;
}
.splash.fade { opacity: 0; pointer-events: none; }
.splash.gone { display: none !important; }
.splash-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
.splash-hint {
  position: absolute;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(58,42,34,0.45);
  color: #fff;
  font-size: .8rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
  animation: splashHint 1.6s ease-in-out infinite;
}
@keyframes splashHint { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .splash-hint { animation: none; } }

body {
  font-family: 'Cairo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--terracotta);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: calc(14px + env(safe-area-inset-top));
}
.brand { font-size: 1.15rem; font-weight: 800; margin: 0; }

.icon-btn {
  background: rgba(255,255,255,0.18);
  border: none;
  color: #fff;
  font-size: 1.3rem;
  width: 42px; height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn:active { background: rgba(255,255,255,0.3); }

main#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.view { animation: fade .25s ease; }
.hidden { display: none !important; }

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

.headline {
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  margin: 24px 0 22px;
  line-height: 1.4;
}

.btn {
  display: block;
  width: 100%;
  padding: 14px 18px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .08s ease, background .15s;
  text-align: center;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .icon-btn:focus-visible, .chip:focus-visible, .del-btn:focus-visible {
  outline: 3px solid var(--mustard);
  outline-offset: 2px;
}

.btn-primary { background: var(--terracotta); color: #fff; }
.btn-primary:active { background: var(--terracotta-dark); }
.btn-secondary { background: var(--green); color: #fff; margin-top: 12px; }
.btn-ghost { background: var(--cream-2); color: var(--ink); margin-bottom: 10px; }
.btn-link { background: transparent; color: var(--muted); font-weight: 600; margin-top: 18px; text-decoration: underline; }

.btn.big { padding: 22px; font-size: 1.25rem; border-radius: 22px; box-shadow: var(--shadow); }
.pot { display: inline-block; }

/* Shuffle */
.shuffle { text-align: center; padding: 40px 0; }
.pot-spin { font-size: 4rem; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.shuffle-name { font-size: 1.6rem; font-weight: 800; margin-top: 16px; color: var(--terracotta); min-height: 2em; }

/* Dish card */
.dish-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 2px solid var(--cream-2);
}
.dish-card .dish-name { font-size: 1.6rem; font-weight: 800; margin: 0 0 8px; color: var(--terracotta); display: flex; align-items: center; gap: 10px; }
.fav-btn { background: transparent; border: none; cursor: pointer; font-size: 1.4rem; padding: 0; line-height: 1; }
.fav-btn:focus-visible { outline: 3px solid var(--mustard); outline-offset: 2px; border-radius: 6px; }
.dish-card .dish-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.tag {
  background: var(--cream-2);
  color: var(--ink);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 600;
}
.tag.cat-فطار { background: #fde8c8; color: #8a5a1a; }
.tag.cat-غدا   { background: #d8ead8; color: #2a5a3a; }
.tag.cat-عشا   { background: #e6d8f0; color: #5a3a8a; }
.tag.tag-type { background: #f0e6d8; color: #6a4a2a; }

/* Tag filter on home */
.tag-filter { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 18px; }
.tag-chip {
  background: #fff;
  border: 2px solid var(--cream-2);
  color: var(--ink);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.tag-chip.on { background: var(--terracotta); border-color: var(--terracotta); color: #fff; }
.tag-chip:focus-visible { outline: 3px solid var(--mustard); outline-offset: 2px; }
.dish-card .dish-desc { color: var(--muted); line-height: 1.6; margin: 8px 0 0; }
.dish-card .missing { background: #fde2e2; color: #a8412c; padding: 8px 10px; border-radius: 10px; margin-top: 10px; font-weight: 600; font-size: .9rem; }

.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.exclude-btn { font-size: .9rem; opacity: .85; }
.clear-all-btn { margin-top: 20px; color: #a8412c; border-color: #f0c8c0; }
.export-row { display: flex; gap: 10px; margin-top: 16px; justify-content: center; }

/* Picker */
.picker .group { margin-bottom: 16px; }
.picker .group-title { font-weight: 800; color: var(--green); margin: 0 0 8px; font-size: 1rem; display: flex; align-items: center; gap: 10px; }
.group-toggle {
  background: transparent; border: 1px solid var(--cream-2); color: var(--muted);
  padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.group-toggle:hover { color: var(--terracotta); border-color: var(--terracotta); }
.group-toggle:focus-visible { outline: 3px solid var(--mustard); outline-offset: 1px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: #fff;
  border: 2px solid var(--cream-2);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: .95rem;
  color: var(--ink);
  user-select: none;
}
.chip.on { background: var(--mustard); border-color: var(--mustard); color: #3a2a22; font-weight: 700; }

.results { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.results .empty { text-align: center; color: var(--muted); padding: 20px; }

/* History */
.stats { background: var(--green); color: #fff; padding: 12px 14px; border-radius: 12px; text-align: center; font-weight: 600; margin-bottom: 14px; }
.search-input {
  width: 100%; padding: 10px 14px; border: 2px solid var(--cream-2); border-radius: 12px;
  font-family: inherit; font-size: 1rem; margin-bottom: 12px; background: #fff; color: var(--ink);
}
.search-input:focus { outline: 3px solid var(--mustard); outline-offset: 1px; border-color: var(--mustard); }
.filter-row { display: flex; gap: 16px; margin-bottom: 14px; justify-content: center; font-size: .95rem; }
.filter-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.history-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.history-item {
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.history-item .h-main { flex: 1; }
.history-item .h-name { font-weight: 700; font-size: 1.05rem; }
.history-item .h-meta { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.history-item .h-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.cooked-toggle { display: flex; align-items: center; gap: 6px; font-size: .85rem; cursor: pointer; }
.del-btn { background: transparent; border: none; color: var(--terracotta); cursor: pointer; font-size: 1.1rem; padding: 0 4px; }
.history-empty { text-align: center; color: var(--muted); padding: 30px 10px; }
