/* Buckreus Kitchen: warm paper look for a ~1280x800 landscape tablet. */
:root {
  --paper: #F6F0E4; --paper-2: #EFE6D4; --card: #FFFBF3; --card-2: #FBF5EA; --line: #E6DAC4; --line-2: #EFE5D3;
  --ink: #3A322B; --ink-2: #6E6255; --ink-3: #9A8D7D; --accent: #E9876B; --accent-ink: #fff; --good: #5BAA78; --warn: #D9822B;
  --today: #E25A4A; --dark: #3B322A;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Noto Serif", "Droid Serif", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --r: 16px; --r-sm: 10px; --shadow: 0 1px 0 rgba(90, 70, 40, .05), 0 2px 10px rgba(90, 70, 40, .06);
  --hour: 46px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); font: 16px/1.35 var(--sans);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
body { overflow: hidden; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
input, select, textarea { font: inherit; color: inherit; user-select: text; -webkit-user-select: text; }
a { color: inherit; }
.boot { display: grid; place-items: center; height: 100vh; font: 28px var(--serif); color: var(--ink-3); }

/* ------------------------------- layout ------------------------------- */
#app { height: 100vh; display: grid; grid-template-columns: 76px minmax(0, 1fr); }
.rail { background: var(--paper-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center;
  padding: 14px 0 12px; gap: 6px; }
.rail .mark { font: 600 26px var(--serif); color: var(--accent); margin-bottom: 10px; }
.rail button { width: 62px; padding: 9px 0 7px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 12px; color: var(--ink-2); }
.rail button svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rail button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.rail .grow { flex: 1; }
.main { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); min-width: 0; min-height: 0; height: 100vh; }

/* ------------------------------- header ------------------------------- */
.header { display: flex; align-items: center; gap: 18px; padding: 10px 22px 6px; min-width: 0; }
.header > * { flex: none; }
.header .date, .header .wx-now { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.header .grow { flex: 1 1 0; }
.clock { font: 400 52px/1 var(--serif); letter-spacing: -1px; white-space: nowrap; }
.clock small { font: 500 18px var(--sans); letter-spacing: 0; margin-left: 4px; color: var(--ink-2); }
.date { font: 22px/1.15 var(--serif); white-space: nowrap; }
.date small { display: block; font: 13px var(--sans); color: var(--ink-3); letter-spacing: .3px; text-transform: uppercase; margin-bottom: 2px; }
.wx-now { display: flex; align-items: center; gap: 10px; padding: 6px 14px; background: var(--card); border: 1px solid var(--line-2); border-radius: 999px; }
.wx-now .ic { font-size: 26px; }
.wx-now b { font-size: 22px; font-weight: 600; }
.wx-now span { color: var(--ink-2); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wx-now { min-width: 0; flex: 0 1 auto; }
.header .grow { flex: 1; }
.badge { font-size: 13px; padding: 5px 11px; border-radius: 999px; background: #F6E2C6; color: #8A5A1C; white-space: nowrap; }
.badge.err { background: #F7D9D3; color: #9A3B2B; }
.iconbtn { width: 44px; height: 44px; border-radius: 50%; background: var(--card); border: 1px solid var(--line-2); display: grid; place-items: center; font-size: 20px; }

/* -------------------------------- strip -------------------------------- */
.strip { display: grid; grid-template-columns: 1.25fr 1fr; gap: 12px; padding: 4px 22px 10px; }
.glance { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 9px 14px; display: flex; align-items: center; gap: 12px; min-width: 0; min-height: 58px; }
.glance .lbl { font: 600 11px var(--sans); letter-spacing: .8px; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; }
.glance .what { font-weight: 600; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.glance .when { color: var(--ink-2); white-space: nowrap; }
.glance .pill { border-radius: 12px; padding: 6px 12px; min-width: 0; display: flex; flex-direction: column; }
.glance .more { color: var(--ink-3); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.glance .grow { flex: 1; min-width: 0; }
.cookbtn { background: var(--dark); color: #fff; border-radius: 12px; padding: 10px 16px; font-weight: 600; white-space: nowrap; }
.cookbtn.small { padding: 7px 12px; font-size: 14px; border-radius: 10px; }

/* ------------------------------ content ------------------------------- */
.content { min-height: 0; min-width: 0; padding: 0 22px 14px; display: flex; flex-direction: column; }
.content > * { min-width: 0; }
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: nowrap; }
.seg { display: inline-flex; background: var(--paper-2); border-radius: 12px; padding: 3px; }
.seg button { padding: 8px 14px; border-radius: 10px; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--dark); color: #fff; }
.navbtn { min-width: 44px; height: 42px; padding: 0 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); font-weight: 600; }
.title { font: 21px var(--serif); margin: 0 4px; white-space: nowrap; }
.chips { display: flex; gap: 5px; margin-left: auto; flex-wrap: nowrap; overflow: hidden; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  font-size: 13.5px; font-weight: 600; white-space: nowrap; flex: none; }
.chip .dot { width: 12px; height: 12px; border-radius: 50%; }
.chip.off { opacity: .45; }
.chip.off .dot { background: transparent !important; border: 2px solid var(--ink-3); }
.chip.money { background: #EFE8DA; }
.chip.money.on { background: #FCE6BF; border-color: #E9C98A; }

.panel { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--shadow); min-height: 0; }

/* ----------------------------- week / day ------------------------------ */
.cal { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; min-width: 0; }
.cal-head { display: grid; border-bottom: 1px solid var(--line); }
.cal-head .dh { padding: 8px 8px 6px; display: flex; align-items: center; gap: 6px; border-left: 1px solid var(--line-2); min-width: 0; }
.cal-head .dh:first-child { border-left: 0; }
.dh .dn { font-weight: 700; }
.dh .num { font-weight: 600; color: var(--ink-2); }
.dh.today .num { background: var(--today); color: #fff; border-radius: 999px; padding: 1px 8px; }
.dh .w { margin-left: auto; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.dh .w .i { font-size: 16px; }
.allday { display: grid; border-bottom: 1px solid var(--line); position: relative; }
.allday .lane-area { position: relative; }
.allday .gutter { font-size: 11px; color: var(--ink-3); padding: 6px 6px 0 0; text-align: right; }
.span { position: absolute; height: 24px; border-radius: 7px; padding: 2px 8px; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; border-left: 4px solid; }
.span.clipL { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.span.clipR { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.span.hol { font-style: italic; font-weight: 500; }
.grid-scroll { flex: 1; overflow-y: auto; position: relative; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.grid-scroll::-webkit-scrollbar { display: none; }
.grid { display: grid; position: relative; }
.hours { position: relative; }
.hours div { position: absolute; right: 8px; font-size: 11px; color: var(--ink-3); transform: translateY(-50%); white-space: nowrap; }
.col { position: relative; border-left: 1px solid var(--line-2); }
.col.today { background: rgba(233, 135, 107, .05); }
.hline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line-2); }
.hline.half { border-top-style: dashed; border-color: #F3ECDF; }
.ev { position: absolute; border-radius: 8px; padding: 3px 7px; overflow: hidden; border-left: 4px solid; font-size: 13px; line-height: 1.2; box-shadow: 0 1px 2px rgba(60, 40, 20, .08); }
.ev b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev span { color: rgba(58, 50, 43, .75); font-size: 12px; white-space: nowrap; }
.ev.past { opacity: .62; }
.ev .dots { position: absolute; right: 5px; top: 5px; display: flex; gap: 3px; }
.ev .dots i, .mchip .dots i { width: 8px; height: 8px; border-radius: 50%; display: block; }
.ev.tall b { white-space: normal; }
.nowline { position: absolute; left: 0; right: 0; height: 2px; background: var(--today); z-index: 3; pointer-events: none; }
.nowline::before { content: ""; position: absolute; left: -6px; top: -5px; width: 12px; height: 12px; border-radius: 50%; background: var(--today); }
.dst-note { position: absolute; left: 4px; right: 4px; pointer-events: none; font-size: 11px; color: var(--ink-3); background: var(--card-2); border: 1px dashed var(--line); border-radius: 6px; padding: 1px 6px; z-index: 0; }
.ev { z-index: 1; }

.dayview { flex: 1; display: grid; grid-template-columns: 1fr 340px; gap: 14px; min-height: 0; }
.side { padding: 16px; overflow-y: auto; }
.side h3 { font: 26px var(--serif); margin: 0 0 4px; }
.side .wxbig { display: flex; align-items: center; gap: 12px; margin: 10px 0 14px; font-size: 18px; }
.side .wxbig .i { font-size: 40px; }
.agenda { display: flex; flex-direction: column; gap: 8px; }
.agenda .a { text-align: left; display: grid; grid-template-columns: 84px 1fr; gap: 8px; padding: 8px 10px; border-radius: 10px; border-left: 4px solid; }
.agenda .a .t { color: var(--ink-2); font-size: 14px; }
.agenda .a b { font-weight: 700; }
.empty { color: var(--ink-3); padding: 18px; text-align: center; }

/* -------------------------------- month -------------------------------- */
.month { flex: 1; display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; min-height: 0; }
.mhead { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line); }
.mhead div { padding: 6px 10px; font-weight: 700; font-size: 13px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .6px; }
.mrows { display: grid; min-height: 0; }
.mrow { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line-2); min-height: 0; }
.mrow:last-child { border-bottom: 0; }
.mcell { border-left: 1px solid var(--line-2); padding: 4px 6px; min-width: 0; overflow: hidden; display: flex; flex-direction: column; gap: 3px; text-align: left; }
.mcell:first-child { border-left: 0; }
.mcell.other { background: rgba(239, 230, 212, .35); }
.mcell.other .mnum { color: var(--ink-3); }
.mcell .top { display: flex; align-items: center; gap: 6px; }
.mnum { font-weight: 700; font-size: 14px; }
.mcell.today .mnum { background: var(--today); color: #fff; border-radius: 999px; padding: 0 7px; }
.mcell .mw { margin-left: auto; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.mchip { flex: none; font-size: 12px; padding: 2px 6px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid; position: relative; }
.mchip .tm { color: rgba(58, 50, 43, .7); margin-right: 3px; }
.mmore { font-size: 12px; color: var(--ink-3); padding-left: 4px; }

/* -------------------------------- meals -------------------------------- */
.meals { flex: 1; display: grid; grid-template-columns: 1fr 430px; gap: 14px; min-height: 0; }
.dinners { display: flex; flex-direction: column; min-height: 0; }
.sec-title { display: flex; align-items: baseline; gap: 10px; margin: 2px 2px 10px; }
.sec-title h2 { font: 26px var(--serif); margin: 0; }
.sec-title span { color: var(--ink-3); }
.dgrid { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 1fr; gap: 10px; flex: 1; min-height: 0; }
.dcard { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; min-height: 0; text-align: left; }
.dcard .dch { padding: 7px 12px; display: flex; align-items: baseline; gap: 6px; font-weight: 700; }
.dcard .dch small { font-weight: 500; color: var(--ink-2); }
.dcard .tags { display: flex; gap: 4px; flex-wrap: wrap; }
.dcard .dcb { padding: 8px 12px 10px; display: flex; flex-direction: column; gap: 5px; flex: 1; min-height: 0; }
.dcard .meal { font: 600 18px/1.2 var(--sans); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.dcard .meal.out { text-decoration: line-through; color: var(--ink-3); }
.dcard .why { font-size: 13px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dcard .req { font-size: 13px; color: #7A5B12; background: #FBF0CF; border-radius: 8px; padding: 3px 7px; }
.dcard .foot { margin-top: auto; display: flex; gap: 6px; align-items: center; }
.dcard.tonight { border: 2px solid #E2B84B; box-shadow: 0 0 0 4px rgba(226, 184, 75, .18), var(--shadow); }
.dcard.past { opacity: .6; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--paper-2); color: var(--ink-2); text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
.tag.tonight { background: var(--today); color: #fff; }
.tag.new { background: #DDF2E4; color: #2F6E47; }
.tag.out { background: #EBE3F8; color: #5B4691; }
.linkbtn { font-size: 14px; color: var(--ink-2); text-decoration: underline; }

.grocery { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.grocery .gh { padding: 12px 14px 8px; display: flex; align-items: baseline; gap: 10px; }
.grocery .gh h2 { font: 24px var(--serif); margin: 0; }
.grocery .gh span { color: var(--ink-3); font-size: 14px; }
.lock { margin: 0 14px 8px; padding: 8px 12px; background: #EFE8DA; border-radius: 10px; font-size: 14px; color: var(--ink-2); }
.addrow { display: flex; gap: 8px; padding: 0 14px 10px; align-items: center; }
.addrow input[type=text] { flex: 1; min-width: 0; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: #fff; padding: 0 12px; font-size: 17px; }
.addrow label { display: flex; align-items: center; gap: 5px; font-size: 14px; color: var(--ink-2); white-space: nowrap; }
.addrow input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
.addbtn { height: 46px; padding: 0 18px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 700; }
.addbtn:disabled, .addrow input:disabled { opacity: .5; }
.glist { overflow-y: auto; padding: 0 8px 14px; flex: 1; -webkit-overflow-scrolling: touch; }
.ggroup { margin-top: 8px; }
.ggroup .gt { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 6px 8px; font: 600 12px var(--sans); letter-spacing: .8px; text-transform: uppercase; color: var(--ink-3); }
.ggroup.hh { background: var(--card-2); border-radius: 12px; }
.item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; min-height: 52px; }
.item + .item { border-top: 1px solid var(--line-2); }
.tog { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; font-weight: 800; color: #fff; }
.item.keep .tog { background: var(--good); border-color: var(--good); }
.item .nm { flex: 1; min-width: 0; text-align: left; }
.item .nm b { display: block; font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .nm small { color: var(--ink-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.item.cut .nm b { text-decoration: line-through; color: var(--ink-3); font-weight: 500; }
.item.cut.hhitem .nm b { text-decoration: none; }
.qty { display: flex; align-items: center; gap: 2px; flex: none; }
.qty button { width: 38px; height: 38px; border-radius: 10px; background: var(--paper-2); font-size: 20px; font-weight: 700; }
.qty span { min-width: 26px; text-align: center; font-weight: 700; }
.item.cut .qty { visibility: hidden; }
.locked .tog, .locked .qty button { pointer-events: none; }
.locked .qty button { opacity: .35; }

/* ------------------------------- overlays ------------------------------ */
.overlay { position: fixed; inset: 0; z-index: 50; }
.sheet-bg { background: rgba(40, 30, 20, .35); display: grid; place-items: center; }
.sheet { background: var(--card); border-radius: 22px; padding: 22px 24px; width: min(560px, 92vw); max-height: 92vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(40, 30, 20, .25); }
.sheet h2 { font: 26px var(--serif); margin: 0 0 6px; }
.sheet p { color: var(--ink-2); margin: 6px 0 12px; }
.sheet .field { display: block; margin: 10px 0; }
.sheet .field span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; font-weight: 600; }
.sheet .field input { width: 100%; height: 46px; border-radius: 12px; border: 1px solid var(--line); padding: 0 12px; font-size: 15px; background: #fff; }
.sheet .row { display: flex; gap: 10px; margin-top: 14px; justify-content: flex-end; flex-wrap: wrap; }
.btn { height: 46px; padding: 0 18px; border-radius: 12px; background: var(--paper-2); font-weight: 700; }
.btn.primary { background: var(--dark); color: #fff; }
.btn.danger { background: #F7D9D3; color: #9A3B2B; }
.errs { color: #9A3B2B; font-size: 14px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 14px; margin: 10px 0; }
.kv b { color: var(--ink-2); font-weight: 600; }

.cook { background: var(--paper); display: flex; flex-direction: column; }
.cook .ch { display: flex; align-items: center; gap: 14px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--card); }
.cook .ch h1 { font: 32px/1.1 var(--serif); margin: 0; flex: 1; }
.cook .ch .meta { color: var(--ink-2); font-size: 18px; white-space: nowrap; }
.wake { font-size: 14px; padding: 6px 12px; border-radius: 999px; background: #DDF2E4; color: #2F6E47; white-space: nowrap; }
.wake.no { background: #F6E2C6; color: #8A5A1C; }
.closebtn { width: 56px; height: 56px; border-radius: 50%; background: var(--dark); color: #fff; font-size: 26px; }
.cook .cb { flex: 1; overflow: hidden; display: grid; grid-template-columns: 0.85fr 1.15fr; gap: 18px; padding: 16px 24px; min-height: 0; }
.cook .colx { overflow-y: auto; min-height: 0; -webkit-overflow-scrolling: touch; padding-bottom: 30px; }
.cook h2 { font: 24px var(--serif); margin: 4px 0 10px; display: flex; gap: 10px; align-items: baseline; }
.cook h2 small { font: 15px var(--sans); color: var(--ink-3); }
.notes { background: #FBF0CF; border-radius: 14px; padding: 12px 16px; font-size: 19px; margin-bottom: 14px; color: #5E4710; }
.ing, .step { display: flex; gap: 14px; align-items: flex-start; width: 100%; text-align: left; padding: 11px 12px; border-radius: 12px; font-size: 22px; line-height: 1.35; }
.ing + .ing, .step + .step { border-top: 1px solid var(--line-2); }
.ing .bx { width: 30px; height: 30px; border-radius: 8px; border: 2px solid var(--ink-3); flex: none; margin-top: 2px; display: grid; place-items: center; font-size: 18px; color: #fff; }
.ing.done .bx { background: var(--good); border-color: var(--good); }
.ing.done span, .step.done span { text-decoration: line-through; color: var(--ink-3); }
.ing.head { font: 600 14px var(--sans); color: var(--ink-3); text-transform: uppercase; letter-spacing: .8px; padding: 14px 12px 4px; }
.step .n { width: 38px; height: 38px; border-radius: 50%; background: var(--dark); color: #fff; display: grid; place-items: center; flex: none; font-weight: 700; font-size: 18px; }
.step.done .n { background: var(--good); }
.cook .cf { display: flex; gap: 12px; align-items: center; padding: 6px 0 0; flex-wrap: wrap; }

.night { background: #0E0C0A; color: #8C7F70; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; cursor: pointer; }
.night .nclock { font: 300 150px/1 var(--serif); color: #A29483; letter-spacing: -3px; }
.night .nclock small { font-size: 36px; letter-spacing: 0; margin-left: 6px; }
.night .ndate { font: 28px var(--serif); }
.night .nnext { font-size: 18px; color: #6F6458; }
.night .nhint { position: absolute; bottom: 24px; font-size: 14px; color: #4F473F; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--dark); color: #fff; padding: 12px 20px; border-radius: 14px; z-index: 80; font-size: 16px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.pop { position: fixed; z-index: 60; background: var(--card); border-radius: 16px; padding: 14px 18px; box-shadow: 0 12px 40px rgba(40, 30, 20, .25); width: 320px; border-left: 6px solid; }
.pop b { font-size: 18px; display: block; margin-bottom: 4px; }
.pop div { color: var(--ink-2); }
.sheet .field input.secret { -webkit-text-security: disc; }
