/*
 * Конспекты предмета: /notes/math.
 *
 * Из макета notes_subject.html — тёмная шапка предмета, липкая полоса
 * поиска (.nf — filter-bar макета), разделы «§ 01» с серифным заголовком и
 * карточки тем. Без кольца «пройдено», метрик «освоено / учёбы / XP»,
 * «продолжить изучение», сегментной полоски раздела, статусов и полосок на
 * карточках и боковых виджетов: всё это про чтение ученика, которого мы не
 * знаем. Боковая колонка разделов стала строкой чипов под поиском.
 *
 * Термины (.terms) и выдача фильтра (.nres, .nrows) — своё, в макете их не
 * было. Строки .nrow повторены в notes.css для страницы поиска: стили
 * подключаются по одному файлу на слаг. Правка строки — в обоих файлах.
 */

  .page.notes-subject { padding-top: 24px; padding-bottom: 80px; }

  .crumbs {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 14px;
  }
  .crumbs a { font-weight: 500; }
  .crumbs a:hover { color: var(--accent); }
  .crumbs b { color: var(--ink); font-weight: 600; }
  .crumbs .mi { font-size: 15px; color: var(--muted-2); }

  /* ---------- шапка предмета ---------- */
  .subj-hero {
    background: linear-gradient(135deg, #1a1530 0%, #2a1f55 35%, var(--accent) 100%);
    color: white;
    border-radius: var(--radius-xl);
    padding: 30px 40px 32px;
    position: relative;
    overflow: hidden;
    margin-bottom: 22px;
  }
  .subj-hero::before {
    content: "";
    position: absolute;
    top: -140px; right: -100px;
    width: 380px; height: 380px;
    background: radial-gradient(circle, rgba(255,255,255,0.18), transparent 70%);
  }
  .subj-hero::after {
    content: "";
    position: absolute;
    bottom: -160px; left: 50%;
    width: 320px; height: 320px;
    background: radial-gradient(circle, rgba(255,184,0,0.22), transparent 70%);
  }
  .subj-hero > * { position: relative; z-index: 1; }
  .subj-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px 5px 6px;
    background: rgba(255,255,255,0.14);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 16px;
  }
  .subj-pill .icon {
    display: grid;
    place-items: center;
    min-width: 22px; height: 22px;
    padding: 0 4px;
    border-radius: 999px;
    background: rgba(255,255,255,0.18);
    font-size: 11px;
  }
  .subj-hero h1 {
    font-family: "Instrument Serif", serif;
    font-weight: 400;
    font-size: clamp(40px, 5.5vw, 60px);
    line-height: 1;
    letter-spacing: -0.025em;
    margin-bottom: 10px;
  }
  .subj-hero h1 em { font-style: italic; color: #ffd966; }
  .subj-hero .sub {
    font-family: "Instrument Serif", serif;
    font-style: italic;
    font-size: 20px;
    line-height: 1.35;
    color: rgba(255,255,255,0.78);
    max-width: 560px;
  }
  .hero-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding: 10px 18px;
    border-radius: 999px;
    background: white;
    color: var(--ink);
    font-size: 13.5px;
    font-weight: 600;
    transition: all 0.2s;
  }
  .hero-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 30px rgba(0,0,0,0.18); }

  /* ---------- полоса поиска ---------- */
  /* Липкая, как filter-bar в макете; top уточняет скрипт по высоте шапки. */
  .nf {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    position: sticky;
    top: 72px;
    z-index: 20;
    transition: box-shadow 0.2s;
  }
  .nf.is-stuck { box-shadow: var(--shadow-lg); }
  .nf-search {
    flex: 1;
    min-width: 0;
    position: relative;
    display: flex;
    align-items: center;
  }
  .nf-search > .mi {
    position: absolute;
    left: 12px;
    font-size: 16px;
    color: var(--muted-2);
    pointer-events: none;
  }
  .nf-search input {
    width: 100%;
    padding: 9px 36px 9px 36px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid transparent;
    outline: none;
    font: inherit;
    font-size: 14px;
    color: var(--ink);
    transition: all 0.15s;
  }
  .nf-search input::placeholder { color: var(--muted-2); }
  /* Родной крестик поля поиска синий и из другой системы; этот — в цвет. */
  .nf-search input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    margin-left: 6px;
    background: var(--muted);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath d='M480-438 270-228q-9 9-21 9t-21-9q-9-9-9-21t9-21l210-210-210-210q-9-9-9-21t9-21q9-9 21-9t21 9l210 210 210-210q9-9 21-9t21 9q9 9 9 21t-9 21L522-480l210 210q9 9 9 21t-9 21q-9 9-21 9t-21-9L480-438Z'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath d='M480-438 270-228q-9 9-21 9t-21-9q-9-9-9-21t9-21l210-210-210-210q-9-9-9-21t9-21q9-9 21-9t21 9l210 210 210-210q9-9 21-9t21 9q9 9 9 21t-9 21L522-480l210 210q9 9 9 21t-9 21q-9 9-21 9t-21-9L480-438Z'/%3E%3C/svg%3E") center / contain no-repeat;
    cursor: pointer;
  }
  .nf-search input:focus {
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
  }
  .nf-kbd {
    position: absolute;
    right: 10px;
    font-family: "Geist Mono", monospace;
    font-size: 11px;
    padding: 1px 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--muted-2);
    pointer-events: none;
  }
  .nf-search input:focus ~ .nf-kbd,
  .nf-search.has-q .nf-kbd { display: none; }

  /* Вид страниц — сегменты, как .filter-chips в макете. */
  .nf-kind {
    display: flex;
    gap: 4px;
    padding: 3px;
    background: var(--surface-2);
    border-radius: 99px;
    flex-shrink: 0;
  }
  .nf-kind a {
    padding: 6px 13px;
    border-radius: 99px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
    transition: all 0.15s;
  }
  .nf-kind a:hover { color: var(--ink); }
  .nf-kind a.active {
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
  }
  .nf-kind .count {
    font-family: "Geist Mono", monospace;
    font-size: 10px;
    color: var(--muted-2);
    margin-left: 3px;
    font-weight: 500;
  }
  .nf-kind a.active .count { color: var(--accent); }

  .nf-task {
    position: relative;
    display: flex;
    align-items: center;
    flex-shrink: 0;
  }
  .nf-task select {
    appearance: none;
    -webkit-appearance: none;
    padding: 8px 32px 8px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-2);
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
  }
  .nf-task select:hover { border-color: var(--border-strong); }
  .nf-task select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); }
  .nf-task.is-on select { background: var(--accent-50); border-color: var(--accent-200); color: var(--accent-700); }
  .nf-task > .mi {
    position: absolute;
    right: 11px;
    font-size: 16px;
    color: var(--muted);
    pointer-events: none;
  }
  /* Кнопка нужна только без скрипта: со скриптом всё применяется сразу. */
  .nf-go {
    padding: 8px 16px;
    border-radius: 999px;
    background: var(--ink);
    color: white;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    border: 0;
    cursor: pointer;
  }
  .nf.is-live .nf-go { display: none; }

  /* Разделы чипами — .filter-chip из общей основы. */
  .nf-parts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0 4px;
  }
  .nf-parts .filter-chip { padding: 6px 12px; font-size: 12.5px; }
  .nf-parts .filter-chip.is-empty:not(.active) { opacity: 0.45; }

  /* ---------- выдача ---------- */
  .nres { margin-top: 26px; }
  .nres[hidden], #nsections[hidden], .part[hidden] { display: none; }
  .nres-h {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 6px;
  }
  .nres-sum { font-size: 14px; color: var(--muted); }
  .nres-sum b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
  .nres-reset {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--surface-2);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-2);
    transition: all 0.15s;
  }
  .nres-reset:hover { background: var(--accent-50); color: var(--accent-700); }
  .nres-part { margin-top: 22px; scroll-margin-top: 140px; }
  .nres-part-h {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 10px;
  }
  .nres-part-h .num {
    font-family: "Geist Mono", monospace;
    font-size: 11.5px;
    color: var(--accent);
    letter-spacing: 0.06em;
  }
  .nres-part-h h3 {
    font-family: "Instrument Serif", serif;
    font-weight: 400;
    font-size: 24px;
    line-height: 1.1;
    letter-spacing: -0.01em;
  }
  .nres-part-h .count {
    font-family: "Geist Mono", monospace;
    font-size: 12px;
    color: var(--muted);
  }
  .nres-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 10px;
  }
  .topic-card.is-compact { padding: 12px 14px 12px; }
  .topic-card.is-compact .top { margin-bottom: 6px; }
  .topic-card.is-compact h3 { font-size: 14.5px; }
  .topic-card.is-compact .preview { margin-bottom: 0; }
  .nres-empty { margin-top: 12px; }
  .nres-more { margin-top: 22px; font-size: 13.5px; }
  .nres-all, .nres-empty a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: var(--accent-700);
  }
  .nres-all:hover { color: var(--accent); }

  /* Строки терминов: заголовок, описание одной строкой, номера заданий. */
  .nrows {
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .nrows li { border-top: 1px solid var(--border); min-width: 0; }
  .nrows li:nth-child(-n+2) { border-top: 0; }
  .nrows li:nth-child(odd) { border-right: 1px solid var(--border); }
  .nrow {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 16px;
    min-width: 0;
    height: 100%;
    transition: background 0.15s;
  }
  .nrow:hover { background: var(--surface-2); }
  .nrow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .nrow-main b {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--ink);
  }
  .nrow:hover .nrow-main b { color: var(--accent-700); }
  .nrow-about {
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .nrow-side { flex: none; display: flex; align-items: center; gap: 8px; }
  .nrow .ege-pill {
    font-size: 10.5px;
    font-variant-numeric: tabular-nums;
    padding: 3px 7px;
    border-radius: 4px;
    background: var(--accent-50);
    color: var(--accent-700);
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
  }
  .nrow .ege-pill.oge { background: var(--blue-soft); color: var(--blue); }

  mark {
    background: var(--yellow-soft);
    color: inherit;
    border-radius: 3px;
    padding: 0 1px;
  }

  /* ---------- раздел ---------- */
  /* Отступ под якорь: иначе липкая шапка закрывает заголовок раздела. */
  .part { margin-top: 40px; scroll-margin-top: 84px; }
  .part-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 16px;
  }
  .part-head .num {
    font-family: "Geist Mono", monospace;
    font-size: 12px;
    color: var(--accent);
    font-weight: 500;
    letter-spacing: 0.06em;
    flex: none;
  }
  .part-head h2 {
    font-family: "Instrument Serif", serif;
    font-weight: 400;
    font-size: 32px;
    line-height: 1.05;
    letter-spacing: -0.015em;
    color: var(--ink);
  }
  .part-head h2 em { font-style: italic; color: var(--accent); }
  .part-count {
    margin-left: auto;
    font-family: "Geist Mono", monospace;
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }

  /* ---------- карточка конспекта ---------- */
  .topics-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
  }
  .topic-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px 14px;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
  .topic-card:hover {
    border-color: var(--accent-100);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
  }
  .topic-card .top {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 9px;
  }
  .topic-card .num-l {
    font-family: "Instrument Serif", serif;
    font-style: italic;
    font-size: 24px;
    line-height: 0.85;
    color: var(--accent);
    flex-shrink: 0;
  }
  .topic-card .kick {
    min-width: 0;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topic-card .top-right {
    margin-left: auto;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  /* Не моноширинный: в Geist Mono нет знака «№», и браузер подставляет
     чужой, похожий на «₽». */
  .topic-card .ege-pill {
    font-size: 10.5px;
    font-variant-numeric: tabular-nums;
    padding: 3px 7px;
    border-radius: 4px;
    background: var(--accent-50);
    color: var(--accent-700);
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
  }
  .topic-card .ege-pill.oge { background: var(--blue-soft); color: var(--blue); }
  .topic-card h3 {
    font-weight: 600;
    font-size: 15.5px;
    line-height: 1.25;
    letter-spacing: -0.005em;
    color: var(--ink);
    margin-bottom: 5px;
  }
  .topic-card .preview {
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.4;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .topic-card .foot {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11.5px;
    color: var(--muted);
  }
  .topic-card .foot .item { display: inline-flex; align-items: center; gap: 4px; }
  .topic-card .diff { display: inline-flex; gap: 2px; margin-left: auto; }
  .topic-card .diff i {
    width: 4px; height: 8px;
    border-radius: 99px;
    background: var(--surface-3);
  }
  .topic-card .diff i.on { background: var(--accent); }
  .sr {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  /* ---------- термины раздела ---------- */
  .terms {
    margin-top: 14px;
    padding: 16px 20px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }
  .terms.alone { margin-top: 0; }
  .terms-h {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .terms-h .count {
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--surface-2);
    font-family: "Geist Mono", monospace;
    font-size: 10.5px;
    letter-spacing: 0;
    color: var(--muted);
  }
  .terms-list {
    list-style: none;
    columns: 4 200px;
    column-gap: 28px;
  }
  .terms-list li { break-inside: avoid; }
  .terms-list a {
    display: block;
    padding: 3px 0;
    font-size: 13.5px;
    line-height: 1.35;
    color: var(--ink-2);
    transition: color 0.15s;
  }
  .terms-list a:hover { color: var(--accent); }
  .terms-more summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-700);
    cursor: pointer;
    list-style: none;
  }
  .terms-more summary::-webkit-details-marker { display: none; }
  .terms-more summary::after { content: "↓"; font-size: 12px; }
  .terms-more[open] summary { display: none; }

  /* ---------- мобильный ---------- */
  @media (max-width: 1100px) {
    .topics-grid, .nres-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .nf { flex-wrap: wrap; }
    .nf-search { flex: 1 1 100%; }
  }
  /* На телефоне полоса не липкая: вместе с шапкой в две строки она заняла
     бы треть экрана, а поле всё равно под рукой — выдача начинается сразу
     под ним. Разделы — одной строкой с прокруткой вбок. */
  @media (max-width: 760px) {
    .nf { position: static; gap: 8px; padding: 10px; }
    .nf-kind { flex: 1 1 auto; }
    .nf-kind a { flex: 1; text-align: center; padding: 6px 8px; }
    .nf-task { flex: 1 1 100%; }
    .nf-task select { width: 100%; }
    .nf-kbd { display: none; }
    .nf-parts {
      flex-wrap: nowrap;
      overflow-x: auto;
      margin: 10px -18px 0;
      padding: 0 18px 4px;
      scrollbar-width: none;
    }
    .nf-parts::-webkit-scrollbar { display: none; }
    .nf-parts .filter-chip { flex: none; white-space: nowrap; }
    .nres-cards { grid-template-columns: 1fr; }
    .nrows { grid-template-columns: 1fr; }
    .nrows li:nth-child(2) { border-top: 1px solid var(--border); }
    .nrows li:nth-child(odd) { border-right: 0; }
    .nrow { flex-wrap: wrap; row-gap: 4px; }
    .nres-part-h h3 { font-size: 21px; }
    .subj-hero { padding: 24px 22px 26px; }
    .subj-hero .sub { font-size: 17px; }
    .topics-grid { grid-template-columns: 1fr; }
    .part-head { flex-wrap: wrap; }
    .part-head h2 { font-size: 26px; }
    .part-count { margin-left: 0; width: 100%; }
    .terms-list { columns: 2 140px; }
  }
