* { box-sizing: border-box; }
body {
  background: var(--paper); color: var(--ink);
  font-family: var(--font-body); font-size: 15px; line-height: 1.45;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.wrap {
  max-width: 980px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-block: 14px 10px; }
.brand { display: flex; align-items: baseline; gap: 10px; margin-right: auto; }
.brand h1 { font-family: var(--font-display); font-weight: 800; font-size: 26px; letter-spacing: -0.02em; margin: 0; }
.brand .url { font-family: var(--font-num); font-size: 12px; color: var(--muted); }
.who { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.who .dot { width: 26px; height: 26px; border-radius: 50%; background: #0082C9; color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 12px; }

.modes { display: inline-flex; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.modes button { border: 0; background: transparent; padding: 7px 14px; border-radius: 7px; font-weight: 600; cursor: pointer; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.modes button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.modes .count { font-family: var(--font-num); font-size: 11px; background: var(--tag); color: var(--tag-ink); padding: 0 6px; border-radius: 4px; }

.bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding-block: 0 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1 1 auto; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--surface); }
#search { flex: 0 1 220px; min-width: 0; border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 6px 10px; }

.tagbar { align-items: flex-start; }
.barlabel { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding-top: 3px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 auto; }
.name .tags { margin-top: 4px; }
.tag { border: 0; background: var(--paper); color: var(--muted); font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 4px; cursor: pointer; }
.tag::before { content: "#"; opacity: .6; }
.tag:hover { color: var(--ink); }
.tag[aria-pressed="true"] { background: var(--tag); color: var(--tag-ink); }
.groupby { display: flex; align-items: center; gap: 4px; }
.groupby button { border: 1px solid var(--line); background: var(--surface); font-size: 12px; padding: 3px 10px; border-radius: 6px; cursor: pointer; }
.groupby button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.listwrap { position: relative; }
.listbtn { border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 4px 10px; font-weight: 600; cursor: pointer; }
.listbtn .people { font-weight: 400; color: var(--muted); font-size: 12px; }
.panel { position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; width: min(340px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgb(0 0 0 / .18);
  display: flex; flex-direction: column; }
.panelsec { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-top: 1px solid var(--line); }
.panelsec:first-child { border-top: 0; }
.switch { text-align: left; border: 1px solid var(--line); background: var(--paper); border-radius: 6px; padding: 6px 10px; cursor: pointer; }
.showzero { display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 0 14px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; font-weight: 600; cursor: pointer; }
.showzero input { width: 24px; height: 24px; accent-color: var(--accent); }
.switch[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.member { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.member .del { margin-left: auto; }
.dot.small, .member .dot { width: 22px; height: 22px; border-radius: 50%; background: #0082C9; color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 600; }
.shareform { display: flex; gap: 6px; }
.shareform input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--paper); border-radius: 6px; padding: 5px 8px; }
.linkbtn { border: 0; background: none; color: var(--short); font-size: 13px; cursor: pointer; text-align: left; padding: 0; }
.hint { margin: 0; font-size: 12px; color: var(--muted); }
.emptytitle { font-family: var(--font-display); font-size: 20px; color: var(--ink); text-transform: none; letter-spacing: 0; justify-content: center; }
.empty p { max-width: 46ch; margin: 0 auto 14px; }
.star { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; padding: 0 6px 0 0; line-height: 1; }
.star[aria-pressed="true"] { color: var(--tag); }
.chip.fav[aria-pressed="true"] { background: var(--tag); color: var(--tag-ink); border-color: var(--tag); }
.sortlabel { display: flex; align-items: center; gap: 6px; padding-top: 0; }
.sortlabel select { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 2px 6px; font-size: 12px; text-transform: none; letter-spacing: 0; color: var(--ink); }
/* ---- touch-first sizing: every tap target is at least 44px ---- */
.filters { display: grid; grid-template-columns: minmax(180px, 1.4fr) repeat(4, minmax(0, 1fr)) auto; gap: 8px; padding-block: 0 12px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); min-width: 0; }
.field select, #search { height: 44px; border: 1px solid var(--line); background: var(--paper); border-radius: 10px; padding: 0 10px;
  font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--ink); width: 100%; min-width: 0; }
#search { flex: none; }
.favtoggle { height: 44px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 0 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.favtoggle[aria-pressed="true"] { background: var(--tag); color: var(--tag-ink); border-color: var(--tag); }
.modes button { min-height: 40px; }
.step { height: 44px; border-radius: 10px; }
.step button { width: 44px; height: 44px; font-size: 22px; }
.step output { min-width: 34px; font-size: 16px; }
.star { width: 36px; height: 36px; font-size: 22px; padding: 0; }
.row { min-height: 60px; }
input[type="checkbox"] { width: 28px; height: 28px; }
.shop .row label { cursor: pointer; }
.btn { min-height: 44px; border-radius: 10px; padding: 0 18px; }
.del { width: 40px; height: 40px; }
.listbtn { min-height: 40px; }
.shareform input { height: 44px; }
.changed { color: var(--accent) !important; }
.grouphead { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.grouphead h2 { margin: 0; }
.groupactions { display: flex; gap: 4px; margin-left: auto; }
.iconbtn { min-width: 44px; height: 44px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 0 12px; font-weight: 600; cursor: pointer; color: var(--accent); }
.iconbtn.danger { color: var(--muted); }
.iconbtn.danger:hover { color: var(--short); background: var(--short-soft); }
.empty.small { padding: 14px; font-size: 14px; }
.modal { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); padding: 20px; width: min(420px, calc(100vw - 32px)); }
.modal::backdrop { background: rgb(0 0 0 / .45); }
.modal form { display: flex; flex-direction: column; gap: 12px; }
.modal p { margin: 0; color: var(--muted); }
.mtitle { font-family: var(--font-display); font-size: 20px; margin: 0; }
.mfield { display: flex; flex-direction: column; gap: 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.mfield input, .mfield select { height: 48px; border: 1px solid var(--line); background: var(--paper); border-radius: 10px; padding: 0 12px; font-size: 16px; color: var(--ink); text-transform: none; letter-spacing: 0; }
.mbuttons { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.mbuttons .btn { min-height: 48px; }
.dangerbtn { background: var(--short); border-color: var(--short); color: #fff; }
.collapse { border: 0; background: none; font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer;
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 8px 0 0; }
.collapse .chev { display: inline-block; transition: transform .15s; font-size: 14px; }
.collapse[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.prio-thinking { --prio: var(--prio-thinking); }
.prio-delayed { --prio: var(--prio-delayed); }
.prio-want { --prio: var(--prio-want); }
.prio-planned { --prio: var(--prio-planned); }
.prio-critical { --prio: var(--prio-critical); }
.row[class*="prio-"] { box-shadow: inset 4px 0 0 var(--prio); }
.row.prio-thinking .name { color: var(--muted); }
.row.prio-critical { background: color-mix(in srgb, var(--prio-critical) 7%, var(--surface)); }
.prio { display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; vertical-align: 2px;
  color: var(--prio); background: color-mix(in srgb, var(--prio) 14%, transparent); border: 1px solid color-mix(in srgb, var(--prio) 40%, transparent); }
.prio-thinking.prio { border-style: dashed; }
.note-text a { color: var(--accent); word-break: break-all; }
.selects { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.prioselect { color: var(--prio) !important; font-weight: 600; }
.name { display: flex; align-items: flex-start; gap: 2px; }
.opener { flex: 1; min-width: 0; cursor: pointer; border-radius: 8px; padding: 4px 6px; margin: -4px 0; }
.opener:hover { background: var(--paper); }
.itemname { font-weight: 500; }
.opener .note-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.opener .tag { cursor: pointer; }
.mview { display: flex; flex-direction: column; gap: 10px; }
.mhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mhead .iconbtn { height: 36px; min-width: 0; font-size: 13px; }
.mmeta { font-size: 13px; color: var(--muted); font-family: var(--font-num); }
.mpills .prio { margin-left: 0; }
.mnote { background: var(--paper); border-radius: 10px; padding: 10px 12px; max-height: 40vh; overflow: auto; }
.mnote .note-text { display: block; font-size: 15px; color: var(--ink); white-space: pre-wrap; }
.modal .tags .tag { font-size: 14px; padding: 8px 12px; min-height: 40px; }
.mfield textarea { border: 1px solid var(--line); background: var(--paper); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--ink); resize: vertical; text-transform: none; letter-spacing: 0; }
.tagfield-wrap { display: flex; flex-direction: column; gap: 6px; text-transform: none; letter-spacing: 0; }
.taginput { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 48px; border: 1px solid var(--line); background: var(--paper); border-radius: 10px; padding: 6px 8px; cursor: text; }
.taginput:focus-within { border-color: var(--accent); }
.tagchip { display: inline-flex; align-items: center; gap: 2px; background: var(--tag); color: var(--tag-ink); border-radius: 999px; padding-left: 10px; font-size: 14px; font-weight: 600; }
.tagchip button { border: 0; background: transparent; color: inherit; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 16px; }
.tagchip button:hover { background: rgb(0 0 0 / .12); }
.mfield .taginput input.tagtyping { flex: 1; min-width: 8em; height: 34px; border: 0; background: transparent; padding: 0 4px; font-size: 16px; }
.suggest { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-top: -6px; max-height: 260px; overflow-y: auto; text-transform: none; letter-spacing: 0; }
.tagfield-wrap .suggest { margin-top: 0; }
.sug { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 48px; padding: 6px 12px; border: 0; border-top: 1px solid var(--line); background: var(--surface); text-align: left; cursor: pointer; font-size: 15px; color: var(--ink); }
.sug:first-child { border-top: 0; }
.sug:hover { background: var(--paper); }
.sug small { display: block; color: var(--muted); font-size: 12px; }
.have { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.have.yes { background: var(--ok-soft); color: var(--ok); }
.have.zero { background: var(--short-soft); color: var(--short); }
.have.new { color: var(--muted); border: 1px dashed var(--line); }
main { padding-block: 18px 60px; display: flex; flex-direction: column; gap: 22px; }
.summary { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; color: var(--muted); align-items: center; }
.summary b { font-family: var(--font-num); color: var(--ink); font-size: 18px; }
.summary .spacer { margin-left: auto; }
.btn { border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); border-radius: 8px; padding: 7px 14px; font-weight: 600; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn:disabled { opacity: .4; cursor: default; }

section h2 {
  font-family: var(--font-display); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 0 0 6px; display: flex; gap: 8px; align-items: baseline;
}
section h2 span { font-family: var(--font-num); font-size: 12px; letter-spacing: 0; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.row { display: grid; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row.head { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding-block: 6px; background: var(--paper); }
.stock .row { grid-template-columns: 1fr 140px 60px 110px; }
.shop  .row { grid-template-columns: 32px 1fr 140px 160px; }
.edit  .row { grid-template-columns: 1fr 140px 136px 136px 136px 40px; }
.row.in-cart .name { text-decoration: line-through; color: var(--muted); }
.name { font-weight: 500; min-width: 0; }
.name small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.num-label { display: none; }

.step { display: inline-flex; align-items: center; background: var(--tag); color: var(--tag-ink); border-radius: 6px; font-family: var(--font-num); font-weight: 700; height: 30px; }
.step button { border: 0; background: transparent; color: inherit; width: 28px; height: 30px; cursor: pointer; font-size: 16px; line-height: 1; }
.step button:disabled { opacity: .3; cursor: not-allowed; }
.step output { min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; }
.step.plain { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.minval { font-family: var(--font-num); color: var(--muted); font-variant-numeric: tabular-nums; }

.pill { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; justify-self: start; white-space: nowrap; }
.pill.short { background: var(--short-soft); color: var(--short); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.none { color: var(--muted); border: 1px dashed var(--line); }
.why { font-size: 12px; color: var(--muted); }
.why b { color: var(--short); font-weight: 600; }

input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
.edit input.text, .edit select {
  width: 100%; min-width: 0; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 5px 7px;
}
.edit input.text:hover, .edit select:hover { border-color: var(--line); }
.del { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; border-radius: 6px; }
.del:hover { color: var(--short); background: var(--short-soft); }


.empty { padding: 30px 14px; text-align: center; color: var(--muted); }
.note { font-size: 12px; color: var(--muted); border-left: 3px solid var(--tag); padding: 4px 10px; max-width: 70ch; }
#toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 9px 16px; border-radius: 8px; font-size: 14px; max-width: calc(100% - 32px); }

@media (max-width: 900px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #search { grid-column: 1 / -1; }
  .favtoggle { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  body { font-size: 16px; }
  .field select, #search, .shareform input, .edit input.text, .modal input, .modal select { font-size: 16px; }
  .modes { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; border-radius: 0; border-width: 1px 0 0; background: var(--surface);
    padding: 6px max(10px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px)); }
  .modes button { flex: 1; justify-content: center; min-height: 54px; font-size: 15px; }
  main { padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px)); }
  #toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  .who { display: none; }
  .summary .spacer { display: none; }
  #checkout { width: 100%; min-height: 54px; font-size: 16px; }
  .shop .row { grid-template-columns: 32px 1fr auto; }

  .row.head { display: none; }
  .stock .row, .shop .row, .edit .row { grid-template-columns: 1fr auto; }
  .shop .row { grid-template-columns: 32px 1fr auto; }
  .shop .row .why { grid-column: 2 / -1; }
  .edit .row { grid-template-columns: 1fr 1fr; }
  .edit .row .name-cell { grid-column: 1 / -1; }
  .num-label { display: inline; font-size: 11px; color: var(--muted); margin-right: 6px; text-transform: uppercase; letter-spacing: .06em; }
}
@media (prefers-reduced-motion: no-preference) { .row { transition: background .15s; } }
/* Phones: larger tap targets everywhere, same rows and information. */
@media (max-width: 700px) {
  .step { height: 50px; }
  .step button { width: 50px; height: 50px; font-size: 24px; }
  .step output { min-width: 36px; font-size: 17px; }
  .star { width: 44px; height: 44px; font-size: 24px; }
  input[type="checkbox"] { width: 34px; height: 34px; }
  .shop .row { grid-template-columns: 40px 1fr auto; }
  .field select, #search, .favtoggle { height: 50px; }
  .iconbtn { min-width: 50px; height: 50px; font-size: 16px; }
  .collapse { min-height: 50px; }
  .del { width: 50px; height: 50px; font-size: 22px; }
  .btn { min-height: 50px; font-size: 16px; }
  .listbtn { min-height: 46px; }
  .modes button { min-height: 58px; font-size: 16px; }
  main { padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px)); }
  .mfield input, .mfield select, .shareform input { height: 52px; }
  .mbuttons .btn { min-height: 54px; flex: 1; }
  .mhead .iconbtn { height: 44px; padding: 0 16px; }
  .modal .tags .tag { min-height: 46px; padding: 10px 14px; }
  .tagchip { font-size: 15px; }
  .tagchip button { width: 40px; height: 40px; font-size: 18px; }
  .sug { min-height: 56px; }
  .switch { min-height: 48px; }
  .edit .row select { height: 46px; }
}

/* ---- additions for the real app ---- */
[hidden] { display: none !important; }
body { margin: 0; }
.who a { color: var(--accent); font-weight: 600; text-decoration: none; margin-left: 4px; }
.who a:hover { text-decoration: underline; }
.account { font-size: 13px; color: var(--muted); }
.starterlist { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; overflow-y: auto; max-height: 45vh; }
.starterrow { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 12px; border-top: 1px solid var(--line); font-size: 15px; color: var(--ink); text-transform: none; letter-spacing: 0; }
.starterrow:first-child { border-top: 0; }
.starterrow label { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
.starterrow .have { margin-left: auto; }
.confirmask { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.starterrow .confirmask .iconbtn { height: 36px; min-width: 0; font-size: 13px; }
.starteradd { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.mbuttons { flex-wrap: wrap; }
.iconbtn:disabled { opacity: .6; cursor: default; }
.starterrow small { display: block; color: var(--muted); font-size: 12px; }
.summary .under { color: var(--short); }
.who .linkbtn { color: var(--accent); font-weight: 600; }
