/* Meal Planner — layout, chrome, forms */
:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-ink: #ffffff;
  --ok-bg: #ecfdf5;
  --ok-ink: #065f46;
  --err-bg: #fef2f2;
  --err-ink: #991b1b;
  --warn-bg: #fffbeb;
  --warn-ink: #92400e;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .65rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.topbar .brand { font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.topbar nav { display: flex; gap: .9rem; align-items: center; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); font-weight: 500; }
.topbar nav a.active, .topbar nav a:hover { color: var(--brand); text-decoration: none; }
.topbar .who { color: var(--muted); font-size: .85rem; }
.topbar nav .logout { color: var(--err-ink); }

.container { max-width: 1180px; margin: 0 auto; padding: 1.25rem; }

.banner {
  padding: .6rem .85rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.banner.ok { background: var(--ok-bg); color: var(--ok-ink); border-color: #a7f3d0; }
.banner.err { background: var(--err-bg); color: var(--err-ink); border-color: #fecaca; }
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: #fde68a; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hint { font-size: .9rem; }

.btn {
  display: inline-block;
  padding: .42rem .8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: .92rem;
  cursor: pointer;
}
.btn:hover { border-color: var(--brand); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { background: var(--err-bg); border-color: #fecaca; color: var(--err-ink); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.pill {
  display: inline-block;
  background: #eef2ff;
  color: #3730a3;
  border-radius: 999px;
  padding: .05rem .55rem;
  font-size: .78rem;
}

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .75rem; }
label.inline { display: flex; align-items: center; gap: .4rem; font-weight: 500; }
input[type="text"], input[type="password"], input[type="url"], input[type="search"],
input[type="number"], input:not([type]), select {
  width: 100%;
  padding: .5rem .6rem;
  margin-top: .3rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}
input:focus, select:focus { outline: 2px solid #bfdbfe; border-color: var(--brand); }

.stack .row, .row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }
.stack { margin-top: .75rem; }

.auth-card {
  max-width: 380px;
  margin: 8vh auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.auth-card h1 { margin: 0 0 .25rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.panel h2 { margin-top: 0; font-size: 1.05rem; }

.page-head, .week-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}
.page-head h1, .week-header h1 { margin: 0; font-size: 1.3rem; }
.week-nav { display: flex; align-items: center; gap: .6rem; }
.week-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty-state h1 { font-size: 2.4rem; margin: 0 0 .5rem; color: var(--ink); }

/* ---- planner grid ---- */
.grid-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); }
.plan-grid { border-collapse: collapse; width: 100%; min-width: 900px; table-layout: fixed; }
.plan-grid th, .plan-grid td { border: 1px solid var(--line); padding: .5rem; vertical-align: top; }
.plan-grid thead th { background: #f1f5f9; font-size: .85rem; text-align: center; }
.plan-grid thead th .date { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; }
.plan-grid .meal-col { width: 92px; background: #f8fafc; text-align: center; font-size: .85rem;
  text-transform: capitalize; }

.slot { position: relative; height: 84px; background: #fff; }
.slot.empty { background: #fcfcfd; }
.slot.filled { background: #f8faff; }
.slot .placeholder { color: #cbd5e1; }
.slot-title { display: block; font-weight: 600; font-size: .88rem; color: var(--ink);
  line-height: 1.25; overflow-wrap: anywhere; }
.slot-title:hover { color: var(--brand); }
.slot-meta { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .3rem; align-items: center; }
.slot .note { font-size: .78rem; color: var(--muted); font-style: italic; overflow-wrap: anywhere; }
.slot-actions { position: absolute; top: .25rem; right: .25rem; display: none; gap: .15rem; }
.slot:hover .slot-actions, .slot:focus-within .slot-actions { display: flex; }
.icon-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  width: 24px; height: 24px; line-height: 1; cursor: pointer; font-size: .85rem;
  color: var(--muted); padding: 0;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }

/* ---- picker modal ---- */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem;
}
.modal.hidden { display: none; }
.modal-card {
  background: #fff; border-radius: var(--radius); width: min(560px, 100%);
  max-height: 88vh; overflow: auto; padding: 1rem 1.1rem;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; font-size: 1.05rem; }
.picker-results { display: grid; gap: .4rem; margin-top: .6rem; max-height: 40vh; overflow: auto; }
.picker-item {
  display: flex; gap: .6rem; align-items: center; text-align: left;
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: .4rem .5rem; cursor: pointer; font: inherit; width: 100%;
}
.picker-item:hover, .picker-item.selected { border-color: var(--brand); background: #eff6ff; }
.picker-item img { width: 46px; height: 34px; object-fit: cover; border-radius: 5px; background: #e2e8f0; }
.picker-item .kw { display: block; color: var(--muted); font-size: .78rem; }
.picker-note { display: flex; gap: .6rem; align-items: end; margin-top: .8rem; flex-wrap: wrap; }
.picker-note .grow { flex: 1 1 180px; }
.picker-note input { margin-top: .25rem; }

/* ---- recipes ---- */
.filter-bar { display: flex; gap: .5rem; margin-bottom: .9rem; flex-wrap: wrap; }
.filter-bar input[type="search"] { flex: 2 1 220px; margin-top: 0; }
.filter-bar select { flex: 1 1 150px; margin-top: 0; width: auto; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .7rem; }
.recipe-card {
  display: flex; gap: .6rem; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .55rem; color: var(--ink); align-items: center;
}
.recipe-card:hover { border-color: var(--brand); text-decoration: none; }
.recipe-card img { width: 72px; height: 54px; object-fit: cover; border-radius: 6px;
  background: #e2e8f0; flex: none; }
.recipe-card-body { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }

.recipe-head { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.recipe-head img { width: 220px; height: 150px; object-fit: cover; border-radius: var(--radius);
  background: #e2e8f0; }
.recipe-head h1 { margin: 0 0 .35rem; font-size: 1.5rem; }
.meta-row { display: flex; gap: .4rem; flex-wrap: wrap; margin: .4rem 0; }
.recipe-columns { display: grid; grid-template-columns: minmax(240px, 1fr) 2fr; gap: 1.5rem;
  margin-top: 1.25rem; }
.ingredients { list-style: none; padding: 0; margin: 0; }
.ingredients li { padding: .3rem 0; border-bottom: 1px dashed var(--line); }
.steps { padding-left: 1.3rem; }
.steps li { margin-bottom: .55rem; }
.nutrition { border-collapse: collapse; }
.nutrition th, .nutrition td { text-align: left; padding: .25rem .8rem .25rem 0;
  border-bottom: 1px dashed var(--line); font-size: .9rem; }

/* ---- shopping list ---- */
.shop-toolbar { display: flex; justify-content: space-between; margin-bottom: .4rem; }
.shopping-list { list-style: none; padding: 0; margin: 0; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); }
.shop-row { display: flex; align-items: center; gap: .7rem; padding: .45rem .8rem;
  border-bottom: 1px solid var(--line); }
.shop-row:last-child { border-bottom: 0; }
.shop-row label { display: flex; align-items: center; gap: .6rem; margin: 0; font-weight: 400;
  flex: 1; cursor: pointer; }
.shop-row input[type="checkbox"] { width: 17px; height: 17px; margin: 0; accent-color: var(--brand); }
.shop-row .qty { min-width: 92px; font-variant-numeric: tabular-nums; font-weight: 600; }
.shop-row.checked .item { text-decoration: line-through; color: var(--muted); }
.share-url input { font-family: ui-monospace, monospace; font-size: .85rem; }

@media (max-width: 760px) {
  .recipe-columns { grid-template-columns: 1fr; }
  .container { padding: .75rem; }
}

/* ---- print ---- */
@media print {
  .topbar, .week-actions, .shop-toolbar, .banner, .hint { display: none !important; }
  body { background: #fff; }
  .container { max-width: none; padding: 0; }
  .shopping-list { border: 0; }
  .shop-row { break-inside: avoid; }
}
