/* ---------- טוקנים ---------- */
:root {
  --bg: #22211f;
  --surface: #302f2c;
  --surface-2: #3a3936;
  --tabbar: #1a1918;
  --text: #f2f1ee;
  --muted: #9c9a94;
  --tab-off: #8c8a85;
  --green: #7fc046;
  --green-shadow: #4f8a26;
  --green-text: #8fd14f;
  --orange: #ff7a2f;
  --orange-shadow: #c4501a;
  --orange-text: #ff9b5e;
  --orange-soft: #3a2a20;
  --hero: #2f5e1d;
  --blue: #5fb3f0;
  --amber: #ffb84d;
  --tab-h: 66px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.45 'Rubik', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.muted { color: var(--muted); }
.sm { font-size: .8rem; }
.ic { width: 20px; height: 20px; fill: currentColor; flex-shrink: 0; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.two { display: flex; gap: 10px; }
.two > * { flex: 1; }

/* ---------- מסכים ---------- */
.screen {
  padding: 14px 14px calc(var(--tab-h) + 28px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}
.screen.has-play { padding-bottom: calc(var(--tab-h) + 96px + env(safe-area-inset-bottom)); }
.screen.wiz { padding-bottom: calc(24px + env(safe-area-inset-bottom)); min-height: 100vh; }
.page-title { font-size: 1.3rem; font-weight: 600; }
.greet { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 1.05rem; }
.avatar { width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; color: #cfcdc8; }
.empty { color: var(--muted); text-align: center; padding: 18px 8px; }

/* ---------- כרטיסים ---------- */
.card { background: var(--surface); border-radius: 16px; padding: 14px; display: block; }
a.card, button.card { width: 100%; text-align: inherit; border: 0; cursor: pointer; }

/* ---------- כרטיס ראשי ---------- */
.hero { position: relative; overflow: hidden; border-radius: 18px; background: var(--hero); padding: 18px 16px; min-height: 144px; }
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to left, rgba(0,0,0,.55) 0%, rgba(0,0,0,.25) 45%, rgba(0,0,0,0) 70%),
    radial-gradient(ellipse at 25% 55%, rgba(0,0,0,0) 45%, rgba(0,0,0,.4) 100%);
}
.hero-txt { position: relative; z-index: 1; max-width: 52%; }
.hero-title { font-size: 1.4rem; font-weight: 700; color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.35); }
.hero-sub { color: #e4f4d6; font-size: .85rem; margin: 4px 0 14px; line-height: 1.4; text-shadow: 0 1px 4px rgba(0,0,0,.35); }
.hero-art { position: absolute; left: 0; bottom: 0; width: 48%; max-width: 210px; height: 100%; }
.hero-ring { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); z-index: 1; }

/* ---------- כפתורים ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 11px 18px; color: #fff; font-weight: 600; cursor: pointer;
  transition: transform .06s, box-shadow .06s;
}
.btn-green { background: var(--green); box-shadow: 0 4px 0 var(--green-shadow); }
.btn-orange { background: var(--orange); box-shadow: 0 4px 0 var(--orange-shadow); }
.btn-ghost { background: var(--surface-2); box-shadow: 0 4px 0 #1a1918; color: var(--text); }
.btn:active { transform: translateY(4px); box-shadow: none; }
.btn[disabled] { opacity: .5; cursor: progress; }
.btn-block { width: 100%; }
.btn-lg { font-size: 1.05rem; padding: 14px 18px; border-radius: 14px; }
.btn.is-cur { outline: 3px solid #fff; outline-offset: 2px; }
.btn.danger { color: var(--orange-text); }
.link { background: none; border: 0; color: var(--muted); font-weight: 500; padding: 8px; cursor: pointer; text-align: center; }
.link.accent { color: var(--green-text); }
.icon-btn { width: 38px; height: 38px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- כותרות סקציה ---------- */
.sec { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; font-size: 1rem; margin-top: 4px; }
.sec a, .sec span { color: var(--muted); font-weight: 400; font-size: .85rem; }

/* ---------- אריחי נתונים ---------- */
.tiles { display: flex; gap: 8px; }
.tile { flex: 1; background: var(--surface); border-radius: 12px; padding: 12px 4px; text-align: center; }
.tile .ic { width: 24px; height: 24px; }
.tile b { display: block; font-size: 1.3rem; font-weight: 600; margin-top: 2px; color: var(--text); }
.tile small { color: var(--muted); font-size: .72rem; }
.tile-green .ic { color: var(--green-text); }
.tile-blue .ic { color: var(--blue); }
.tile-amber .ic { color: var(--amber); }

/* ---------- כרטיס "לשפר" ---------- */
.tip { background: var(--orange-soft); border-radius: 14px; padding: 12px; display: flex; gap: 12px; align-items: center; }
.tip-ico { width: 36px; height: 36px; border-radius: 10px; background: var(--orange); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
.tip small { color: var(--orange-text); font-weight: 500; font-size: .75rem; display: block; }
.tip ul { margin: 2px 0 0; padding: 0; list-style: none; }
.tip li { font-weight: 500; }

/* ---------- שבועות ---------- */
.weeks { display: flex; gap: 8px; }
.wk { flex: 1; background: var(--surface); border-radius: 12px; padding: 12px 6px; text-align: center; }
.wk b { display: block; font-size: 1.2rem; font-weight: 600; }
.wk span { font-size: .75rem; color: var(--muted); }
.tone-green { color: var(--green-text); }
.tone-orange { color: var(--orange-text); }
.tone-muted { color: var(--muted); }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.bar span { display: block; height: 100%; border-radius: 4px; background: var(--green); }
.bar span.tone-bg-orange { background: var(--orange); }
.bar span.tone-bg-muted { background: var(--surface-2); }

/* ---------- טבעת ---------- */
.ring {
  --s: 56px; width: var(--s); height: var(--s); border-radius: 50%; flex-shrink: 0;
  background: conic-gradient(var(--green) calc(var(--p) * 1%), var(--surface-2) 0);
  display: grid; place-items: center;
}
.ring b { width: calc(var(--s) - 14px); height: calc(var(--s) - 14px); border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: calc(var(--s) * .22); font-weight: 600; }
.hero .ring b { background: var(--hero); }

/* ---------- פס כפתור ראשי + ניווט ---------- */
.playbar {
  position: fixed; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding: 12px 14px; z-index: 5;
  background: linear-gradient(transparent, var(--bg) 35%);
}
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px; z-index: 6;
  display: flex; justify-content: space-around; background: var(--tabbar);
  padding: 9px 0 calc(9px + env(safe-area-inset-bottom)); min-height: var(--tab-h);
}
.tabbar[hidden] { display: none; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 64px; font-size: .72rem; color: var(--tab-off); font-weight: 400; }
.tab .ic { width: 24px; height: 24px; }
.tab.on { color: #fff; font-weight: 500; }

/* ---------- מסע ---------- */
.topline { display: flex; align-items: center; gap: 10px; }
.prog { flex: 1; height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.prog span { display: block; height: 100%; background: var(--green); border-radius: 6px; transition: width .25s; }
.counter { color: var(--muted); font-size: .8rem; font-weight: 500; min-width: 32px; text-align: center; }
.wiz-body { flex: 1; display: flex; flex-direction: column; gap: 14px; padding-top: 8px; }
.wiz-title { font-size: 1.35rem; font-weight: 600; text-align: center; }
.wiz-sub { text-align: center; color: var(--muted); margin-top: -8px; }
.wiz-actions { display: flex; flex-direction: column; gap: 8px; }
.bigicon { width: 76px; height: 76px; border-radius: 22px; margin: 6px auto 0; display: grid; place-items: center; background: var(--surface); color: var(--green-text); }
.bigicon .ic { width: 42px; height: 42px; }
.bigicon.gold { color: #ffd166; }
.sub-label { text-align: center; color: var(--muted); font-weight: 500; }
.subs { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.subsq { width: 46px; height: 46px; border-radius: 12px; border: 0; background: var(--surface-2); box-shadow: 0 3px 0 #1a1918; font-weight: 600; font-size: 1.05rem; cursor: pointer; }
.subsq.on { background: var(--green); box-shadow: 0 3px 0 var(--green-shadow); color: #fff; }
.subrows { display: flex; flex-direction: column; gap: 8px; }
.subrow { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 0; border-radius: 12px; padding: 10px 12px; text-align: right; cursor: pointer; }
.subbox { width: 24px; height: 24px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; color: transparent; flex-shrink: 0; }
.subrow.on .subbox { background: var(--green); color: #fff; }

/* ---------- שדות ---------- */
.field {
  font: inherit; color: var(--text); width: 100%;
  background: var(--surface); border: 2px solid transparent; border-radius: 12px; padding: 12px;
}
.field::placeholder { color: var(--tab-off); }
.field:focus { outline: none; border-color: var(--green); }
textarea.field { resize: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-block; border: 0; border-radius: 99px; padding: 5px 12px; background: var(--surface-2); color: var(--text); font-size: .85rem; cursor: pointer; }
.chip.on { background: var(--green); color: #fff; }
.chip.sm { padding: 1px 9px; font-size: .72rem; cursor: default; background: var(--surface-2); color: var(--muted); }
.lesson-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--surface); border-radius: 12px; padding: 10px 12px; width: 100%; border: 0; text-align: right; }
.lesson-item > div { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.opt-title { font-weight: 600; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }

/* ---------- תצוגת שבוע ---------- */
.week-head { display: flex; align-items: center; gap: 6px; }
.week-head h1 { font-size: 1.15rem; flex: 1; }
.week-head small { color: var(--muted); font-weight: 400; font-size: .8rem; display: block; }
.fchips { display: flex; gap: 8px; overflow-x: auto; }
.fchip { border: 0; border-radius: 99px; padding: 7px 14px; background: var(--surface); color: var(--muted); font-weight: 500; white-space: nowrap; cursor: pointer; }
.fchip.on { background: #fff; color: #111; }
.goal-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 0; border-radius: 14px; padding: 12px; width: 100%; text-align: right; cursor: pointer; }
.status { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-2); color: transparent; }
.status.ok { background: var(--green); color: #fff; }
.gtxt { flex: 1; min-width: 0; }
.gname { font-weight: 500; }
.gnote { display: block; color: var(--muted); font-size: .8rem; margin-top: 2px; }

/* ---------- bottom sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; max-height: 90vh; overflow-y: auto; }
.sheet select.field { appearance: none; }
.dialog-layer { z-index: 30; }

/* ---------- היסטוריה ---------- */
.hist-pct { font-size: 1.3rem; font-weight: 600; }
.unsum { font-size: .72rem; color: var(--orange-text); font-weight: 500; }

/* ---------- שבב סטטוס סנכרון ---------- */
.sync-chip-slot { margin-inline-start: auto; }
.sync-chip { display: inline-block; font-size: .75rem; font-weight: 500; color: var(--orange-text); background: var(--orange-soft); border-radius: 99px; padding: 4px 12px; }

/* ---------- הגדרות ---------- */
.tag-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--surface-2); }
.tag-row:last-child { border-bottom: 0; }
.add-row { display: flex; gap: 8px; margin-top: 10px; }
.add-row .field { flex: 1; }
