/*
 * Общая основа страниц: токены, сброс, шапка, каркас .page, кнопки,
 * заголовки секций, панели и анимация появления.
 *
 * Всё это одинаково на рабочем столе, в каталоге задач и в списках, поэтому
 * лежит отдельно и подключается раньше стилей страницы: страница дописывает
 * своё поверх, а не копирует шестьсот строк к себе.
 */

  :root {
    /* база */
    --bg: #fafafa;
    --surface: #ffffff;
    --surface-2: #f5f5f7;
    --surface-3: #ececef;
    --border: #ececec;
    --border-strong: #e0e0e2;

    /* текст */
    --ink: #0a0a0a;
    --ink-2: #2a2a2a;
    --ink-body: #1f1f23;
    --muted: #737378;
    --muted-2: #a3a3a8;

    /* акцент */
    --accent: #725DFF;
    --accent-50: #f1eeff;
    --accent-100: #e2dcff;
    --accent-200: #c4b8ff;
    --accent-600: #5a45e8;
    --accent-700: #4632c4;
    --accent-glow: rgba(114, 93, 255, 0.18);

    /* функциональные */
    --green: #1aae5b;
    --green-soft: #e3f7eb;
    --green-tint: #f0faf4;
    --yellow: #f5b800;
    --yellow-soft: #fef4d6;
    --orange: #ff7a1a;
    --orange-soft: #fff0e0;
    --red: #ef3b3b;
    --red-soft: #fde4e4;
    --red-tint: #fef5f5;
    --blue: #2a8eff;
    --blue-soft: #e0efff;
    --pink: #ff4d8d;
    --pink-soft: #ffe2ec;

    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 22px;
    --radius-xl: 28px;

    --shadow-sm: 0 1px 2px rgba(15, 15, 20, 0.04), 0 1px 1px rgba(15, 15, 20, 0.03);
    --shadow: 0 4px 14px rgba(15, 15, 20, 0.05), 0 1px 2px rgba(15, 15, 20, 0.04);
    --shadow-lg: 0 18px 40px -12px rgba(15, 15, 20, 0.12), 0 4px 10px rgba(15, 15, 20, 0.04);
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  html, body {
    background: var(--bg);
    color: var(--ink);
    font-family: "Geist", -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
  }

  /* мягкое цветное свечение в углу страницы */
  body::before {
    content: "";
    position: fixed;
    top: -200px; right: -200px;
    width: 600px; height: 600px;
    background: radial-gradient(circle, var(--accent-glow), transparent 70%);
    pointer-events: none;
    z-index: 0;
  }
  body::after {
    content: "";
    position: fixed;
    bottom: -300px; left: -200px;
    width: 700px; height: 700px;
    background: radial-gradient(circle, rgba(245, 184, 0, 0.08), transparent 70%);
    pointer-events: none;
    z-index: 0;
  }

  a { color: inherit; text-decoration: none; }
  button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }

  .mono { font-family: "Geist Mono", ui-monospace, monospace; }
  .serif { font-family: "Instrument Serif", Georgia, serif; font-weight: 400; }

  /* ============== TOP NAV ============== */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    background: rgba(250, 250, 250, 0.75);
    border-bottom: 1px solid var(--border);
  }
  .topbar-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 14px 32px;
    display: flex;
    align-items: center;
    gap: 32px;
  }

  .logo {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 600;
    font-size: 17px;
    letter-spacing: -0.01em;
  }
  .logo-mark {
    width: 30px; height: 30px;
    border-radius: 9px;
    background: var(--ink);
    color: white;
    display: grid;
    place-items: center;
    font-family: "Instrument Serif", serif;
    font-style: italic;
    font-size: 19px;
    line-height: 1;
    position: relative;
    overflow: hidden;
  }
  .logo-mark::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--accent) 0%, transparent 60%);
    opacity: 0.7;
  }
  .logo-mark span { position: relative; z-index: 1; }

  /* Экзамен приходит из куки, которую ставит выбор на index.html */
  .exam-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: -20px;
    padding: 6px 11px 6px 13px;
    border-radius: 999px;
    background: var(--surface-2);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
    transition: background 0.18s;
  }
  .exam-pill:hover { background: var(--border); }
  .exam-pill svg { color: var(--muted); }

  .nav {
    display: flex;
    gap: 4px;
    font-size: 14px;
  }
  /* Не только ссылки: пункт без готовой страницы рисуется span'ом. */
  .nav > * {
    padding: 8px 14px;
    border-radius: 999px;
    color: var(--muted);
    font-weight: 500;
    transition: all 0.2s;
  }
  .nav a:hover { color: var(--ink); background: var(--surface-2); }
  .nav a.active {
    color: var(--ink);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }

  .topbar-right {
    margin-left: auto;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
  }

  /* Поле поиска (.search-pill) — в common.css: оно стоит и в шапке лендинга. */

  .icon-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    color: var(--ink-2);
    transition: all 0.2s;
    position: relative;
  }
  .icon-btn:hover { background: var(--surface-2); }
  .icon-btn .dot {
    position: absolute;
    top: 6px; right: 7px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--surface);
  }

  /* Пока личного кабинета нет, на месте аватара стоит кнопка входа. */
  .btn-login {
    padding: 8px 16px;
    border-radius: 999px;
    background: var(--ink);
    color: white;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
  }
  .btn-login:hover { background: var(--ink-2); }

  .avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--pink));
    color: white;
    display: grid;
    place-items: center;
    font-weight: 600;
    font-size: 13px;
    flex: none;
  }

  /* Профиль спрятан под аватар: в шапке остаются только разделы,
     ради которых сюда возвращаются каждый день. */
  .user { position: relative; flex: none; }
  .avatar-btn {
    display: grid;
    place-items: center;
    width: 36px; height: 36px;
    padding: 0;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    transition: all 0.2s;
  }
  .avatar-btn:hover { border-color: var(--border-strong); }
  .avatar-btn[aria-expanded="true"] {
    border-color: var(--accent-200);
    box-shadow: 0 0 0 3px var(--accent-50);
  }

  .user-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 248px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 60;
    animation: menuIn 0.16s ease both;
  }
  @keyframes menuIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: none; }
  }
  .user-menu .who {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px 12px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border);
  }
  .user-menu .who b { display: block; font-size: 14px; font-weight: 600; }
  .user-menu .who small { font-size: 12px; color: var(--muted); }
  .user-menu a,
  .user-menu .mbtn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink-2);
    text-align: left;
    transition: background 0.15s;
  }
  .user-menu a:hover,
  .user-menu .mbtn:hover { background: var(--surface-2); }
  .user-menu .mi { font-size: 17px; color: var(--muted); }
  .user-menu .tail {
    margin-left: auto;
    font-size: 12px;
    color: var(--muted-2);
  }
  .user-menu .sep { height: 1px; margin: 6px 4px; background: var(--border); }

  :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 6px;
  }

  /* ============== LAYOUT ============== */
  .page {
    max-width: 1320px;
    margin: 0 auto;
    padding: 32px;
    position: relative;
    z-index: 1;
  }

  /*
   * Две колонки: поток и липкая колонка сбоку. Пропорции переопределяет
   * страница — на рабочем столе сбоку врезки, в каталоге задач фильтры.
   */
  .desk {
    display: grid;
    grid-template-columns: minmax(0, 1.95fr) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
  }
  .flow {
    min-width: 0;
    display: flex;
    flex-direction: column;
  }
  .rail {
    min-width: 0;
    position: sticky;
    top: 90px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: calc(100vh - 92px);
    overflow-y: auto;
    padding: 3px;
    margin: -3px;
    scrollbar-width: thin;
  }
  .rail::-webkit-scrollbar { width: 6px; }
  .rail::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
  .flow .section-h { margin-top: 0; }

  /* ---------- ярлыки ---------- */
  .tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 7px;
    font-size: 11px;
    font-weight: 600;
  }
  .tag-violet { background: var(--accent-50); color: var(--accent-700); }
  .tag-ghost { background: var(--surface-2); color: var(--muted); }
  .tag-green { background: var(--green-soft); color: var(--green); }
  .tag-yellow { background: var(--yellow-soft); color: #946d00; }
  .tag-red { background: var(--red-soft); color: var(--red); }
  .tag-blue { background: var(--blue-soft); color: var(--blue); }

  .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
    white-space: nowrap;
  }
  /* Главное действие на светлом фоне. Наведение у каждой страницы своё:
     на тёмном лендинге кнопка приподнимается, в каталоге — светлеет. */
  .btn-dark {
    background: var(--ink);
    color: white;
  }
  .btn-primary {
    background: white;
    color: var(--ink);
  }
  .btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 30px rgba(0,0,0,0.18); }
  .btn-ghost {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
  }
  .btn-ghost:hover { background: rgba(255,255,255,0.16); }

  /* ============== SECTION HEADER ============== */
  .section-h {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 18px;
    margin-top: 8px;
  }
  .section-h h2 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.015em;
  }
  .section-h h2 em {
    font-family: "Instrument Serif", serif;
    font-style: italic;
    font-weight: 400;
    color: var(--accent);
  }
  .section-h .right-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
    color: var(--muted);
  }
  .section-h .right-actions a { color: var(--ink); font-weight: 500; }
  .section-h .right-actions a:hover { color: var(--accent); }

  .filter-row {
    display: flex;
    gap: 6px;
    margin-bottom: 18px;
    flex-wrap: wrap;
  }
  .filter-chip {
    padding: 8px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
  }
  .filter-chip:hover { color: var(--ink); border-color: var(--border-strong); }
  .filter-chip.active {
    background: var(--ink);
    color: white;
    border-color: var(--ink);
  }
  .filter-chip .count {
    background: rgba(255,255,255,0.18);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
  }
  .filter-chip:not(.active) .count {
    background: var(--surface-2);
    color: var(--muted);
  }

  .panel {
    background: var(--surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }
  .panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 22px 12px;
  }
  .panel-head h3 {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
  }
  .panel-head .link {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
  }
  .panel-head .link:hover { color: var(--accent); }

  /* ============== ANIMATIONS ============== */
  .reveal { opacity: 0; transform: translateY(10px); animation: rev 0.7s cubic-bezier(.2,.8,.2,1) forwards; }
  @keyframes rev { to { opacity: 1; transform: translateY(0); } }
  .reveal:nth-child(1) { animation-delay: 0.04s; }
  .reveal:nth-child(2) { animation-delay: 0.08s; }
  .reveal:nth-child(3) { animation-delay: 0.12s; }
  .reveal:nth-child(4) { animation-delay: 0.16s; }
  .reveal:nth-child(5) { animation-delay: 0.20s; }
  .reveal:nth-child(6) { animation-delay: 0.24s; }
  .reveal:nth-child(7) { animation-delay: 0.28s; }
  .reveal:nth-child(8) { animation-delay: 0.32s; }

  /* ============== RESPONSIVE ============== */
  @media (max-width: 1000px) {
    .topbar-inner { padding: 12px 18px; gap: 14px; flex-wrap: wrap; }
    /* три раздела переезжают на вторую строку целиком, а не прячутся */
    .nav { order: 3; width: 100%; margin: 0 -14px; padding: 0 14px; overflow-x: auto; scrollbar-width: none; }
    .nav::-webkit-scrollbar { display: none; }
    .nav a { white-space: nowrap; }
    .topbar-right { order: 2; }
    .page { padding: 18px; }
    .hero, .main-grid { grid-template-columns: 1fr; }
    .hero-main { min-height: auto; padding: 28px 22px; }
    .hero-main h1 { font-size: 34px; }
    .hero-mini-stats { position: static; margin-top: 18px; }
    .topics { grid-template-columns: repeat(2, 1fr); }
  }

/* Material Symbols, встроенные как svg */
.mi{display:inline-block;width:1em;height:1em;vertical-align:-.14em;fill:currentColor;flex:none}

  /* Липкая колонка и липкая шапка считают контейнером прокрутки ближайшего
     предка с overflow. От overflow-x: hidden на html/body sticky перестаёт
     работать, clip режет так же, но контейнер прокрутки не создаёт. */
  html, body { overflow-x: clip; }

  /* ============== ПЕРЕКЛЮЧАТЕЛЬ ЭКЗАМЕНА ============== */
  /* Страна определяется доменом, и у неё может быть несколько экзаменов:
     в России ЕГЭ и ОГЭ, в Беларуси ЦЭ и ЦТ. Это не фильтр — у каждого
     экзамена свой адрес, поэтому внутри переключателя ссылки. */
  .exam-switch {
    display: flex;
    gap: 4px;
    padding: 3px;
    margin-left: -22px;
    background: var(--surface-2);
    border-radius: 999px;
    flex: none;
  }
  .exam-switch a {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--muted);
    white-space: nowrap;
    transition: all 0.18s;
  }
  .exam-switch a:hover { color: var(--ink); }
  .exam-switch a.active {
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
  }
  .logo span { white-space: nowrap; }

  [hidden] { display: none !important; }

  /* ============== КАРКАС: ПОТОК + ЛИПКАЯ КОЛОНКА ============== */
  .tnum { font-variant-numeric: tabular-nums; }

  /* ============== ЦВЕТА СЕМЕЙСТВ ПРЕДМЕТОВ ============== */
  /* Значок предмета красится по семье: точные сиреневые, естественные
     зелёные, гуманитарные оранжевые, языки синие, грамотности жёлтые. */
  .ic-violet { background: var(--accent-50); color: var(--accent-700); }
  .ic-green { background: var(--green-soft); color: var(--green); }
  .ic-yellow { background: var(--yellow-soft); color: #a17800; }
  .ic-blue { background: var(--blue-soft); color: var(--blue); }
  .ic-red { background: var(--red-soft); color: var(--red); }
  .ic-pink { background: var(--pink-soft); color: var(--pink); }
  .ic-orange { background: var(--orange-soft); color: var(--orange); }
  .ic-dark { background: var(--ink); color: white; }
