@import url(/fonts/fonts.css);

/* Paper by day, studio by night. --lamp is the one accent: Save, the play head, the "new" dot. */
:root {
  color-scheme: light dark;
  --bg: light-dark(#f3eee4, #14120f);
  --ink: light-dark(#211d18, #ece6da);
  --muted: light-dark(#6b6358, #9a9184);
  --lamp: light-dark(#b4321f, #ff6a3d);
  --on-lamp: light-dark(#ffffff, #14120f);
  --line: light-dark(rgb(33 29 24 / .14), rgb(236 230 218 / .13));
  --chip: light-dark(rgb(33 29 24 / .06), rgb(236 230 218 / .07));
  --raised: light-dark(#fbf8f2, #1e1b17);
  --serif: 'Frank Ruhl Libre', 'Times New Roman', serif;
  --sans: 'Heebo', -apple-system, system-ui, sans-serif;
}
@view-transition { navigation: auto; }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* author display rules (e.g. .mini flex) must not beat hidden */
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--sans); }
main {
  max-width: 680px; margin: 0 auto;
  padding: 8px max(16px, env(safe-area-inset-right)) calc(84px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
a { color: var(--lamp); }
h1, h2, h3 { font-weight: 600; line-height: 1.25; text-wrap: balance; }
h1 { font-family: var(--serif); font-size: 30px; margin: 4px 0 6px; }
h2.section { font-size: 14px; color: var(--muted); font-weight: 500; letter-spacing: .02em; margin: 28px 0 4px; }

/* navigation: bottom tabs (thumb reach) + a sticky header that is both "back" and the breadcrumb */
nav.tabs { position: fixed; bottom: 0; inset-inline: 0; z-index: 4; display: flex; justify-content: center; gap: 8px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: 4px 16px calc(4px + env(safe-area-inset-bottom)); }
nav.tabs a { flex: 0 1 140px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 52px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; border-radius: 12px; }
nav.tabs a[aria-current=page] { color: var(--ink); }
nav.tabs a[aria-current=page] svg { color: var(--lamp); }
nav.tabs svg { width: 24px; height: 24px; }
html.kb-open nav.tabs { display: none; }  /* only while the on-screen keyboard is up (common.js), not on mere focus */
header.top { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 4px;
  background: var(--bg); border-bottom: 1px solid var(--line);
  padding: env(safe-area-inset-top) max(6px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left)); }
.crumbs { display: flex; align-items: center; min-width: 0; font-size: 15px; }
.crumbs a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; color: var(--muted); text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 62vw; }
.crumbs a:first-child::before { content: '› '; white-space: pre; }
.crumbs .sep { color: var(--muted); flex: none; }
button.more { background: transparent; color: var(--ink); font-size: 22px; min-width: 44px; padding: 0 8px; letter-spacing: 1px; }
body:not(:has(header.top)) main { padding-top: calc(12px + env(safe-area-inset-top)); }

/* the artist's own words vs. the AI's */
.mine { font-family: var(--serif); font-size: 19px; line-height: 1.7; text-wrap: pretty; }
.ai { font-family: var(--sans); color: var(--muted); font-size: 15px; }
.ai-line::before { content: '✦ '; }
.ai-block { border-inline-start: 2px solid var(--line); padding-inline: 14px 0; margin: 16px 0; color: var(--muted); font-size: 16px; }
.ai-block .label { display: block; font-size: 12px; letter-spacing: .04em; margin-bottom: 4px; }
.ai-block ul { margin: 4px 0 0; padding-inline-start: 18px; }
.ai-block li { margin: 4px 0; }

/* controls */
textarea, input[type=search] { width: 100%; font: inherit; color: inherit; background: transparent; }
textarea {
  field-sizing: content; min-height: 3lh; max-height: 60vh; resize: none; border: 0; border-bottom: 1px solid var(--line);
  padding: 12px 2px; font-family: var(--serif); font-size: 20px; line-height: 1.6; caret-color: var(--lamp); outline: none;
}
textarea:focus-visible { border-bottom: 2px solid var(--lamp); }
input[type=search] { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 8px 0; min-height: 44px; outline: none; }
input[type=search]:focus-visible { border-color: var(--lamp); }
button, .btn { font: inherit; font-weight: 600; border: 0; border-radius: 12px; padding: 11px 18px; min-height: 44px; cursor: pointer;
  background: var(--chip); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button.lamp { background: var(--lamp); color: var(--on-lamp); }
button.danger { color: var(--lamp); }
button:focus-visible, a:focus-visible, .btn:focus-within { outline: 2px solid var(--lamp); outline-offset: 2px; }
.row { display: flex; gap: 8px; margin: 12px 0; }
.row > * { flex: 1; }
.seg { display: flex; background: var(--chip); border-radius: 12px; padding: 3px; margin: 16px 0; }
.seg button { flex: 1; background: transparent; color: var(--muted); font-weight: 500; min-height: 44px; padding: 6px; border-radius: 9px; }
.seg button[aria-pressed=true] { background: var(--raised); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }

/* lists */
.muted { color: var(--muted); font-size: 14px; }
.type { color: var(--muted); font-size: 13px; font-weight: 500; }
.chip { display: inline-block; font-size: 13px; padding: 1px 9px; border-radius: 999px; background: var(--chip); color: var(--muted); }
.chip.warn { color: var(--lamp); }
.tags { color: var(--muted); font-size: 13px; }
ul.list { list-style: none; margin: 0; padding: 0; }
ul.list > li { border-bottom: 1px solid var(--line); }
ul.list a.item { display: block; padding: 14px 2px; color: inherit; text-decoration: none; min-height: 44px; }
.title { font-weight: 600; }
.piece-link { display: flex; align-items: center; min-height: 44px; color: inherit; text-decoration: none; }
.work-title { font-family: var(--serif); font-size: 20px; font-weight: 600; }
.new-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--lamp); margin-inline-end: 6px; vertical-align: middle; }
.empty { color: var(--muted); text-align: center; padding: 40px 16px; font-size: 16px; }
.banner { background: var(--chip); border-radius: 12px; padding: 10px 14px; margin: 12px 0; font-size: 15px; }

/* transcript */
audio { width: 100%; margin: 12px 0; }
.words span { cursor: pointer; border-radius: 4px; }
.words span.now { background: color-mix(in srgb, var(--lamp) 22%, transparent); }
.words span.unsure { opacity: .5; text-decoration: underline dotted; }
details > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }

/* searchable work picker */
.picker a { padding: 12px 2px; }

/* take player: time runs left-to-right even in the Hebrew UI; the play triangle is never mirrored */
.take { display: flex; align-items: center; gap: 10px; direction: ltr; margin: 10px 0; }
.take .play { width: 44px; height: 44px; padding: 0; border-radius: 50%; flex: none; font-size: 14px; }
.take.playing .play { background: var(--lamp); color: var(--on-lamp); }
.take .wave { flex: 1; height: 34px; touch-action: none; cursor: pointer; }
.take .wave rect { fill: var(--muted); opacity: .5; }
.take .wave rect.played { fill: var(--lamp); opacity: 1; }
.take .time, .mini .mpos { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; direction: ltr; unicode-bidi: isolate; }
.mini { position: fixed; z-index: 5; inset-inline: 10px; bottom: calc(70px + env(safe-area-inset-bottom)); max-width: 660px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 16px;
  background: var(--raised); border: 1px solid var(--line); box-shadow: 0 6px 24px rgb(0 0 0 / .22); }
.mini .pp { width: 44px; height: 44px; padding: 0; border-radius: 50%; background: var(--lamp); color: var(--on-lamp); flex: none; }
.mini .mt { flex: 1; min-width: 0; }
.mini .mtitle { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .msub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body:has(.mini:not([hidden])) main { padding-bottom: calc(160px + env(safe-area-inset-bottom)); }

/* tags are links (Works filtered by that tag); the hit area grows to 44px without growing the row */
a.tag { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; margin: -12px 0;
  padding: 0 6px; color: var(--muted); font-size: 13px; text-decoration: none; }
.tags { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 0 2px; direction: rtl; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }

/* toast (sits above the tabs and the mini player) */
.toast { position: fixed; z-index: 6; inset-inline: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto;
  background: var(--ink); color: var(--bg); border-radius: 14px; padding: 12px 16px; font-weight: 500; box-shadow: 0 6px 24px rgb(0 0 0 / .25); }
.toast a { color: inherit; font-weight: 700; display: inline-flex; min-height: 24px; }
.toast:has(#from-t) { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 8px; }
.toast:has(#from-t)[hidden] { display: none; }
body:has(.mini:not([hidden])) .toast { bottom: calc(140px + env(safe-area-inset-bottom)); }

/* the ⋯ sheet */
dialog.sheet { margin: auto auto 0; width: 100%; max-width: 680px; border: 0; padding: 0; background: transparent; color: var(--ink); max-height: 85vh; }
dialog.sheet::backdrop { background: rgb(0 0 0 / .38); }
.sheet-body { background: var(--raised); border-radius: 18px 18px 0 0; display: flex; flex-direction: column; gap: 8px;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet-content { display: flex; flex-direction: column; gap: 8px; }
.sheet-content > button, .sheet-body > button { width: 100%; justify-content: flex-start; }
.sheet-body > button[data-close] { justify-content: center; background: transparent; color: var(--muted); }

/* the one question (#1): AI voice, but the thing to read on the page */
.q-card .q { color: var(--ink); font-size: 18px; line-height: 1.5; font-weight: 500; margin: 2px 0 8px; }
.q-about { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip-btn { min-height: 44px; padding: 6px 14px; border-radius: 999px; font-size: 14px; font-weight: 500; background: var(--chip); color: var(--ink); }
#reask { min-height: 44px; font-size: 14px; }

/* takes (#2): a part with several takes = a take switcher + the chosen take + a labeled keeper button */
.part { padding: 8px 2px 14px; }
.part-head { margin: 4px 0 6px; }
.takes { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 4px; }
.takes button { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 0; min-width: 88px; min-height: 52px;
  padding: 6px 14px; border-radius: 12px; background: var(--chip); color: var(--muted); font-weight: 500; }
.takes button b { font-weight: 600; font-size: 15px; }
.takes button small { font-size: 12px; }
.takes button[aria-selected=true] { background: var(--raised); color: var(--ink); box-shadow: 0 0 0 2px var(--lamp) inset; }
.takes-hint { margin: 2px 0 6px; font-size: 13px; }
.takes-hint.done { color: var(--lamp); }
.keep { min-height: 44px; margin-top: 6px; font-size: 14px; background: var(--chip); color: var(--muted); }
.keep[aria-pressed=true] { color: var(--lamp); }

/* the Sheet: a work's parts in order, each in the artist's own words, one breath per line */
.sheet-tools { display: flex; align-items: center; gap: 12px; margin: 4px 0 8px; }
.sheet-tools button { flex: none; }
ul.sheet > li { border-bottom: 0; }
.sheet-part { border-inline-start: 3px solid transparent; padding-inline-start: 9px; margin-inline-start: -12px; border-radius: 2px; }
.sheet-part.on { border-inline-start-color: var(--lamp); }
.sheet-part { padding-block: 0 2px; }
.sheet-part .part-head { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; }
.sheet-part h2 { margin: 0; flex: 1; font-size: 15px; font-weight: 500; }
.arrange { display: flex; gap: 2px; flex: none; }
.arrange button { width: 44px; padding: 0; background: transparent; color: var(--muted); font-size: 18px; }
.arrange button:disabled { opacity: .25; cursor: default; }
.lines { margin: 2px 0 6px; }
.line { padding: 5px 0; cursor: pointer; border-radius: 6px; }
.line:active { background: var(--chip); }
.line span { border-radius: 4px; }
.line span.now { background: color-mix(in srgb, var(--lamp) 22%, transparent); }
.line span.unsure { opacity: .5; text-decoration: underline dotted; }
.line.melody { font-family: var(--sans); color: var(--muted); font-size: 16px; min-height: 44px; display: flex; align-items: center; }
.typed { white-space: pre-wrap; margin: 4px 0 8px; }
.part-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.part-foot a { color: var(--muted); display: inline-flex; align-items: center; min-height: 44px; }
.part-foot .keep { margin: 0 auto 0 0; }

@media print {
  html, body { background: #fff; color: #000; }
  header.top, nav.tabs, .mini, .toast, .seg, .sheet-tools, .ai-block, .takes, .takes-hint, .part-foot, .arrange, .banner, .empty, .chip, #work > .muted { display: none !important; }
  main { padding: 0; max-width: none; }
  h1 { color: #000; }
  .sheet-part { border: 0; margin: 0 0 14pt; padding: 0; break-inside: avoid; }
  .sheet-part h2, .line.melody { color: #000; }
  .line { padding: 0; }
  .line span.now { background: none; }
  .line span.unsure { opacity: 1; text-decoration: none; }
}

/* Browse search: the words around the match, a tap opens the take there */
a.hit { display: flex; flex-direction: column; gap: 2px; padding: 8px 2px; min-height: 44px; color: inherit; text-decoration: none; }
a.hit .mine { font-size: 17px; line-height: 1.5; }
a.hit + a.hit { border-top: 1px dashed var(--line); }
mark { background: color-mix(in srgb, var(--lamp) 25%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
ul.list > li:has(a.hit) { padding-bottom: 6px; }
button.more-row { width: 100%; margin: 12px 0; background: var(--chip); color: var(--ink); }

/* login */
main.login { max-width: 420px; padding-top: calc(18vh + env(safe-area-inset-top)); }
main.login form { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
main.login input[type=password] { font: inherit; color: inherit; background: transparent; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; min-height: 44px; outline: none; }
main.login input[type=password]:focus-visible { border-color: var(--lamp); }
main.login #err { color: var(--lamp); }

/* the tutorial (#10) */
dialog.tour { width: min(100% - 24px, 440px); max-height: calc(100dvh - 24px); border: 0; border-radius: 18px; padding: 14px;
  background: var(--raised); color: var(--ink); overflow: auto; }
dialog.tour::backdrop { background: rgb(0 0 0 / .55); }
.tour-shot { position: relative; margin: 0 0 12px; border-radius: 12px; overflow: hidden; background: #000; }
.tour-shot img { display: block; width: 100%; height: auto; max-height: 52dvh; object-fit: contain; object-position: top; }
.tour-box { position: absolute; border: 3px solid var(--lamp); border-radius: 10px; box-shadow: 0 0 0 999px rgb(0 0 0 / .35); }
.tour-icon { display: grid; place-items: center; height: 160px; font-size: 72px; background: var(--chip); }
dialog.tour h2 { font-family: var(--serif); font-size: 21px; margin: 4px 0 4px; outline: none; }
dialog.tour p { margin: 0 0 10px; color: var(--muted); font-size: 16px; line-height: 1.5; }
.tour-dots { display: flex; justify-content: center; gap: 6px; margin: 10px 0; }
.tour-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.tour-dots i.on { background: var(--lamp); }
.tour-nav { display: flex; gap: 8px; }
.tour-nav .lamp { flex: 1; }
.tour-nav .ghost { background: transparent; color: var(--muted); }
