:root {
  color-scheme: light;
  --cream: #f8f2ec;
  --paper: #fffdfb;
  --ink: #30262f;
  --muted: #776b74;
  --plum: #754a6c;
  --plum-dark: #583650;
  --rose: #ead4e3;
  --sage: #dbe9df;
  --sage-dark: #587766;
  --line: #e8ddd7;
  --shadow: 0 18px 55px rgba(64, 42, 57, .09);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 8% 5%, #f5e5ed 0, transparent 24rem), var(--cream); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid rgba(117, 74, 108, .28); outline-offset: 2px; }
.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; }
.hidden { display: none !important; }
.topbar { position: sticky; z-index: 20; top: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; padding: .8rem clamp(1rem, 3vw, 2.5rem); border-bottom: 1px solid rgba(117, 74, 108, .12); background: rgba(255, 253, 251, .88); backdrop-filter: blur(18px); }
.brand { display: inline-flex; align-items: center; gap: .65rem; width: fit-content; color: var(--plum-dark); text-decoration: none; letter-spacing: -.02em; }
.brand span { font-size: 1.4rem; }
.week-nav { display: flex; align-items: center; gap: .35rem; }
.icon-button, .week-label, .small-button, .text-button, .secondary-button, .danger-button, .primary-button { border: 0; border-radius: 999px; cursor: pointer; }
.icon-button { width: 2.4rem; height: 2.4rem; background: transparent; font-size: 1.5rem; line-height: 1; }
.icon-button:hover { background: #f1e5ec; }
.week-label { min-width: 8rem; padding: .62rem .8rem; background: transparent; font-weight: 700; }
.primary-button { justify-self: end; padding: .72rem 1rem; background: var(--plum); color: white; font-weight: 700; box-shadow: 0 6px 18px rgba(117, 74, 108, .2); }
.primary-button:hover { background: var(--plum-dark); }
main { width: min(100% - 2rem, 1500px); margin: 0 auto; }
.welcome-card { display: grid; grid-template-columns: 9rem 1fr; align-items: center; gap: clamp(1.5rem, 4vw, 3.5rem); width: min(100%, 74rem); margin: 2.25rem auto; padding: 1rem clamp(1rem, 4vw, 2.5rem) 1rem 1rem; border: 1px solid var(--line); border-radius: 1.7rem; background: linear-gradient(125deg, rgba(255,255,255,.97), rgba(248,235,242,.84)); box-shadow: var(--shadow); overflow: hidden; }
.welcome-card img { width: 100%; height: 10.2rem; object-fit: cover; border-radius: 1.15rem; }
.welcome-card h1 { margin: .15rem 0 .5rem; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 4.2vw, 3.55rem); font-weight: 500; line-height: .98; letter-spacing: -.045em; }
.welcome-card h1 em { color: var(--plum); font-weight: 500; }
.welcome-card p:last-child { max-width: 47rem; margin: .8rem 0 0; color: var(--muted); line-height: 1.55; }
.eyebrow { margin: 0 0 .3rem; color: var(--sage-dark); font-size: .73rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.planner-layout { display: grid; grid-template-columns: minmax(15rem, .72fr) minmax(42rem, 2fr) minmax(15rem, .75fr); gap: 1rem; align-items: start; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: 1.35rem; background: rgba(255,253,251,.93); box-shadow: var(--shadow); }
.ideas-panel, .grocery-panel { position: sticky; top: 5.5rem; max-height: calc(100vh - 6.5rem); overflow: auto; padding: 1.2rem; }
.week-panel { padding: 1.2rem; }
.panel-heading, .dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.panel h2, dialog h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.55rem; font-weight: 600; letter-spacing: -.025em; }
.small-button { padding: .5rem .72rem; background: #f0e4eb; color: var(--plum-dark); font-weight: 750; white-space: nowrap; }
.text-button { padding: .5rem .7rem; background: transparent; color: var(--muted); font-size: .84rem; }
.text-button:hover { background: #f5ecef; color: var(--plum-dark); }
.subtle { margin: .3rem 0 0; color: var(--muted); font-size: .83rem; line-height: 1.4; }
.search { display: flex; align-items: center; gap: .45rem; margin: 1rem 0 .7rem; padding: .68rem .8rem; border: 1px solid var(--line); border-radius: .85rem; background: white; color: var(--muted); }
.search:focus-within { border-color: var(--plum); box-shadow: 0 0 0 3px rgba(117,74,108,.1); }
.search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; }
.filters { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .75rem; }
.filter-chip { padding: .35rem .58rem; border: 1px solid var(--line); border-radius: 999px; background: white; color: var(--muted); cursor: pointer; font-size: .75rem; }
.filter-chip.active { border-color: transparent; background: var(--sage); color: #30483b; font-weight: 750; }
.tap-hint { display: none; margin: .2rem 0 .7rem; color: var(--plum); font-size: .78rem; }
.tap-hint.active { display: block; }
.meal-library { display: grid; gap: .65rem; }
.empty-state { padding: 1rem; border: 1px dashed var(--line); border-radius: .9rem; color: var(--muted); text-align: center; font-size: .85rem; }
.meal-card { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: stretch; min-width: 0; border: 1px solid var(--line); border-radius: .95rem; background: white; box-shadow: 0 4px 14px rgba(64,42,57,.04); overflow: hidden; cursor: grab; }
.meal-card:active { cursor: grabbing; }
.meal-card.selected { border-color: var(--plum); box-shadow: 0 0 0 3px rgba(117,74,108,.11); }
.meal-card.dragging { opacity: .45; }
.meal-main { display: grid; gap: .38rem; min-width: 0; padding: .78rem .25rem .78rem .78rem; border: 0; background: transparent; text-align: left; cursor: pointer; }
.meal-top { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.meal-top strong { overflow: hidden; text-overflow: ellipsis; }
.category-pill { margin-left: auto; padding: .2rem .4rem; border-radius: 999px; background: var(--sage); color: #3d5d4b; font-size: .63rem; font-weight: 800; text-transform: uppercase; }
.ingredient-preview { color: var(--muted); font-size: .74rem; line-height: 1.35; }
.meal-note { color: var(--plum); font-size: .7rem; font-style: italic; }
.edit-meal { align-self: start; margin: .48rem .3rem 0 0; padding: .25rem .35rem; border: 0; border-radius: .5rem; background: transparent; color: var(--muted); cursor: pointer; letter-spacing: .08em; }
.edit-meal:hover { background: #f5ecef; }
.schedule-wrap { margin-top: 1rem; overflow-x: auto; padding-bottom: .3rem; }
.schedule { display: grid; grid-template-columns: 5.3rem repeat(7, minmax(7.4rem, 1fr)); min-width: 58rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--line); gap: 1px; overflow: hidden; }
.corner, .day-head, .meal-label, .meal-slot { background: white; }
.corner { padding: .75rem .35rem; }
.day-head { padding: .72rem .35rem; text-align: center; }
.day-head strong, .day-head span { display: block; }
.day-head strong { font-family: Georgia, "Times New Roman", serif; font-size: 1rem; }
.day-head span { margin-top: .15rem; color: var(--muted); font-size: .68rem; }
.day-head.today { background: #f7edf3; color: var(--plum-dark); }
.meal-label { display: flex; align-items: center; padding: .7rem .6rem; color: var(--muted); font-size: .73rem; font-weight: 800; }
.meal-slot { position: relative; min-height: 6.2rem; padding: .38rem; cursor: pointer; transition: background .15s ease; }
.meal-slot:hover, .meal-slot.drag-over { background: #fbf4f8; }
.meal-slot.drag-over { box-shadow: inset 0 0 0 2px var(--plum); }
.slot-label { position: absolute; width: 1px; height: 1px; overflow: hidden; }
.slot-meals { display: grid; gap: .3rem; }
.empty-slot { display: grid; place-items: center; min-height: 5.35rem; border: 1px dashed #ddcdd6; border-radius: .6rem; color: #ad9da7; font-size: .72rem; }
.planned-meal { position: relative; padding: .45rem 1.25rem .45rem .48rem; border-radius: .62rem; background: var(--sage); color: #355043; font-size: .7rem; font-weight: 750; line-height: 1.25; overflow-wrap: anywhere; }
.planned-meal button { position: absolute; top: .12rem; right: .16rem; width: 1rem; height: 1rem; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; opacity: .65; line-height: 1; }
.planned-meal button:hover { background: rgba(255,255,255,.5); opacity: 1; }
.grocery-list { display: grid; gap: .12rem; margin: .9rem 0 0; padding: 0; list-style: none; }
.grocery-item label { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .55rem; padding: .55rem .2rem; border-bottom: 1px solid #f0e8e3; cursor: pointer; font-size: .84rem; }
.grocery-item input { accent-color: var(--plum); }
.grocery-item.checked span { color: #a3979f; text-decoration: line-through; }
.grocery-count { min-width: 1.55rem; padding: .16rem .35rem; border-radius: 999px; background: #f0e4eb; color: var(--plum-dark); font-size: .67rem; font-weight: 800; text-align: center; }
footer { padding: 2rem 1rem 2.6rem; color: var(--muted); text-align: center; font-size: .8rem; }
dialog { width: min(calc(100% - 2rem), 34rem); padding: 0; border: 1px solid var(--line); border-radius: 1.3rem; background: var(--paper); color: var(--ink); box-shadow: 0 30px 90px rgba(42,30,39,.3); }
dialog::backdrop { background: rgba(41,31,39,.45); backdrop-filter: blur(3px); }
dialog form { display: grid; gap: 1rem; padding: 1.3rem; }
dialog label { display: grid; gap: .38rem; font-size: .83rem; font-weight: 750; }
dialog label small { color: var(--muted); font-weight: 500; }
dialog input, dialog select, dialog textarea { width: 100%; padding: .72rem .78rem; border: 1px solid var(--line); border-radius: .75rem; background: white; color: var(--ink); outline: none; }
dialog textarea { resize: vertical; }
dialog input:focus, dialog select:focus, dialog textarea:focus { border-color: var(--plum); box-shadow: 0 0 0 3px rgba(117,74,108,.1); }
.dialog-actions { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: .55rem; margin-top: .25rem; }
.secondary-button, .danger-button { padding: .7rem .9rem; background: #eee7e4; font-weight: 700; }
.danger-button { background: #f7e1e2; color: #9d3f48; }

@media (max-width: 1180px) {
  .planner-layout { grid-template-columns: minmax(15rem, .65fr) minmax(40rem, 1.8fr); }
  .grocery-panel { position: static; grid-column: 1 / -1; max-height: none; }
  .grocery-list { grid-template-columns: repeat(3, 1fr); column-gap: 1rem; }
}
@media (max-width: 830px) {
  .topbar { grid-template-columns: 1fr auto; }
  .brand strong { display: none; }
  .week-nav { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .topbar > .primary-button { grid-column: 2; grid-row: 1; }
  .welcome-card { grid-template-columns: 6.5rem 1fr; gap: 1.2rem; margin: 1.2rem auto; }
  .welcome-card img { height: 8rem; }
  .planner-layout { display: flex; flex-direction: column; }
  .panel { width: 100%; }
  .ideas-panel, .grocery-panel { position: static; max-height: none; }
  .meal-library { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grocery-list { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 560px) {
  main { width: min(100% - 1rem, 1500px); }
  .topbar { padding: .7rem .75rem; }
  .topbar > .primary-button { padding: .65rem .75rem; font-size: .8rem; }
  .welcome-card { grid-template-columns: 5.2rem 1fr; padding: .65rem; border-radius: 1.2rem; }
  .welcome-card img { height: 7.3rem; border-radius: .85rem; }
  .welcome-card h1 { font-size: 1.65rem; }
  .welcome-card p:last-child { font-size: .82rem; }
  .panel { border-radius: 1.1rem; }
  .week-panel, .ideas-panel, .grocery-panel { padding: .9rem; }
  .meal-library, .grocery-list { grid-template-columns: 1fr; }
  .schedule-wrap { margin-right: -.9rem; padding-right: .9rem; }
  .dialog-actions { grid-template-columns: 1fr 1fr; }
  .dialog-actions span { display: none; }
  .danger-button { grid-row: 2; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
