/* Contemplative Siddur — Mishkan palette, white ground */
:root {
  --ground: #FFFFFF;
  --ink: #1E1C1A;
  --ink-soft: #3D3A36;
  --silver-ink: #5F656C;
  --silver: #C4C8CC;
  --ash: #CDD0D3;
  --ash-soft: #ECEEEF;
  --line: rgba(30, 28, 26, 0.13);
  --techelet: #1F5AA6;
  --translit: #A3162F;
  --gold: #C29A3A;
  --gold-text: #8C6A1E;
  --shadow: 0 10px 40px rgba(20, 18, 16, 0.12), 0 1px 3px rgba(20, 18, 16, 0.08);
  --w0: #1F5AA6; --w1: #3E78BE; --w2: #6E9AD0; --w3: #A3BFE2; --w4: #C4C8CC;

  --he-font: 'Noto Serif Hebrew', 'Frank Ruhl Libre', serif;
  --he-weight: 300;
  --tr-font: 'Manrope', system-ui, sans-serif;
  --en-font: 'Cormorant Garamond', Georgia, serif;
  --ui-font: 'Manrope', system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="night"] {
  --ground: #181716;
  --ink: #EDEAE4;
  --ink-soft: #CFCAC2;
  --silver-ink: #A3A8AE;
  --silver: #55595E;
  --ash: #55595E;
  --ash-soft: #2A2927;
  --line: rgba(237, 234, 228, 0.14);
  --techelet: #8DB3E8;
  --translit: #EE8090;
  --gold: #D9B65E;
  --gold-text: #D9B65E;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--ui-font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  transition: background .4s ease, color .4s ease;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: inherit; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--techelet); outline-offset: 3px; border-radius: 8px; }
a { color: var(--techelet); }
a:hover { color: var(--translit); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { min-height: 100%; }
.loading { display: grid; place-items: center; height: 100vh; color: var(--silver-ink); letter-spacing: .14em; font-size: 12px; }

/* ---------- shared bits ---------- */
.eyebrow { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--silver-ink); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line); font-size: 13px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.pill:hover { background: var(--ash-soft); color: var(--ink); }
.pill.solid { background: var(--ash); border-color: transparent; font-weight: 600; }
.pill.solid:hover { background: var(--silver); }
.status { display: inline-block; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--silver); color: var(--silver-ink); white-space: nowrap; }
.status.warn { border-color: var(--gold); color: var(--gold-text); }

/* ============ PLAYER ============ */
.player {
  position: relative;
  height: 100vh; height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

/* top perimeter */
.top { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto; align-items: start; gap: 20px; padding: 22px 28px 0; position: relative; z-index: 10; }
.thumb { display: flex; gap: 12px; align-items: center; padding: 8px 12px 8px 8px; border-radius: 14px; border: 1px solid var(--line); min-width: 0; }
.thumb:hover { background: var(--ash-soft); }
.thumb-map { display: flex; gap: 3px; align-items: center; height: 36px; padding: 0 6px; border-radius: 9px; background: var(--ash-soft); }
.thumb-map i { display: block; width: 7px; height: 7px; border-radius: 50%; opacity: .85; }
.thumb-map i.now { width: 9px; height: 9px; background: var(--gold) !important; opacity: 1; box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 25%, transparent); }
.thumb-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.thumb-text b { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb-text span { font-size: 11px; color: var(--silver-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.title-block { text-align: center; pointer-events: none; min-width: 0; padding-top: 4px; }
.title-block .t { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--silver-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-block .m { font-family: var(--en-font); font-style: italic; font-size: 17px; color: var(--ink-soft); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.controls { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; position: relative; }
.ctl { padding: 9px 14px; border-radius: 999px; font-size: 13px; color: var(--silver-ink); border: 1px solid transparent; white-space: nowrap; }
.ctl:hover { color: var(--ink); background: var(--ash-soft); }
.ctl[aria-expanded="true"] { background: var(--ash); color: var(--ink); }
.ctl .v { color: var(--ink); font-weight: 600; margin-left: 4px; }
.ctl .exp { color: var(--gold-text); font-size: 10px; letter-spacing: .08em; margin-left: 4px; }

/* popovers */
.pop {
  position: absolute; right: 0; top: calc(100% + 10px);
  background: var(--ground); color: var(--ink);
  border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  padding: 18px 20px 16px; min-width: 300px; max-width: min(560px, 92vw);
  z-index: 20;
}
.pop.wide { min-width: min(480px, 92vw); }
.pop h3 { margin: 0 0 12px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--silver-ink); font-weight: 600; }
.pop .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px 22px; }
.pop .col h4 { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.pop .hint { font-size: 12px; color: var(--silver-ink); line-height: 1.45; margin: 12px 0 0; }
.pop .row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pop .sep { height: 1px; background: var(--line); margin: 14px 0; }
.opt { position: relative; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 10px; font-size: 14px; }
.opt:hover { background: var(--ash-soft); }
.opt small { color: var(--silver-ink); font-size: 11px; }
.opt[aria-pressed="true"] { font-weight: 600; }
.opt[aria-pressed="true"]::before { content: ''; position: absolute; left: -2px; top: 50%; width: 5px; height: 5px; margin-top: -2px; border-radius: 50%; background: var(--gold); }
.opt .he { font-family: var(--he-font); font-size: 18px; font-weight: 300; }
.chip { position: relative; white-space: nowrap; padding: 8px 13px 10px; border-radius: 999px; font-size: 13px; border: 1px solid var(--line); }
.chip:hover { background: var(--ash-soft); }
.chip[aria-pressed="true"] { font-weight: 600; border-color: var(--silver); }
.chip[aria-pressed="true"]::after { content: ''; position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--gold); }
.chip.tiny { padding: 6px 10px 8px; font-size: 12px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 8px 10px; border-radius: 10px; font-size: 14px; }
.switch:hover { background: var(--ash-soft); }
.switch .knob { flex: none; width: 34px; height: 20px; border-radius: 999px; background: var(--ash); position: relative; transition: background .2s; }
.switch .knob::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--ground); transition: transform .2s; }
.switch[aria-checked="true"] .knob { background: var(--techelet); }
.switch[aria-checked="true"] .knob::after { transform: translateX(14px); }
.switch .lbl { display: flex; flex-direction: column; gap: 2px; }
.switch .lbl small { color: var(--silver-ink); font-size: 11px; }

/* center field: only Hebrew / transliteration / translation */
.field { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2vh 7vw; min-height: 0; overflow: hidden; }
.stack { display: flex; flex-direction: column; align-items: center; gap: 2.2vh; max-width: 100%; text-align: center; }
.unit { display: flex; flex-direction: column; align-items: center; gap: 1.6vh; }
.he { font-family: var(--he-font); font-weight: var(--he-weight); line-height: 1.35; direction: rtl; }
.field .he { font-size: 9vmin; text-wrap: balance; }
.field .tr { font-family: var(--tr-font); color: var(--translit); font-size: var(--tr-size, 3.2vmin); letter-spacing: .01em; line-height: 1.4; text-wrap: balance; }
.field .en { font-family: var(--en-font); color: var(--ink-soft); font-size: var(--en-size, 3.4vmin); line-height: 1.35; max-width: 62ch; }
.field .en.main { font-style: italic; color: var(--ink); font-size: var(--he-size-en, 6vmin); }
.field .note { font-size: 12px; color: var(--silver-ink); letter-spacing: .04em; }
.tr .st { }
.stress-bold .tr .st { font-weight: 700; }
.stress-underline .tr .st { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: .22em; }
.fb { text-decoration: underline dotted var(--silver); text-decoration-thickness: 2px; text-underline-offset: .28em; }
.field .w { transition: opacity .25s ease, color .25s ease; }
.wordcues .w { opacity: .38; }
.wordcues .w.now { opacity: 1; }
.phrase-many .unit { gap: .8vh; }

.breaths { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 3.2vh; }
.breaths button { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.breaths button i { display: block; width: 6px; height: 6px; border-radius: 50%; background: var(--silver); transition: all .25s; }
.breaths button[aria-current="true"] i { width: 9px; height: 9px; background: var(--gold); }
.breaths button:hover i { background: var(--silver-ink); }

.niggun { display: flex; flex-direction: column; align-items: center; gap: 2.4vh; }
.ring { width: 22vmin; height: 22vmin; border-radius: 50%; border: 1.5px solid var(--silver); display: grid; place-items: center; animation: breathe 8s ease-in-out infinite; }
.ring::after { content: ''; width: 34%; height: 34%; border-radius: 50%; background: color-mix(in srgb, var(--gold) 22%, transparent); }
@keyframes breathe { 0%, 100% { transform: scale(.86); opacity: .7; } 50% { transform: scale(1.04); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ring { animation: none; } }

.empty { text-align: center; color: var(--silver-ink); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty .he { font-size: 8vmin; color: var(--ink); }

/* bottom perimeter */
.bottom { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px; padding: 0 28px 22px; position: relative; z-index: 5; }
.nav { display: flex; gap: 6px; align-items: center; }
.navbtn { display: flex; flex-direction: column; gap: 1px; padding: 8px 14px; border-radius: 12px; font-size: 12px; color: var(--silver-ink); max-width: 200px; }
.navbtn b { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navbtn:hover { background: var(--ash-soft); }
.navbtn[disabled] { opacity: .35; cursor: default; background: none; }
.navbtn.next { text-align: right; }

.deck { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.rec-row { display: flex; gap: 6px; align-items: center; justify-content: center; flex-wrap: wrap; }
.audio { display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 8px; border-radius: 999px; border: 1px solid var(--line); min-width: 0; }
.play { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--ash); display: grid; place-items: center; }
.play:hover { background: var(--silver); }
.play svg { width: 16px; height: 16px; fill: var(--ink); }
.play[disabled] { opacity: .4; cursor: default; }
.scrub { position: relative; flex: 1; height: 28px; cursor: pointer; min-width: 80px; }
.scrub .track { position: absolute; left: 0; right: 0; top: 13px; height: 3px; border-radius: 2px; background: var(--ash); }
.scrub .fill { position: absolute; left: 0; top: 13px; height: 3px; border-radius: 2px; background: var(--techelet); }
.scrub .tick { position: absolute; top: 9px; width: 2px; height: 11px; margin-left: -1px; border-radius: 1px; background: var(--silver); }
.scrub .tick.now { background: var(--gold); }
.scrub .head { position: absolute; top: 8px; width: 13px; height: 13px; margin-left: -6px; border-radius: 50%; background: var(--techelet); }
.time { font-size: 12px; color: var(--silver-ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.audio-msg { font-size: 12px; color: var(--silver-ink); text-align: center; }
.audio-msg a { margin-left: 6px; }
.modes { display: flex; gap: 4px; }

/* overlay sheets: overview, melodies */
.overlay { position: fixed; inset: 0; background: color-mix(in srgb, var(--ground) 96%, transparent); z-index: 40; overflow: auto; }

/* ============ LEAD MODE ============ */
.lead .top, .lead .bottom { transition: opacity .6s ease; }
.lead.idle .top, .lead.idle .bottom { opacity: 0; pointer-events: none; }
.lead.idle { cursor: none; }
.lead .field .en { font-size: var(--en-size-lead, 3.8vmin); }
.zone-hint { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 2fr; pointer-events: none; opacity: 0; transition: opacity .3s; }
.blank { position: fixed; inset: 0; background: var(--ground); z-index: 60; display: grid; place-items: center; }
.blank span { font-size: 11px; letter-spacing: .14em; color: var(--silver); }

/* ============ PLANNER & OVERVIEW ============ */
.page { max-width: 1240px; margin: 0 auto; padding: 40px 28px 64px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head h1 { font-family: var(--en-font); font-weight: 500; font-size: 44px; line-height: 1.05; margin: 6px 0 0; }
.page-head h1 .he { font-size: 30px; color: var(--silver-ink); margin-left: 12px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.filters { display: flex; gap: 22px; flex-wrap: wrap; align-items: center; margin: 0 0 22px; }
.filters .grp { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.filters .grp > span { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--silver-ink); margin-right: 4px; }

.routes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 34px; }
.route-card { display: flex; flex-direction: column; gap: 10px; padding: 18px 18px 16px; border-radius: 16px; border: 1px solid var(--line); text-align: left; }
.route-card:hover { background: var(--ash-soft); }
.route-card[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.route-card h2 { margin: 0; font-family: var(--en-font); font-weight: 500; font-size: 26px; }
.route-card .meta { font-size: 12px; color: var(--silver-ink); }
.route-card .kav { font-family: var(--en-font); font-style: italic; font-size: 16px; color: var(--ink-soft); }
.route-card .strip { display: flex; gap: 3px; }
.route-card .strip i { flex: 1; height: 4px; border-radius: 2px; }

.trail { position: relative; border: 1px solid var(--line); border-radius: 22px; padding: 26px 22px 22px; }
.trail-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.trail-head h2 { margin: 0; font-family: var(--en-font); font-weight: 500; font-size: 30px; }
.worlds { display: grid; grid-template-columns: repeat(var(--nw, 5), minmax(0, 1fr)); gap: 12px; }
.world { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.world-head { display: flex; flex-direction: column; gap: 2px; padding-bottom: 10px; border-bottom: 3px solid var(--wc); }
.world-head b { font-size: 13px; font-weight: 600; }
.world-head .he { font-size: 17px; color: var(--silver-ink); }
.world-head small { font-size: 11px; color: var(--silver-ink); }
.stop { display: flex; flex-direction: column; gap: 4px; padding: 12px 12px 11px; border-radius: 12px; border: 1px solid var(--line); text-align: left; position: relative; }
.stop:hover { background: var(--ash-soft); }
.stop .n { font-size: 10px; letter-spacing: .12em; color: var(--silver-ink); }
.stop .he { font-size: 20px; line-height: 1.3; text-align: right; }
.stop b { font-size: 13px; font-weight: 600; }
.stop span { font-size: 12px; color: var(--silver-ink); }
.stop .pin { position: absolute; right: 10px; top: 9px; font-size: 10px; color: var(--gold-text); letter-spacing: .08em; }
.src-note { margin-top: 26px; font-size: 12px; color: var(--silver-ink); display: flex; gap: 14px; flex-wrap: wrap; }

.ov-strip { display: flex; gap: 5px; margin-bottom: 18px; }
.ov-strip i { flex: 1; height: 5px; border-radius: 3px; }
.ov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 22px 18px; }
.card { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.card .scr { position: relative; aspect-ratio: 16 / 9; width: 100%; border-radius: 12px; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; padding: 0 14px; background: var(--ground); box-shadow: 0 1px 3px rgba(20, 18, 16, .06); }
.card[aria-current="true"] .scr { border: 2px solid var(--gold); }
.card .scr .num { position: absolute; left: 10px; top: 8px; font-size: 10px; letter-spacing: .1em; color: var(--silver-ink); }
.card .scr .now { position: absolute; right: 10px; top: 7px; font-size: 10px; letter-spacing: .1em; border: 1px solid var(--gold); border-radius: 999px; padding: 1px 7px; }
.card .scr .he { font-size: 26px; text-align: center; }
.card .scr .en { font-family: var(--en-font); font-style: italic; font-size: 24px; text-align: center; }
.card .cap { display: flex; flex-direction: column; gap: 2px; padding: 0 2px; }
.card .cap small { font-size: 10px; letter-spacing: .12em; color: var(--silver-ink); text-transform: uppercase; }
.card .cap b { font-size: 14px; font-weight: 600; }
.card .cap span { font-size: 12px; color: var(--silver-ink); }

/* melody sheet */
.mel-list { display: flex; flex-direction: column; gap: 4px; }
.mel { display: flex; align-items: center; gap: 8px; }
.mel .opt { flex: 1; }
.pinbtn { font-size: 11px; letter-spacing: .06em; padding: 6px 10px; border-radius: 999px; color: var(--silver-ink); border: 1px solid var(--line); white-space: nowrap; }
.pinbtn[aria-pressed="true"] { color: var(--gold-text); border-color: var(--gold); }

/* ============ small screens ============ */
@media (max-width: 860px) {
  .top { grid-template-columns: 1fr; padding: 14px 16px 0; gap: 10px; }
  .title-block { text-align: left; padding-top: 0; }
  .controls { justify-content: flex-start; }
  .ctl { padding: 7px 10px; font-size: 12px; }
  .pop, .pop.wide { left: 0; right: auto; min-width: 0; width: calc(100vw - 32px); max-height: calc(100dvh - 190px); overflow: auto; }
  .pop .opt small { display: none; }
  .pop .opt { padding: 7px 10px; }
  .field { padding: 2vh 16px; }
  .field .he { font-size: var(--he-size-m, 11vmin); }
  .field .tr { font-size: var(--tr-size-m, 4.6vmin); }
  .field .en { font-size: var(--en-size-m, 4.8vmin); }
  .bottom { grid-template-columns: 1fr 1fr; padding: 0 16px 14px; gap: 10px; }
  .deck { grid-column: 1 / -1; order: -1; }
  .navbtn { max-width: none; }
  .audio { gap: 8px; padding-right: 6px; }
  .modes .chip.tiny { padding: 6px 8px 8px; }
  .page { padding: 24px 16px 48px; }
  .page-head h1 { font-size: 34px; }
  .worlds { grid-template-columns: 1fr; }
}
