/* =========================================================================
   Shas Tracker v2 — "Duolingo-style" learning trail
   Bright, chunky, 3D-button gamified path over the full Mishnah (525 perakim).
   Rainbow section (Seder) colors · white canvas · Nunito rounded type.
   ========================================================================= */

:root {
  --fui: "Nunito", system-ui, sans-serif;
  --fhe: "Heebo", system-ui, sans-serif;

  --ink:   #4b4b4b;
  --ink-2: #777777;
  --ink-3: #afafaf;
  --bg:    #ffffff;
  --panel: #ffffff;
  --line:  #e5e5e5;
  --line-2:#d8d8d8;

  /* locked / not-yet node */
  --grey:   #e5e5e5;
  --grey-d: #c4c4c4;

  /* person accents (Abba / Yehuda) — used in header + stats + current pulse */
  --abba:   #58cc02;
  --abba-d: #58a700;
  --yeh:    #1cb0f6;
  --yeh-d:  #1899d6;

  /* gold — chests & crowns */
  --gold:   #ffc800;
  --gold-d: #e0a800;

  --r-lg: 18px;
  --r-md: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: #e8e8e8; }
body { font-family: var(--fui); color: var(--ink); -webkit-font-smoothing: antialiased; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* app shell — phone column centered */
.duo {
  --acc:   var(--abba);
  --acc-d: var(--abba-d);
  max-width: 480px; margin: 0 auto; height: 100dvh; overflow: hidden;
  background: var(--bg); position: relative;
  display: flex; flex-direction: column;
  box-shadow: 0 0 0 1px var(--line), 0 10px 60px rgba(0,0,0,.12);
}
.duo[dir="rtl"] { font-family: var(--fhe); }

/* ============================ TOP BAR (stats) ============================ */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: var(--bg);
  border-bottom: 2px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; margin-inline-end: auto; min-width: 0; }
.brand .mark {
  width: 38px; height: 38px; border-radius: 12px; flex: 0 0 auto;
  background: var(--acc); color: #fff; display: grid; place-items: center;
  box-shadow: 0 3px 0 var(--acc-d);
}
.brand .bt { font-weight: 900; font-size: 17px; letter-spacing: -.4px; color: var(--ink); line-height: 1; }
.brand .bs { font-weight: 800; font-size: 10.5px; letter-spacing: .3px; color: var(--ink-3); margin-top: 3px; text-transform: uppercase; }

.statpill {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 900; font-size: 15px; color: var(--ink); flex: 0 0 auto;
}
.statpill .ic { display: grid; place-items: center; }
.statpill.crown { color: var(--gold-d); }

.flagtoggle { display: flex; background: #f0f0f0; border-radius: 999px; padding: 3px; flex: 0 0 auto; }
.flagtoggle button { width: 30px; height: 28px; border-radius: 999px; font-weight: 900; font-size: 13px; color: var(--ink-3); font-family: var(--fhe); }
.flagtoggle button.on { background: #fff; color: var(--acc-d); box-shadow: 0 1px 3px rgba(0,0,0,.15); }

/* person switch — big segmented control under the brand row */
.personbar { display: flex; gap: 10px; padding: 12px 16px 14px; background: var(--bg); border-bottom: 2px solid var(--line); position: sticky; top: 63px; z-index: 39; }
.pbtn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 9px;
  height: 52px; border-radius: 16px; font-weight: 800; font-size: 15px;
  background: #fff; border: 2px solid var(--line); color: var(--ink-2);
  box-shadow: 0 2px 0 var(--line-2); transition: transform .08s;
}
.pbtn:active { transform: translateY(2px); box-shadow: none; }
.pbtn .av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 14px; color: #fff; flex: 0 0 auto; }
.pbtn .meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1; }
.pbtn .meta b { font-size: 15px; font-weight: 900; }
.pbtn .meta i { font-size: 11px; font-weight: 800; font-style: normal; color: var(--ink-3); margin-top: 3px; }
.pbtn.abba.on { border-color: var(--abba); background: #f0ffe0; color: var(--abba-d); box-shadow: 0 3px 0 var(--abba-d); }
.pbtn.yeh.on  { border-color: var(--yeh);  background: #e6f7ff; color: var(--yeh-d);  box-shadow: 0 3px 0 var(--yeh-d); }
.pbtn.abba.on .meta i, .pbtn.yeh.on .meta i { color: inherit; opacity: .8; }

/* ===================== STICKY UNIT BAR (scroll-spy) ===================== */
.stickyunit {
  position: sticky; top: 129px; z-index: 30;
  margin: 0; padding: 12px 18px; color: #fff;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,.10);
}
.stickyunit .label { flex: 1; min-width: 0; }
.stickyunit .label .u { font-size: 11px; font-weight: 900; letter-spacing: .6px; text-transform: uppercase; opacity: .85; }
.stickyunit .label .n { font-size: 18px; font-weight: 900; letter-spacing: -.3px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stickyunit .crown {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 900; font-size: 14px;
  background: rgba(0,0,0,.16); padding: 7px 12px; border-radius: 999px; flex: 0 0 auto;
}

/* ============================== SCROLL AREA ============================== */
.scroll { flex: 1 1 0; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.pathwrap { padding: 8px 0 120px; }

/* section (Seder) divider */
.section-div { display: flex; align-items: center; gap: 14px; padding: 26px 26px 20px; width: 100%; text-align: center; }
.section-div .ln { flex: 1; height: 3px; border-radius: 3px; background: var(--line); transition: opacity .2s; }
.section-div .mid { text-align: center; }
.section-div .mid .k { display: block; font-size: 11px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-3); }
.section-div .mid .s { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 20px; font-weight: 900; letter-spacing: -.4px; margin-top: 2px; white-space: nowrap; }
.section-div .chev { display: inline-flex; transition: transform .2s; transform: rotate(90deg); }
.section-div.collapsed .chev { transform: rotate(0deg); }
.section-div.collapsed .ln { opacity: .45; }

/* unit (Masechta) header banner */
.unit {
  position: sticky; top: 8px; z-index: 25; width: 100%; text-align: start;
  margin: 20px 16px 6px; padding: 15px 18px; border-radius: var(--r-lg);
  color: #fff; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 5px 0 var(--ud, rgba(0,0,0,.25));
}
.unit:first-of-type { margin-top: 6px; }
.unit .info { flex: 1; min-width: 0; }
.unit .info .k { display: block; font-size: 11px; font-weight: 900; letter-spacing: .7px; text-transform: uppercase; opacity: .82; }
.unit .info .m { display: block; font-size: 20px; font-weight: 900; letter-spacing: -.4px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit .crown {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 900; font-size: 15px;
  background: rgba(0,0,0,.17); padding: 8px 13px; border-radius: 999px; flex: 0 0 auto;
}
.unit .crown.full { background: var(--gold); color: #6b4c00; }
.unit .chev { flex: 0 0 auto; display: inline-flex; transition: transform .2s; transform: rotate(90deg); opacity: .85; }
.unit.collapsed .chev { transform: rotate(0deg); }

/* ============================== THE TRAIL ============================== */
.trail { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 20px 0 6px; }
.noderow { position: relative; display: flex; justify-content: center; width: 100%; }

.node {
  position: relative; width: 62px; height: 58px; border-radius: 50%;
  display: grid; place-items: center; transition: transform .09s ease;
}
.node .cap {
  width: 62px; height: 58px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 900; font-size: 17px; position: relative; z-index: 2;
}
.node .num { position: relative; z-index: 3; }
.node:active .cap { transform: translateY(4px); }

/* future / not-yet */
.node.future .cap { background: var(--grey); color: #b0b0b0; box-shadow: 0 5px 0 var(--grey-d); }
.node.future:active .cap { box-shadow: 0 1px 0 var(--grey-d); }
/* done */
.node.done .cap { background: var(--nc); color: var(--non); box-shadow: 0 5px 0 var(--nd); }
.node.done:active .cap { box-shadow: 0 1px 0 var(--nd); }
/* current — outlined, pulsing, with START bubble */
.node.current .cap {
  background: #fff; color: var(--nc); border: 3px solid var(--nc);
  box-shadow: 0 5px 0 var(--nd);
}
.node.current:active .cap { box-shadow: 0 1px 0 var(--nd); }
.node.current .pulse {
  position: absolute; inset: -6px; border-radius: 50%; z-index: 1;
  border: 3px solid var(--nc); opacity: .55; animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse { 0%{ transform: scale(.9); opacity: .6 } 70%{ transform: scale(1.35); opacity: 0 } 100%{ opacity: 0 } }

.startbubble {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  margin-bottom: 12px; background: #fff; color: var(--nc);
  font-weight: 900; font-size: 12px; letter-spacing: 1px; text-transform: uppercase;
  padding: 8px 14px; border-radius: 12px; white-space: nowrap; z-index: 6;
  box-shadow: 0 3px 0 rgba(0,0,0,.10); animation: bob 1.4s ease-in-out infinite;
}
.startbubble::after {
  content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 8px solid transparent; border-top-color: #fff; margin-top: -1px;
}
@keyframes bob { 0%,100%{ transform: translateX(-50%) translateY(0) } 50%{ transform: translateX(-50%) translateY(-5px) } }

/* star check on done nodes */
.node .star svg { display: block; }

/* chest at masechta end */
.chest { position: relative; width: 70px; height: 66px; display: grid; place-items: center; transition: transform .09s; }
.chest .box {
  width: 66px; height: 58px; border-radius: 16px; display: grid; place-items: center;
  box-shadow: 0 5px 0 var(--cd, var(--grey-d));
}
.chest:active .box { transform: translateY(3px); box-shadow: 0 2px 0 var(--cd, var(--grey-d)); }
.chest.locked .box { background: var(--grey); color: #adadad; box-shadow: 0 5px 0 var(--grey-d); }
.chest.ready .box { background: var(--gold); color: #6b4c00; box-shadow: 0 5px 0 var(--gold-d); }
.chest.ready { animation: chestwiggle 2.4s ease-in-out infinite; }
@keyframes chestwiggle { 0%,92%,100%{ transform: rotate(0) } 94%{ transform: rotate(-5deg) } 96%{ transform: rotate(5deg) } 98%{ transform: rotate(-3deg) } }

.trophy-end { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 30px 20px 10px; text-align: center; }
.trophy-end .big { width: 92px; height: 92px; border-radius: 26px; display: grid; place-items: center; background: var(--gold); color: #6b4c00; box-shadow: 0 6px 0 var(--gold-d); }
.trophy-end .tt { font-weight: 900; font-size: 20px; letter-spacing: -.4px; }
.trophy-end .ts { font-weight: 700; font-size: 13px; color: var(--ink-2); }

/* hide numbers when toggled */
.duo.nonum .node.future .num, .duo.nonum .node.done .num { display: none; }

/* ============================ CELEBRATION ============================ */
.cele-overlay {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center;
  background: rgba(30,30,30,.55); padding: 24px; animation: fade .2s ease;
}
@keyframes fade { from{ opacity: 0 } to{ opacity: 1 } }
.cele-card {
  position: relative; width: 100%; max-width: 340px; background: #fff; border-radius: 22px;
  padding: 30px 26px 24px; text-align: center; box-shadow: 0 18px 50px rgba(0,0,0,.3);
  animation: pop .32s cubic-bezier(.2,1.3,.5,1);
}
@keyframes pop { from{ transform: scale(.8); opacity: .5 } to{ transform: scale(1); opacity: 1 } }
.cele-card .medal {
  width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 16px; display: grid; place-items: center;
  color: #fff; box-shadow: 0 8px 0 var(--md, rgba(0,0,0,.2)); animation: medalIn .5s cubic-bezier(.2,1.4,.5,1) both; }
@keyframes medalIn { 0%{ transform: scale(.3) rotate(-30deg); opacity: 0 } 100%{ transform: scale(1) rotate(0); opacity: 1 } }
.cele-card .yell { font-weight: 900; font-size: 24px; letter-spacing: -.5px; color: var(--cc, var(--abba-d)); }
.cele-card .sub { font-weight: 800; font-size: 15px; color: var(--ink); margin-top: 8px; }
.cele-card .meta { font-weight: 700; font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.cele-card .xp {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 16px; padding: 8px 16px; border-radius: 999px;
  background: #fff7d6; color: var(--gold-d); font-weight: 900; font-size: 14px; border: 2px solid #ffe58a;
}
.cele-btn {
  margin-top: 22px; width: 100%; height: 52px; border-radius: 16px; font-weight: 900; font-size: 16px;
  letter-spacing: .3px; text-transform: uppercase; color: #fff; background: var(--cc, var(--abba));
  box-shadow: 0 4px 0 var(--cd2, var(--abba-d)); transition: transform .08s;
}
.cele-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--cd2, var(--abba-d)); }

/* confetti */
.confetti { position: absolute; inset: -40px -20px 0; overflow: hidden; pointer-events: none; z-index: -1; }
.confetti i { position: absolute; top: -12px; width: 10px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(520px) rotate(720deg); opacity: 0; } }

/* ======================= WRITE PASSWORD GATE (reading Shas stays public) ======================= */
.authgate-overlay {
  position: fixed; inset: 0; z-index: 95; display: grid; place-items: center;
  background: rgba(30,30,30,.55); padding: 24px; animation: fade .2s ease;
}
.authgate-card {
  width: 100%; max-width: 320px; background: #fff; border-radius: 20px;
  padding: 26px 22px 22px; text-align: center; box-shadow: 0 18px 50px rgba(0,0,0,.3);
  animation: pop .28s cubic-bezier(.2,1.3,.5,1);
}
.authgate-lock {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 12px; display: grid; place-items: center;
  background: var(--acc); color: #fff; box-shadow: 0 4px 0 var(--acc-d);
}
.authgate-title { font-weight: 900; font-size: 18px; letter-spacing: -.3px; }
.authgate-sub { font-weight: 700; font-size: 12.5px; color: var(--ink-2); margin-top: 5px; }
.authgate-input {
  width: 100%; height: 46px; margin-top: 16px; border: 2px solid var(--line); border-radius: 12px;
  text-align: center; font: inherit; font-weight: 800; font-size: 16px; letter-spacing: 4px; outline: none;
}
.authgate-input:focus { border-color: var(--acc); }
.authgate-err { color: #e0393e; font-weight: 800; font-size: 12px; margin-top: 8px; }
.authgate-actions { display: flex; gap: 10px; margin-top: 18px; }
.authgate-cancel, .authgate-submit { flex: 1; height: 46px; border-radius: 13px; font-weight: 900; font-size: 14px; }
.authgate-cancel { background: #f4f4f4; color: var(--ink-2); }
.authgate-submit { background: var(--acc); color: #fff; box-shadow: 0 3px 0 var(--acc-d); }
.authgate-submit:active { transform: translateY(2px); box-shadow: none; }

/* ============================== BOTTOM NAV ============================== */
.bottomnav {
  position: sticky; bottom: 0; z-index: 40; display: flex; gap: 4px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: #fff;
  border-top: 2px solid var(--line);
}
.navbtn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px; border-radius: 14px; color: var(--ink-3); font-weight: 900; font-size: 11px;
  letter-spacing: .3px; transition: background .12s;
}
.navbtn .ic { display: grid; place-items: center; }
.navbtn.on { color: var(--acc-d); background: color-mix(in srgb, var(--acc) 14%, #fff); }

/* ============================== SEARCH VIEW ============================== */
.searchview { padding: 16px 16px 120px; }
.searchbox { display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 16px; background: #f4f4f4; border-radius: 16px; color: var(--ink-2); margin-bottom: 14px; }
.searchbox input { flex: 1; border: none; outline: none; background: transparent; font: inherit; font-weight: 700; font-size: 15px; color: var(--ink); }
.searchbox input::placeholder { color: var(--ink-3); font-weight: 700; }

.statseg { display: flex; gap: 8px; margin-bottom: 12px; }
.statseg button { flex: 1; height: 42px; border-radius: 12px; font-weight: 900; font-size: 13px; background: #f4f4f4; color: var(--ink-2); border: 2px solid transparent; }
.statseg button.on { background: color-mix(in srgb, var(--acc) 16%, #fff); color: var(--acc-d); border-color: var(--acc); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips .chip { flex: 0 0 auto; height: 38px; padding: 0 15px; border-radius: 999px; font-weight: 800; font-size: 13px; background: #f4f4f4; color: var(--ink-2); white-space: nowrap; display: inline-flex; align-items: center; }
.chips .chip.on { background: var(--ink); color: #fff; }

.mcard { border: 2px solid var(--line); border-radius: 16px; padding: 14px 15px; margin-bottom: 12px; }
.mcard .mh { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.mcard .mh .dot { width: 12px; height: 12px; border-radius: 4px; flex: 0 0 auto; }
.mcard .mh .nm { font-weight: 900; font-size: 16px; letter-spacing: -.2px; }
.mcard .mh .ct { margin-inline-start: auto; font-weight: 900; font-size: 13px; color: var(--ink-3); }
.mcard .mtiles, .nowcard .mtiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 7px; }
.mtile { aspect-ratio: 1; border-radius: 10px; font-weight: 900; font-size: 13px; display: grid; place-items: center; color: #b0b0b0; background: var(--grey); box-shadow: 0 3px 0 var(--grey-d); transition: transform .08s; }
.mtile:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--grey-d); }
.mtile.done { color: var(--non); }
.searchhint { text-align: center; color: var(--ink-3); font-weight: 800; font-size: 14px; padding: 40px 12px; }

/* ============================== STATS VIEW ============================== */
.stats { padding: 18px 16px 120px; }
.stats h2 { font-weight: 900; font-size: 22px; letter-spacing: -.5px; margin: 0 0 4px; }
.stats .subhead { font-weight: 700; font-size: 13px; color: var(--ink-2); margin: 0 0 18px; }

.srange { display: flex; gap: 8px; margin-bottom: 18px; }
.srange button { flex: 1; height: 40px; border-radius: 12px; font-weight: 900; font-size: 13px; background: #f4f4f4; color: var(--ink-2); border: 2px solid transparent; }
.srange button.on { background: var(--ink); color: #fff; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.kpi { border: 2px solid var(--line); border-radius: 16px; padding: 15px 16px; }
.kpi .l { font-weight: 900; font-size: 11px; letter-spacing: .5px; text-transform: uppercase; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.kpi .v { font-weight: 900; font-size: 30px; letter-spacing: -1px; margin-top: 6px; line-height: 1; }
.kpi .v small { font-size: 15px; font-weight: 800; color: var(--ink-3); }
.kpi .s { font-weight: 700; font-size: 12px; color: var(--ink-2); margin-top: 6px; }

.scard { border: 2px solid var(--line); border-radius: 18px; padding: 16px 16px 14px; margin-bottom: 16px; }
.scard .ch { display: flex; align-items: center; margin-bottom: 3px; }
.scard .ch .t { font-weight: 900; font-size: 16px; letter-spacing: -.3px; }
.scard .ch .leg { margin-inline-start: auto; display: flex; gap: 12px; }
.scard .ch .leg span { display: inline-flex; align-items: center; gap: 5px; font-weight: 800; font-size: 11px; color: var(--ink-2); }
.scard .ch .leg .sw { width: 10px; height: 10px; border-radius: 3px; }
.scard .cs { font-weight: 700; font-size: 12px; color: var(--ink-3); margin-bottom: 12px; }

.linechart { width: 100%; display: block; }
.linechart .grid { stroke: var(--line); stroke-width: 1.5; }
.linechart .axislbl { fill: var(--ink-3); font-size: 9px; font-weight: 800; font-family: var(--fui); }
.linechart .ln { fill: none; stroke-width: 3.5; stroke-linejoin: round; stroke-linecap: round; }
.linechart .area { opacity: .12; }

.sbreak { display: flex; flex-direction: column; gap: 14px; }
.sbrow .sbn { display: flex; align-items: baseline; font-weight: 900; font-size: 13px; margin-bottom: 7px; }
.sbrow .sbn .tot { margin-inline-start: auto; font-weight: 800; font-size: 11px; color: var(--ink-3); }
.sbrow .pr { display: flex; align-items: center; gap: 9px; }
.sbrow .pr + .pr { margin-top: 6px; }
.sbrow .pr .ini { width: 16px; font-weight: 900; font-size: 11px; color: var(--ink-3); }
.sbrow .pr .track { flex: 1; height: 12px; border-radius: 999px; background: #efefef; overflow: hidden; }
.sbrow .pr .track i { display: block; height: 100%; border-radius: 999px; transition: width .5s; }
.sbrow .pr .n { width: 42px; text-align: right; font-weight: 900; font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.pace { display: flex; gap: 14px; }
.pacecol { flex: 1; }
.pacecol .ph { display: flex; align-items: center; gap: 7px; font-weight: 900; font-size: 12px; color: var(--ink-2); margin-bottom: 10px; }
.pacecol .ph .sw { width: 11px; height: 11px; border-radius: 4px; }
.pacecol .ph b { margin-inline-start: auto; font-size: 17px; font-weight: 900; color: var(--ink); }
.pacebars { display: flex; align-items: flex-end; gap: 5px; height: 66px; }
.pacebars .pb { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.pacebars .pb .b { width: 100%; border-radius: 5px 5px 3px 3px; min-height: 4px; transition: height .4s; }
.pacebars .pb .d { font-weight: 900; font-size: 9px; color: var(--ink-3); }

/* toast */
.toast { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; font-weight: 800; font-size: 13.5px; padding: 12px 20px; border-radius: 999px; box-shadow: 0 10px 24px rgba(0,0,0,.25); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 80; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.loading { display: grid; place-items: center; min-height: 60vh; color: var(--ink-3); font-weight: 800; font-size: 15px; }

/* ============================================================================
   WEB (desktop, full-width) shell — three-column layout, Duolingo-web style
   ============================================================================ */
.duoweb {
  --acc: var(--abba); --acc-d: var(--abba-d);
  height: 100vh; max-width: 1360px; margin: 0 auto;
  display: grid; grid-template-columns: 260px minmax(0, 700px) 320px; justify-content: center;
  gap: 32px; padding: 0 24px; background: var(--bg);
}
.duoweb[dir="rtl"] { font-family: var(--fhe); }
.duoweb .loading { grid-column: 1 / -1; }

/* left sidebar */
.websidebar {
  height: 100%; overflow-y: auto;
  display: flex; flex-direction: column; padding: 28px 12px 20px; gap: 26px;
}
.websidebar .brand { display: flex; align-items: center; gap: 11px; padding: 0 10px; }
.websidebar .brand .mark { width: 42px; height: 42px; border-radius: 13px; background: var(--acc); color: #fff; display: grid; place-items: center; box-shadow: 0 3px 0 var(--acc-d); flex: 0 0 auto; }
.websidebar .brand .bt { font-weight: 900; font-size: 19px; letter-spacing: -.4px; }
.websidebar .brand .bs { font-weight: 800; font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .3px; margin-top: 2px; }

.webnav { display: flex; flex-direction: column; gap: 4px; }
.webnavbtn {
  display: flex; align-items: center; gap: 14px; padding: 13px 14px; border-radius: 14px;
  font-weight: 800; font-size: 15.5px; color: var(--ink-2); transition: background .12s;
}
.webnavbtn:hover { background: #f4f4f4; }
.webnavbtn.on { color: var(--acc-d); background: color-mix(in srgb, var(--acc) 14%, #fff); }
.webnavbtn .ic { display: grid; place-items: center; flex: 0 0 auto; }

.webpersons { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.webpbtn {
  display: flex; align-items: center; gap: 11px; padding: 11px 13px; border-radius: 14px;
  border: 2px solid var(--line); background: #fff; box-shadow: 0 2px 0 var(--line-2); transition: transform .08s;
}
.webpbtn:active { transform: translateY(2px); box-shadow: none; }
.webpbtn .av { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 900; font-size: 14px; flex: 0 0 auto; }
.webpbtn .meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; text-align: start; }
.webpbtn .meta b { font-size: 14px; font-weight: 900; }
.webpbtn .meta i { font-size: 11px; font-weight: 800; font-style: normal; color: var(--ink-3); }
.webpbtn.abba.on { border-color: var(--abba); background: #f0ffe0; color: var(--abba-d); box-shadow: 0 3px 0 var(--abba-d); }
.webpbtn.yeh.on { border-color: var(--yeh); background: #e6f7ff; color: var(--yeh-d); box-shadow: 0 3px 0 var(--yeh-d); }
.webpbtn.abba.on .meta i, .webpbtn.yeh.on .meta i { color: inherit; opacity: .8; }

/* center column */
.webcenter { height: 100%; min-height: 0; border-inline: 2px solid var(--line); display: flex; flex-direction: column; }
.webcenterhead {
  position: sticky; top: 0; z-index: 45; background: var(--bg); padding: 18px 4px 14px;
  display: flex; align-items: center; gap: 12px; border-bottom: 2px solid var(--line);
}
.webcenterhead h1 { font-size: 20px; font-weight: 900; letter-spacing: -.4px; margin: 0; flex: 1; }
.webscroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding-bottom: 60px; }
.webscroll .unit, .webscroll .section-div { top: 0; }

/* right rail */
.webrail { height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding: 28px 0 20px; }
.railcard { border: 2px solid var(--line); border-radius: 18px; padding: 18px; }
.railcard .rh { font-weight: 900; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-3); margin-bottom: 12px; }
.railcrown { display: flex; align-items: center; gap: 12px; }
.railcrown .ic { width: 46px; height: 46px; border-radius: 14px; background: #fff7d6; color: var(--gold-d); display: grid; place-items: center; flex: 0 0 auto; }
.railcrown .v { font-size: 26px; font-weight: 900; letter-spacing: -.5px; line-height: 1; }
.railcrown .l { font-size: 12px; font-weight: 800; color: var(--ink-2); margin-top: 3px; }
.railprog { display: flex; flex-direction: column; gap: 12px; }
.railprogrow .t { display: flex; align-items: baseline; font-weight: 800; font-size: 13px; margin-bottom: 6px; }
.railprogrow .t b { margin-inline-start: auto; font-weight: 900; }
.railprogrow .track { height: 10px; border-radius: 999px; background: #efefef; overflow: hidden; }
.railprogrow .track i { display: block; height: 100%; border-radius: 999px; }
.raillang { display: flex; gap: 8px; }
.raillang button { flex: 1; height: 38px; border-radius: 11px; font-weight: 900; font-size: 13px; background: #f4f4f4; color: var(--ink-2); }
.raillang button.on { background: var(--ink); color: #fff; }

@media (max-width: 1180px) { .duoweb { grid-template-columns: 84px minmax(0, 640px) 300px; } .websidebar .brand .bt, .websidebar .brand .bs, .webnavbtn span:last-child, .webpbtn .meta { display: none; } .websidebar .brand { justify-content: center; } .webnavbtn { justify-content: center; } .webpbtn { justify-content: center; } }
/* mobile: sidebar + rail collapse into a bottom tab bar and compact header controls */
.webmobilenav, .webcenterhead .mobilectl { display: none; }
@media (max-width: 900px) {
  .duoweb { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; height: 100dvh; gap: 0; padding: 0; }
  .websidebar, .webrail { display: none; }
  .webcenter { border-inline: none; }
  .webcenterhead { padding: 12px 14px 10px; }
  .webcenterhead .mobilectl { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
  .mobilectl .mpbtn {
    width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
    color: #fff; font-weight: 900; font-size: 14px; opacity: .4; flex: 0 0 auto;
  }
  .mobilectl .mpbtn.on { opacity: 1; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--pc); }
  .webmobilenav {
    display: flex; gap: 4px; padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
    background: var(--bg); border-top: 2px solid var(--line);
  }
  .wmnbtn {
    flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 2px; border-radius: 14px; color: var(--ink-3);
    font-weight: 900; font-size: 10.5px; letter-spacing: .2px;
  }
  .wmnbtn .lb { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .wmnbtn.on { color: var(--acc-d); background: color-mix(in srgb, var(--acc) 14%, #fff); }
}

/* ============================== PIN (currently-learning) BUTTON ============================== */
.pinbtn { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 8px; color: var(--ink-3); margin-inline-start: 4px; transition: background .12s, color .12s; flex: 0 0 auto; }
.pinbtn:hover { background: #f0f0f0; }
.pinbtn.on { color: var(--acc-d); background: color-mix(in srgb, var(--acc) 16%, #fff); }

/* ============================== SIYUM CALCULATOR ============================== */
.siyum .siyum-rem { font-weight: 900; font-size: 15px; color: var(--ink); margin: 2px 0 14px; }
.siyum .siyum-rem .loadingdots { color: var(--ink-3); font-weight: 800; font-size: 13px; }
.siyum-modes { display: flex; gap: 8px; margin-bottom: 14px; }
.siyum-modes button { flex: 1; height: 40px; border-radius: 12px; font-weight: 900; font-size: 12.5px; background: #f4f4f4; color: var(--ink-2); border: 2px solid transparent; padding: 0 8px; }
.siyum-modes button.on { background: color-mix(in srgb, var(--acc) 16%, #fff); color: var(--acc-d); border-color: var(--acc); }
.siyum-field { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.siyum-field .fl { font-weight: 800; font-size: 13.5px; color: var(--ink-2); flex: 1; }
.siyum-field input { width: 150px; height: 46px; border: 2px solid var(--line); border-radius: 12px; text-align: center; font: inherit; font-weight: 900; font-size: 16px; color: var(--ink); outline: none; background: #fff; }
.siyum-field input:focus { border-color: var(--acc); }
.siyum-out { border-top: 2px solid var(--line); padding-top: 14px; min-height: 40px; text-align: center; }
.siyum-out .l { font-weight: 900; font-size: 11px; letter-spacing: .5px; text-transform: uppercase; color: var(--ink-3); }
.siyum-out .v { font-weight: 900; font-size: 26px; letter-spacing: -.6px; color: var(--acc-d); margin-top: 4px; line-height: 1.05; }
.siyum-out .s { font-weight: 700; font-size: 13px; color: var(--ink-2); margin-top: 5px; }
.siyum-out .big { font-weight: 900; font-size: 16px; color: var(--acc-d); }
.siyum-out .hint { font-weight: 700; font-size: 13px; color: var(--ink-3); }
.siyum-note { margin-top: 12px; font-weight: 700; font-size: 11.5px; line-height: 1.4; color: var(--ink-3); }

/* ============================== PATH TOOLS (collapse all) ============================== */
.pathtools { display: flex; justify-content: flex-end; padding: 14px 20px 0; }
.collapsebtn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: 999px; font-weight: 900; font-size: 12.5px; letter-spacing: .2px;
  color: var(--acc-d); background: color-mix(in srgb, var(--acc) 12%, #fff);
  border: 2px solid color-mix(in srgb, var(--acc) 40%, #fff); transition: transform .08s;
}
.collapsebtn:active { transform: translateY(1px); }

/* ============================== COMPLETION DATE (set + display) ============================== */
.datebtn { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 8px; color: var(--ink-3); transition: background .12s, color .12s; flex: 0 0 auto; }
.datebtn:hover { background: #f0f0f0; }
.datectl { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.datectl input[type="date"] { height: 30px; border: 2px solid var(--line); border-radius: 9px; padding: 0 8px; font: inherit; font-weight: 700; font-size: 12px; color: var(--ink); background: #fff; outline: none; }
.datectl input[type="date"]:focus { border-color: var(--acc); }
.datectl .dateapply { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 9px; background: var(--acc); color: #fff; box-shadow: 0 2px 0 var(--acc-d); }
.datectl .dateapply:disabled { opacity: .4; box-shadow: none; }
.datectl .datecancel { width: 26px; height: 30px; border-radius: 8px; color: var(--ink-3); font-weight: 900; font-size: 13px; }
.mcard .mdone { font-weight: 800; font-size: 11px; color: var(--acc-d); margin: -4px 0 10px; }

/* ============================== NEXT UP (button + queue) ============================== */
.nextbtn { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 8px; color: var(--ink-3); transition: background .12s, color .12s; flex: 0 0 auto; }
.nextbtn:hover { background: #f0f0f0; }
.nextbtn.on { color: var(--acc-d); background: color-mix(in srgb, var(--acc) 16%, #fff); }

.nextsec { margin-top: 14px; border-top: 2px solid var(--line); padding-top: 12px; }
.nexthead { font-weight: 900; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px; }
.nextempty { font-weight: 700; font-size: 12.5px; color: var(--ink-3); padding: 2px 0 4px; }
.nextlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.nextrow { display: flex; align-items: center; gap: 10px; }
.nextrow .nnum { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; font-weight: 900; font-size: 12px; flex: 0 0 auto; }
.nextrow .nnm { font-weight: 800; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nextrow .nct { margin-inline-start: auto; font-weight: 900; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.nextrow .nread { width: 28px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: #f4f4f4; color: var(--ink-2); flex: 0 0 auto; }
.nextrow .nread:active { transform: translateY(1px); }
.nextrow .nremove { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; color: var(--ink-3); font-weight: 900; font-size: 13px; flex: 0 0 auto; }
.nextrow .nremove:hover { background: #f0f0f0; color: var(--ink); }

/* ============================== NOW LEARNING VIEW ============================== */
.nowview { padding: 18px 16px 120px; display: flex; flex-direction: column; gap: 18px; }
.nowcard { border: 2px solid var(--line); border-radius: 18px; padding: 16px; }
.nowhead { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.nowhead .av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 900; font-size: 13px; flex: 0 0 auto; }
.nowhead .nm { font-weight: 900; font-size: 16px; }
.nowhead .nowclear { margin-inline-start: auto; font-weight: 800; font-size: 12px; color: var(--ink-3); text-decoration: underline; }
.nowempty { font-weight: 700; font-size: 13px; color: var(--ink-3); padding: 10px 2px; }
.nowhint { font-weight: 700; font-size: 12px; color: var(--ink-3); margin-top: 10px; text-align: center; }
.nowview .unit { position: static; margin: 0 0 14px; }

/* tweak swatch grid */
.tw-accents { display: flex; gap: 10px; }
.tw-accents .sw { flex: 1; height: 44px; border-radius: 12px; border: 3px solid transparent; display: grid; place-items: center; font-weight: 900; font-size: 12px; color: #fff; }
.tw-accents .sw.on { outline: 3px solid #111; outline-offset: 2px; }

/* ============================ SEFARIA READER ============================ */
/* small book button beside each path node */
.noderow .readbtn {
  position: absolute; inset-inline-start: calc(50% + 46px); top: 50%;
  transform: translateY(-50%);
  width: 34px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: #fff; color: var(--nd, var(--ink-2));
  border: 2px solid var(--line); box-shadow: 0 3px 0 var(--line-2);
  transition: transform .08s;
}
.noderow .readbtn:active { transform: translateY(calc(-50% + 2px)); box-shadow: 0 1px 0 var(--line-2); }

/* book button in a search masechta card header */
.mcard .mh .mread {
  margin-inline-start: auto; width: 32px; height: 30px; border-radius: 10px;
  display: grid; place-items: center; background: #f4f4f4;
}
.mcard .mh .mread:active { transform: translateY(1px); }
.mcard .mh .mread + .ct { margin-inline-start: 0; }

/* the reader modal */
.rdr-overlay {
  position: fixed; inset: 0; z-index: 85; display: grid; place-items: center;
  background: rgba(30,30,30,.55); padding: 18px; animation: fade .2s ease;
}
.rdr-card {
  display: flex; flex-direction: column; width: 100%; max-width: 620px;
  max-height: min(86dvh, 900px); background: #fff; border-radius: 22px; overflow: hidden;
  box-shadow: 0 18px 50px rgba(0,0,0,.3); animation: pop .28s cubic-bezier(.2,1.3,.5,1);
}
.rdr-head {
  display: flex; align-items: center; gap: 8px; padding: 14px 14px 10px;
  border-bottom: 2px solid var(--line);
}
.rdr-head .rdr-title { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 8px; }
.rdr-head .rdr-title .em { font-size: 20px; }
.rdr-head .rdr-title .tt { font-weight: 900; font-size: 17px; letter-spacing: -.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rdr-nav {
  width: 38px; height: 36px; border-radius: 12px; display: grid; place-items: center;
  background: #f4f4f4; color: var(--rd, var(--ink-2)); flex: 0 0 auto;
}
.rdr-nav:disabled { opacity: .3; cursor: default; }
.rdr-nav:not(:disabled):active { transform: translateY(1px); }
.rdr-close {
  width: 38px; height: 36px; border-radius: 12px; display: grid; place-items: center;
  background: #f4f4f4; color: var(--ink-2); font-weight: 900; font-size: 15px; flex: 0 0 auto;
}
.rdr-modes { display: flex; gap: 8px; padding: 10px 14px; }
.rdr-modes button { flex: 1; height: 38px; border-radius: 11px; font-weight: 900; font-size: 13px; background: #f4f4f4; color: var(--ink-2); border: 2px solid transparent; }
.rdr-modes button.on { background: color-mix(in srgb, var(--rc, var(--abba)) 16%, #fff); color: var(--rd, var(--abba-d)); border-color: var(--rc, var(--abba)); }
.rdr-body { flex: 1 1 0; min-height: 120px; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 18px 14px; }
.rdr-hint { text-align: center; color: var(--ink-3); font-weight: 800; font-size: 14px; padding: 40px 12px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.rdr-retry { height: 40px; padding: 0 22px; border-radius: 12px; background: var(--rc, var(--abba)); color: #fff; font-weight: 900; font-size: 13px; box-shadow: 0 3px 0 var(--rd, var(--abba-d)); }
.rdr-mishnah { display: flex; align-items: flex-start; gap: 12px; padding: 14px 0; border-bottom: 1.5px solid var(--line); }
.rdr-mishnah:last-child { border-bottom: none; }
.rdr-mishnah .badge {
  flex: 0 0 auto; min-width: 28px; height: 28px; padding: 0 6px; border-radius: 9px; margin-top: 2px;
  display: grid; place-items: center; font-weight: 900; font-size: 13px;
  background: color-mix(in srgb, var(--rc, var(--abba)) 16%, #fff); color: var(--rd, var(--abba-d));
  font-family: var(--fhe);
}
.rdr-mishnah .texts { flex: 1; min-width: 0; }
.rdr-mishnah .he { margin: 0; font-family: var(--fhe); font-weight: 500; font-size: 19px; line-height: 1.75; color: var(--ink); text-align: right; }
.rdr-mishnah .en { margin: 0; font-weight: 600; font-size: 14.5px; line-height: 1.6; color: var(--ink-2); text-align: left; }
.rdr-mishnah .he + .en { margin-top: 8px; }
.rdr-foot {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 2px solid var(--line);
}
.rdr-mark {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px;
  border-radius: 13px; font-weight: 900; font-size: 13.5px;
  background: var(--rc, var(--abba)); color: #fff; box-shadow: 0 3px 0 var(--rd, var(--abba-d));
  transition: transform .08s;
}
.rdr-mark:active { transform: translateY(2px); box-shadow: none; }
.rdr-mark.done { background: #fff; color: var(--rd, var(--abba-d)); border: 2px solid var(--rc, var(--abba)); box-shadow: none; }
.rdr-sefaria { margin-inline-start: auto; font-weight: 800; font-size: 12.5px; color: var(--ink-3); text-decoration: none; }
.rdr-sefaria:hover { color: var(--ink-2); text-decoration: underline; }

/* read button on the Now Learning masechta banner */
.nowview .unit .nowread {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 32px; border-radius: 999px; flex: 0 0 auto;
  background: rgba(255,255,255,.22); color: inherit; margin-inline-start: 8px;
}
.nowview .unit .nowread:active { transform: translateY(1px); }
