:root {
  color-scheme: light;
  --ink: #25352e;
  --muted: #718077;
  --paper: #f8f6ef;
  --card: #fffdf8;
  --line: #e5e6d9;
  --sage: #b7c9a8;
  --deep-sage: #55715d;
  --yellow: #f3c969;
  --coral: #db8068;
  --shadow: 0 18px 50px rgba(52, 68, 52, .08);
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: radial-gradient(circle at 15% -10%, #fff7d8 0, transparent 32rem), var(--paper);
  font-size: 16px;
  line-height: 1.45;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0;
}

.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; letter-spacing: -.03em; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 11px 11px 11px 3px; background: var(--deep-sage); color: white; transform: rotate(-6deg); }
.site-nav { display: flex; align-items: center; gap: 6px; }
.site-nav a {
  padding: 8px 14px;
  border-radius: 11px;
  color: var(--muted);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 700;
  transition: color .16s ease, background .16s ease;
}
.site-nav a:hover { color: var(--ink); background: #eef2ea; }
.account-nav { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: .9rem; }
.user-name { color: var(--ink); font-weight: 700; text-decoration: none; }
.user-name:hover { color: var(--deep-sage); }
.text-button { border: 0; padding: 0; color: var(--deep-sage); background: transparent; cursor: pointer; font-weight: 700; }

.site-main { width: min(1120px, calc(100% - 40px)); margin: 30px auto 80px; }
.site-footer { width: min(1120px, calc(100% - 40px)); margin: 0 auto 28px; color: var(--muted); font-size: .78rem; text-align: center; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(2rem, 5vw, 3.7rem); line-height: 1.02; letter-spacing: -.065em; }
h2 { margin-bottom: 0; font-size: 1.05rem; letter-spacing: -.02em; }
h3 { margin-bottom: 6px; font-size: 1rem; }
.lede { max-width: 500px; margin-bottom: 0; color: var(--muted); font-size: 1.05rem; }
.eyebrow { margin-bottom: 10px; color: var(--deep-sage); font-size: .72rem; font-weight: 800; letter-spacing: .15em; }
.muted { color: var(--muted); }

.page-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 34px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, .8fr); gap: 22px; align-items: start; }
.panel { padding: 26px; border: 1px solid rgba(221, 225, 210, .9); border-radius: 24px; background: rgba(255, 253, 248, .88); box-shadow: var(--shadow); }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 22px; }
.count-badge { display: inline-grid; place-items: center; min-width: 27px; height: 27px; padding: 0 8px; border-radius: 99px; color: var(--deep-sage); background: #e8f0e1; font-size: .78rem; font-weight: 800; }
.stack { display: grid; gap: 9px; }
.stack label { color: var(--muted); font-size: .82rem; font-weight: 700; }
input { width: 100%; min-height: 46px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px; outline: none; color: var(--ink); background: #fff; }
input:focus { border-color: var(--deep-sage); box-shadow: 0 0 0 4px rgba(85, 113, 93, .12); }
textarea { width: 100%; padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px; outline: none; color: var(--ink); background: #fff; font: inherit; resize: vertical; }
textarea:focus { border-color: var(--deep-sage); box-shadow: 0 0 0 4px rgba(85, 113, 93, .12); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 17px; border: 0; border-radius: 12px; cursor: pointer; text-decoration: none; font-weight: 800; transition: transform .16s ease, box-shadow .16s ease, background .16s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--deep-sage); box-shadow: 0 8px 18px rgba(85, 113, 93, .2); }
.button-secondary { color: var(--deep-sage); background: #e7f0e1; }
.button-quiet { color: var(--deep-sage); background: transparent; border: 1px solid var(--line); }
.button-small { min-height: 35px; padding: 7px 11px; font-size: .8rem; }

.list-cards { display: grid; gap: 10px; }
.list-card { display: flex; align-items: center; gap: 13px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; text-decoration: none; background: #fff; transition: border-color .16s ease, transform .16s ease; }
.list-card:hover { border-color: var(--sage); transform: translateX(2px); }
.list-card-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 13px; color: var(--deep-sage); background: #eef4e9; font-weight: 900; }
.list-card-copy { display: grid; flex: 1; gap: 2px; }
.list-card-copy small { color: var(--muted); font-size: .75rem; }
.list-card-arrow { color: var(--muted); font-size: 1.25rem; }
.empty-state { padding: 35px 18px 24px; text-align: center; color: var(--muted); }
.empty-mark { display: grid; place-items: center; width: 50px; height: 50px; margin: 0 auto 15px; border-radius: 18px; color: var(--deep-sage); background: #edf3e8; font-size: 1.8rem; }
.empty-state h3 { color: var(--ink); }

.auth-card { width: min(100%, 480px); margin: 7vh auto 0; padding: clamp(27px, 6vw, 54px); border: 1px solid var(--line); border-radius: 28px; background: rgba(255, 253, 248, .9); box-shadow: var(--shadow); }
.auth-card .button { margin-top: 11px; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0 4px; color: var(--muted); font-size: .8rem; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.passkey-list { display: grid; gap: 8px; margin-bottom: 16px; }
.passkey-row { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.passkey-row .item-copy { flex: 1; }
.passkey-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-switch { margin: 25px 0 0; color: var(--muted); font-size: .9rem; text-align: center; }
.auth-switch a { color: var(--deep-sage); font-weight: 800; }
.alert { margin-bottom: 18px; padding: 12px 14px; border-radius: 12px; font-size: .9rem; }
.alert-error { color: #874d40; background: #fbe7e0; }

.list-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 27px; }
.back-link { color: var(--muted); font-size: .85rem; font-weight: 700; text-decoration: none; }
.back-link:hover { color: var(--deep-sage); }
.list-topbar-actions { display: flex; align-items: center; gap: 12px; }
.live-pill { display: inline-flex; align-items: center; gap: 7px; color: var(--deep-sage); font-size: .78rem; font-weight: 800; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #75ae6e; box-shadow: 0 0 0 4px rgba(117, 174, 110, .15); }
.add-meal-button {
  color: #fff;
  background: var(--deep-sage);
  box-shadow: 0 8px 18px rgba(85, 113, 93, .25);
}
.add-meal-button:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(85, 113, 93, .32); }
.add-meal-button:active { transform: translateY(0); }
.list-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(265px, .72fr); gap: 22px; align-items: start; }
.list-panel { min-width: 0; }
.list-heading { display: flex; justify-content: space-between; margin-bottom: 25px; }
.list-heading h1 { max-width: 100%; margin-bottom: 5px; overflow-wrap: anywhere; font-size: clamp(1.45rem, 2.8vw, 2.05rem); }
.list-meta { margin: 0; color: var(--muted); font-size: .85rem; }
.add-item-form { display: grid; grid-template-columns: minmax(0, 1fr) 90px 145px auto; gap: 8px; margin-bottom: 19px; }
.add-item-form input { min-height: 50px; }
.add-item-form select { min-height: 50px; }
.add-button { min-height: 50px; }
.items { min-height: 90px; }
.item-list { display: grid; gap: 6px; }
.category-group + .category-group { margin-top: 18px; }
.category-heading { margin: 0 7px 4px; color: var(--deep-sage); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; }
.item-row { display: flex; align-items: center; gap: 12px; min-height: 66px; padding: 9px 7px 9px 10px; border-bottom: 1px solid #edf0e6; }
.item-row:last-child { border-bottom: 0; }
.check-form { flex: 0 0 auto; }
.check-button { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 2px solid #c8d6c1; border-radius: 9px; color: #fff; background: transparent; cursor: pointer; font-size: .88rem; font-weight: 900; }
.is-checked .check-button { border-color: var(--deep-sage); background: var(--deep-sage); }
.item-copy { display: grid; grid-template-columns: auto 1fr; flex: 1; min-width: 0; gap: 2px 7px; align-items: baseline; }
.item-copy strong { grid-column: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-qty { grid-column: 1; grid-row: 1; color: var(--muted); font-weight: 700; white-space: nowrap; }
.item-copy small { grid-column: 1 / -1; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; }
.is-checked .item-copy strong { color: var(--muted); text-decoration: line-through; }
.item-actions-button {
  flex: 0 0 auto;
  padding: 7px 8px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: .9rem;
  letter-spacing: 2px;
  line-height: 1;
}
.item-actions-button:hover { color: var(--ink); background: #f0f3ea; }
/* Rendered markdown (meal descriptions) */
.markdown { line-height: 1.6; color: var(--ink); }
.markdown p { margin: 0 0 12px; }
.markdown ul, .markdown ol { margin: 0 0 12px; padding-left: 22px; }
.markdown li { margin-bottom: 4px; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { margin: 18px 0 8px; letter-spacing: -.02em; }
.markdown h1 { font-size: 1.5rem; }
.markdown h2 { font-size: 1.25rem; }
.markdown h3 { font-size: 1.1rem; }
.markdown code { padding: 2px 5px; border-radius: 6px; background: #eef2ea; font-size: .9em; }
.markdown pre { padding: 12px; border-radius: 12px; background: #eef2ea; overflow-x: auto; }
.markdown pre code { padding: 0; background: transparent; }
.markdown blockquote { margin: 0 0 12px; padding-left: 14px; border-left: 3px solid var(--sage); color: var(--muted); }
.markdown a { color: var(--deep-sage); text-decoration: underline; }
/* Meal ingredient list */
.ingredient-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.ingredient-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 6px 8px 4px;
  border-bottom: 1px solid #edf0e6;
}
.ingredient-list li:last-child { border-bottom: 0; }
/* Item / ingredient edit modal */
.item-modal {
  width: min(100%, 420px);
  padding: 0;
  border: 1px solid rgba(221, 225, 210, .9);
  border-radius: 24px;
  background: rgba(255, 253, 248, .98);
  box-shadow: var(--shadow);
}
.item-modal::backdrop {
  background: rgba(37, 53, 46, .28);
}
.item-modal-card { padding: 22px 24px 24px; }
.item-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.item-modal-header h3 { margin: 0; font-size: 1.15rem; letter-spacing: -.02em; }
.item-modal .stack { margin-bottom: 14px; }
.edit-form { margin-bottom: 12px; }
.edit-form input { min-height: 38px; padding: 7px 10px; font-size: .85rem; }
.danger-link { padding: 0; border: 0; color: var(--coral); background: none; cursor: pointer; font-size: .8rem; font-weight: 800; }
.empty-items { padding: 34px 10px 18px; color: var(--muted); text-align: center; }
.empty-items-icon { display: block; margin-bottom: 7px; color: var(--yellow); font-size: 1.7rem; }
.empty-items p { margin-bottom: 2px; color: var(--ink); font-weight: 800; }
.empty-items small { font-size: .8rem; }
.side-column { display: grid; gap: 22px; }
.categories-panel > p { margin-bottom: 14px; color: var(--muted); font-size: .82rem; }
.category-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.category-form input { min-height: 38px; padding: 7px 10px; font-size: .84rem; }
.category-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.category-chip { padding: 5px 9px; border-radius: 99px; color: var(--deep-sage); background: #edf3e8; font-size: .72rem; font-weight: 800; }
.category-empty { margin: 13px 0 0; font-size: .8rem; }
.category-result { margin-top: 10px; }
.category-success { margin: 0; color: var(--deep-sage); font-size: .76rem; font-weight: 800; }
.presence-list { display: grid; gap: 12px; }
.presence-person { display: flex; align-items: center; gap: 10px; font-size: .9rem; font-weight: 700; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 11px; color: var(--deep-sage); background: #e6f0df; font-size: .7rem; font-weight: 900; }
.sharing-panel p, .tip-panel p { color: var(--muted); font-size: .86rem; }
.invite-result { margin-top: 15px; }
.invite-link-result { padding: 11px; border-radius: 12px; background: #f1f5ec; }
.invite-link-result p { margin-bottom: 7px; color: var(--deep-sage); font-size: .76rem; font-weight: 800; }
.invite-link-result input { min-height: 37px; padding: 7px; font-size: .72rem; }
.tip-panel { border-color: #eee3bf; background: #fff9df; box-shadow: none; }
.tip-label { display: inline-block; margin-bottom: 11px; color: #a27c25; font-size: .67rem; font-weight: 900; letter-spacing: .15em; }
.tip-panel p { margin-bottom: 0; color: #806a35; }
.live-stream { display: none; }
.invite-actions { display: grid; gap: 10px; margin-top: 20px; }
.invite-card p:last-of-type { margin-bottom: 0; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Meal picker modal */
.meal-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(37, 53, 46, .28);
  animation: meal-picker-fade .15s ease;
}
@keyframes meal-picker-fade { from { opacity: 0; } to { opacity: 1; } }
.meal-picker-modal {
  width: min(100%, 460px);
  max-height: min(78vh, 620px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(221, 225, 210, .9);
  border-radius: 24px;
  background: rgba(255, 253, 248, .98);
  box-shadow: var(--shadow);
  animation: meal-picker-pop .18s ease;
}
@keyframes meal-picker-pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.meal-picker-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid #edf0e6;
}
.meal-picker-header .eyebrow { margin-bottom: 5px; }
.meal-picker-header h2 { margin-bottom: 0; font-size: 1.25rem; letter-spacing: -.02em; }
.meal-picker-close {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  background: #fff;
  cursor: pointer;
  font-size: .9rem;
  transition: color .16s ease, border-color .16s ease;
}
.meal-picker-close:hover { color: var(--ink); border-color: var(--sage); }
.meal-picker-list {
  display: grid;
  gap: 8px;
  padding: 16px 24px 22px;
  overflow-y: auto;
}
.meal-picker-row { margin: 0; }
.meal-picker-button {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: border-color .16s ease, transform .16s ease;
}
.meal-picker-button:hover { border-color: var(--sage); transform: translateX(2px); }
.meal-picker-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 13px;
  color: var(--deep-sage);
  background: #eef4e9;
  font-size: 1.1rem;
}
.meal-picker-copy { display: grid; flex: 1; min-width: 0; gap: 2px; }
.meal-picker-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.meal-picker-copy small { color: var(--muted); font-size: .76rem; }
.meal-picker-add {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 99px;
  color: var(--deep-sage);
  background: #e7f0e1;
  font-size: .74rem;
  font-weight: 800;
}
.meal-picker-empty { padding: 34px 22px 30px; text-align: center; color: var(--muted); }
.meal-picker-empty h3 { color: var(--ink); }
.meal-picker-empty p { margin-bottom: 18px; }

@media (max-width: 780px) {
  .site-header, .site-main, .site-footer { width: min(100% - 28px, 600px); }
  .site-header { padding: 18px 0; }
  .site-main { margin-top: 20px; }
  .dashboard-grid, .list-layout { grid-template-columns: 1fr; }
  .side-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tip-panel { display: none; }
}

@media (max-width: 500px) {
  .site-header { flex-wrap: wrap; gap: 12px 16px; }
  .site-nav { order: 3; width: 100%; justify-content: center; gap: 8px; }
  .site-nav a { flex: 1; text-align: center; padding: 10px 8px; }
  .account-nav { gap: 9px; }
  .user-name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .panel { padding: 20px 16px; border-radius: 20px; }
  .page-heading { margin-bottom: 24px; }
  .list-topbar { margin-bottom: 20px; }
  .list-heading h1 { font-size: clamp(1.45rem, 7vw, 1.75rem); }
  .add-item-form { grid-template-columns: minmax(0, 1fr) 75px; }
  .add-button { grid-column: 1 / -1; }
  .side-column { grid-template-columns: 1fr; }
  .site-footer { margin-bottom: 20px; }
}
