/* Palgi Home: warm linen + terracotta. Mobile-first at 390px, works to 320px. */
:root {
  --bg: #f6f1e7;
  --surface: #fffcf6;
  --surface-2: #efe7d8;
  --text: #2b2520;
  --muted: #7a6e62;
  --line: #e4dacb;
  --accent: #a8553a;
  --accent-soft: #f3e0d6;
  --on-accent: #fffaf3;
  --olive: #6b7445;
  --olive-soft: #e7e9d6;
  --danger: #b23a2e;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 14px rgba(60, 40, 20, .06);
  --radius: 14px;
  --tab-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1a17;
    --surface: #26231f;
    --surface-2: #322e29;
    --text: #f1ebe2;
    --muted: #a99d90;
    --line: #3a352f;
    --accent: #e08a68;
    --accent-soft: #43302a;
    --on-accent: #1c1a17;
    --olive: #b9c08e;
    --olive-soft: #33362a;
    --danger: #ef7d70;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Rubik, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(16px + var(--safe-t)) 16px calc(var(--tab-h) + var(--safe-b) + 24px);
  min-height: 100vh;
}
#app.no-tabs { padding-bottom: calc(24px + var(--safe-b)); }

/* ---------- Header ---------- */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin: 4px 0 18px; }
.top h1 { font-size: 26px; line-height: 1.2; margin: 0; font-weight: 700; }
.top .sub { color: var(--muted); margin-top: 4px; }
.icon-btn {
  min-width: 44px; min-height: 44px; display: inline-grid; place-items: center;
  background: none; border: 0; border-radius: 12px; color: var(--muted); font-size: 22px; line-height: 1;
}
.icon-btn:active { background: var(--surface-2); }

/* ---------- Cards ---------- */
.card {
  display: block; text-decoration: none;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 14px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; min-height: 28px; }
.card-head h2 { font-size: 17px; margin: 0; font-weight: 650; }
button.more { background: none; border: 0; font: inherit; cursor: pointer; }
.card-head .more { color: var(--accent); font-size: 14px; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; padding-inline: 4px; margin-block: -8px; }
.empty { color: var(--muted); margin: 4px 0; }
.note { font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 6px 10px; margin: 0 0 10px; }

.day { margin-top: 10px; }
.day:first-of-type { margin-top: 0; }
.day-label { font-size: 13px; font-weight: 650; color: var(--accent); margin-bottom: 4px; }
.day-label span { color: var(--muted); font-weight: 400; }
.ev { display: flex; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); }
.day-label + .ev { border-top: 0; }
.ev-time { flex: 0 0 auto; min-width: 64px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; padding-top: 1px; }
.ev-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ev-loc { display: block; color: var(--muted); font-size: 13px; }

.list { list-style: none; margin: 0; padding: 0; }
.task { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.task:first-child { border-top: 0; }
.task-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.task-meta { display: block; font-size: 13px; color: var(--muted); }
.task-meta.late { color: var(--danger); }
.chip {
  flex: 0 0 auto; display: inline-block; font-size: 13px; padding: 2px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); white-space: nowrap;
}
.chip.roei { background: var(--accent-soft); }
.chip.eilat { background: var(--olive-soft); }

.appt-title { font-weight: 600; overflow-wrap: anywhere; }
.appt-when { color: var(--muted); font-size: 14px; }

.count-card { display: flex; align-items: center; gap: 14px; }
.count-card .big { font-size: 34px; font-weight: 700; color: var(--accent); min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.count-card .lbl { flex: 1; }
.count-card .chev { color: var(--muted); font-size: 22px; }

/* ---------- Buttons & fields ---------- */
.btn {
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 0;
  background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 16px;
}
.btn:active { filter: brightness(.94); }
.btn:disabled { opacity: .55; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.danger { background: none; color: var(--danger); border: 1px solid currentColor; }
.btn.block { width: 100%; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.input, select.input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); font-size: 17px;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

/* ---------- Login ---------- */
.login { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; gap: 14px; text-align: center; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto 8px; display: block; }
.login h1 { margin: 0; font-size: 26px; }
.login p { margin: 0 0 8px; color: var(--muted); }
.login .input { text-align: center; font-size: 24px; letter-spacing: .3em; }
.who { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.who button {
  min-height: 120px; border-radius: var(--radius); border: 0; background: var(--surface); box-shadow: var(--shadow);
  font-size: 24px; font-weight: 650; display: grid; place-items: center; gap: 4px; padding: 12px;
}
.who button .av { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; }
.who .roei .av { background: var(--accent-soft); color: var(--accent); }
.who .eilat .av { background: var(--olive-soft); color: var(--olive); }

/* ---------- Shopping ---------- */
.add-bar {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  margin: 0 -16px 8px; padding: calc(8px + var(--safe-t)) 16px 8px;
}
.add-row { display: flex; gap: 8px; }
.add-row .input { flex: 1; min-width: 0; min-height: 54px; font-size: 18px; }
.add-row .btn { min-height: 54px; min-width: 54px; padding: 0 14px; font-size: 26px; line-height: 1; }
.sugg { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 8px; }
.sugg:empty { display: none; }
.sugg button {
  min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 15px;
}
.sugg button::before { content: "+ "; color: var(--accent); }
.dept { margin-bottom: 14px; }
.dept h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 4px 6px; }
.dept ul { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item { display: flex; align-items: stretch; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; min-height: 56px;
  padding-block: 8px; padding-inline: 16px 4px; background: none; border: 0; text-align: start;
}
.box {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center; transition: background .15s, border-color .15s;
}
.item.done .box { background: var(--olive); border-color: var(--olive); }
.item.done .box::after { content: ""; width: 10px; height: 6px; border: solid var(--surface); border-width: 0 0 2.5px 2.5px; transform: translateY(-1px) rotate(-45deg); }
.item-text { flex: 1; min-width: 0; font-size: 17px; overflow-wrap: anywhere; }
.item-sub { display: block; font-size: 13px; color: var(--muted); }
.item.done .item-name { text-decoration: line-through; color: var(--muted); }
.item.pending { opacity: .6; }
.item .icon-btn { min-width: 48px; border-radius: 0; font-size: 20px; }
.clear-btn { margin-top: 4px; }

/* ---------- Bottom sheet ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(20, 14, 8, .38); z-index: 40; animation: fade .15s ease-out; }
.sheet {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 41; max-width: 560px; margin: 0 auto;
  background: var(--surface); border-radius: 18px 18px 0 0;
  padding: 10px 16px calc(16px + var(--safe-b)); animation: up .18s ease-out;
  max-height: 88vh; overflow-y: auto;
}
.sheet .grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { font-size: 19px; margin: 0 0 14px; overflow-wrap: anywhere; }
.sheet .row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.sheet .row2 .input { min-width: 0; }
.sheet .actions { display: flex; gap: 10px; margin-top: 6px; }
.sheet .actions .btn { flex: 1; }
.menu-item { display: flex; width: 100%; align-items: center; min-height: 52px; padding: 0 4px; background: none; border: 0; border-top: 1px solid var(--line); font-size: 17px; text-align: start; }
.menu-item:first-of-type { border-top: 0; }
@keyframes up { from { transform: translateY(30%); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Shared list rows (tasks, Ari, info) ---------- */
.top > h1 { align-self: center; }
.btn.sm { min-height: 44px; padding: 0 14px; font-size: 15px; flex: 0 0 auto; }
textarea.input { resize: vertical; min-height: 72px; line-height: 1.4; }
.rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card .rows { box-shadow: none; border-radius: 0; background: none; margin-inline: -16px; }
.rows > li { display: flex; align-items: center; border-top: 1px solid var(--line); min-height: 56px; }
.rows > li:first-child { border-top: 0; }
.row-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; min-height: 56px;
  padding-block: 8px; padding-inline: 16px 8px; background: none; border: 0; text-align: start;
}
.row-main:active { background: var(--surface-2); }
.row-text { flex: 1; min-width: 0; display: block; }
.row-title { display: block; font-size: 17px; overflow-wrap: anywhere; }
.row-sub { display: block; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.row-sub .late, .late { color: var(--danger); font-weight: 600; }
.mark { margin-inline-start: 6px; font-size: 12px; }
.mark.warn { color: var(--danger); }
.pending { opacity: .6; }
.center { text-align: center; padding: 24px 0; }
.empty-state { text-align: center; padding: 36px 8px; color: var(--muted); }
.empty-state p { margin: 0 0 14px; }
.empty-state.small { padding: 8px 0 4px; }
.sub-h { font-size: 13px; color: var(--muted); font-weight: 600; margin: 14px 0 2px; }

/* segmented radios + toggle buttons */
.seg { border: 0; padding: 0; margin: 0 0 12px; min-width: 0; }
.seg legend { padding: 0; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.seg-opts { display: flex; flex-wrap: wrap; gap: 6px; background: var(--surface-2); border-radius: 12px; padding: 4px; }
.seg label { flex: 1 1 auto; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.seg span { display: grid; place-items: center; min-height: 40px; padding: 0 10px; border-radius: 9px; font-size: 15px; white-space: nowrap; }
.seg input:checked + span { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; color: var(--accent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.check-field { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-bottom: 8px; }
.check-field input { width: 22px; height: 22px; accent-color: var(--accent); }
.tabs2 { display: flex; gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 10px; }
.tabs2 button { flex: 1; min-height: 44px; border: 0; border-radius: 9px; background: none; font-size: 16px; color: var(--muted); }
.tabs2 button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chips button { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 15px; }
.chips button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }

/* ---------- Tasks ---------- */
.trow { padding-inline-end: 12px; }
.check { flex: 0 0 auto; min-width: 52px; min-height: 56px; display: grid; place-items: center; background: none; border: 0; padding-inline-start: 8px; }
.trow .row-main { padding-inline-start: 0; }
.trow.done .box { background: var(--olive); border-color: var(--olive); }
.trow.done .box::after { content: ""; width: 10px; height: 6px; border: solid var(--surface); border-width: 0 0 2.5px 2.5px; transform: translateY(-1px) rotate(-45deg); }
.trow.done .row-title { text-decoration: line-through; color: var(--muted); }

/* ---------- Ari ---------- */
.kind { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 18px; }
.kind-lbl { color: var(--muted); font-size: 14px; }
.arow.past { opacity: .72; }
.sizes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sizes .field { margin: 0; }
.sizes .input { padding-inline: 10px; font-size: 16px; }
.spark { margin: 0 0 10px; color: var(--accent); }
.spark svg { display: block; width: 100%; height: auto; overflow: visible; }
.spark figcaption { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 4px; direction: ltr; }
.spark figcaption span { direction: rtl; unicode-bidi: isolate; }
.spark figcaption strong { color: var(--text); }
.grow { padding-inline-start: 16px; gap: 10px; font-variant-numeric: tabular-nums; }
.g-date { flex: 1; color: var(--muted); }
.g-val { min-width: 64px; }
.rows > .nrow { padding-inline-start: 16px; align-items: flex-start; padding-block: 8px; }
.note-text { display: block; white-space: pre-wrap; overflow-wrap: anywhere; }
.rows .icon-btn { flex: 0 0 auto; min-width: 48px; }

/* ---------- Info ---------- */
.search { margin-bottom: 14px; }
.crow .details { white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
/* The phone pill wraps under the name when the text column would get narrower than 170px (320px screens). */
.crow { flex-wrap: wrap; }
.crow .row-main { flex: 1 1 170px; }
.phone {
  flex: 0 0 auto; min-height: 44px; display: inline-flex; align-items: center; margin-block: 4px; margin-inline: 16px 10px; padding: 0 12px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent); text-decoration: none; font-weight: 600;
  font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 4px max(8px, env(safe-area-inset-left)) calc(4px + var(--safe-b)) max(8px, env(safe-area-inset-right));
}
.tabbar a {
  flex: 1; min-height: 52px; min-width: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 12px; border-radius: 12px; position: relative;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; inset-inline: 16px; bottom: calc(var(--tab-h) + var(--safe-b) + 16px); z-index: 50;
  max-width: 420px; margin: 0 auto; padding: 12px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); text-align: center; box-shadow: var(--shadow);
  animation: up .18s ease-out;
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
}
.toast-act { min-height: 44px; padding: 0 14px; border: 0; border-radius: 10px; background: color-mix(in srgb, var(--bg) 18%, transparent); color: var(--bg); font-weight: 700; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
