:root {
  --ink: #111;
  --muted: #666;
  --border: #ccc;
  --surface: #fff;
  --bg: #fff;
  --accent: #111;
  --accent-ink: #000;
  --accent-soft: #eee;
  --ok: #111;
  --dot: 0.55rem;
}

* { box-sizing: border-box; }

html {
  font-size: 17px;
}

body {
  margin: 0;
  font-family: Helvetica, Arial, sans-serif;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---------- header ---------- */

.site-header {
  padding: 2.5rem 1.25rem 1.25rem;
  text-align: center;
}

.site-header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.9rem;
  letter-spacing: -0.02em;
}

/* ---------- layout ---------- */

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

/* ---------- controls ---------- */

.controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.9rem;
}

button {
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: background 0.15s ease, color 0.15s ease;
}

button:hover { background: #333; }

button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--ink);
}

button.ghost:hover { background: #f2f2f2; }

/* ---------- selected chips ---------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-height: 1.8rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--accent-soft);
  color: var(--ink);
  padding: 0.25rem 0.55rem 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.chip .remove {
  border: none;
  background: transparent;
  color: inherit;
  padding: 0 0.2rem;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.chip .remove:hover { color: #000; text-decoration: underline; }

/* ---------- recipe list ---------- */

.recipe-grid {
  display: flex;
  flex-direction: column;
}

.recipe-card {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  width: 100%;
  padding: 0.65rem;
  border: none;
  border-block: 1px solid var(--border);
  user-select: none;
  background: var(--surface);
  transition: background 0.15s ease;
}

.recipe-card + .recipe-card {
    border-top: none;
}

.recipe-card:hover { background: #f7f7f7; }

.recipe-card.selected {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.recipe-card h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
  user-select: text;
}

.recipe-card .meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.recipe-card .meta a {
  color: var(--ink);
}

.badge.uncategorized {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: #000;
  color: #fff;
}

/* ---------- shopping list ---------- */

.chips .empty {
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
}

.category-section { margin-bottom: 1.25rem; }

.category-section:last-child { margin-bottom: 0; }

.category-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  margin-bottom: 0.45rem;
}

.category-dot {
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: #111;
  flex-shrink: 0;
}

.category-count {
  margin-left: auto;
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85rem;
}

ul.ingredients {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

ul.ingredients li {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.5rem 0.8rem;
  background: var(--surface);
}

ul.ingredients li:nth-child(odd) { background: #fafafa; }

ul.ingredients li:hover { background: #f2f2f2; }

input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--ok);
  flex-shrink: 0;
}

.ingredient-text { flex: 1; }

.ingredient-text .recipes-for {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

ul.ingredients li.checked .ingredient-text {
  text-decoration: line-through;
  color: var(--muted);
}

.empty {
  color: var(--muted);
  font-style: italic;
  margin: 0;
}

/* ---------- footer ---------- */

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0 1.25rem 2.5rem;
}

code {
  background: #eee;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

/* ---------- print ---------- */

@media print {
  body { background: #fff; }

  .site-header, .site-footer, #planner, #picker,
  .category-count {
    display: none;
  }

  main { padding: 0; }
  .panel { border: none; padding: 0; margin: 0; }

  ul.ingredients { border: none; }
  ul.ingredients li { padding: 0.35rem 0; }
  ul.ingredients li:nth-child(odd) { background: #fff; }
  ul.ingredients li:hover { background: #fff; }

  input[type="checkbox"] { display: none; }
  .ingredient-text .recipes-for { display: none; }
}

/* ---------- small screens ---------- */

@media (max-width: 520px) {
  .panel-head { flex-direction: column; align-items: flex-start; }
  .controls { width: 100%; }
  .controls button { flex: 1; }
  .controls label { flex: 1; }
}
