/* shadcn-inspired design tokens (zinc palette) */
:root {
  --background: #fafafa;
  --card: #ffffff;
  --foreground: #18181b;
  --muted: #71717a;
  --muted-bg: #f4f4f5;
  --border: #e4e4e7;
  --primary: #18181b;
  --primary-fg: #fafafa;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --warning: #a16207;
  --warning-bg: #fefce8;
  --warning-border: #fde047;
  --destructive: #dc2626;
  --destructive-bg: #fef2f2;
  --destructive-border: #fecaca;
  --radius: 12px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.07), 0 1px 2px -1px rgb(0 0 0 / 0.07);
}

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

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

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--background);
  color: var(--foreground);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

svg { width: 1.15em; height: 1.15em; flex-shrink: 0; }

/* ------- top bar ------- */
.topbar {
  background: rgba(250, 250, 250, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
}
.logo {
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo svg { width: 18px; height: 18px; }
.whoami {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--foreground);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* ------- alerts ------- */
#alerts { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.alert {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  line-height: 1.45;
  border: 1px solid;
}
.alert svg { width: 16px; height: 16px; margin-top: 2px; }
.alert b { font-weight: 600; }
.alert a { color: inherit; font-weight: 600; }
.alert.warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.alert.critical { background: var(--destructive-bg); color: var(--destructive); border-color: var(--destructive-border); }

/* ------- layout ------- */
.container { max-width: 640px; margin: 0 auto; padding: 16px 16px 28px; }
.section-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 26px 2px 10px;
}
.section-title:first-child { margin-top: 4px; }
.muted { color: var(--muted); font-size: 0.83rem; }
.hint { color: var(--muted); font-size: 0.83rem; margin: -4px 2px 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}

/* ------- today hero ------- */
.hero {
  background: var(--primary);
  color: var(--primary-fg);
  border: none;
  padding: 22px 20px;
  box-shadow: var(--shadow);
}
.hero .day-label {
  font-size: 0.72rem;
  font-weight: 600;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.hero h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; margin: 8px 0 6px; line-height: 1.25; }
.hero .desc { font-size: 0.87rem; opacity: 0.75; line-height: 1.5; }
.hero-tags { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.hero-tag {
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.9;
}
.hero .status-row { margin-top: 16px; }

/* ------- status pills ------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid;
}
.pill.ordered { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.pill.pending { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.pill.off { background: var(--muted-bg); color: var(--muted); border-color: var(--border); }
.hero .pill.ordered { background: rgba(34, 197, 94, 0.15); border-color: rgba(34, 197, 94, 0.35); color: #4ade80; }
.hero .pill.pending { background: rgba(250, 204, 21, 0.12); border-color: rgba(250, 204, 21, 0.3); color: #facc15; }

/* ------- day rows ------- */
.day-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}
.day-row .date-box { min-width: 44px; text-align: center; }
.day-row .date-box .dow { font-size: 0.68rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.day-row .date-box .dom { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.day-row.today-row { border-color: var(--foreground); }
.day-row.today-row .date-box .dom { color: var(--foreground); }
.day-row .meal { flex: 1; min-width: 0; }
.day-row .meal .name { font-weight: 600; font-size: 0.9rem; letter-spacing: -0.01em; }
.day-row .meal .sub { font-size: 0.75rem; color: var(--muted); margin-top: 1px; }
.day-row.sunday { background: transparent; border-style: dashed; box-shadow: none; }
.day-row.sunday .meal .name { color: var(--muted); font-weight: 500; }

/* ------- buttons ------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 10px;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.75; }

.order-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  font-weight: 600;
  font-family: inherit;
  font-size: 0.75rem;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: var(--shadow-sm);
}
.order-btn svg { width: 13px; height: 13px; }
.order-btn.done {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}
.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 7px;
  color: var(--muted);
  border-radius: 8px;
  display: inline-flex;
}
.icon-btn:active { background: var(--muted-bg); }
.icon-btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
  border: none;
  padding: 12px 18px;
  font-size: 0.9rem;
}
.btn-ghost {
  background: transparent;
  color: var(--foreground);
  border: 1px solid var(--border);
  padding: 12px 18px;
  font-size: 0.9rem;
}
.btn-destructive {
  width: 100%;
  margin-top: 10px;
  background: transparent;
  color: var(--destructive);
  border: 1px solid var(--destructive-border);
  padding: 11px;
  font-size: 0.85rem;
}
.btn-full { width: 100%; margin-top: 18px; }

.btn-approve, .btn-reject {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  font-weight: 600;
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.btn-approve { background: var(--primary); color: var(--primary-fg); border: none; }
.btn-reject { background: transparent; color: var(--destructive); border: 1px solid var(--destructive-border); }

/* ------- groceries ------- */
.grocery-group h3 { font-size: 0.92rem; font-weight: 600; letter-spacing: -0.01em; }
.grocery-group .when { font-size: 0.75rem; color: var(--muted); margin-bottom: 10px; }
.grocery-group ul { list-style: none; margin-bottom: 12px; }
.grocery-group li {
  padding: 8px 0;
  font-size: 0.87rem;
  border-bottom: 1px solid var(--muted-bg);
  display: flex;
  align-items: center;
  gap: 9px;
}
.grocery-group li:last-child { border-bottom: none; }
.grocery-group li::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--muted);
  opacity: 0.5;
  flex-shrink: 0;
}
.all-clear { text-align: center; padding: 48px 20px; color: var(--muted); }
.all-clear svg { width: 34px; height: 34px; color: var(--success); margin-bottom: 12px; }
.all-clear b { color: var(--foreground); font-weight: 600; display: block; margin-bottom: 3px; }

/* ------- recipes ------- */
.recipe-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.recipe-card h3 .actions { display: flex; gap: 2px; margin: -4px -6px 0 0; }
.recipe-card .desc { font-size: 0.83rem; color: var(--muted); margin: 5px 0 0; line-height: 1.5; }
.recipe-card .ing { font-size: 0.79rem; color: var(--foreground); line-height: 1.6; margin-top: 10px; }
.recipe-card .ing b { font-weight: 600; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; display: block; margin-bottom: 2px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.tag-chip {
  background: var(--muted-bg);
  color: var(--foreground);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid var(--border);
}
.by-tag { font-size: 0.74rem; color: var(--muted); margin-top: 10px; }

/* ------- forms ------- */
form label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin: 14px 0 6px;
}
form label:first-child { margin-top: 0; }
form input, form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px; /* prevents iOS zoom */
  font-family: inherit;
  background: var(--card);
  color: var(--foreground);
  box-shadow: var(--shadow-sm);
}
form input:focus, form textarea:focus {
  outline: 2px solid var(--foreground);
  outline-offset: -1px;
}
form textarea { resize: vertical; min-height: 72px; }
form ::placeholder { color: #a1a1aa; }
.btn-row { display: flex; gap: 8px; margin-top: 18px; }
.btn-row .btn { flex: 1; }

/* ------- tab bar ------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
}
.tab {
  flex: 1;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  cursor: pointer;
  letter-spacing: 0.01em;
}
.tab svg { width: 21px; height: 21px; stroke-width: 1.8; }
.tab.active { color: var(--foreground); }
.tab.active svg { stroke-width: 2.2; }

/* ------- modal ------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 11, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--card);
  border-radius: 16px;
  padding: 24px 20px;
  width: 100%;
  max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgb(0 0 0 / 0.25);
}
.modal-card h2 { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 4px; }
.modal-card form { margin-top: 16px; }
#name-options { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
#name-options button {
  padding: 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
#name-options button:active { background: var(--muted-bg); }

/* ------- toast ------- */
.toast {
  position: fixed;
  bottom: calc(88px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: var(--primary-fg);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.83rem;
  font-weight: 500;
  z-index: 60;
  max-width: 90vw;
  text-align: center;
  box-shadow: var(--shadow);
}
