/* Matala Ktana. Colors: navy #1E2A4A, blue #2F5BD3, red #E53935, yellow #FFC629. Hebrew, right to left. Dark mode follows the phone. */
:root {
  --bg: #F3F6FD; --card: #FFFFFF; --text: #1E2A4A; --sub: #5B6680; --line: #DCE3F2;
  --primary: #2F5BD3; --on: #FFFFFF; --soft: #EEF3FF; --danger: #E53935; --dangerSoft: #FCEBEB; --dangerText: #A32D2D;
  --warn: #FFC629; --ok: #1E9E6A; --edge: #747E96; --toastBtn: #FFC629; --overlay: rgba(20, 28, 48, .5);
  --chip: #E8ECF6; --chipText: #1E2A4A; --t6bg: #DDF3E8; --t6fg: #14664A; --t4bg: #FFF1CC; --t4fg: #7A5A00;
  --font: Rubik, system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1626; --card: #19233A; --text: #EEF2FB; --sub: #9DA9C4; --line: #2A3652;
    --primary: #6C8DF0; --on: #0F1626; --soft: #172040; --edge: #6B7799; --toastBtn: #7A5A00; --danger: #FF6B66; --dangerSoft: #3A1F24; --dangerText: #FF9C98;
    --chip: #26324F; --chipText: #EEF2FB; --t6bg: #17382B; --t6fg: #7FE0B0; --t4bg: #3D3010; --t4fg: #FFD772; --overlay: rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  --bg: #0F1626; --card: #19233A; --text: #EEF2FB; --sub: #9DA9C4; --line: #2A3652;
  --primary: #6C8DF0; --on: #0F1626; --soft: #172040; --edge: #6B7799; --toastBtn: #7A5A00; --danger: #FF6B66; --dangerSoft: #3A1F24; --dangerText: #FF9C98;
  --chip: #26324F; --chipText: #EEF2FB; --t6bg: #17382B; --t6fg: #7FE0B0; --t4bg: #3D3010; --t4fg: #FFD772; --overlay: rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.45; }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 700; }

#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
#app.plain { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.sub { color: var(--sub); font-size: 14px; }
.hint { color: var(--sub); font-size: 14px; line-height: 1.6; }
.empty { color: var(--sub); text-align: center; padding: 28px 8px; }
[hidden] { display: none !important; }

/* buttons and fields */
.btn { border: none; border-radius: 14px; padding: 13px 18px; font-weight: 600; font-size: 16px; background: var(--chip); color: var(--chipText); text-align: center; display: inline-block; }
.btn.primary { background: var(--primary); color: var(--on); }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.danger { background: var(--dangerSoft); color: var(--dangerText); }
.btn.sm { padding: 8px 14px; font-size: 14px; border-radius: 12px; }
.btn.block { display: block; width: 100%; }
.btn:active { transform: scale(.98); }
.fld { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--sub); }
.fld input, .fld select, .field { width: 100%; border: 1.5px solid var(--edge); background: var(--card); border-radius: 14px; padding: 12px 14px; font-size: 17px; color: var(--text); }
.fld input:focus, .fld select:focus, .field:focus { outline: none; border-color: var(--primary); }
input[dir="ltr"] { text-align: left; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 9px 15px; font-size: 15px; color: var(--text); }
.chip.on { background: var(--primary); border-color: var(--primary); color: var(--on); }
.welcome { display: flex; flex-direction: column; gap: 14px; padding-top: 8vh; }
.welcome .logo { font-size: 15px; color: var(--sub); font-weight: 600; letter-spacing: .3px; }
.welcome p { color: var(--sub); }
.back { align-self: flex-start; background: none; border: none; color: var(--primary); font-size: 15px; padding: 4px 0; }

/* header and tabs */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 4px; }
.top .icons { display: flex; gap: 6px; }
.iconbtn { background: none; border: none; font-size: 22px; color: var(--sub); padding: 6px; border-radius: 10px; line-height: 1; }
.tabs { position: fixed; inset-inline: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs .in { display: flex; width: 100%; max-width: 520px; }
.tab { flex: 1; background: none; border: none; padding: 10px 4px 9px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 14px; color: var(--sub); }
.tab i { font-size: 22px; font-style: normal; line-height: 1; }
.tab.on { color: var(--primary); font-weight: 700; }

/* chore list */
.sec { font-size: 14px; color: var(--sub); font-weight: 600; margin: 8px 4px 0; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { background: var(--card); border-radius: 16px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.item.late { box-shadow: inset -4px 0 0 var(--danger); }
.item.dim { opacity: .62; }
.item .ck { width: 28px; height: 28px; border-radius: 9px; border: 2px solid var(--primary); background: transparent; flex: none; display: flex; align-items: center; justify-content: center; color: var(--on); font-size: 17px; padding: 0; }
.item .ck.on { background: var(--primary); }
.item .ck.off { border-color: var(--line); cursor: default; }
.item .txt { flex: 1; min-width: 0; }
.item .nm { font-size: 17px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item.donecard .nm { text-decoration: line-through; color: var(--sub); }
.item .meta { font-size: 14px; color: var(--sub); }
.pill { font-size: 14px; font-weight: 600; border-radius: 999px; padding: 3px 10px; background: var(--soft); color: var(--primary); flex: none; white-space: nowrap; }
.pill.late { background: var(--dangerSoft); color: var(--dangerText); }
.pill.lock { background: var(--chip); color: var(--sub); }
.av { width: 26px; height: 26px; border-radius: 50%; color: #fff; font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.more { background: none; border: none; color: var(--sub); font-size: 20px; padding: 4px 6px; line-height: 1; }
.linkbtn { background: none; border: none; color: var(--primary); font-size: 14px; font-weight: 600; padding: 4px; }
.emoji { font-size: 22px; width: 28px; text-align: center; flex: none; }

/* cards, balance */
.card { background: var(--card); border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.bar { height: 12px; border-radius: 6px; background: var(--chip); overflow: hidden; }
.bar > div { height: 100%; border-radius: 6px; }
.row { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.type { background: var(--card); border: 2px solid transparent; border-radius: 18px; padding: 16px; display: flex; align-items: center; gap: 14px; text-align: start; width: 100%; }
.type.on { border-color: var(--primary); }
.type b { display: block; font-size: 18px; }
.type .big { font-size: 28px; }
.pick { display: flex; align-items: center; gap: 10px; background: var(--card); border: none; border-radius: 14px; padding: 11px 14px; width: 100%; text-align: start; font-size: 16px; }
.pick .sq { width: 24px; height: 24px; border: 2px solid var(--primary); border-radius: 7px; flex: none; display: flex; align-items: center; justify-content: center; color: var(--on); font-size: 15px; }
.pick.on .sq { background: var(--primary); }
.pick .when { margin-inline-start: auto; font-size: 14px; color: var(--sub); }
.pick:not(.on) .nm { color: var(--sub); }
.toggle { width: 46px; height: 28px; border-radius: 14px; background: var(--edge); border: none; position: relative; flex: none; padding: 0; }
.toggle::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: inset-inline-start .15s; }
.toggle.on { background: var(--primary); }
.toggle.on::after { inset-inline-start: 21px; }
.stickybar { position: sticky; bottom: calc(10px + env(safe-area-inset-bottom)); }

/* sheet and toast */
/* While a sheet is open the page behind it does not move (top is set from JS to keep the scroll place) */
body.locked { position: fixed; inset-inline: 0; width: 100%; overflow: hidden; }
.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 20; display: flex; align-items: flex-end; justify-content: center; overscroll-behavior: contain; }
.sheet { background: var(--card); width: 100%; max-width: 520px; border-radius: 22px 22px 0 0; padding: 0 16px calc(18px + env(safe-area-inset-bottom)); max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain; transition: transform .2s ease; }
.sheet.dragging { transition: none; }
.sheet .sbody { display: flex; flex-direction: column; gap: 12px; }
.sheethead { position: sticky; top: 0; z-index: 2; background: var(--card); height: 40px; display: flex; align-items: center; justify-content: center; touch-action: none; cursor: grab; margin: 0 -16px 4px; }
.grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); }
.sheetx { position: absolute; inset-inline-end: 12px; top: 6px; width: 30px; height: 30px; border-radius: 50%; border: none; background: var(--bg); color: var(--sub); font-size: 15px; line-height: 1; }
.sheet h2 { text-align: center; }

/* welcome */
.welcome.hero { align-items: center; text-align: center; padding-top: 6vh; gap: 12px; }
.hero .appicon { width: 96px; height: 96px; border-radius: 24px; }
.hero h1 { font-size: 30px; }
.hero .promise { font-size: 17px; color: var(--sub); margin-top: -6px; }
.perks { width: 100%; display: flex; flex-direction: column; gap: 8px; margin: 6px 0; text-align: start; }
.perks div { background: var(--card); border-radius: 14px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; font-size: 16px; }
.perks i { font-style: normal; font-size: 20px; }
.hero .btn.block { width: 100%; }
.brandline { color: var(--sub); font-size: 14px; letter-spacing: .3px; margin-top: 6px; }
.sheet .opt { display: flex; align-items: center; gap: 12px; width: 100%; background: var(--bg); border: none; border-radius: 14px; padding: 13px 14px; font-size: 16px; text-align: start; }
.sheet .opt.red { color: var(--dangerText); }
.sheet .opt i { font-style: normal; font-size: 20px; width: 26px; text-align: center; }
.lbl { font-size: 14px; color: var(--sub); margin-bottom: -4px; }
#toast { position: fixed; inset-inline: 0; bottom: calc(86px + env(safe-area-inset-bottom)); display: flex; justify-content: center; pointer-events: none; z-index: 30; opacity: 0; transition: opacity .2s; }
#toast.show { opacity: 1; pointer-events: auto; }
#toast .msg { background: var(--text); color: var(--bg); border-radius: 14px; padding: 11px 16px; font-size: 15px; display: flex; gap: 14px; align-items: center; max-width: 92vw; }
#toast button { background: none; border: none; color: var(--toastBtn); font-weight: 700; font-size: 15px; padding: 0; }
.offline { background: var(--t4bg); color: var(--t4fg); font-size: 14px; text-align: center; border-radius: 12px; padding: 6px; }

/* admin page compat (admin.html uses the same palette) */
.searchbar input { width: 100%; border: 1.5px solid var(--line); background: var(--card); border-radius: 14px; padding: 11px 14px; font-size: 16px; }
.mrow { display: flex; gap: 8px; align-items: center; }
.ownertag { font-size: 14px; background: var(--soft); color: var(--primary); border-radius: 999px; padding: 2px 8px; }

/* links to the legal pages (welcome screen and settings) */
.legal { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 16px; font-size: 14px; }
.legal a { color: var(--sub); display: inline-flex; align-items: center; min-height: 44px; }

/* accessibility: visible keyboard focus, 44px touch targets, reduced motion, screen reader messages */
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.sheet:focus-visible { outline: none; }
.fld input:focus-visible, .fld select:focus-visible, .field:focus-visible { outline: 3px solid var(--primary); outline-offset: 1px; }
.iconbtn, .more { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.linkbtn, .back, .chip, .btn.sm, .field, #toast button { min-height: 44px; }
.linkbtn { min-width: 44px; }
.item .ck, .toggle { position: relative; }
.sheetx::before, .item .ck::before, .toggle::before { content: ''; position: absolute; inset: -8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .btn:active { transform: none; }
}
