/* Light and dark follow the phone. Colours mirror the Android app. */
:root {
  color-scheme: light dark;
  --bg: #f0eff6;
  --fg: #1b1b1f;
  --muted: #5d5f6b;
  --accent: #3a56a0;
  --on-accent: #ffffff;
  --line: #d6d6e0;
  --card: #e3e2ec;
  --field: #8a8b97;
  --danger: #ba1a1a;
  /* one colour per section, handed out in route order (see sectionColorIndex); all >= 5:1 on the background */
  --sc0: #8F5512; --sc1: #195FC8; --sc2: #0E7132; --sc3: #BA177E;
  --sc4: #0E6F6F; --sc5: #872AE5; --sc6: #C31E18; --sc7: #5F680D;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1b21;
    --fg: #f1f0f7;
    --muted: #b4b4c0;
    --accent: #dae2ff;
    --on-accent: #1a1b21;
    --line: #34353d;
    --card: #2a2b33;
    --field: #8f909a;
    --danger: #ffb4ab;
    --sc0: #EAA353; --sc1: #8BB4F1; --sc2: #19CC5B; --sc3: #F292CF;
    --sc4: #18C5C5; --sc5: #C9A0F3; --sc6: #F29A97; --sc7: #ACBC17;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
#app {
  min-height: 100%;
  padding: var(--sat) var(--sar) var(--sab) var(--sal);
  max-width: 640px;
  margin: 0 auto;
}
button, input, textarea { font: inherit; color: inherit; }
[dir="auto"], .auto { text-align: start; }

/* ---- header */
.bar { display: flex; align-items: center; gap: 4px; padding: 10px 8px 4px 16px; }
.bar h1 { flex: 1; margin: 0; font-size: 22px; font-weight: 700; }
.back { background: none; border: 0; font-size: 26px; min-width: 48px; min-height: 44px; padding: 0 8px; cursor: pointer; }
.titles { flex: 1; min-width: 0; }
.titles h1 { margin: 0; font-size: 22px; overflow-wrap: anywhere; }
.titles .sub { color: var(--accent); font-size: 13px; }
.textbtn { background: none; border: 0; padding: 10px 10px; min-height: 44px; font-weight: 500; cursor: pointer; border-radius: 8px; }
.textbtn:disabled { opacity: .4; cursor: default; }
.textbtn:active:not(:disabled) { background: var(--card); }
.status { padding: 0 16px 4px; font-size: 12px; color: var(--accent); cursor: pointer; }

/* ---- add form */
.addrow { display: flex; align-items: center; padding: 0 8px 0 16px; }
.addrow input, .field {
  flex: 1; min-width: 0; background: transparent; border: 0; border-bottom: 1.5px solid var(--field);
  padding: 10px 2px; font-size: 17px; outline: none; border-radius: 0;
}
.addrow input:focus, .field:focus { border-bottom-color: var(--accent); }
.addrow .clear { background: none; border: 0; min-width: 44px; min-height: 44px; font-size: 18px; opacity: .7; cursor: pointer; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 16px 2px; }
.suggest[hidden] { display: none; }
.pill { background: var(--card); border: 0; border-radius: 16px; padding: 7px 14px; min-height: 34px; font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.pill:active { background: var(--line); }

.bulkrow { display: flex; justify-content: flex-end; padding: 0 8px; }
.bulkrow .textbtn { color: var(--accent); font-size: 14px; min-height: 36px; padding: 6px 10px; }

/* ---- list */
.list { margin-top: 8px; }
.row { display: flex; align-items: center; min-height: 54px; padding: 0 4px; border-top: 1px solid var(--line); background: var(--bg); position: relative; user-select: none; -webkit-user-select: none; }
.row.lifted { z-index: 5; box-shadow: 0 4px 14px rgba(0,0,0,.35); transition: none; }
.handle { width: 38px; text-align: center; font-size: 24px; opacity: .6; touch-action: none; cursor: grab; flex: none; line-height: 54px; }
.handle.hidden { visibility: hidden; }
.box { width: 24px; height: 24px; border: 2px solid var(--fg); border-radius: 4px; margin: 0 12px 0 6px; flex: none; display: grid; place-items: center; }
.row.done .box { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.row.done .box::after { content: "✓"; font-weight: 700; font-size: 16px; line-height: 1; }
.name { flex: 1; min-width: 0; font-size: 18px; padding: 8px 8px 8px 0; overflow-wrap: anywhere; cursor: pointer; }
.row.done .name { text-decoration: line-through; opacity: .45; }
.row.gap { margin-top: 16px; }   /* a blank band where the section changes (see markGroups) */
.chip { flex: none; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: none; border: 0; color: var(--fg); font-size: 16px; font-weight: 600; padding: 14px 6px 14px 8px; cursor: pointer; }
.chip.empty { opacity: .4; font-weight: 400; }
.row.done .chip { opacity: .45; }
.icon { flex: none; background: none; border: 0; min-width: 40px; min-height: 44px; font-size: 22px; opacity: .55; cursor: pointer; padding: 0 6px; }
.icon.has { color: var(--accent); opacity: 1; }
.row.done .icon { opacity: .35; }
.icon.x { font-size: 18px; opacity: .6; }
.empty-state { text-align: center; opacity: .6; padding: 60px 0; }
.applink { display: block; text-align: center; padding: 28px 16px 36px; color: var(--muted); font-size: 14px; text-decoration: underline; }

/* ---- details */
.page .field { width: 100%; margin-bottom: 8px; }
.page { padding: 8px 16px 32px; }
.label { color: var(--accent); font-weight: 700; font-size: 14px; margin: 22px 0 8px; display: flex; justify-content: space-between; align-items: baseline; }
.label .val { color: var(--fg); font-weight: 400; font-size: 16px; }
.label .val.dim { opacity: .6; }
.rating { display: flex; gap: 4px; }
.rating button { flex: 1; min-width: 0; height: 38px; border-radius: 19px; border: 1px solid var(--field); background: none; font-size: 14px; padding: 0; cursor: pointer; }
.rating button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.photo { display: block; max-width: 100%; max-height: 320px; margin: 0 auto; border-radius: 12px; }
.noimg { border: 1px solid var(--field); border-radius: 12px; height: 120px; display: grid; place-items: center; opacity: .6; }
.photobtns { display: flex; gap: 4px; margin-top: 4px; }
textarea.notes { width: 100%; min-height: 130px; background: none; border: 1px solid var(--field); border-radius: 12px; padding: 12px; font-size: 17px; resize: vertical; outline: none; }
textarea.notes:focus { border-color: var(--accent); }

/* ---- dialogs */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.dialog { background: var(--card); color: var(--fg); border-radius: 28px; padding: 24px; width: min(100%, 420px); max-height: 85vh; overflow: auto; }
.dialog h2 { margin: 0 0 12px; font-size: 22px; font-weight: 600; }
.dialog p { margin: 0 0 12px; overflow-wrap: anywhere; }
.dialog .field { width: 100%; margin-bottom: 8px; }
.dialog .buttons { display: flex; justify-content: flex-end; gap: 4px; margin-top: 12px; flex-wrap: wrap; }
.dialog .buttons .textbtn { color: var(--accent); }
.choice { display: block; width: 100%; text-align: start; background: none; border: 0; padding: 14px 4px; font-size: 17px; cursor: pointer; border-radius: 8px; }
.choice:active { background: var(--bg); }
.dialog .row { background: transparent; border-top: 0; min-height: 52px; }
.dialog .row.lifted { background: var(--card); }
.dialog .row .name { cursor: default; font-size: 17px; }

/* ---- sharing screens */
.card { padding: 4px 0 8px; }
.card p { margin: 6px 0; }
.dim { opacity: .7; }
.btn { display: block; width: 100%; background: var(--card); border: 0; border-radius: 10px; min-height: 48px; font-weight: 500; margin: 8px 0; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.member { display: flex; align-items: center; min-height: 44px; }
.member .who { flex: 1; }
.member .who.pending { font-weight: 600; }
.member .textbtn { color: var(--accent); }
.notice { background: var(--card); border-radius: 12px; padding: 12px 14px; margin: 12px 0; }
.notice strong { display: block; margin-bottom: 4px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--sab)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 80; max-width: 90vw; font-size: 15px; }
