/* Saved baskets, clubs and preferences on /compare (personal-ui.js): the app's screens (src/app/baskets, memberships,
   preferences on feat/clickacart-v1-lists-split-delivery) with the app's tokens (src/theme.ts). The phone shows them
   inside the app frame (#m-root), the desktop in the #personal dialog. 1 pt = 1 CSS px. */

#personal, .m-root, .p-alert-wrap {
  /* palette A (app b94d037 src/theme.ts) */
  --primary: #1467F5; --primaryDark: #0F55D0; --primarySoft: #E3EDFE; --primaryTint: #F0F5FF;
  --accentStrong: #168540; --background: #F7F9FC; --surface: #FFFFFF; --text: #111827; --textMuted: #5F6B76;
  --border: #E5E9EF; --disabled: #C9CED6; --danger: #B3261E; --white: #FFFFFF; --tile: #F2F4F7; --darkTile: #1F2A26;
  --shadow: 0 3px 10px rgb(17 24 39 / .07);
}

/* Icons (MaterialCommunityIcons masks) */
.p-mi { display: inline-block; flex: none; width: var(--s); height: var(--s); background: currentColor;
  -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.p-mi.muted { color: var(--textMuted); }

/* Screen body */
.p-list { display: grid; grid-template-columns: minmax(0, 1fr); grid-auto-rows: max-content; gap: 12px; }
.p-list > * { min-width: 0; }
.p-muted { font-size: 14px; color: var(--textMuted); margin: 0; }
.p-muted.center { text-align: center; }
.p-muted.strong { font-size: 14.5px; font-weight: 600; }
.p-titleicon { display: flex; justify-content: center; color: var(--primary); }
.p-group { font-size: 16px; font-weight: 800; color: var(--text); margin: 4px 0 0; }

/* Cards */
.p-card { background: var(--surface); border-radius: 16px; padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px;
  border: 1px solid var(--border); box-shadow: var(--shadow); }
.p-head { display: flex; align-items: center; gap: 12px; color: var(--primary); width: 100%; min-height: 44px;
  font: inherit; text-align: start; background: none; border: 0; padding: 0; cursor: default; }
button.p-head { cursor: pointer; }
.p-headtext { flex: 1; min-width: 0; display: grid; gap: 2px; }
.p-name { font-size: 19px; font-weight: 800; color: var(--text); margin: 0; overflow-wrap: anywhere; }
.p-count { font-size: 14px; color: var(--textMuted); margin: 0; }
.p-sectitle { font-size: 17px; font-weight: 800; color: var(--text); }
.p-secbody { font-size: 14px; color: var(--textMuted); line-height: 19px; }
.p-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.p-compare { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.p-chains { display: flex; flex-wrap: wrap; gap: 4px; flex-shrink: 1; min-width: 0; }
.p-actions { display: flex; gap: 8px; }
.p-actions > * { flex: 1; min-width: 0; }

/* Buttons (the app's Button: primary terracotta, outline, soft; compact) */
.p-btn { min-height: 52px; border-radius: 10px; padding: 6px 20px; display: flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 17px; font-weight: 700; text-align: center; width: 100%; cursor: pointer; border: 1px solid transparent;
  background: var(--accentStrong); color: var(--white); }
.p-btn.compact { min-height: 48px; font-size: 15.5px; padding: 6px 14px; }
.p-btn.small { width: auto; min-height: 44px; padding: 6px 14px; flex: none; }
.p-btn.compare { width: auto; min-height: 48px; padding: 6px 16px; }
.p-btn.outline { background: var(--surface); color: var(--primary); border-color: var(--primary); }
.p-btn.soft { background: var(--primarySoft); color: var(--primaryDark); }
.p-btn.danger { background: var(--danger); color: var(--white); }
.p-btn:disabled { opacity: .45; cursor: default; }
.p-btn:focus-visible, .p-club:focus-visible, .p-chip:focus-visible, .p-step:focus-visible, button.p-head:focus-visible {
  outline: 3px solid var(--primary); outline-offset: 2px; }

/* ProductVisual (compact) and ChainMark */
.p-vis { display: block; width: var(--sz); height: var(--sz); flex: none; }
.p-vis .p-pic { width: 100%; height: 100%; border-radius: 10px; overflow: hidden; display: grid; place-items: center;
  background: var(--white); border: 1px solid var(--border); }
.p-vis .p-pic img { width: 100%; height: 100%; object-fit: contain; }
.p-vis .p-pic.logo-tile { padding: 6px; }
.p-vis .p-pic.dark { background: var(--darkTile); border-color: var(--darkTile); }
.p-vis .p-pic.na { background: var(--tile); border-color: var(--tile); color: var(--textMuted); font-size: var(--lbl); line-height: 1.15;
  text-align: center; font-weight: 600; }
.p-chain { display: inline-grid; place-items: center; flex: none; background: var(--white); border: 1px solid var(--border); overflow: hidden; }
.p-chain img { width: calc(100% - 6px); height: calc(100% - 6px); object-fit: contain; }
.p-chain.letter { border: 0; color: var(--white); font-weight: 800; }

/* Basket edit */
.p-field { display: grid; gap: 6px; }
.p-field label { font-size: 16px; font-weight: 700; color: var(--text); }
.p-input { min-height: 54px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0 16px;
  font: inherit; font-size: 17px; color: var(--text); width: 100%; box-sizing: border-box; }
.p-input:focus { outline: 2px solid var(--primary); outline-offset: 0; }
.p-row { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface); border-radius: 12px;
  border: 1px solid var(--border); box-shadow: var(--shadow); }
.p-rowtext { flex: 1; min-width: 0; display: grid; gap: 2px; }
.p-rowname { font-size: 16px; font-weight: 800; color: var(--text); margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.p-meta { font-size: 13.5px; color: var(--textMuted); margin: 0; }
.p-stepper { flex: none; display: flex; align-items: center; background: var(--primarySoft); border-radius: 10px; padding: 0 2px; color: var(--primaryDark); }
.p-step { width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; color: inherit; cursor: pointer; padding: 0; }
.p-qty { min-width: 22px; text-align: center; font-size: 17px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }

/* Clubs */
.p-club { display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 8px 16px; background: var(--surface); border-radius: 12px;
  border: 2px solid var(--surface); box-shadow: var(--shadow); font: inherit; text-align: start; width: 100%; cursor: pointer; color: var(--text); }
.p-club.on { border-color: var(--primary); background: var(--primaryTint); }
.p-clubtext { flex: 1; min-width: 0; display: grid; gap: 2px; }
.p-clubname { font-size: 18px; font-weight: 800; color: var(--text); }
.p-clubblurb { font-size: 14px; color: var(--textMuted); }
.p-check { width: 30px; height: 30px; flex: none; border: 2px solid var(--textMuted); border-radius: 8px; background: var(--surface);
  display: grid; place-items: center; color: var(--white); }
.p-check.on { background: var(--primary); border-color: var(--primary); }

/* Preferences: chips and the fixed switch */
.p-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.p-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 10px; font: inherit;
  font-size: 15px; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--border); cursor: pointer; }
.p-chip.on { border-color: var(--primary); background: var(--primaryTint); color: var(--text); }
.p-chip.on .p-mi { color: var(--primary); }
.p-chip.radio-on { background: var(--primary); border-color: var(--primary); color: var(--white); }
.p-chip:disabled { cursor: default; opacity: 1; }
.p-none { font-size: 14.5px; color: var(--textMuted); }
.p-switch { flex: none; width: 51px; height: 31px; border-radius: 16px; background: var(--primary); position: relative; opacity: .6; }
.p-switch::after { content: ""; position: absolute; top: 2px; inset-inline-start: 22px; width: 27px; height: 27px; border-radius: 50%; background: var(--white); }
[dir="rtl"] .p-switch::after, .p-switch:dir(rtl)::after { inset-inline-start: 2px; }

/* InfoNote */
.p-infonote { display: flex; align-items: flex-start; gap: 8px; padding: 12px; border-radius: 10px; background: var(--primaryTint); color: var(--primary); }
.p-infonote p { margin: 0; flex: 1; font-size: 14px; line-height: 20px; color: var(--text); }

/* PersonalGate: sign-in, loading, failed */
.p-gate { display: grid; justify-items: center; gap: 16px; padding: 32px 8px; text-align: center; }
.p-empty-circle { width: 96px; height: 96px; border-radius: 48px; background: var(--primarySoft); color: var(--primary); display: grid; place-items: center; }
.p-gate-lead { font-size: 18px; font-weight: 600; line-height: 26px; color: var(--text); margin: 0; }
.p-empty-title { font-size: 20px; font-weight: 800; margin: 0; color: var(--text); }
.p-empty-text { font-size: 16px; color: var(--textMuted); margin: 0; line-height: 22px; }
.p-gate .p-btn { max-width: 340px; }
.p-spinner { width: 40px; height: 40px; border-radius: 50%; border: 4px solid var(--primarySoft); border-top-color: var(--primary); animation: p-spin .9s linear infinite; }
@keyframes p-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .p-spinner { animation-duration: 3s; } }

/* Alert (the app's Alert.alert) */
.p-alert-wrap { position: fixed; inset: 0; z-index: 100; background: rgb(31 45 56 / .45); display: grid; place-items: center; padding: 16px; }
.p-alert { background: var(--surface); color: var(--text); border-radius: 14px; padding: 20px; width: min(100%, 360px); display: grid; gap: 12px;
  box-shadow: 0 8px 32px rgb(31 45 56 / .3); text-align: center; }
.p-alert-title { font-size: 18px; font-weight: 800; margin: 0; }
.p-alert-text { font-size: 15.5px; line-height: 22px; margin: 0; color: var(--text); }
.p-alert-actions { display: flex; gap: 8px; }
.p-alert-actions > * { flex: 1; }

/* Desktop dialog (#personal): the screen in a sheet with its own header */
#personal { width: min(560px, calc(100vw - 32px)); max-height: min(88vh, 900px); padding: 0; border: 0; border-radius: 16px;
  background: var(--background); color: var(--text); overflow: hidden; }
#personal[open] { display: flex; flex-direction: column; }
#personal::backdrop { background: rgb(31 45 56 / .45); }
.p-dhead { display: flex; align-items: center; gap: 8px; padding: 12px 16px 8px; }
.p-dhead h2 { margin: 0; font-size: 21px; font-weight: 800; flex: 1; text-align: center; }
.p-dhead p { margin: 0; font-size: 14px; color: var(--textMuted); text-align: center; }
.p-dtitle { flex: 1; min-width: 0; display: grid; gap: 2px; }
.p-dbtn { width: 44px; height: 44px; flex: none; display: grid; place-items: center; background: none; border: 0; border-radius: 10px;
  color: var(--primary); cursor: pointer; font: inherit; font-size: 26px; }
.p-dbtn.hidden { visibility: hidden; }
.p-dbody { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 4px 16px 16px; }
.p-dfoot { flex: none; padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--border); }
.p-dfoot:empty { display: none; }
/* Desktop basket panel and account menu entries */
.save-basket { width: 100%; margin-bottom: 8px; }
.personal-links { display: grid; gap: 8px; }
/* Results (desktop): delivery line, club and claim tags */
.o-delivery { display: block; font-size: 13.5px; color: var(--textMuted, #5B6670); }
.o-delivery.warn { color: #8A5A00; font-weight: 700; }
.o-total.muted { color: #5B6670; font-weight: 600; }
.tag.member { margin-inline-start: 6px; }
.tag.claim { margin-inline-start: 6px; }

/* Split basket (part B): SplitCard and the "הסל בשתי רשתות" screen */
.p-split { background: var(--primaryTint); border: 1.5px solid var(--primary); border-radius: 10px; padding: 12px; display: grid; gap: 8px; }
.p-split-title { display: flex; align-items: center; gap: 6px; color: var(--primary); }
.p-split-title h2 { margin: 0; font-size: 17px; font-weight: 800; color: var(--primaryDark); }
.p-split-lead { margin: 0; font-size: 14px; color: var(--textMuted); }
.p-split-part { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: var(--text); }
.p-split-total { margin: 0; font-size: 14px; font-weight: 600; color: var(--text); }
.p-split-summary { margin: 0; font-size: 15px; font-weight: 600; color: var(--text); }
.p-splitpart.done { background: var(--primaryTint); }
.p-splitline { margin: 0; font-size: 15px; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.p-link { justify-self: start; min-height: 44px; background: none; border: 0; padding: 0; font: inherit; font-size: 14.5px; font-weight: 700; color: var(--primary); text-decoration: underline; cursor: pointer; }
.p-done { display: flex; align-items: center; gap: 8px; min-height: 44px; background: none; border: 0; padding: 0; font: inherit; font-size: 15.5px; font-weight: 600; color: var(--text); cursor: pointer; text-align: start; }
.p-done .p-mi { color: var(--primary); }
.p-splitpart .p-head h2 { margin: 0; flex: 1; }
/* Desktop results: the card sits between the best chain and the others */
#results .p-split { margin: 12px 0; }
