/* «Слушать конспект» (js/listen.js): a player card over the note. Bottom centre, above the phone tab bar.
   A card with the play button, where we are and how long is left; the thin line along its bottom edge is the
   seek bar of the whole note (drag or tap). The place being read is lit on the page itself by ::highlight. */
.ls {
  --p: 0%;
  position: fixed;
  left: 50%;
  bottom: calc(16px + var(--tabbar-offset, 0px) + env(safe-area-inset-bottom, 0px));
  z-index: 70;
  width: min(680px, calc(100vw - 32px));
  transform: translateX(-50%);
  /* Movement only, no opacity: a faded ancestor becomes the «backdrop root» and the glass inside blurs nothing. */
  animation: ls-in 0.22s ease-out;
}
@keyframes ls-in { from { transform: translate(-50%, 24px); } }
@media (prefers-reduced-motion: reduce) { .ls { animation: none; } }

.ls__card {
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  color: var(--text);                  /* the glass itself (fill, blur, rim, shadow) is in css/glass.css */
}
.ls__main { display: flex; align-items: center; gap: var(--s-3); padding: 12px 14px 10px 12px; }

.ls__play {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  transition: background-color 0.15s;
  position: relative;
}
.ls__play:hover { background: var(--accent-hover); }
/* The voice is still being made: a ring runs round the button (transform only, no opacity above the glass). */
.ls__play.is-wait::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  animation: ls-wait 0.9s linear infinite;
}
@keyframes ls-wait { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ls__play.is-wait::after { animation-duration: 3s; } }
.ls__play svg { width: 18px; height: 18px; fill: currentColor; stroke: currentColor; }

.ls__now { display: grid; flex: 1; min-width: 0; gap: 2px; }
.ls__label { overflow: hidden; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.ls__sub { overflow: hidden; color: var(--text-3); font-size: var(--fs-12); text-overflow: ellipsis; white-space: nowrap; }
.mv__step { margin: 0 0 4px; color: var(--accent-text); font-size: var(--fs-12); font-weight: 700; }
.ls__why { margin-top: 2px; color: var(--text-3); font-size: var(--fs-12); line-height: 1.35; }
.ls__why[hidden] { display: none; }
.ls.is-prep .ls__sub { white-space: normal; }

.ls__ctl { display: flex; align-items: center; flex: none; gap: 2px; }
.ls__btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.ls__btn:hover { background: var(--accent-soft); color: var(--accent-ink); }
.ls__btn svg { width: 18px; height: 18px; }
.ls__chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  margin-left: 4px;
  padding: 0 11px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 7%, transparent);
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-14);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.ls__chip:hover, .ls__chip[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-ink); }
.ls__chip svg { width: 14px; height: 14px; }

/* Seek: a transparent range over a thin drawn track, so the control stays a real, keyboard-friendly input. */
.ls__seek { position: relative; height: 18px; margin-top: -4px; }
.ls__track {
  position: absolute;
  inset: 8px 0 auto;
  height: 3px;
  background: var(--accent-soft);
  transition: height 0.12s, inset 0.12s;
}
.ls__track i { display: block; width: var(--p); height: 100%; background: var(--accent); }
.ls__seek:hover .ls__track, .ls__seek:focus-within .ls__track { inset: 7px 0 auto; height: 5px; }
.ls__seek input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.ls__seek:focus-within { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Voice menu: a small sheet over the card, right-aligned under the voice chip. */
.ls__menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  display: grid;
  min-width: 240px;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
}
.ls__menu[hidden] { display: none; }
.ls__voice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ls__voice:hover { background: var(--surface-2); }
.ls__voicename { display: grid; gap: 1px; font-weight: 600; }
.ls__voicename small { color: var(--text-3); font-size: var(--fs-12); font-weight: 400; }
.ls__voice svg { width: 18px; height: 18px; color: var(--accent); opacity: 0; }
.ls__voice[aria-checked="true"] svg { opacity: 1; }

/* What is being read: the sentence, lit softly on the page. No line at the edge, no layout shift. */
::highlight(ls-now) { background-color: color-mix(in srgb, var(--accent) 17%, transparent); }
/* Browsers without the Custom Highlight API: the whole paragraph, with a halo instead of padding. */
.is-listening { border-radius: 6px; background: var(--accent-soft); box-shadow: 0 0 0 5px var(--accent-soft); }
body.has-listen [data-ls-block] { cursor: pointer; }

body.has-listen:not(.ls-docked) #app { padding-bottom: 110px; }
.nt-head__listen { width: fit-content; margin-top: var(--s-3); }

@media (max-width: 599px) {
  .ls { width: calc(100vw - 20px); }
  .ls__main { flex-wrap: wrap; row-gap: 6px; padding: 10px 10px 8px; }
  .ls__now { order: 1; }
  .ls__ctl { order: 2; flex-basis: 100%; justify-content: space-between; }
  .ls__ctl .ls__chip { margin-left: 0; }
  .ls__menu { right: 0; left: 0; min-width: 0; }
}
@media print { .ls { display: none; } .is-listening { background: none; box-shadow: none; } }

/* ---------- In the corner: the player follows the reader to other pages (it lives in <body>) ---------- */
.ls__mini { display: none; }
.ls.is-mini {
  left: 20px;
  bottom: calc(20px + var(--tabbar-offset, 0px) + env(safe-area-inset-bottom, 0px));
  width: min(340px, calc(100vw - 40px));
  transform: translate(var(--dx, 0px), var(--dy, 0px));
  transition: transform 0.2s ease-out;
  animation: ls-in-mini 0.22s ease-out;
}
@keyframes ls-in-mini { from { transform: translateY(24px); } }
@media (prefers-reduced-motion: reduce) { .ls.is-mini { animation: none; } }
.ls.is-mini .ls__card, .ls.is-mini .ls__menu { display: none; }
.ls.is-mini .ls__mini {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  overflow: hidden;
  padding: 8px 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  color: var(--text);
}
.ls__mini .ls__play { width: 40px; height: 40px; }
.ls__mini .ls__play svg { width: 16px; height: 16px; }
.ls__minitext {
  display: grid;
  flex: 1;
  min-width: 0;
  gap: 2px;
  padding: 2px 4px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ls__minibar { position: absolute; inset: auto 0 0; height: 3px; background: var(--accent-soft); }
.ls__minibar i { display: block; width: var(--p); height: 100%; background: var(--accent); }
body.has-listen-mini:not(.ls-docked) #app { padding-bottom: 96px; }
@media (max-width: 599px) { .ls.is-mini { left: 10px; width: calc(100vw - 20px); } }

/* The «play on other pages» switch in the voice menu. */
.ls__sep { height: 1px; margin: 6px 4px; background: var(--border); }
.ls__keep {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ls__keep:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
.ls__switch {
  position: relative;
  flex: none;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 18%, transparent);
  transition: background-color 0.15s;
}
.ls__switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--plum) 35%, transparent);
  transition: transform 0.15s;
}
.ls__keep[aria-checked="true"] .ls__switch { background: var(--accent); }
.ls__keep[aria-checked="true"] .ls__switch::after { transform: translateX(16px); }
.ls.is-drag { transition: none; }
.ls.is-mini .ls__mini, .ls__dock { touch-action: none; user-select: none; -webkit-user-select: none; }

/* ---------- Docked: a narrow strip on the left or right edge, the bottom of the page stays free ---------- */
.ls__dock { display: none; }
.ls.is-docked {
  left: auto;
  right: 0;
  top: var(--dock-y, 55%);
  bottom: auto;
  width: auto;
  transform: none;
  transition: none;
  animation: ls-dock-in 0.22s ease-out;
}
.ls.is-docked.is-dock-l { left: 0; right: auto; animation-name: ls-dock-in-l; }
@keyframes ls-dock-in { from { transform: translateX(100%); } }
@keyframes ls-dock-in-l { from { transform: translateX(-100%); } }
.ls.is-docked .ls__card, .ls.is-docked .ls__mini, .ls.is-docked .ls__menu { display: none; }
.ls.is-docked .ls__dock {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  width: 52px;
  padding: 9px 6px 9px 9px;
  border: 1px solid var(--border-strong);
  border-right: 0;
  border-radius: 22px 0 0 22px;
  color: var(--text);
  cursor: grab;
}
.ls.is-docked.is-dock-l .ls__dock {
  padding: 9px 9px 9px 6px;
  border-right: 1px solid var(--border-strong);
  border-left: 0;
  border-radius: 0 22px 22px 0;
}
.ls.is-drag .ls__dock { cursor: grabbing; }
.ls__dock .ls__play { width: 38px; height: 38px; }
.ls__dock .ls__play svg { width: 15px; height: 15px; }
.ls__dock .ls__btn { width: 34px; height: 34px; }
.ls__dockbar { position: absolute; top: 0; bottom: 0; left: 0; width: 3px; background: var(--accent-soft); }
.ls.is-dock-l .ls__dockbar { left: auto; right: 0; }
.ls__dockbar i { display: block; width: 100%; height: var(--p); background: var(--accent); }
@media (prefers-reduced-motion: reduce) { .ls.is-docked { animation: none; } }
@media print { .ls.is-mini, .ls.is-docked { display: none; } }

/* ---------- «Мой голос» (js/myvoice.js): recording dialog ---------- */
.ls__mine svg { opacity: 1; color: var(--text-2); }
.mv {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
}
.mv::backdrop { background: color-mix(in srgb, var(--plum, #000) 35%, transparent); }
.mv__card {
  display: grid;
  gap: var(--s-3);
  padding: 20px 20px 18px;
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  background: var(--surface-raised);
}
.mv__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.mv__title { margin: 0; font-size: var(--fs-20, 1.25rem); }
.mv__body { display: grid; gap: var(--s-3); }
.mv__lead { margin: 0; color: var(--text-2); }
.mv__phrase {
  margin: 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: var(--fs-18, 1.125rem);
  line-height: 1.55;
}
.mv__row { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.mv__row .btn svg { width: 18px; height: 18px; margin-right: 6px; }
.mv__rec { display: flex; align-items: center; gap: var(--s-3); }
.mv__dot { width: 10px; height: 10px; border-radius: 999px; background: var(--danger, #d33); animation: mv-blink 1s steps(2) infinite; }
@keyframes mv-blink { 50% { visibility: hidden; } }
.mv__time { font-variant-numeric: tabular-nums; font-weight: 600; }
.mv__level { flex: 1; height: 6px; overflow: hidden; border-radius: 999px; background: var(--surface-2); }
.mv__level i { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; }
.mv__audio { width: 100%; }
.mv__consent { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.mv__consent input { margin-top: 3px; accent-color: var(--accent); }
.mv__note { margin: 0; color: var(--text-3); font-size: var(--fs-12, 0.8rem); }
.mv__progress { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; }
.mv__progress .mv__dot { background: var(--accent-text); }
.mv__link { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.mv__error { margin: 0; color: var(--danger-ink, var(--danger, #c22)); }
.mv__forget { color: var(--text-2); }
@media (prefers-reduced-motion: reduce) { .mv__dot { animation: none; } }
@media (max-width: 599px) { .mv__row .btn { flex: 1 1 100%; justify-content: center; } }
