@font-face {
  font-family: "TT Hebrew";
  src: url("../fonts/NotoSerifHebrew.ttf") format("truetype");
  font-weight: 100 900;
}

:root {
  --bg: #f6f3ec;
  --panel: #fffdf8;
  --side: #efe9dd;
  --ink: #1f2430;
  --muted: #6c6f78;
  --line: #ddd5c4;
  --accent: #2f5d8a;
  --accent-ink: #ffffff;
  --hl: #ffe08a;
  --hl-ink: #1f2430;
  --c-major: #b23a3a;      /* sof pasuk, etnachta */
  --c-mid: #2f6f4f;        /* segol, zakef, revia, tevir... */
  --c-minor: #7a4fa0;      /* pashta, zarka, geresh, telisha, pazer */
  --c-conj: #8a7a55;       /* conjunctives */
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 6px 20px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17191e; --panel: #1f2228; --side: #14161a; --ink: #e9e6df; --muted: #9a9ca3;
    --line: #2f333b; --accent: #6fa3d8; --accent-ink: #0d1117; --hl: #5a4a12; --hl-ink: #fff4cf;
    --c-major: #ff8a80; --c-mid: #7fd1a3; --c-minor: #c9a5ef; --c-conj: #c8b98f;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif; }
#app { display: grid; grid-template-columns: 270px 1fr; height: 100vh; }
button, select, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* ---------- sidebar ---------- */
#sidebar { background: var(--side); border-right: 1px solid var(--line); overflow-y: auto; padding: 14px 14px 30px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 4px 14px; }
.logo { width: 38px; height: 38px; border-radius: 10px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font: 600 24px/1 "TT Hebrew", serif; padding-bottom: 4px; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand-sub { color: var(--muted); font-size: 12px; }
.tabs { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.tab { text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 7px; cursor: pointer; }
.tab:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.tab.active { background: var(--accent); color: var(--accent-ink); }
.panel { border-top: 1px solid var(--line); padding: 12px 2px 6px; }
.panel h3 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 8px; }
select { display: block; width: 100%; margin-top: 3px; padding: 5px 6px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 13px; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
.chk { display: flex; align-items: center; gap: 6px; color: var(--ink); font-size: 13px; margin: 2px 0; cursor: pointer; }
.range input { width: 100%; }
.seg { display: flex; background: color-mix(in srgb, var(--ink) 8%, transparent); border-radius: 8px; padding: 2px; margin-bottom: 10px; }
.seg button { flex: 1; border: 0; background: none; padding: 5px 6px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.seg button.on { background: var(--panel); box-shadow: var(--shadow); }
.seg.wide { max-width: 640px; }
.seg.small button { padding: 3px 8px; }

/* ---------- main ---------- */
#main { display: grid; grid-template-rows: 1fr auto auto; min-height: 0; }
.view { overflow-y: auto; padding: 22px 34px 40px; min-height: 0; }
.readhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 14px; }
.readhead h1 { margin: 0; font-size: 22px; font-weight: 650; }
.note { max-width: 360px; font-size: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.lead { margin-top: -4px; }

.text { --size: 34px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 22px 26px; font-family: "TT Hebrew", "Times New Roman", serif; }
.verse { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px 2px; padding: 8px 4px; border-radius: 8px; }
.verse.current { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.vnum { font: 600 12px/1 -apple-system, sans-serif; color: var(--muted); align-self: flex-start; padding: calc(var(--size) * .45) 0 0 8px; min-width: 28px; text-align: left; direction: ltr; }
.unit { display: inline-flex; flex-direction: column; align-items: center; padding: 2px 5px 4px; border-radius: 7px; cursor: pointer;
  transition: background .12s; }
.unit:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.unit.playing { background: var(--hl); color: var(--hl-ink); }
.heb { font-size: var(--size); line-height: 1.75; white-space: nowrap; }
.tname { font: 600 10px/1.2 -apple-system, sans-serif; letter-spacing: .3px; text-transform: uppercase; margin-top: -2px; direction: ltr; white-space: nowrap; }
.tlit { font: 12px/1.3 -apple-system, sans-serif; color: var(--muted); direction: ltr; white-space: nowrap; }
.unit.playing .tlit { color: inherit; }
.tlit b { color: var(--ink); font-weight: 700; }
.unit.playing .tlit b { color: inherit; }
.k-major { color: var(--c-major); } .k-mid { color: var(--c-mid); } .k-minor { color: var(--c-minor); } .k-conj { color: var(--c-conj); }
.nocolor .tname { color: var(--muted); }
.pmark { font: 600 13px/1 -apple-system, sans-serif; color: var(--muted); align-self: center; padding: 0 6px; }
.scroll .heb { font-weight: 600; }

/* ---------- transport ---------- */
#transport { display: flex; align-items: center; gap: 18px; padding: 10px 18px; border-top: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.tgroup { display: flex; align-items: center; gap: 6px; }
.icon, .play { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; height: 32px; min-width: 34px; cursor: pointer; font-size: 14px; }
.play { background: var(--accent); color: var(--accent-ink); border-color: transparent; min-width: 46px; font-size: 16px; }
.icon.toggle.on { background: var(--accent); color: var(--accent-ink); }
.now { flex: 1; min-width: 160px; font-size: 13px; }
.now .heb-now { font: 22px/1 "TT Hebrew", serif; margin-left: 8px; }
.sliders label { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 12px; }
.sliders input[type=range] { width: 90px; }
.sliders span { min-width: 34px; font-variant-numeric: tabular-nums; }
.sliders .seg { margin: 0; }
.vol input { width: 70px !important; }

/* ---------- library ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); }
.card .top { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.glyph { font: 48px/1 "TT Hebrew", serif; width: 44px; height: 52px; display: grid; place-items: center; border-radius: 8px;
  background: color-mix(in srgb, var(--ink) 5%, transparent); }
.card .nm { font-weight: 650; }
.card .sub { font-size: 12px; color: var(--muted); }
.card .notes { font: 12px/1.4 ui-monospace, Menlo, monospace; color: var(--muted); margin-top: 6px; }
.card details { margin-top: 6px; font-size: 12px; }
.card summary { cursor: pointer; color: var(--accent); }
.var { display: flex; align-items: center; gap: 6px; padding: 3px 0; border-top: 1px dashed var(--line); }
.var button, .mini { border: 1px solid var(--line); background: var(--bg); border-radius: 6px; cursor: pointer; padding: 1px 7px; font-size: 12px; }
.lessons { margin-top: 26px; max-width: 760px; }
.lessons h3 { font-size: 15px; margin: 18px 0 4px; }
.lessons p { margin: 4px 0 10px; white-space: pre-line; }

/* ---------- practice ---------- */
.score { font-size: 15px; font-weight: 600; }
.game { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 28px; max-width: 760px; text-align: center; }
.game .big { font: 64px/1.6 "TT Hebrew", serif; direction: rtl; }
.game .prompt { color: var(--muted); margin-bottom: 8px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px auto 8px; max-width: 520px; }
.choice { padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-weight: 600; font-size: 15px; }
.choice:hover { border-color: var(--accent); }
.choice.right { background: #2e7d4f; color: #fff; border-color: transparent; }
.choice.wrong { background: #b23a3a; color: #fff; border-color: transparent; }
.actions { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.btn { padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.feedback { min-height: 22px; margin-top: 6px; font-weight: 600; }
.rec-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #d33; margin-right: 6px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* ---------- about ---------- */
.about { max-width: 720px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 24px; }
.about li { margin: 6px 0; }
.keys td { padding: 3px 14px 3px 0; }
kbd { font: 12px ui-monospace, Menlo, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--bg); }

.toast { position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 8px 14px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow); }

@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; min-height: 100vh; }
  #sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .view { padding: 16px; }
}

/* ---------- notation ---------- */
.staff { display: block; color: var(--ink); }
.staff .sl { stroke: var(--muted); stroke-width: 1; opacity: .7; }
.staff .stem { stroke: currentColor; stroke-width: 1.3; }
.staff .head { fill: currentColor; stroke: currentColor; stroke-width: 1; }
.staff .head.open { fill: none; stroke-width: 1.6; }
.staff .flag { fill: currentColor; }
.staff .clef, .staff .acc, .staff .rest { fill: currentColor; font-family: "Apple Symbols", "Bravura", "Noto Music", serif; }
.staff .lyr { font: 11px -apple-system, sans-serif; fill: var(--muted); }
.staff .lyr.st { font-weight: 700; fill: var(--ink); }
.staff .n.up { color: var(--accent); }
.staffbox { overflow-x: auto; margin-top: 6px; }
.card .staffbox { margin: 6px -4px 0; }
.var { display: block; padding: 6px 0; }
.varhead { display: flex; align-items: center; gap: 6px; }
.notation { display: flex; align-items: center; gap: 18px; padding: 8px 18px 4px; border-top: 1px solid var(--line); background: var(--panel); overflow-x: auto; }
.nhead { min-width: 150px; }
.nheb { font: 26px/1.3 "TT Hebrew", serif; }
.nname { font: 600 11px -apple-system, sans-serif; letter-spacing: .3px; text-transform: uppercase; }
.notation .staffbox { margin: 0; }

/* Web edition: preserve the Mac palette and notation while fitting browser sizes. */
html, body { font-size: 16px; }
#app { height: 100dvh; }
#main, .view, .card, .staffbox { min-width: 0; }
.studio-home { display: inline-block; margin-top: 3px; color: var(--accent); font-size: 13px; }
.brand-sub, .panel h3, .vnum, .card .sub, .nname, kbd { font-size: 13px; }
label, .chk, select, .seg button, .sliders label, .card details, .var button, .mini, .tlit, .now { font-size: 14px; }
.tname { font-size: 12px; }
select { min-height: 38px; padding: 7px 28px 7px 8px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='m1 1 5 5 5-5' fill='none' stroke='%237d8792' stroke-width='2'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
.icon, .play, .tab, .seg button { min-height: 40px; }
.sliders { flex-wrap: wrap; row-gap: 12px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.unit { max-width: 100%; }
.settings-toggle { display: none; }
.actions, .readhead { flex-wrap: wrap; }
.toast { max-width: calc(100vw - 32px); z-index: 10; }
.noscript { position: fixed; inset: 16px; z-index: 20; background: var(--panel); padding: 24px; }
.about a { color: var(--accent); }
@media (max-width: 820px) {
  #app { height: 100dvh; min-height: 0; grid-template-rows: auto minmax(0, 1fr); }
  #sidebar { padding: 8px 12px; max-height: 60dvh; }
  .brand { padding: 2px 0 8px; }
  .tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 8px; }
  .tab { text-align: center; padding: 6px 4px; font-size: 14px; }
  .settings-toggle { display: block; width: 100%; padding: 7px; font-size: 14px; }
  #settingsPanels { display: none; }
  #settingsPanels.open { display: block; }
  select { font-size: 16px; }
  .view { padding: 16px 12px 28px; }
  .text { padding: 10px 8px; }
  .heb { white-space: normal; overflow-wrap: anywhere; }
  #transport { padding: 8px 12px max(8px, env(safe-area-inset-bottom)); gap: 8px; }
  .tgroup.sliders { width: 100%; gap: 8px 12px; }
  .sliders input[type=range] { width: 72px; }
  .now { min-width: 0; font-size: 12px; }
  .now .heb-now { display: none; }
  .notation { padding: 6px 12px; max-height: 142px; }
  .nhead { min-width: 105px; max-width: 125px; }
  .nheb { font-size: 22px; }
  .grid { grid-template-columns: 1fr; }
  .game { padding: 16px 12px; }
  .game .big { overflow-wrap: anywhere; }
  .seg.wide { flex-wrap: wrap; }
  .choices { gap: 8px; }
  .about { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
