/* Bento Buddy: Kawaii Buddy theme (A1, with a lilac Buddy). See docs/STYLE.md.
   Everything down to "Added for the server version" is the original page's CSS, unchanged. */
@font-face { font-family: 'Fredoka'; font-weight: 400 700; font-display: swap; src: url(../fonts/fredoka.woff2) format('woff2'); }
@font-face { font-family: 'Nunito'; font-weight: 400 800; font-display: swap; src: url(../fonts/nunito.woff2) format('woff2'); }

:root {
  color-scheme: light;
  --bg: #fff8f0; --card: #ffffff; --ink: #4a3b35; --muted: #9a8579; --line: #f1e3d6;
  --chicken: #ffd9bf; --beef: #ffc9cf; --tuna: #c9e2fb; --beans: #cdeec1; --ordered: #e4d7fb;
  --buddy: #9b84d6; --buddy-lid: #c7b6f0; --buddy-cheek: #ffc2d6;
  --accent: #4a3b35; --accent-ink: #fff8f0;
  --pill: rgba(255,255,255,.8); --warn: #c0603a; --highlight: #e07a5f;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 Fredoka, system-ui, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }
main { max-width: 1000px; margin: 0 auto; padding: 20px 16px 110px; }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
h1 { margin: 0; font-size: 26px; font-weight: 800; }
h2 { font-size: 20px; font-weight: 800; margin: 0 0 12px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 0 8px; font-weight: 800; }
.legend { display: flex; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.legend span { padding: 2px 10px; border-radius: 999px; }
.chicken { background: var(--chicken); } .beef { background: var(--beef); } .tuna { background: var(--tuna); }
.beans { background: var(--beans); } .ordered { background: var(--ordered); }

/* Week nav */
.weeknav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.weeknav .range { flex: 1; font-weight: 700; color: var(--muted); }
.navbtn { width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); font-size: 20px; }

/* Bento */
.bento { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; grid-auto-rows: minmax(170px, auto); gap: 12px; }
.tile { border-radius: 22px; padding: 16px; display: flex; flex-direction: column; gap: 8px; text-align: left; border: 0; min-height: 170px; }
.tile.big { grid-row: span 2; padding: 22px; }
.tile.empty { background: var(--card); border: 2px dashed var(--line); }
.t-dow { font-weight: 800; font-size: 14px; opacity: .75; }
.tile.big .t-dow { font-size: 16px; opacity: 1; }
.t-din { font-weight: 800; font-size: 17px; line-height: 1.2; flex: 1; }
.tile.big .t-din { font-size: 28px; }
.tile.empty .t-din { color: var(--muted); font-weight: 700; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { background: var(--pill); border-radius: 999px; padding: 3px 10px; font-size: 13px; border: 1px solid transparent; }
button.pill { min-height: 30px; }
.pill.maybe { background: transparent; border: 1px dashed currentColor; opacity: .7; }
.pill.task { font-weight: 800; border-color: currentColor; }
.pill.done { text-decoration: line-through; opacity: .6; }
.need { font-size: 13px; color: var(--warn); font-weight: 700; }
.tile.big .need { font-size: 15px; }

/* Shop + kitchen */
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.seg button { flex: 1; min-height: 42px; border: 0; border-radius: 10px; background: transparent; font-weight: 700; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 6px 14px; }
.row { display: flex; align-items: center; gap: 12px; min-height: 54px; border-bottom: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; padding: 6px 0; }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; }
.row small { display: block; color: var(--muted); font-size: 13px; }
.box { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--muted); flex: none; display: grid; place-items: center; font-weight: 800; }
.row.ticked .box { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.row.ticked .grow { text-decoration: line-through; color: var(--muted); }
.qty { font-weight: 800; white-space: nowrap; }
.toggle { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); font-size: 14px; font-weight: 700; }
.toggle.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.primary { min-height: 50px; padding: 0 20px; border-radius: 14px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 800; flex: 1; }
.secondary { min-height: 50px; padding: 0 20px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); font-weight: 800; flex: 1; }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.empty-note { color: var(--muted); padding: 14px 0; }

.finished { font-size: 13px; font-weight: 800; margin-top: 4px; opacity: .8; }
.switches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.switch { min-height: 64px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); text-align: left; padding: 10px 12px; font-weight: 800; }
.switch small { display: block; font-weight: 700; font-size: 13px; color: var(--muted); }
.switch.out { background: transparent; border: 2px dashed var(--warn); }
.switch.out small { color: var(--warn); }

/* Tab bar */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); gap: 6px; z-index: 5; }
nav.tabs button { flex: 1; max-width: 200px; min-height: 52px; border: 0; border-radius: 14px; background: transparent; font-weight: 800; color: var(--muted); }
nav.tabs button.on { background: var(--bg); color: var(--ink); }

/* Sheet */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: none; z-index: 10; }
.overlay.open { display: block; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto; max-height: 90vh; overflow-y: auto; background: var(--card); border-radius: 24px 24px 0 0; padding: 20px 16px 24px; transform: translateY(105%); transition: transform .2s; z-index: 11; }
.sheet.open { transform: none; }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.opt { min-height: 64px; border-radius: 16px; border: 2px solid transparent; background: var(--bg); text-align: left; padding: 10px 12px; font-weight: 800; }
.opt small { display: block; font-weight: 700; font-size: 13px; color: var(--muted); }
.opt small.buy { color: var(--warn); }
.opt.sel { border-color: var(--accent); }
.opt.wide { grid-column: 1 / -1; }
.xrow { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.xrow .row { border-bottom: 0; }
.xdel { width: 40px; height: 40px; flex: none; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 20px; font-weight: 800; color: var(--muted); }
.addrow { display: flex; gap: 8px; padding: 10px 0; }
.addrow input { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: 700 16px Nunito, system-ui, sans-serif; }
.groupsel { min-height: 44px; padding: 0 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: 700 15px Nunito, system-ui, sans-serif; max-width: 42%; }
.dropzone { min-height: 72px; border-radius: 18px; padding: 4px; margin: -4px; transition: background .15s; }
.dropzone.over { background: var(--chicken); }
.switch[draggable="true"] { cursor: grab; }
.switch.dragging { opacity: .4; }
.dropnote { color: var(--muted); font-weight: 700; font-size: 14px; padding: 20px 8px; border: 2px dashed var(--line); border-radius: 16px; text-align: center; grid-column: 1 / -1; }
.pill.act { border: 1px solid rgba(58,51,48,.15); font-weight: 800; }
.pill.add { background: transparent; border: 1px dashed currentColor; font-weight: 700; }
.selectrow { display: flex; gap: 10px; }
.selectrow label { flex: 1; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 800; }
.selectrow select { display: block; width: 100%; margin-top: 6px; min-height: 50px; padding: 0 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: 800 16px Nunito, system-ui, sans-serif; text-transform: none; letter-spacing: 0; }

.topbar { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.brand { margin-right: auto; font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.btn-hdr { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 13px; font-weight: 800; }
.btn-hdr svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--accent); color: var(--accent-ink); padding: 10px 18px; border-radius: 999px; font-weight: 800; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; }
.toast.show { opacity: 1; }

/* ---- Buddy + speech bubble ---- */
.hello { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.hello svg { flex: none; }
.bubble { flex: 1; background: #fff; border-radius: 22px; padding: 12px 18px; font-size: 18px; font-weight: 500; position: relative; box-shadow: 0 3px 0 var(--line); }
.bubble::before { content: ""; position: absolute; left: -10px; top: 50%; margin-top: -10px; border: 10px solid transparent; border-right-color: #fff; border-left: 0; }
.bubble b { color: var(--highlight); font-weight: 700; }

/* ---- Juicy tiles ---- */
.tile { border-radius: 28px; box-shadow: 0 5px 0 rgba(0,0,0,.07); cursor: pointer; transition: transform .12s ease; }
.tile.empty { background: #fff; border: 3px dashed #ead9c8; box-shadow: none; }
.t-dow { font-weight: 600; }
.t-din { font-weight: 600; }
.t-emoji { font-size: 34px; line-height: 1; }
.tile.big .t-emoji { font-size: 72px; }
.tile.empty .t-emoji { opacity: .6; }
.pill { font-weight: 500; }
.tile:active, .switch:active, .opt:active, .pill:active, .primary:active, .secondary:active { transform: scale(.96); }
.switch, .opt, .pill, .primary, .secondary { transition: transform .12s ease; }
.happy-note { text-align: center; padding: 22px 0; font-weight: 600; font-size: 18px; }
.happy-note small { display: block; color: var(--muted); font-weight: 500; font-size: 14px; }

@media (max-width: 700px) {
  .bento { grid-template-columns: 1fr 1fr; grid-auto-rows: minmax(150px, auto); }
  .tile.big { grid-column: span 2; grid-row: span 1; min-height: 200px; }
  .tile.big .t-din { font-size: 24px; }
  .tile.big .t-emoji { font-size: 52px; }
  .bubble { font-size: 15px; }
}

/* ---- Added for the server version ---- */
[hidden] { display: none !important; }
html { -webkit-tap-highlight-color: transparent; }
main { padding-top: max(20px, env(safe-area-inset-top)); }

/* Sync status: Saved / Saving… / Offline */
.sync { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 0; background: var(--beans); font-size: 13px; font-weight: 700; margin-right: auto; }
.sync::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .5; }
.sync[data-state="saving"] { background: var(--tuna); }
.sync[data-state="offline"] { background: var(--chicken); }
.sync[data-state="error"] { background: var(--beef); color: var(--warn); }
.brand { margin-right: 0; }

.version { text-align: center; color: var(--muted); font-size: 12px; margin: 28px 0 0; }

/* Saved versions sheet */
.vrow { display: flex; align-items: center; gap: 10px; min-height: 54px; border-bottom: 1px solid var(--line); }
.vrow:last-child { border-bottom: 0; }
.vrow .grow { flex: 1; }
.vrow small { display: block; color: var(--muted); font-size: 13px; }
.vrow.now { font-weight: 700; }

/* Login and first-time setup */
.gate { max-width: 420px; margin: 0 auto; padding: max(48px, env(safe-area-inset-top)) 20px 40px; display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.gate h1 { font-size: 28px; font-weight: 700; }
.gate p { margin: 0; color: var(--muted); }
.gate form { width: 100%; display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.gate label { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 800; }
.gate input { display: block; width: 100%; margin-top: 6px; min-height: 52px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: 700 17px Nunito, system-ui, sans-serif; text-transform: none; letter-spacing: 0; }
.gate .primary { width: 100%; flex: none; }
.gate .error { color: var(--warn); font-weight: 700; min-height: 1.4em; }
.noscript { padding: 24px; }

/* ---- Kitchen and Shop: colourful, like the Week ---- */
:root { --carb: #ffe9b3; --veg: #d3f0da; --brekkie: #ffe0ea; --pantry: #d9e8fa; --other: #ece2f7; }
.hello.small { gap: 12px; margin-bottom: 16px; }
.hello.small .bubble { font-size: 16px; padding: 10px 16px; }

.khead { flex-wrap: nowrap; }
.hbtns { display: flex; gap: 8px; align-items: center; }
.addbtn { min-height: 40px; padding: 0 18px; border-radius: 999px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 15px; box-shadow: 0 3px 0 rgba(0,0,0,.12); transition: transform .12s ease; }
.addbtn:active, .btn-hdr:active, .chip:active, .emo:active, .sem:active, .stepper button:active { transform: scale(.94); }

/* A section = a pastel card, like a day tile */
.kgroup { border-radius: 28px; padding: 14px 14px 16px; margin: 0 0 14px; box-shadow: 0 5px 0 rgba(0,0,0,.06); }
.kgroup h3 { margin: 2px 4px 10px; color: var(--ink); opacity: .8; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.kgroup h3 span { text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 13px; color: var(--warn); }
.g-list h3 span { color: var(--muted); }
.khint { margin: -4px 4px 10px; font-size: 13px; color: var(--muted); }
.g-list { background: var(--card); }
.g-proteins, .s-proteins { background: var(--chicken); }
.g-carbs, .s-carbs { background: var(--carb); }
.g-beanNight, .s-beanNight { background: var(--beans); }
.g-veg, .s-veg { background: var(--veg); }
.g-breakfast, .s-breakfast { background: var(--brekkie); }
.g-pantry, .s-pantry { background: var(--pantry); }
.g-other, .s-other { background: var(--other); }
.g-check { background: var(--chicken); }

/* Kitchen cards */
.kgroup .switches { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.kgroup .switch { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 92px; padding: 12px; border: 0; border-radius: 20px; background: rgba(255,255,255,.88); box-shadow: 0 3px 0 rgba(0,0,0,.06); font-weight: 600; line-height: 1.2; }
.kgroup .switch .em { font-size: 28px; line-height: 1; margin-bottom: 4px; }
.kgroup .switch small { font-weight: 500; color: var(--muted); margin-top: auto; }
.kgroup .switch.out { background: transparent; border: 2px dashed var(--warn); box-shadow: none; padding: 10px; }
.kgroup .switch.out .em { filter: grayscale(1); opacity: .5; }
.kgroup .switch.out small { color: var(--warn); font-weight: 700; }
.kgroup .switch .pen { position: absolute; top: 8px; right: 10px; font-size: 15px; opacity: .55; }
.editing .switch { outline: 2px dashed rgba(74,59,53,.25); outline-offset: -5px; }
.kgroup .dropnote { border-color: rgba(74,59,53,.15); padding: 14px 8px; }
.dropzone.over { background: rgba(255,255,255,.5); }

/* Shopping list items */
.sitem { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 20px; background: var(--bg); margin-bottom: 8px; }
.g-check .sitem { background: rgba(255,255,255,.75); }
.sem { width: 44px; height: 44px; flex: none; border-radius: 16px; display: grid; place-items: center; font-size: 24px; border: 0; padding: 0; transition: transform .12s ease; }
.sitem.ticked .sem { background: var(--accent); color: var(--accent-ink); font-size: 20px; font-weight: 700; }
.sname { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 0; font-weight: 600; font-size: 16px; line-height: 1.25; overflow-wrap: anywhere; }
.sname small { display: block; color: var(--muted); font-weight: 500; font-size: 13px; }
.sitem.ticked .sname { text-decoration: line-through; color: var(--muted); }
.stepper { display: flex; align-items: center; flex: none; background: var(--card); border-radius: 999px; padding: 3px; box-shadow: 0 2px 0 rgba(0,0,0,.05); }
.stepper button { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--bg); font-size: 18px; font-weight: 700; line-height: 1; padding: 0; }
.stepper button:disabled { opacity: .35; }
.stepper .q { min-width: 50px; text-align: center; font-size: 13px; font-weight: 700; white-space: nowrap; padding: 0 2px; }
.sitem .xdel { width: 32px; height: 32px; border-radius: 50%; font-size: 18px; background: var(--card); }
.g-check .toggle { background: var(--card); white-space: nowrap; }
.g-list .addrow { padding: 4px 0 0; }

/* Add / edit a card */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 42px; padding: 0 16px; border-radius: 999px; border: 2px solid transparent; font-weight: 600; transition: transform .12s ease; }
.chip.sel { border-color: var(--accent); }
.emojis { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.emo { height: 44px; border-radius: 14px; border: 2px solid transparent; background: var(--bg); font-size: 22px; padding: 0; transition: transform .12s ease; }
.emo.sel { border-color: var(--accent); background: var(--card); }
.sheet .addrow input { min-height: 50px; font-size: 17px; }

@media (max-width: 700px) {
  .kgroup .switches { grid-template-columns: 1fr 1fr; }
  .hello.small .bubble { font-size: 15px; }
}
@media (max-width: 360px) {
  .stepper .q { min-width: 40px; }
  .sem { width: 38px; height: 38px; font-size: 20px; }
}

/* Activity sheet: chips for what, − / + and hours for when */
.chip-new { background: transparent; border: 2px dashed var(--line); color: var(--muted); }
.newact { margin-top: 10px; padding: 12px; border-radius: 20px; background: var(--bg); }
.newact .addrow { padding: 0 0 10px; }
.newact .emojis { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); }
.newact .emo { background: var(--card); height: 40px; }
.timepick { display: flex; align-items: center; justify-content: center; gap: 14px; background: var(--bg); border-radius: 22px; padding: 10px; }
.timepick button { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--card); font-size: 24px; font-weight: 700; box-shadow: 0 3px 0 rgba(0,0,0,.06); transition: transform .12s ease; }
.timepick button:active { transform: scale(.92); }
.tbig { min-width: 130px; text-align: center; font-size: 34px; font-weight: 700; }
.hours { display: flex; gap: 6px; overflow-x: auto; padding: 10px 2px 4px; scrollbar-width: none; }
.hours::-webkit-scrollbar { display: none; }
.hour { flex: none; min-height: 38px; padding: 0 12px; border-radius: 999px; border: 2px solid transparent; background: var(--bg); font-weight: 600; font-size: 14px; }
.hour.sel { border-color: var(--accent); background: var(--card); }
