/* Lists: iPhone first, light and dark. */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #121417;
  --muted: #6b7280;
  --faint: #9aa1ab;
  --line: rgba(17, 20, 23, 0.07);
  --fill: #eceef1;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 2px 8px rgba(16, 24, 40, 0.05);
  --sheet: #ffffff;
  --danger: #e5484d;
  --accent: #22a861;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --radius: 16px;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f12;
    --card: #17191d;
    --text: #f1f2f4;
    --muted: #9aa1ab;
    --faint: #6b7280;
    --line: rgba(255, 255, 255, 0.07);
    --fill: #24272c;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.03);
    --sheet: #1b1d22;
  }
}
.c-green { --accent: #22a861; }
.c-blue { --accent: #3478f6; }
.c-orange { --accent: #f0841f; }
.c-pink { --accent: #e5508a; }
.c-purple { --accent: #8b5cf6; }
.c-teal { --accent: #0fa3a3; }
.c-red { --accent: #e5484d; }
.c-yellow { --accent: #d19d00; }
.c-slate { --accent: #64748b; }
/* The tint has to be declared where the color is, or it keeps the green it was computed with on :root. */
.c-green, .c-blue, .c-orange, .c-pink, .c-purple, .c-teal, .c-red, .c-yellow, .c-slate {
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--bottom) + 24px);
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; font-size: 16px; color: inherit; }
.wrap { max-width: 640px; margin: 0 auto; }

/* ---------- top bars ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--top) + 6px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
}
.bar { display: flex; align-items: center; gap: 8px; min-height: 44px; max-width: 640px; margin: 0 auto; }
.bar h1 { flex: 1; margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar h1 .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home .bar h1 { font-size: 32px; letter-spacing: -0.03em; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  color: var(--accent);
}
.icon-btn:active { background: var(--fill); }
.icon-btn svg { width: 24px; height: 24px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-weight: 700; font-size: 15px; color: #fff; background: #3478f6;
}
.avatar.p { background: #e5508a; }
.avatar.none { background: var(--faint); }
.status-pill { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--fill); padding: 3px 8px; border-radius: 99px; }

/* ---------- home ---------- */
.hello { color: var(--muted); font-size: 15px; margin: -4px 0 0; max-width: 640px; margin-inline: auto; }
.section { padding: 8px 16px 0; max-width: 640px; margin: 0 auto; }
.cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.lrow { position: relative; }
.lrow .row {
  display: flex; align-items: center; gap: 14px; padding: 14px 8px 14px 14px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: pan-y;
  transition: transform 0.15s ease, background 0.15s;
}
.lrow .row:active { transform: scale(0.985); }
.tile {
  width: 46px; height: 46px; border-radius: 13px; flex: none; display: grid; place-items: center;
  font-size: 24px; background: var(--accent-soft);
}
.lrow .txt { flex: 1; min-width: 0; }
.lrow .t { font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrow .sub { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.count { min-width: 28px; height: 28px; padding: 0 9px; border-radius: 99px; background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; display: grid; place-items: center; }
.count.zero { background: var(--fill); color: var(--muted); }
.group-lbl { display: flex; align-items: center; gap: 6px; margin: 22px 4px 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.main-cards > .cards + .group-lbl { margin-top: 22px; }
.main-cards > .group-lbl:first-child { margin-top: 4px; }
svg.lock { width: 0.8em; height: 0.8em; vertical-align: -0.05em; color: var(--muted); flex: none; }
.group-lbl svg.lock { width: 13px; height: 13px; }
.seg button svg.lock { color: inherit; }
.new-list {
  width: 100%; margin-top: 12px; padding: 15px; border-radius: var(--radius);
  border: 1.5px dashed color-mix(in srgb, var(--muted) 45%, transparent); color: var(--muted); font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.new-list:active { background: var(--fill); }
.archived-toggle { margin: 22px auto 8px; display: block; color: var(--muted); font-size: 14px; font-weight: 600; padding: 8px 12px; }
.archived .lrow .row { opacity: 0.7; }
.hint-card {
  margin: 4px 0 14px; padding: 14px 14px 14px 16px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow);
  display: flex; gap: 12px; align-items: flex-start; font-size: 15px; color: var(--muted);
}
.hint-card b { color: var(--text); }
.hint-card .x { margin-left: auto; color: var(--faint); font-size: 20px; line-height: 1; padding: 0 4px; }

/* ---------- list view ---------- */
.addform { display: flex; gap: 8px; max-width: 640px; margin: 8px auto 0; }
.addform input {
  flex: 1; min-width: 0; height: 46px; border-radius: 14px; border: 0; padding: 0 14px;
  background: var(--card); box-shadow: var(--shadow); outline: none;
}
.addform input:focus { box-shadow: 0 0 0 2px var(--accent); }
.addform .plus {
  width: 46px; height: 46px; border-radius: 14px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none;
}
.addform .plus svg { width: 22px; height: 22px; }
.addform .cam {
  width: 46px; height: 46px; border-radius: 14px; background: var(--card); color: var(--accent); box-shadow: var(--shadow); display: grid; place-items: center; flex: none;
}
.addform .cam[hidden] { display: none; }
.addform .cam svg { width: 24px; height: 24px; }
.photo-spin { width: 34px; height: 34px; margin: 6px auto 18px; border-radius: 50%; border: 3px solid var(--fill); border-top-color: var(--accent); animation: photo-spin .8s linear infinite; }
@keyframes photo-spin { to { transform: rotate(360deg); } }
.photo-rows { list-style: none; margin: 0 0 14px; padding: 0; max-height: 52vh; overflow-y: auto; }
.photo-rows li { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.photo-rows input[type=checkbox] { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
.photo-rows input[type=text] { flex: 1; min-width: 0; height: 40px; border: 0; border-radius: 10px; padding: 0 10px; background: var(--fill); font: inherit; color: inherit; }
.photo-rows .already { font-size: 12px; color: var(--muted); white-space: nowrap; }
.btn:disabled { opacity: .5; }
.sugg { display: flex; gap: 8px; overflow-x: auto; max-width: 640px; margin: 0 auto; padding: 10px 0 2px; scrollbar-width: none; }
.sugg::-webkit-scrollbar { display: none; }
.sugg:empty { display: none; }
.sugg .lbl { font-size: 13px; color: var(--muted); align-self: center; white-space: nowrap; }
.chip {
  flex: none; padding: 7px 12px; border-radius: 99px; background: var(--card); box-shadow: var(--shadow);
  font-size: 15px; white-space: nowrap; display: inline-flex; gap: 5px; align-items: center;
}
.chip:active { background: var(--accent-soft); }
.chip .pl { color: var(--accent); font-weight: 700; }

.items { list-style: none; margin: 0; padding: 0; }
.group-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.ghead {
  display: flex; align-items: center; gap: 6px; padding: 18px 4px 6px; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); list-style: none;
}
.ghead:first-child { padding-top: 6px; }
.ghead em { font-style: normal; font-weight: 600; color: var(--faint); }
.item { position: relative; list-style: none; }
.item .row {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 6px 8px 14px;
  background: var(--card); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: pan-y;
  transition: transform 0.22s cubic-bezier(.2,.8,.2,1), background 0.15s;
}
.items .item { margin-bottom: 1px; }
.items .item:first-child .row, .items .ghead + .item .row { border-top-left-radius: 14px; border-top-right-radius: 14px; }
.items .item:last-child .row, .items .item:has(+ .ghead) .row { border-bottom-left-radius: 14px; border-bottom-right-radius: 14px; }
.items .item:first-child .del-btn, .items .ghead + .item .del-btn { border-top-right-radius: 14px; }
.items .item:last-child .del-btn, .items .item:has(+ .ghead) .del-btn { border-bottom-right-radius: 14px; }
.item.pressed .row { background: var(--fill); }
.del-btn {
  position: absolute; right: 0; top: 0; bottom: 0; width: 50%; display: flex; align-items: center; justify-content: flex-end;
  padding-right: 22px; background: var(--danger); color: #fff; font-weight: 600; font-size: 15px;
}
.check {
  width: 26px; height: 26px; border-radius: 50%; flex: none; border: 2px solid color-mix(in srgb, var(--muted) 55%, transparent);
  display: grid; place-items: center; transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.check svg { width: 15px; height: 15px; opacity: 0; color: #fff; transition: opacity 0.12s; }
.item.checking .check, .item.done .check { background: var(--accent); border-color: var(--accent); }
.item.checking .check { transform: scale(1.12); }
.item.checking .check svg, .item.done .check svg { opacity: 1; }
.item.checking .t, .item.done .t { text-decoration: line-through; color: var(--muted); }
.item .txt { flex: 1; min-width: 0; padding: 2px 0; }
.item .t { word-break: break-word; transition: color 0.15s; }
.qty { display: inline-block; margin-left: 4px; padding: 1px 7px; border-radius: 7px; font-size: 13px; font-weight: 600; background: var(--accent-soft); color: var(--accent); vertical-align: 1px; }
.qty.price { font-variant-numeric: tabular-nums; }
.note { font-size: 14px; color: var(--muted); word-break: break-word; }
.subs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; margin-top: 2px; font-size: 14px; color: var(--muted); }
.subs .when { color: var(--faint); }
.subs .warn { color: var(--danger); font-weight: 600; }
.ilink {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 2px 8px 2px 6px; border-radius: 8px;
  background: var(--fill); color: var(--accent); font-size: 13px; font-weight: 600; text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ilink svg { width: 13px; height: 13px; flex: none; }
.ilink:active { background: var(--accent-soft); }
.check.star { border: 0; background: none; color: var(--accent); opacity: 0.85; }
.check.star svg { opacity: 1; width: 20px; height: 20px; color: var(--accent); }

/* ---------- wish lists ---------- */
.wish-info { margin: 0 2px 14px; display: flex; flex-direction: column; gap: 8px; }
.wi-priv { display: flex; align-items: flex-start; gap: 6px; font-size: 14px; color: var(--muted); }
.wi-priv svg.lock { width: 13px; height: 13px; margin-top: 3px; }
.wi-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.wi-stats span { padding: 4px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 600; }
.starters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.starters .chip { font-size: 14px; }
.group-lbl .right { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 600; }
.lbl2 .opt { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--faint); }
.sheet .meta.fixed { margin: 0 2px 4px; font-weight: 600; }
.linkrow { display: flex; gap: 8px; }
.linkrow .field { flex: 1; min-width: 0; }
.linkrow .btn.open { width: auto; height: 48px; margin: 0; padding: 0 16px; color: var(--accent); text-decoration: none; }
input[type="date"].field { -webkit-appearance: none; appearance: none; display: flex; align-items: center; min-width: 0; }
.seg button:disabled { opacity: 0.4; cursor: default; }
.menu button:disabled { opacity: 0.45; cursor: default; }
.btn.danger-fill { background: var(--danger); }
[hidden] { display: none !important; }
.by {
  width: 20px; height: 20px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff; background: #3478f6; opacity: 0.85;
}
.by.p { background: #e5508a; }
.grip { width: 34px; height: 40px; flex: none; display: grid; place-items: center; color: var(--faint); touch-action: none; cursor: grab; }
.grip svg { width: 18px; height: 18px; }
.item.dragging .row, .lrow.dragging .row { box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22); transform: scale(1.02); border-radius: 14px; transition: none; }
.item.dragging .del-btn { display: none; }
.ph { list-style: none; border-radius: 14px; background: var(--accent-soft); margin-bottom: 1px; }
.flash .row { animation: flash 0.9s ease; }
@keyframes flash { 0%, 100% { background: var(--card); } 30% { background: var(--accent-soft); } }

.done-sec { margin-top: 22px; }
.done-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 8px; }
.done-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 6px 0; }
.done-toggle svg { width: 14px; height: 14px; transition: transform 0.2s; }
.done-sec.collapsed .done-toggle svg { transform: rotate(-90deg); }
.done-sec.collapsed .items { display: none; }
.link-btn { color: var(--accent); font-weight: 600; font-size: 15px; padding: 6px 4px; }
.item.done .txt { opacity: 0.62; }
.del-btn { visibility: hidden; }
.item.swiping .del-btn, .item.open .del-btn { visibility: visible; }
.more-done { text-align: center; color: var(--muted); font-size: 13px; padding: 10px; }

.empty { text-align: center; color: var(--muted); padding: 48px 24px 24px; }
.empty .big { font-size: 44px; margin-bottom: 8px; }
.empty b { color: var(--text); display: block; font-size: 17px; margin-bottom: 4px; }

/* ---------- sheets ---------- */
.sheet-bd {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0); display: flex; align-items: flex-end; justify-content: center;
  transition: background 0.22s;
}
.sheet-bd.in { background: rgba(0, 0, 0, 0.36); }
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--sheet); border-radius: 22px 22px 0 0; padding: 8px 18px calc(var(--bottom) + 18px);
  transform: translateY(100%); transition: transform 0.26s cubic-bezier(.2,.8,.2,1);
}
.sheet-bd.in .sheet { transform: none; }
.grab { width: 38px; height: 5px; border-radius: 3px; background: var(--fill); margin: 0 auto 12px; }
.sheet h2 { margin: 2px 0 14px; font-size: 20px; letter-spacing: -0.01em; }
.sheet .meta { color: var(--muted); font-size: 14px; margin: -8px 0 14px; }
.field {
  width: 100%; height: 48px; border-radius: 12px; border: 0; background: var(--fill); padding: 0 14px; outline: none; margin-bottom: 10px;
}
textarea.field { height: auto; min-height: 72px; padding: 12px 14px; resize: vertical; }
.field:focus { box-shadow: 0 0 0 2px var(--accent); }
.row2 { display: flex; gap: 10px; }
.row2 > * { flex: 1; min-width: 0; }
.lbl2 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 12px 2px 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.grid button { height: 44px; border-radius: 12px; font-size: 24px; display: grid; place-items: center; }
.grid button.on { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); box-shadow: inset 0 0 0 0 var(--sheet); }
.swatch.on { box-shadow: 0 0 0 3px var(--sheet), 0 0 0 5px var(--accent); }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { padding: 9px 14px; border-radius: 99px; background: var(--fill); font-size: 15px; font-weight: 500; }
.seg button.on { background: var(--accent); color: #fff; }
.cats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cats button { text-align: left; padding: 10px 12px; border-radius: 12px; background: var(--fill); font-size: 15px; }
.cats button.on { background: var(--accent); color: #fff; }
.templates { display: flex; gap: 8px; overflow-x: auto; margin: 0 -18px 6px; padding: 0 18px 4px; scrollbar-width: none; }
.templates::-webkit-scrollbar { display: none; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 50px; border-radius: 14px;
  background: var(--fill); font-weight: 600; margin-top: 10px;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.big { height: 52px; font-size: 17px; }
.menu { display: flex; flex-direction: column; background: var(--fill); border-radius: 14px; overflow: hidden; margin-bottom: 10px; }
.menu button { display: flex; align-items: center; gap: 12px; padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--line); }
.menu button:last-child { border-bottom: 0; }
.menu button:active { background: color-mix(in srgb, var(--fill) 70%, var(--muted)); }
.menu .ic { width: 24px; text-align: center; }
.menu .danger { color: var(--danger); }
.menu .right { margin-left: auto; color: var(--muted); font-size: 15px; }
.who-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0 6px; }
.who-pick button { padding: 22px 10px; border-radius: 18px; background: var(--fill); display: flex; flex-direction: column; align-items: center; gap: 10px; font-weight: 600; }
.who-pick button.on { box-shadow: inset 0 0 0 2px var(--accent); }
.who-pick .avatar { width: 56px; height: 56px; font-size: 24px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bottom) + 18px); z-index: 70; transform: translate(-50%, 140%);
  display: flex; align-items: center; gap: 14px; width: max-content; max-width: calc(100vw - 32px); padding: 12px 14px 12px 18px; border-radius: 14px;
  background: #1f2328; color: #fff; font-size: 15px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
  opacity: 0; pointer-events: none; transition: transform 0.25s cubic-bezier(.2,.8,.2,1), opacity 0.2s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.toast button { color: #6ee7a0; font-weight: 700; padding: 4px 6px; }
@media (prefers-color-scheme: dark) { .toast { background: #f1f2f4; color: #121417; } .toast button { color: #128a4a; } }

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; padding: calc(var(--top) + 24px) 24px calc(var(--bottom) + 24px); --accent: #22a861; }
.login { width: 100%; max-width: 360px; text-align: center; }
.login-icon { border-radius: 20px; box-shadow: 0 6px 24px rgba(34, 168, 97, 0.28); }
.login h1 { margin: 16px 0 4px; font-size: 30px; letter-spacing: -0.03em; }
.login-sub { color: var(--muted); margin: 0 0 26px; }
.login .field { background: var(--card); box-shadow: var(--shadow); text-align: center; height: 52px; }
.login-err { color: var(--danger); font-weight: 600; margin: 14px 0 0; }
.login-hint { color: var(--muted); font-size: 14px; margin-top: 22px; }

@media (min-width: 700px) { .top { padding-left: 24px; padding-right: 24px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Sharing a private list with someone */
svg.lock.ppl { width: 1.05em; height: 0.95em; }
.lrow .sub .shr { font-weight: 600; }
.share-info { display: flex; align-items: center; gap: 6px; margin: 2px 4px 12px; font-size: 14px; color: var(--muted); }
.share-info svg { width: 16px; height: 16px; flex: none; }
