/* Поиск, повторение, поток и вопрос к лекции.

   Отдельный файл: это надстройка над конспектом, а не его часть, и держать
   её рядом с полкой и листом было бы кашей. */

/* Панель вопроса лежит внутри экрана конспекта, поэтому ему нужна опора:
   без position экран не считается контейнером и панель уезжает к окну. */
#screen-note.active { position: relative; }

/* ── Поиск по всем конспектам ─────────────────────────────────────────────── */

#search-results { padding-bottom: 20px; }
#search-results .list { padding: 0; }
.card .snippet {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-soft);
  margin: 2px 0 7px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card mark {
  background: color-mix(in srgb, var(--accent) 26%, transparent);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}
.empty.small { padding: 26px 20px; }
.badge.stream {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
}

/* ── Плитка повторения на полке ───────────────────────────────────────────── */

.revise-tile {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  text-align: left;
  padding: 14px 15px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.revise-tile::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--accent);
}
.revise-tile.waiting::before { background: var(--line); }
.revise-tile:active { transform: scale(.99); }
.revise-ic { font-size: 22px; line-height: 1; }
.revise-text { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.revise-text b { font-size: 15px; font-weight: 650; }
.revise-text small { font-size: 12.5px; color: var(--hint); }
.revise-count {
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  border-radius: 15px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.revise-count:empty { display: none; }

/* ── Экран повторения ─────────────────────────────────────────────────────── */

#screen-cards.active {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-bottom: 0;
  overflow: hidden;
}
.cards-head {
  flex: none;
  padding: calc(16px + var(--sat)) 18px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.cards-head h2 { margin: 0 0 3px; font-size: 19px; font-family: var(--serif); }
.cards-head small { color: var(--hint); font-size: 12.5px; }
.cards-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--ground-deep);
  margin-top: 12px;
  overflow: hidden;
}
.cards-progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .3s ease;
}

.card-stage {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 18px 16px 12px;
  min-height: 0;
  overflow-y: auto;
}
.card-stage[hidden] { display: none; }

/* Карточка — та же бумага, что и лист конспекта: повторяешь то же, что читал.
   Свет сверху и тёплый кант по краю берутся у .sheet: карточка должна
   читаться как вырванный из тетради кусок, а не как модальное окно. */
.flash {
  width: 100%;
  max-width: 560px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 16px;
  padding: 24px 24px 20px;
  /* Свет сверху — ровно одна линия по верхней грани, а не растяжка на 120 px.
     Растяжка делала верх карточки светлее низа, и подсказка о прокрутке у
     формулы (math.css красит края цветом подложки) вставала на этом градиенте
     двумя заметными прямоугольниками. Грань даёт тот же объём и ничего не
     ломает. */
  box-shadow: var(--shadow-md), inset 0 0 0 1px var(--rule), inset 0 1px 0 rgba(255, 255, 255, .6);
  font-family: var(--serif);
  cursor: pointer;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  transition: transform .12s ease;
}
html.dark .flash {
  box-shadow: var(--shadow-md), inset 0 0 0 1px var(--rule), inset 0 1px 0 rgba(255, 255, 255, .09);
}
.flash:active { transform: scale(.995); }
/* Метка вида и подпись источника лежат на бумаге, значит и красятся
   бумажным --paper-label: --hint не проходит по контрасту ни в одной теме. */
.flash-kind {
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--paper-label);
}
.flash-front { font-size: 20px; line-height: 1.35; font-weight: 700; }
/* Формулы в вопросе идут вперемежку с текстом, и выключная не должна
   раздвигать карточку на пол-экрана. */
.flash-front .math-block { margin: 8px 0 4px; }
.flash-back {
  font-size: 15.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  border-top: 1px solid var(--rule);
  padding-top: 13px;
  animation: reveal .18s ease;
}
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; } }
.flash-src {
  margin-top: auto;
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--paper-label);
}
.flash:not(.open) .flash-front { margin-bottom: auto; }

.card-actions {
  flex: none;
  padding: 0 16px calc(20px + var(--sab));
  display: grid;
  gap: 10px;
  justify-items: center;
  /* На телефоне вопрос плюс четыре ответа выше экрана: пусть низ
     прокручивается, а не срезается. */
  max-height: 62dvh;
  overflow-y: auto;
}
.card-actions[hidden] { display: none; }
.card-actions .primary { max-width: 560px; }
/* Четыре варианта ответа. Кнопки крупные и в один столбец: ответы —
   это фразы, а не слова, и в строку они не помещаются ни на одном экране. */
.options {
  display: grid;
  gap: 8px;
  width: 100%;
  max-width: 560px;
}
.options[hidden] { display: none; }

/* Вариант ответа.

   Кружок слева — не украшение. Во-первых, он делает из четырёх похожих
   прямоугольников список, по которому глаз идёт сверху вниз. Во-вторых,
   после ответа именно он несёт «верно/неверно» знаком, а не одним цветом:
   у карточки по матанализу вариант часто целиком состоит из формулы, и
   зелёная рамка вокруг чёрной формулы — слабый сигнал. */
/* Раскладка блочная, а НЕ flex, и это принципиально. Внутрь кнопки кладётся
   готовый inline-HTML: текст вперемежку с <span class="math-inline">. У flex-
   контейнера каждый такой span становится отдельным элементом строки, и вместо
   абзаца получается лента «Число | A | называется пределом | f | в точке»,
   которая не переносится, вылезает за экран и тянет за собой всю колонку
   ответов. Кружок поэтому вынут из потока и стоит абсолютом. */
.option {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  padding: 13px 15px 13px 51px;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, border-color .12s ease, background .16s ease;
}
.option::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 12px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--chip);
  color: var(--text-soft);
  font: 700 12.5px/26px var(--sans);
  text-align: center;
  transition: background .16s ease, color .16s ease;
}
.options .option:nth-child(1)::before { content: "А"; }
.options .option:nth-child(2)::before { content: "Б"; }
.options .option:nth-child(3)::before { content: "В"; }
.options .option:nth-child(4)::before { content: "Г"; }
.option:active { transform: scale(.99); }
@media (hover: hover) and (pointer: fine) {
  .option:enabled:hover { border-color: var(--accent); }
}
.option:disabled { cursor: default; }
.option.right {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--card));
  color: var(--text);
  font-weight: 600;
}
.option.right::before {
  content: "✓";
  background: var(--accent);
  color: var(--accent-text);
}
.option.wrong {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, var(--card));
}
.option.wrong::before {
  content: "✕";
  background: var(--danger);
  color: #fff;
}
/* Зачёркивание убрано намеренно: через формулу оно идёт ровно по знаку
   равенства, и «=» превращается в «≠». Что вариант неверный, говорят крестик,
   красная рамка и подложка. */

/* Формула внутри варианта.

   app.css гасит у неё прокрутку, чтобы нажатие доходило до кнопки; здесь
   прокрутка возвращается, иначе длинный ряд символов вылезает за кнопку и
   ложится на соседний вариант. Само нажатие не страдает: pointer-events
   снят только с .katex, а обработчик ищет кнопку через closest. */
.option .math-block {
  overflow-x: auto;
  margin: 3px 0;
  max-width: 100%;
}
.option .math-block .katex-display > .katex { font-size: 1em; }
.option .katex { font-size: 1.06em; }
/* Подсказка о прокрутке (math.css) закрашивает края формулы цветом подложки.
   У отвеченного варианта подложка другая — и «карточная» заплатка вставала
   двумя тёмными прямоугольниками по краям верной формулы. Смешение то же
   самое, что и у фона кнопки строкой выше. */
.option.right .math-block { --math-base: color-mix(in srgb, var(--accent) 14%, var(--card)); }
.option.wrong .math-block { --math-base: color-mix(in srgb, var(--danger) 12%, var(--card)); }

/* Вердикт — чип, а не строчка: он появляется на 1-2 секунды между ответом и
   следующей карточкой, и его надо успеть поймать глазом. */
.verdict {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 7px 15px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  text-align: center;
  line-height: 1.35;
}
.verdict[hidden] { display: none; }
.verdict.ok { background: var(--accent-soft); color: var(--accent); }
.verdict.no { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

.grades {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 560px;
}
.grades[hidden] { display: none; }
.grade {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 10px 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, border-color .12s ease;
}
.grade b { font-size: 13.5px; font-weight: 650; }
.grade small { font-size: 11px; color: var(--hint); font-variant-numeric: tabular-nums; }
.grade:active { transform: scale(.97); }
.grade.again { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.grade.again b { color: var(--danger); }
.grade.good { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.grade.good b { color: var(--accent); }

/* ── Поток ────────────────────────────────────────────────────────────────── */

/* Шапка предмета: обложка, название, счётчик и одна кнопка «ещё».
   Название длинное почти всегда, поэтому оно обрезается, а не лезет под кнопку. */
.subject-head .subject-name { flex: 1; min-width: 0; overflow: hidden; }
.subject-head h2 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.subject-head small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.subject-head .tool-btn { flex: none; margin-left: 2px; }
.ghost-btn {
  flex: none;
  border: 1px solid var(--line);
  background: var(--ground);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 13px;
  border-radius: 10px;
  cursor: pointer;
}
.ghost-btn:active { background: var(--chip); transform: scale(.97); }
.ghost-btn[hidden] { display: none; }
.stream-note {
  padding: 10px 15px;
  font-size: 12.5px;
  color: var(--accent);
  background: var(--accent-soft);
  border-bottom: 1px solid var(--line);
}
.stream-note[hidden] { display: none; }

.sheet-text { font-size: 14px; line-height: 1.55; color: var(--text-soft); margin: 0 0 14px; }
.code-box {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 26px;
  letter-spacing: .18em;
  text-align: center;
  padding: 16px;
  border-radius: 12px;
  background: var(--chip);
  color: var(--text);
  margin-bottom: 12px;
}
.row-btn.danger .ic, .row-btn.danger span { color: var(--danger); }

/* ── Конспект: пометка о чужом и вопрос к лекции ──────────────────────────── */

.readonly-note {
  flex: none;
  padding: 8px 15px;
  font-size: 12.5px;
  color: var(--accent);
  background: var(--accent-soft);
  border-bottom: 1px solid var(--line);
}
.readonly-note[hidden] { display: none; }

.ask-panel {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  max-height: min(62dvh, 520px);
  background: var(--card);
  border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow-lg);
  padding: 12px 14px calc(12px + var(--sab));
}
.ask-panel[hidden] { display: none; }
.ask-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 8px;
}
.ask-log {
  overflow-y: auto;
  display: grid;
  gap: 12px;
  padding-bottom: 10px;
  min-height: 0;
}
.ask-log:empty { display: none; }
.qa .q {
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
  margin-bottom: 5px;
}
.qa .a {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-soft);
  border-left: 3px solid var(--accent);
  padding-left: 11px;
}
.qa .a.thinking { color: var(--hint); font-style: italic; }
.qa-src { display: flex; flex-wrap: wrap; gap: 6px; margin: 7px 0 0 14px; }
.src {
  border: 1px solid var(--line); background: var(--ground); color: var(--text-soft);
  font-size: 12px; padding: 5px 10px; border-radius: 8px; cursor: pointer;
}
.src:active { background: var(--chip); transform: scale(.96); }
.ask-row { display: flex; gap: 8px; align-items: center; }
.ask-row .field { flex: 1; margin: 0; }
.ask-send { flex: none; width: auto; padding: 11px 16px; font-size: 14px; }
.ask-send:disabled { opacity: .55; }

/* На ноутбуке панель вопроса не растягивается на всю ширину конспекта. */
@media (min-width: 860px) {
  .ask-panel { left: auto; right: 18px; width: 460px; border-radius: 16px; bottom: 18px; }
}
/* На телефоне панель занимает низ экрана целиком и не залезает под клавиатуру. */
@media (max-width: 859px) {
  .ask-panel { max-height: min(70dvh, 560px); }
}

/* ── Подписка ─────────────────────────────────────────────────────────────── */

.paywall-why {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
}
.price {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 4px 0 14px;
}
.price b { font-size: 34px; font-family: var(--serif); letter-spacing: -.01em; }
.price small { font-size: 13.5px; color: var(--hint); }
.perks { margin: 0 0 16px; padding: 0; list-style: none; display: grid; gap: 9px; }
.perks li {
  position: relative;
  padding-left: 26px;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--text);
}
.perks li::before {
  content: "✓";
  position: absolute;
  left: 0; top: 0;
  color: var(--accent);
  font-weight: 700;
}
.free-note {
  margin-top: 12px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--hint);
  text-align: center;
}
.row-btn.accent-row .ic { color: var(--accent); }
.head-add.locked::after {
  content: "";
  position: absolute;
  right: 2px; bottom: 2px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--exam-line);
  box-shadow: 0 0 0 2px var(--ground);
}
.head-add { position: relative; }

/* Тариф на полке отдельной строкой */
.plan-tile {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  text-align: left;
  padding: 13px 15px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.plan-tile[hidden] { display: none; }
.plan-tile:active { transform: scale(.99); }
.plan-ic {
  flex: none;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
}
.plan-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.plan-text b { font-size: 14.5px; font-weight: 650; }
.plan-text small { font-size: 12px; color: var(--hint); line-height: 1.35; }
.plan-cta {
  flex: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-text);
  background: var(--accent);
  padding: 7px 12px;
  border-radius: 10px;
}
.plan-cta:empty { display: none; }
.plan-tile.full { border-color: var(--exam-line); background: var(--exam); }
.plan-tile.full .plan-title, .plan-tile.full b { color: var(--exam-text); }
.plan-tile.full .plan-ic { background: var(--exam-line); color: var(--exam-text); }
.plan-tile.full small { color: var(--exam-text); opacity: .85; }
.plan-tile.paid .plan-cta { display: none; }

/* Предупреждение о лимите на экране предмета */
.limit-note {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 15px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--accent-soft);
  color: var(--accent);
  font: 12.5px/1.45 var(--sans);
  cursor: pointer;
}
.limit-note[hidden] { display: none; }
.limit-note.full { background: var(--exam); color: var(--exam-text); font-weight: 600; }

/* Лист и доска внутри предмета: та же карточка, но с иконкой слева. */
.card.kind-board, .card.kind-sheet {
  display: flex;
  align-items: center;
  gap: 12px;
}
/* Значок листа или доски на карточке. Фон — --chip, а не --ground-deep:
   последний в тёмной теме темнее самой карточки, и значок читался как
   вырезанная в ней дырка. */
.card-ic {
  flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--chip);
  color: var(--text-soft);
  font-size: 17px;
}
.card.kind-board .card-ic { background: var(--accent-soft); color: var(--accent); }
.card-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.card-body .title { font-size: 15.5px; font-weight: 600; }
.card-body .sub { font-size: 12px; color: var(--hint); }
.subject-head .tool-btn { flex: none; }

.sel-order { display: flex; gap: 4px; }
.sel-order[hidden] { display: none; }
.sel-order .mopt { min-width: 32px; justify-content: center; }

/* Кнопка «ещё» на карточке листа, доски или лекции */
.card-more {
  flex: none;
  width: 40px; height: 40px;
  margin-right: -6px;
  display: grid; place-items: center;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--hint);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .12s ease;
}
.card-more:active { background: var(--chip); color: var(--text); transform: scale(.92); }
@media (hover: hover) and (pointer: fine) {
  .card-more:hover { background: var(--chip); color: var(--text); }
}
.card { align-items: center; }
.card.kind-lecture { display: flex; gap: 12px; }

/* Плашка над выделенным куском конспекта */
.quote-bar {
  position: fixed;
  z-index: 40;
  display: flex;
  gap: 4px;
  padding: 5px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  max-width: calc(100vw - 16px);
  overflow-x: auto;
  scrollbar-width: none;
}
.quote-bar[hidden] { display: none; }
.quote-bar::-webkit-scrollbar { display: none; }
.quote-act {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  padding: 0 13px;
  background: transparent;
  color: var(--text);
  font: 13px var(--sans);
  white-space: nowrap;
  cursor: pointer;
  transition: background .14s ease, transform .12s ease;
}
.quote-act:active { background: var(--chip); transform: scale(.96); }
/* Без обёртки подсветка залипает на последней нажатой кнопке и читается как
   выбранное действие. */
@media (hover: hover) and (pointer: fine) {
  .quote-act:hover { background: var(--chip); }
}
.quote-act:first-child { color: var(--accent); font-weight: 600; }

/* «Ещё» на обложке предмета — как у элементов внутри папки */
.book { position: relative; }
.book-more {
  position: absolute;
  left: 6px; top: 6px;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, .28);
  color: #fff;
  cursor: pointer;
  opacity: .85;
}
.book-more:active { background: rgba(0, 0, 0, .5); transform: scale(.92); }
