:root {
  --bg: #f6f7f9; --card: #fff; --ink: #16181d; --muted: #5d6470; --line: #e2e5ea;
  --blue: #1f4fd1; --blue-soft: #e8eefc; --yellow: #b88a00; --yellow-soft: #fff6d6; --red: #c62828; --red-soft: #fdeaea;
  --radius: 12px; --tabh: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 1.5rem; margin: .2rem 0 .8rem; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.1rem 0 .4rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: .85rem; }

/* layout: tabs at the bottom on phones, at the top on wide screens */
.top { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 1rem; padding: .55rem 1rem; }
.brand { font-weight: 700; color: var(--blue); }
.tabs { display: flex; gap: .25rem; margin-left: auto; }
.tabs a { text-decoration: none; color: var(--muted); padding: .45rem .8rem; border-radius: 999px; font-weight: 600; }
.tabs a.on { background: var(--blue-soft); color: var(--blue); }
main { max-width: 760px; margin: 0 auto; padding: 1rem 1rem 2rem; }
@media (max-width: 700px) {
  .top { justify-content: center; }
  .tabs { position: fixed; bottom: 0; left: 0; right: 0; margin: 0; background: var(--card); border-top: 1px solid var(--line);
    height: calc(var(--tabh) + env(safe-area-inset-bottom)); padding: 0 .3rem env(safe-area-inset-bottom); justify-content: space-around; align-items: center; }
  .tabs a { flex: 1; text-align: center; padding: .6rem .2rem; font-size: .9rem; }
  main { padding-bottom: calc(var(--tabh) + 2rem + env(safe-area-inset-bottom)); }
}

/* building blocks */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.stack > * + * { margin-top: .6rem; }
.row { display: flex; gap: .5rem; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: .55rem .9rem; cursor: pointer;
  font-weight: 600; text-decoration: none; display: inline-block; color: var(--ink); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.btn:disabled { opacity: .5; }
input[type=text], input[type=url], input:not([type]), select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; background: var(--card); }
textarea { min-height: 12rem; resize: vertical; }
select { appearance: auto; }
.chip { display: inline-block; font-size: .75rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px;
  background: #eef0f3; color: var(--muted); }
.chip.good { background: var(--blue-soft); color: var(--blue); }
.chip.warn { background: var(--yellow-soft); color: #7a5b00; }
.chip.bad { background: var(--red-soft); color: var(--red); }
.warn { background: var(--yellow-soft); border: 1px solid #f0d675; border-radius: 10px; padding: .6rem .8rem; color: #5c4400; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--card); padding: .35rem .65rem; font-size: .85rem; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on.good { background: var(--blue); color: #fff; }
.seg button.on.warn { background: #f2c94c; color: #3b2c00; }
.seg button.on.bad { background: var(--red); color: #fff; }
.seg button.on.neutral { background: #5d6470; color: #fff; }

/* week */
.weekbar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.weekbar h1 { margin: 0; text-align: center; flex: 1; }
.night { display: grid; grid-template-columns: 3.6rem 1fr; gap: .7rem; padding: .75rem 0; border-top: 1px solid var(--line); }
.night:first-child { border-top: 0; }
.night .day b { display: block; }
.night .day span { font-size: .8rem; color: var(--muted); }
.night .today b { color: var(--blue); }
.night .links { margin-top: .35rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.rate { margin-top: .45rem; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .7rem; }
.opt { display: flex; flex-direction: column; text-decoration: none; color: inherit; padding: 0; overflow: hidden; }
.opt img, .opt .ph { width: 100%; height: 120px; object-fit: cover; background: #eef0f3; display: block; }
.opt .ph { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .85rem; }
.opt .body { padding: .6rem .75rem .8rem; }
.opt .t { font-weight: 700; }
.opt .s { font-size: .88rem; color: var(--muted); margin-top: .2rem; }
.opt .why { font-size: .82rem; margin-top: .35rem; }

/* list */
.summary { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .4rem; }
.progress { height: 6px; background: #e7eaef; border-radius: 99px; overflow: hidden; margin-top: .5rem; }
.progress i { display: block; height: 100%; background: var(--blue); }
.line { display: grid; grid-template-columns: 1.6rem 52px 1fr; gap: .6rem; align-items: center; padding: .55rem 0;
  border-top: 1px solid var(--line); cursor: pointer; }
.line input { width: 1.3rem; height: 1.3rem; accent-color: var(--blue); }
.line .thumb { width: 52px; height: 52px; object-fit: contain; border-radius: 8px; background: #fff; border: 1px solid var(--line); }
.line .thumb.none { display: flex; align-items: center; justify-content: center; font-size: .7rem; color: var(--muted); text-align: center; }
.line .n { font-weight: 650; }
.line .q { color: var(--muted); font-size: .88rem; }
.line .f { color: var(--muted); font-size: .8rem; }
.line .note { font-size: .8rem; color: #5c4400; }
.line.done .n, .line.done .q { text-decoration: line-through; color: #9aa0aa; }
.line.done .thumb { opacity: .45; }
details summary { cursor: pointer; font-weight: 650; padding: .4rem 0; }
.addrow { display: flex; gap: .5rem; }
.addrow input { flex: 1; }

/* recipe detail */
.hero { width: 100%; max-height: 260px; object-fit: cover; border-radius: var(--radius); background: #fff; }
.recipe ol, .recipe ul { padding-left: 1.3rem; }
.recipe li { margin: .35rem 0; }
.tip { border-left: 4px solid var(--blue); background: var(--blue-soft); padding: .55rem .8rem; border-radius: 0 10px 10px 0; margin: .6rem 0; }
.filters { display: flex; gap: .4rem; flex-wrap: wrap; margin: .8rem 0; }
.filters button { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: .3rem .75rem; font-weight: 600; cursor: pointer; }
.filters button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* simple list rows */
.item { display: flex; align-items: center; gap: .6rem; padding: .55rem 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.x { border: 0; background: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: .2rem .45rem; }
table.spend { width: 100%; border-collapse: collapse; }
table.spend td, table.spend th { padding: .45rem .3rem; border-top: 1px solid var(--line); text-align: left; }
table.spend th { font-size: .8rem; color: var(--muted); }
table.spend td.num { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: var(--blue); border-radius: 4px; }

.signin { max-width: 380px; margin: 18vh auto 0; text-align: center; padding: 1rem; }
.signin h1 { font-size: 2rem; color: var(--blue); }
.signin .btn { margin-top: 1rem; padding: .8rem 1.2rem; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabh) + 1rem + env(safe-area-inset-bottom));
  background: var(--ink); color: #fff; padding: .55rem .9rem; border-radius: 10px; font-size: .9rem; opacity: 0;
  transition: opacity .2s; pointer-events: none; max-width: 90vw; z-index: 20; }
#toast.show { opacity: .95; }
#toast.err { background: var(--red); }
