  /* Layout: a subway platform. White-tile wall, a black station sign up top with a yellow platform-edge strip, MTA-green vote buttons, and a sign-style tab bar. Cards update in place so votes animate instead of redrawing. */
  :root {
    --bg: #f3f3f0;
    --grout: #dcdcd6;
    --surface: #ffffff;
    --tint: #ececE6;
    --fg: #111111;
    --muted: #55565a;
    --line: #cfcfc9;
    --sign: #111111;
    --sign-fg: #ffffff;
    --platform: #fccc0a;
    --platform-fg: #111111;
    --vote: #00933c;
    --vote-fg: #ffffff;
    --accent: #0039a6;
    --shadow: 0 2px 0 rgba(17, 17, 17, .9);
    --font: "Helvetica Neue", Helvetica, "Arimo", Arial, sans-serif;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #0f1012; --grout: #1a1b1e; --surface: #1a1b1f; --tint: #26272c; --fg: #f4f4f2; --muted: #a6a7ad; --line: #34353b;
      --sign: #26272c; --sign-fg: #ffffff; --vote: #2fbf6a; --vote-fg: #08150d; --accent: #6f9bff;
      --shadow: 0 2px 0 rgba(244, 244, 242, .85);
      color-scheme: dark;
    }
  }
  :root[data-theme="dark"] {
    --bg: #0f1012; --grout: #1a1b1e; --surface: #1a1b1f; --tint: #26272c; --fg: #f4f4f2; --muted: #a6a7ad; --line: #34353b;
    --sign: #26272c; --sign-fg: #ffffff; --vote: #2fbf6a; --vote-fg: #08150d; --accent: #6f9bff;
    --shadow: 0 2px 0 rgba(244, 244, 242, .85);
    color-scheme: dark;
  }
  body {
    margin: 0;
    background-color: var(--bg);
    background-image: linear-gradient(var(--grout) 2px, transparent 2px), linear-gradient(90deg, var(--grout) 2px, transparent 2px);
    background-size: 72px 36px;
    color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.4;
  }
  .wrap { max-width: 780px; margin: 0 auto; padding: 20px 16px 64px; display: flex; flex-direction: column; gap: 24px; }

  .station { background: var(--sign); color: var(--sign-fg); border-radius: 14px 14px 0 0; padding: 22px 20px 18px; border: 2px solid var(--fg); border-bottom: 0; }
  h1 { font-weight: 700; font-size: clamp(38px, 11vw, 68px); line-height: 1; letter-spacing: -.02em; margin: 0; text-wrap: balance; }
  .sub { margin: 10px 0 0; color: var(--sign-fg); opacity: .8; }
  .edge { height: 18px; border: 2px solid var(--fg); border-top: 0; border-radius: 0 0 14px 14px; background: repeating-linear-gradient(135deg, var(--platform) 0 14px, #111 14px 28px); }

  h2 { margin: 0; font-weight: 700; font-size: 20px; letter-spacing: -.01em; }
  h2.bar { display: inline-block; background: var(--sign); color: var(--sign-fg); padding: 6px 14px; border-radius: 8px; border: 2px solid var(--fg); }
  .sechead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
  .meter { font-weight: 700; font-variant-numeric: tabular-nums; background: var(--surface); border: 2px solid var(--fg); border-radius: 999px; padding: 3px 12px; font-size: 13px; }
  .meter:empty { display: none; }
  .banner { background: var(--platform); color: var(--platform-fg); border: 2px solid var(--fg); border-radius: 10px; padding: 10px 14px; font-weight: 700; }

  .menu { background: var(--surface); border: 2px solid var(--fg); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); }
  .menulist { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
  .row { display: grid; grid-template-columns: 38px 1fr auto; gap: 12px; align-items: center; will-change: transform; }
  .rank { width: 36px; height: 36px; border-radius: 50%; background: var(--sign); color: var(--sign-fg); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; border: 2px solid var(--fg); box-sizing: border-box; }
  .row:first-child .rank { background: var(--platform); color: var(--platform-fg); }
  .rname { font-weight: 700; font-size: 17px; overflow-wrap: anywhere; }
  .bar2 { height: 8px; border-radius: 4px; background: var(--grout); margin-top: 5px; overflow: hidden; }
  .bar2 i { display: block; height: 100%; width: 0; background: var(--vote); transition: width .5s cubic-bezier(.2,.8,.2,1); }
  .count { font-weight: 700; font-size: 26px; font-variant-numeric: tabular-nums; min-width: 1.2em; text-align: right; display: inline-block; }
  .count.bump { animation: bump .4s cubic-bezier(.3,1.6,.5,1); }
  .empty { color: var(--muted); margin: 6px 0 0; }
  .copyrow { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

  .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 236px), 1fr)); gap: 14px; }
  .card { position: relative; display: flex; flex-direction: column; gap: 9px; background: var(--surface); border: 2px solid var(--fg); border-radius: 14px; padding: 14px 14px 14px; min-width: 0; box-shadow: var(--shadow); transition: box-shadow .25s ease, border-color .25s ease, transform .25s ease; }
  .card:hover { transform: translateY(-2px); }
  .card.enter { animation: deal .5s cubic-bezier(.2,.8,.2,1) both; animation-delay: var(--d, 0ms); }
  .card.mine { box-shadow: 0 0 0 3px var(--vote), var(--shadow); border-color: var(--vote); }
  .ctop { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .tag { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--sign-fg); background: var(--sign); padding: 3px 9px; border-radius: 4px; }
  .mname { font-weight: 700; font-size: 22px; line-height: 1.1; letter-spacing: -.01em; overflow-wrap: anywhere; }
  .desc { font-size: 13px; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }
  .who { font-size: 12px; color: var(--muted); min-height: 1.3em; overflow-wrap: anywhere; }
  .cardfoot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: nowrap; }
  .tally { font-weight: 700; font-variant-numeric: tabular-nums; display: inline-block; }
  .tally.bump { animation: bump .4s cubic-bezier(.3,1.6,.5,1); }
  button.pop { animation: pop .38s cubic-bezier(.3,1.6,.5,1); }
  @keyframes deal { from { transform: translateY(22px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
  @keyframes pop { 0% { transform: scale(.9); } 55% { transform: scale(1.12); } 100% { transform: scale(1); } }
  @keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 100% { transform: scale(1); } }

  .swaprow { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: -2px 0 14px; }
  button { font-family: var(--font); font-weight: 700; font-size: 15px; color: var(--fg); background: var(--surface); border: 2px solid var(--fg); border-radius: 999px; padding: 9px 16px; cursor: pointer; transition: background-color .2s ease, color .2s ease, border-color .2s ease, transform .15s ease, opacity .2s ease; }
  button:hover:not(:disabled) { background: var(--tint); }
  button:active:not(:disabled) { transform: scale(.95); }
  button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
  button:disabled { opacity: .4; cursor: default; }
  button.vote[aria-pressed="true"] { background: var(--vote); color: var(--vote-fg); border-color: var(--vote); }
  button.vote[aria-pressed="true"]::before { content: "\2713\00a0"; }
  button.primary { background: var(--platform); color: var(--platform-fg); }
  button.primary:hover:not(:disabled) { background: #ffd93a; }

  .tools { display: flex; flex-direction: column; gap: 12px; background: var(--surface); border: 2px solid var(--fg); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); }
  .controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; }
  .field { display: flex; flex-direction: column; gap: 4px; }
  label.f { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .aisle { margin: 20px 0 10px; }
  .aisle h3 { display: inline-block; margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; background: var(--sign); color: var(--sign-fg); padding: 4px 12px; border-radius: 4px; }
  .shopitem { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); cursor: pointer; transition: opacity .2s ease; }
  .shopitem input { width: 22px; height: 22px; flex: none; accent-color: var(--vote); }
  .shopitem .si { flex: 1; min-width: 0; }
  .shopitem .sn { font-weight: 700; overflow-wrap: anywhere; transition: color .2s ease; }
  .shopitem .sm { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
  .shopitem .sq { font-weight: 700; font-size: 13px; background: var(--platform); color: var(--platform-fg); border-radius: 999px; padding: 2px 10px; white-space: nowrap; }
  .shopitem:has(input:checked) { opacity: .45; }
  .shopitem:has(input:checked) .sn { text-decoration: line-through; }
  input[type="number"] { width: 84px; }
  input[type="number"], input[type="text"], select { font: inherit; font-size: 16px; color: var(--fg); background: var(--bg); border: 2px solid var(--fg); border-radius: 8px; padding: 8px 10px; box-sizing: border-box; }
  input[type="text"] { width: min(100%, 320px); }
  .status { margin: 0; min-height: 1.3em; color: var(--muted); overflow-wrap: anywhere; }
  .hint { margin: 0; color: var(--muted); }
  details summary { cursor: pointer; font-weight: 700; }
  .pool { margin: 10px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
  .pool li { font-size: 13px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; }
  textarea.copybox { width: 100%; box-sizing: border-box; font: inherit; font-size: 13px; color: var(--fg); background: var(--bg); border: 2px solid var(--fg); border-radius: 8px; padding: 8px; margin-top: 8px; }
  .pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 136px), 1fr)); gap: 12px; }
  .prod { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 2px solid var(--fg); border-radius: 12px; overflow: hidden; cursor: pointer; min-width: 0; box-shadow: var(--shadow); transition: transform .2s ease; }
  .prod:hover { transform: translateY(-2px); }
  .prod input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 3; }
  .prod:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
  /* One square frame for every photo: larger or oddly shaped pictures are cropped to fill it, centered. */
  .pphoto { position: relative; box-sizing: border-box; aspect-ratio: 1 / 1; width: 100%; overflow: hidden; background: #fff; display: flex; align-items: center; justify-content: center; border-bottom: 2px solid var(--fg); }
  .pphoto img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; transition: opacity .2s ease, filter .2s ease; }
  .pphoto.none { background: repeating-linear-gradient(135deg, var(--grout) 0 10px, var(--bg) 10px 20px); }
  .pnone { font-weight: 700; font-size: 17px; color: var(--muted); text-align: center; text-transform: uppercase; letter-spacing: .06em; padding: 8px; }
  .pstrip { background: var(--sign); color: var(--sign-fg); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; text-align: center; padding: 6px 4px; }
  .pqty { position: absolute; left: 8px; top: 8px; z-index: 2; background: var(--platform); color: var(--platform-fg); font-weight: 700; font-size: 14px; line-height: 1; padding: 5px 9px; border-radius: 999px; border: 2px solid var(--fg); max-width: calc(100% - 52px); box-sizing: border-box; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ptick { position: absolute; right: 8px; top: 8px; z-index: 2; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--fg); background: var(--surface); display: flex; align-items: center; justify-content: center; transition: background-color .2s ease, border-color .2s ease, transform .2s cubic-bezier(.3,1.6,.5,1); }
  .ptick svg { width: 15px; height: 15px; stroke: #fff; stroke-width: 3.5; fill: none; opacity: 0; transition: opacity .2s ease; }
  .pinfo { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; transition: opacity .2s ease; }
  .pbrand { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
  .pname { font-weight: 700; font-size: 14px; line-height: 1.25; overflow-wrap: anywhere; }
  .pmeta { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
  .prod:has(input:checked) .pphoto img { opacity: .22; filter: grayscale(1); }
  .prod:has(input:checked) .ptick { background: var(--vote); border-color: var(--vote); transform: scale(1.12); }
  .prod:has(input:checked) .ptick svg { opacity: 1; }
  .prod:has(input:checked) .pinfo { opacity: .55; }
  .prod:has(input:checked) .pname { text-decoration: line-through; }
  .need { margin-top: 14px; padding: 12px 14px; border: 2px dashed var(--fg); border-radius: 12px; display: flex; flex-direction: column; gap: 8px; }
  .need .hint { color: var(--fg); }
  @media (prefers-reduced-motion: reduce) {
    .card.enter, .tally.bump, .count.bump, button.pop { animation: none; }
    .bar2 i, .card, button, .prod, .ptick { transition: none; }
  }

  /* ---- standalone app additions */
  .who-chip { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--sign-fg); opacity: .85; }
  .who-chip button { font-size: 12px; padding: 3px 10px; background: transparent; color: var(--sign-fg); border-color: var(--sign-fg); }
  .who-chip button:hover:not(:disabled) { background: rgba(255, 255, 255, .15); }
  dialog { border: 2px solid var(--fg); border-radius: 14px; background: var(--surface); color: var(--fg); padding: 22px; width: min(92vw, 420px); }
  dialog::backdrop { background: rgba(0, 0, 0, .55); }
  dialog h2 { margin-bottom: 6px; }
  dialog form { display: flex; flex-direction: column; gap: 12px; }
  dialog input[type="text"], dialog input[type="password"], dialog input[type="file"] { width: 100%; box-sizing: border-box; font: inherit; font-size: 16px; color: var(--fg); background: var(--bg); border: 2px solid var(--fg); border-radius: 8px; padding: 8px 10px; }
  dialog .row2 { display: flex; gap: 10px; flex-wrap: wrap; }
  dialog p { margin: 0; color: var(--muted); }
  .addphoto { margin-top: 6px; align-self: flex-start; font-size: 13px; padding: 5px 12px; }
  .toast { position: fixed; left: 50%; transform: translateX(-50%); background: var(--sign); color: var(--sign-fg); border: 2px solid var(--fg); border-radius: 999px; padding: 9px 18px; font-weight: 700; z-index: 20; max-width: 90vw; text-align: center; bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
  .busy { color: var(--muted); font-weight: 700; }

  button.danger { background: transparent; color: var(--fg); border-style: dashed; }
  button.danger:hover:not(:disabled) { border-color: #ee352e; color: #ee352e; background: transparent; }

  /* ---- phase tabs: one section at a time, subway-sign nav along the bottom */
  .wrap { padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px)); }
  .tabpane { display: none; }
  .wrap[data-active="vote"] .tabpane[data-tab="vote"],
  .wrap[data-active="menu"] .tabpane[data-tab="menu"],
  .wrap[data-active="shop"] .tabpane[data-tab="shop"],
  .wrap[data-active="pantry"] .tabpane[data-tab="pantry"],
  .wrap[data-active="week"] .tabpane[data-tab="week"] { display: block; animation: rise .35s cubic-bezier(.2,.8,.2,1); }
  .wrap[data-active="week"] .tabpane[data-tab="week"] { display: flex; }
  @keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
  .tabbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); width: min(calc(100% - 24px), 460px); z-index: 10; display: flex; gap: 4px; padding: 6px; background: var(--sign); border: 2px solid var(--fg); border-radius: 18px; box-shadow: 0 6px 0 -2px var(--platform), 0 10px 24px -8px rgba(0, 0, 0, .5); }
  .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 4px; border-radius: 12px; background: transparent; color: var(--sign-fg); border-color: transparent; font-size: 14px; }
  .tabbar button:hover:not(:disabled) { background: rgba(255, 255, 255, .12); }
  .tabbar button[aria-selected="true"] { background: var(--platform); color: var(--platform-fg); }
  .tabbar .tb { font-size: 11px; font-weight: 700; min-height: 13px; opacity: .85; font-variant-numeric: tabular-nums; }

  /* ---- vote confetti (subway line colors) */
  .confetti { position: fixed; z-index: 30; width: 8px; height: 8px; border-radius: 50%; pointer-events: none; animation: confetti .75s cubic-bezier(.15,.7,.3,1) forwards; }
  @keyframes confetti { from { transform: translate(-50%, -50%) rotate(0); opacity: 1; } to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--rot)); opacity: 0; } }
  @media (prefers-reduced-motion: reduce) { .confetti { display: none; } .tabpane { animation: none !important; } }

  /* ---- subway-map lines along the edges (drawn by lines.js) */
  #lines { position: absolute; top: 0; left: 0; z-index: 0; pointer-events: none; }
  #lines path { stroke-dasharray: 1; stroke-dashoffset: 0; animation: draw 1.4s cubic-bezier(.3,.7,.2,1) backwards; animation-delay: calc(var(--i, 0) * 110ms); }
  #lines.still path { animation: none; }
  #lines .stop { fill: #fff; stroke: #111; stroke-width: 2.5; }
  #lines .hub { stroke-width: 3; }
  @keyframes draw { from { stroke-dashoffset: 1; } }
  .wrap { position: relative; z-index: 1; }

  /* ---- permanently remove: one per person per hand, takes a meal out of the pool */
  button.rm { flex: 0 1 auto; min-width: 0; white-space: nowrap; font-size: 12px; padding: 7px 12px; background: transparent; color: var(--muted); border-style: dashed; box-shadow: none; }
  button.rm:hover:not(:disabled) { border-color: #ee352e; color: #ee352e; background: transparent; }
  button.rm.armed { background: #ee352e; color: #fff; border-style: solid; border-color: #ee352e; }
  .dealrow { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; background: var(--surface); border: 2px solid var(--fg); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }

  .swaprow[hidden], .dealrow[hidden] { display: none; }

  /* ---- pantry + press-and-hold menu */
  .prod { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
  .prod.inpantry { opacity: .5; }
  .prod.inpantry .pname { text-decoration: none; }
  .ppantry { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--vote); }
  .pantadd { margin: 14px 0 6px; }
  .pitem { cursor: default; }
  .pitem .pinfo { flex: 1; }
  .pitem .addphoto { margin: 0 10px 10px; align-self: flex-start; }
  .pitem .pqty { position: static; display: inline-block; align-self: flex-start; margin: 10px 10px 0; }
  dialog.sheet { margin: auto auto 0; width: min(100%, 520px); max-width: 100%; border-radius: 20px 20px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px)); }
  .sheetbody { display: flex; flex-direction: column; gap: 10px; }
  .sheetbody h2.bar { align-self: flex-start; max-width: 100%; overflow-wrap: anywhere; font-size: 17px; }
  .sheetbody button { padding: 13px 16px; font-size: 16px; }

  /* Side margin for the edge lines (set by lines.js; 16px when there is plenty of room). */
  .wrap { padding-left: var(--gutter, 16px); padding-right: var(--gutter, 16px); }

  /* Room above the header for the arch the lines make over it (set by lines.js). */
  .wrap { padding-top: var(--toppad, 20px); }
