.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
body { padding-bottom: 76px; }

.top { background: linear-gradient(180deg, #fff, var(--cream)); border-bottom: 1px solid var(--line); position: static; z-index: 20; }
.top-in { max-width: 1240px; margin: 0 auto; padding: 12px 16px 8px; display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; justify-content: space-between; }
.brand { display: flex; gap: 10px; align-items: center; }
.logo { width: 42px; height: 42px; display: grid; place-items: center; background: var(--sage); border-radius: 14px; font-size: 1.4rem; box-shadow: var(--shadow); }
.brand h1 { font-size: 1.25rem; line-height: 1.1; letter-spacing: -.01em; }
.brand p { font-size: .8rem; color: var(--ink-2); }
.plans { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.plans select { max-width: 190px; font-weight: 700; padding: 7px 10px; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); display: flex; padding-bottom: env(safe-area-inset-bottom); z-index: 30; box-shadow: 0 -6px 20px rgba(43,58,47,.08); }
.tabs button { flex: 1; border: 0; background: none; padding: 8px 4px 10px; font-weight: 700; font-size: .78rem; color: var(--ink-2); display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
.tabs button span { font-size: 1.3rem; }
.tabs button[aria-current="page"] { color: var(--sage-d); }
.tabs button[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; background: var(--turmeric); border-radius: 0 0 4px 4px; }
.tabs b { position: absolute; top: 4px; left: calc(50% + 14px); background: var(--turmeric); color: #2b1d04; border-radius: 999px; font-size: .68rem; padding: 1px 6px; }

main { max-width: 1240px; margin: 0 auto; padding: 14px 16px 0; }
.pane { display: none; }
.v-plan #paneplan, .v-recipes #panerecipes, .v-shop #paneshop { display: block; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin-bottom: 6px; }
.stepper { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; background: #fff; padding: 4px 6px 4px 14px; border-radius: 999px; box-shadow: var(--shadow); }
.stepper button { width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--sage-l); color: var(--sage-d); font-size: 1.1rem; font-weight: 800; }
.stepper b { min-width: 1.4em; text-align: center; }
.hint { color: var(--ink-2); font-size: .88rem; margin: 6px 2px 12px; }
.link { background: none; border: 0; color: var(--sage-d); font-weight: 700; text-decoration: underline; padding: 0; font-size: .85rem; }

.meal-head { display: none; }
.grid { display: grid; gap: 12px; }
.day { background: #fff; border-radius: var(--r); box-shadow: var(--shadow); padding: 10px; }
.dname { font-weight: 800; font-size: 1.02rem; padding: 2px 4px 8px; display: flex; justify-content: space-between; align-items: baseline; }
.dname small { color: var(--ink-2); font-weight: 600; font-size: .78rem; }
.slots { display: grid; gap: 8px; }
.slot { border: 2px dashed var(--line); border-radius: 12px; min-height: 58px; position: relative; background: var(--cream); transition: border-color .12s, background .12s; }
.slot.over { border-color: var(--turmeric); background: #FFF3DA; }
.slot.target { border-color: var(--turmeric); border-style: solid; box-shadow: 0 0 0 4px #E39B2D33; }
.slot .mlabel { position: absolute; top: 5px; left: 10px; font-size: .66rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); }
.slot.empty { display: grid; place-items: center; width: 100%; color: var(--sage-d); font-weight: 800; padding: 22px 8px 8px; }
button.slot.empty:hover { background: var(--sage-l); border-color: var(--sage); }
.slot.empty .plus { font-size: 1.5rem; line-height: 1; }
.slot.filled { border: 1px solid var(--line); background: #fff; padding: 22px 8px 8px; display: grid; grid-template-columns: 46px 1fr; gap: 4px 10px; cursor: grab; }
.slot.filled .th { grid-row: span 2; width: 46px; height: 46px; border-radius: 10px; overflow: hidden; background: var(--cream-2); }
.slot.filled .th .rimg { width: 46px; height: 46px; aspect-ratio: 1; }
.slot.filled .th .ph span { font-size: 1.4rem; }
.slot .rt { font-weight: 700; font-size: .9rem; line-height: 1.2; text-align: left; background: none; border: 0; padding: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.slot .rm { display: flex; align-items: center; gap: 6px; font-size: .76rem; color: var(--ink-2); font-weight: 600; flex-wrap: wrap; }
.slot .rm button { width: 22px; height: 22px; border: 0; border-radius: 50%; background: var(--sage-l); color: var(--sage-d); font-weight: 800; line-height: 1; padding: 0; }
.slot .del { position: absolute; top: 3px; right: 4px; border: 0; background: none; color: var(--ink-2); font-size: 1.1rem; width: 28px; height: 28px; border-radius: 50%; }
.slot .del:hover { background: #FBE3D8; color: var(--danger); }

/* recipes */
.target { background: var(--turmeric); color: #2b1d04; padding: 10px 14px; border-radius: 12px; margin-bottom: 12px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; gap: 10px; box-shadow: var(--shadow); }
.filters { padding: 12px; margin-bottom: 14px; display: grid; gap: 10px; }
.f-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.chips .chip { flex: none; }
.f-foot { display: flex; justify-content: space-between; font-size: .85rem; color: var(--ink-2); font-weight: 600; }
.rlist { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.rc { background: #fff; border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; cursor: grab; }
.rc .imgbtn { border: 0; padding: 0; background: none; display: block; position: relative; }
.rc .rimg { aspect-ratio: 4 / 3; }
.rc .time { position: absolute; right: 8px; bottom: 8px; background: rgba(255,255,255,.94); border-radius: 999px; padding: 2px 9px; font-size: .74rem; font-weight: 800; }
.rc .bd { padding: 9px 10px 10px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.rc h3 { font-size: .93rem; line-height: 1.2; }
.rc .pills { display: flex; flex-wrap: wrap; gap: 4px; max-height: 21px; overflow: hidden; }
.rc .btn { margin-top: auto; width: 100%; }
.empty-msg { grid-column: 1 / -1; text-align: center; padding: 40px 10px; color: var(--ink-2); }

/* shopping */
.shop-head { display: flex; flex-wrap: wrap; gap: 10px 14px; justify-content: space-between; align-items: flex-end; margin-bottom: 14px; }
.shop-head h2 { font-size: 1.5rem; }
.shop-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tgl { display: inline-flex; gap: 6px; align-items: center; font-size: .86rem; font-weight: 600; }
.aisle { background: #fff; border-radius: var(--r); box-shadow: var(--shadow); padding: 6px 14px 8px; margin-bottom: 12px; break-inside: avoid; }
.aisle h3 { font-size: .86rem; text-transform: uppercase; letter-spacing: .08em; color: var(--sage-d); padding: 8px 0 4px; }
.item { display: flex; gap: 12px; align-items: center; padding: 9px 0; border-top: 1px dashed var(--line); cursor: pointer; }
.item:first-of-type { border-top: 0; }
.item .t b { font-weight: 700; }
.item .t span { color: var(--ink-2); display: block; font-size: .86rem; }
.item.done .t { text-decoration: line-through; opacity: .5; }
.shop-empty { background: #fff; border-radius: var(--r); padding: 36px 18px; text-align: center; color: var(--ink-2); box-shadow: var(--shadow); }
.shop-empty b { display: block; color: var(--ink); font-size: 1.1rem; margin-bottom: 4px; }
.shop-cols { columns: 1; column-gap: 14px; }

.d-add { margin: 16px 0 0; padding: 14px; background: #fff; border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; position: sticky; bottom: 0; }
.d-add select { flex: 1 1 100px; }
.d-add .stepper { box-shadow: none; background: var(--cream); }
.d-add .btn { flex: 1 1 100%; }

#printArea { display: none; }

@media (min-width: 560px) {
  .rlist { grid-template-columns: repeat(3, 1fr); }
  .shop-cols { columns: 2; }
}
@media (min-width: 1000px) {
  body { padding-bottom: 0; }
  .top { position: sticky; top: 0; }
  .tabs { position: static; box-shadow: none; border: 0; max-width: 1240px; margin: 0 auto; padding: 0 16px; background: none; gap: 6px; }
  .tabs button { flex: none; flex-direction: row; gap: 8px; padding: 10px 18px; font-size: .95rem; border-radius: 12px 12px 0 0; }
  .tabs button span { font-size: 1.1rem; }
  .tabs button[aria-current="page"] { background: var(--cream); }
  .tabs button[aria-current="page"]::before { left: 18px; right: 18px; }
  .tabs b { position: static; }
  #toast { bottom: 24px; }
  main { padding-top: 20px; }
  .v-plan, .v-recipes { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 22px; align-items: start; }
  .v-plan #panerecipes, .v-recipes #paneplan { display: block; }
  .v-plan #paneplan, .v-recipes #paneplan { grid-column: 1; grid-row: 1; }
  .v-plan #panerecipes, .v-recipes #panerecipes { grid-column: 2; grid-row: 1; position: sticky; top: 130px; max-height: calc(100vh - 150px); overflow: auto; padding-right: 4px; }
  .rlist { grid-template-columns: repeat(2, 1fr); }
  .chips { flex-wrap: wrap; overflow: visible; }
  .meal-head { display: grid; grid-template-columns: 96px repeat(4, 1fr); gap: 8px; padding: 0 10px 6px; font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); }
  .day { display: grid; grid-template-columns: 88px 1fr; gap: 8px; align-items: stretch; padding: 8px 10px; }
  .dname { flex-direction: column; justify-content: center; padding: 0; }
  .slots { grid-template-columns: repeat(4, 1fr); }
  .slot .mlabel { display: none; }
  .slot.empty { padding: 8px; min-height: 76px; }
  .slot.filled { padding: 8px; grid-template-columns: 1fr; }
  .slot.filled .th { display: none; }
  .slot .rt { padding-right: 18px; font-size: .84rem; }
  .shop-cols { columns: 3; }
  .grid { gap: 8px; }
}
@media (min-width: 1000px) and (max-width: 1180px) {
  .v-plan, .v-recipes { grid-template-columns: minmax(0, 1fr) 340px; }
}

/* ---------- print ---------- */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; padding: 0; font-size: 11pt; }
  .top, .tabs, main, footer, #toast, #modalRoot { display: none !important; }
  #printArea { display: block !important; }
  #printArea h1 { font-size: 20pt; margin-bottom: 2pt; }
  #printArea .ps { color: #555; margin-bottom: 12pt; font-size: 10pt; }
  #printArea table { width: 100%; border-collapse: collapse; }
  #printArea th, #printArea td { border: 1px solid #bbb; padding: 5pt 6pt; vertical-align: top; font-size: 9.5pt; text-align: left; }
  #printArea th { background: #eef3ec; }
  #printArea td small { color: #666; display: block; }
  #printArea .pa { break-inside: avoid; margin-bottom: 10pt; }
  #printArea .pa h3 { font-size: 11pt; border-bottom: 2px solid #6B8F71; margin-bottom: 3pt; text-transform: uppercase; letter-spacing: .05em; color: #4F7357; }
  #printArea .pl { list-style: none; padding: 0; margin: 0; columns: 1; }
  #printArea .pl li { padding: 2pt 0; display: flex; gap: 6pt; align-items: baseline; }
  #printArea .pl li::before { content: ""; width: 9pt; height: 9pt; border: 1.2px solid #444; border-radius: 2px; flex: none; transform: translateY(1pt); }
  #printArea .pl li.done { text-decoration: line-through; color: #888; }
  #printArea .cols { columns: 2; column-gap: 20pt; }
  #printArea .foot { margin-top: 14pt; font-size: 8pt; color: #777; }
}
