/* ===== Lists ===== */
.items-list{
  margin: 12px 0 0;
  padding-left: 22px;
}

.items-list > li{
  /* чуть больше воздуха между карточками */
  margin: 16px 0;
}

.block-items-list{
  list-style: none;
  padding-left: 0;
  margin: 12px 0 0;
  display:flex;
  flex-direction:column;
  gap:16px;
}

/* ===== Каталог по заданиям ЕГЭ: блок с раскрытием списка тем ===== */
.catalog-index-stack{
  max-width: 66.666%; /* в 1.5 раза уже (100% / 1.5) */
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 768px) {
  .page-is-catalog .page {
    padding-left: 20px;
    padding-right: 20px;
  }
  .catalog-index-stack {
    max-width: none;
  }
}

/* Catalog index: topics rows were styled inline in template; make them night-friendly */
/* Layout tweaks (catalog index only) */
.topics-list > li.row{
  margin-left: 16px;
  text-align: left;
}
.topics-list > li.row a{
  padding-left: 20px;
}

/* Title padding in catalog summary */
.catalog-block__title{
  padding-left: 20px;
  display: inline-block;
}

html.invert-images .topics-list > li.row{
  border-color: rgba(233, 233, 233, 0.14) !important;
  background: rgba(39, 23, 34, 0.75) !important;
}
.catalog-block{ display: block; }
.catalog-block__summary{ list-style: none; cursor: pointer; user-select: none; }
.catalog-block__summary::-webkit-details-marker{ display: none; }
.catalog-block__summary::marker{ content: none; }
.catalog-block__summary-row{
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.catalog-block__summary-row > div:first-child{ min-width: 0; flex: 1; }
.catalog-block__count{
  --p: 0%;
  --pnum: 0;
  --fill: hsl(calc(var(--pnum) * 1.2), 85%, 45%);
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 6rem;
  padding: 6px 12px;
  font-weight: 600;
  color: var(--c-muted);
  border-radius: var(--r-xl); /* 25px */
  background: rgba(255,255,255,0.4);
  border: 1px solid var(--c-border);
  overflow: hidden;
}
html.invert-images .catalog-block__count{
  color: rgba(233, 233, 233, 0.80);
  background: rgba(255,255,255,0.06);
  border-color: rgba(233, 233, 233, 0.14);
}
.catalog-block__count::before{
  content: "";
  position: absolute;
  inset: 0;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--p);
  min-width: 0;
  background: var(--fill);
  opacity: 0.4;
  z-index: 0;
  transition: width .25s ease;
  border-radius: var(--r-xl); /* 25px */
}
html.invert-images .catalog-block__count::before{
  opacity: 0.22;
}
.catalog-block__count-total{
  position: relative;
  z-index: 1;
  font-size: 13px;
  line-height: 1.2;
}
.catalog-block__count-solved{
  position: relative;
  z-index: 1;
  font-size: 11px;
  line-height: 1.2;
  opacity: 0.9;
}

/* ===== Universal “accent rail” ===== */
.accent-rail{
  position: relative;
}
.accent-rail::before{
  /* Accent rails were removed by request (no colored полоски). */
  content: none;
}

/* ===== Task / Video cards ===== */
.task-item,
.video-item{
  position: relative;
  padding: 14px 14px 0;
  border: none;
  border-radius: 25px;
  background: rgba(255,255,255,.95);
  box-shadow: var(--shadow-sm);
}
.task-item{
  padding-top: 0;
}

/* общая полоска слева (и задача, и видео) — один отступ */
.task-item,
.video-item{
  padding-left: 32px;
}

/* ===== Video cards: без внутренних отступов (только видео) ===== */
.video-item{
  padding-top: 0;
  padding-left: 0;
  padding-right: 0;
}

/* ===== Task / Video: одна и та же левая полоска по статусу ===== */
.task-item.accent-rail,
.video-item.accent-rail{
  border-left-color: transparent;
  overflow: hidden;
}

.task-item.accent-rail::before,
.video-item.accent-rail::before{
  left: 0;
  top: 0;
  bottom: 0;
  width: 10px; /* делаем полоску толще */
  border-radius: var(--r-xl) 0 0 var(--r-xl);
  background: rgba(18,18,18,.16); /* нейтральный серый – “нет попыток” */
}

.task-item.accent-rail::before,
.video-item.accent-rail::before{ z-index: 2; border-radius: 25px 0 0 25px; }
.task-item.task-status-untouched.accent-rail::before,
.video-item.accent-rail:not(.task-status-solved)::before{
  background: linear-gradient(to right, rgba(18,18,18,.16), rgba(18,18,18,0));
}

.task-item.task-status-solved.accent-rail::before,
.video-item.task-status-solved.accent-rail::before{
  background: linear-gradient(to right, #46c45a, rgba(70, 196, 90, 0));
}

.task-item.task-status-wrong.accent-rail::before{
  background: linear-gradient(to right, #ff3b30, rgba(255, 59, 48, 0)); /* яркий, более тёмный красный */
}

.task-item.is-hidden,
.video-item.is-hidden{
  opacity: .45;
  filter: saturate(.85);
}

.task-item.is-solved,
.video-item.is-solved{
  background: rgba(111,44,255,.08);
}

.card-top{
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

/* Video cards: header in one row */
.video-item .card-top{
  /* 3-column grid keeps title truly centered,
     regardless of left-side actions width */
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  justify-content: stretch;
  gap: 0;
}

.video-item .card-actions{
  grid-column: 1;
  justify-self: start;
  align-self: center;
}

/* Карточка задачи: card-top и task-check на всю ширину li (фото условия крупнее) */
.task-item .card-top{
  margin-left: -32px;
  margin-right: -14px;
  width: calc(100% + 46px);
  padding-left: 0;
  gap: 0;
  box-sizing: border-box;
}
.task-item .card-actions{
  width: auto;
  order: -1;
}
.task-item .card-top > div:first-child{
  order: 0;
}

.card-title{
  font-weight: 800;
}

/* Video title block inside .card-top (see `_video_block_card.html`) */
.video-title{
  grid-column: 2;
  justify-self: center;
  flex: initial;
  font-weight: 900;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.video-title__text{
  width: auto;
  text-align: center;
}
.video-title__hidden{
  width: auto;
  text-align: center;
  margin-top: 4px;
}

/* Верхняя полоска: номер в левом верхнем углу + кнопки; на всю ширину */
.card-actions{
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-self: flex-start;

  margin-left: 1px;
  padding: 10px 14px 10px 14px;
  border-radius: 25px 25px 0 0;
  border: 1px solid rgba(0, 0, 0, 0);
  border-bottom: none;
  border-color: rgba(0, 0, 0, 0);
  background: #fff;
}

/* Video cards: no actions strip background/border */
.video-item .card-actions{
  background: rgba(255, 255, 255, 0);
  border-color: rgba(0, 0, 0, 0);
}
/* Порядковый номер задачи — левый верхний угол card-actions (заполняется JS из data-no) */
.task-no-pill:empty{ display: none; }
.task-no-pill{
  position: static;
  left: auto;
  top: auto;
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  box-sizing: border-box;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  border-radius: 999px;
  background: rgba(255,255,255,.85); /* как .attempts-badge */
  border: 1px solid var(--c-border);
  color: var(--c-text);
}
html.invert-images .task-no-pill{
  background: rgba(62, 60, 62, 0.85);
}
.task-item.has-no-pill::after{ content: none !important; }
.video-item.has-no-pill::after{ content: none !important; }

/* В card-actions все элементы одной высоты и шрифта */
.card-actions .btn{
  height: 32px;
  padding: 0 12px;
  box-sizing: border-box;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
}
.card-actions .chip{
  height: 32px;
  padding: 0 12px;
  box-sizing: border-box;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
}
.card-actions .attempts-badge{
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  box-sizing: border-box;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
}

.task-actions{
  display:flex;
  gap:6px;
  align-items:center;
}

.task-actions .btn--icon{
  width:34px; height:34px;
}

/* Кружки «Важная» / «Повтор» в режиме редактирования */
.task-flag{
  box-sizing: border-box;
  width: 22px;
  min-width: 22px;
  max-width: 22px;
  height: 22px;
  min-height: 22px;
  max-height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,.25);
  background: transparent;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  flex-grow: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s;
}
.task-flag svg,
.task-flag img{
  flex-shrink: 0;
}
.task-flag:hover{
  border-color: rgba(0,0,0,.45);
  background: rgba(0,0,0,.06);
}
.task-flag--important.task-flag--on{
  background: #1a73e8;
  border-color: #1a73e8;
}
.task-flag--repeat.task-flag--on{
  background: #9e9e9e;
  border-color: #9e9e9e;
}

/* ===== FIX #1: image frame (NO rounding on image, small white border) ===== */
.media-box{
  margin-top: 10px;
  padding: 10px;                 /* рамка, чтобы текст не упирался в углы */
  border-radius: var(--r-lg);     /* скругляем РАМКУ */
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.96);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.60),
    0 10px 24px rgba(0,0,0,.06);
}

.media-box img{
  border-radius: 0 !important;    /* НЕ скругляем саму картинку */
  width: 100%;
  height: auto;
  display:block;
  background:#fff;
}

/* ===== Invert mode: dark surfaces for task UI (to match inverted images) ===== */
html.invert-images .media-box{
  background: rgba(62, 62, 62, 0.95);
  border-color: rgba(255,255,255,.14);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.06),
    0 10px 24px rgba(0,0,0,.14);
}
html.invert-images .media-box img{
  background: transparent;
}

.statement-text{
  margin-top: 8px;
  color: var(--c-text);
  line-height: 1.45;
}

/* внутри .task-check условие идёт первым, без зазора и слияние по верху; без тени и контура */
.task-check > .media-box--inside-task-check{
  margin-left: -44px;
  margin-right: 0;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: calc(100% + 56px);
  box-sizing: border-box;
  padding: 10px 18px;
  border: none;
  border-radius: 0 25px 0 0;
  box-shadow: none;
}
html.invert-images .task-check > .media-box--inside-task-check{
  background: rgba(62, 62, 62, 1);
  color: rgba(59, 59, 59, 0);
  box-shadow: none;
}
.task-check > .media-box--inside-task-check img{
  width: 100%;
  display: block;
  margin-left: 0;
  margin-right: 0;
  position: static;
  left: auto;
  top: auto;
}
.task-check > .statement-text--inside-task-check{
  margin-top: 0;
  margin-bottom: 12px;
}

/* ===== Attempts badge + tooltip ===== */
.attempts-wrap { position: relative; display: inline-block; }
.attempts-badge{
  font-size: 12px;
  padding: 5px 10px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: rgba(255,255,255,.85);
  cursor: help;
  user-select: none;
  font-weight: 650;
}

.attempts-tooltip{
  display:none;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 99999;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 10px;
  min-width: 280px;
  max-height: min(70vh, 400px);
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.attempts-wrap:hover .attempts-tooltip{ display: block; }

.attempt-row{
  display:flex;
  gap:8px;
  justify-content:space-between;
  border-top: 1px solid rgba(0,0,0,.07);
  padding-top: 6px;
  margin-top: 6px;
  font-size: 12px;
}

.attempt-time{ color: var(--c-muted); white-space: nowrap; }
.attempt-answer{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
.attempt-verdict{ white-space: nowrap; }

/* ===== Answer / check box: условие (media/statement) + форма внутри одного блока ===== */
.task-check{
  margin-top: 0;
  padding: 12px;
  border: 1px solid rgba(0,0,0,.08);
  border-top: none;
  border-radius: 0 25px 25px 25px;
  background: #fff;
}
.task-item .task-check{
  margin-top: -10px;
  margin-left: -32px;
  margin-right: -14px;
  width: calc(100% + 46px);
  padding-left: 44px;
  box-sizing: border-box;
}
.task-check:has(> .media-box--inside-task-check){
  padding-top: 0;
}
.task-check:has(> .statement-text--inside-task-check){
  padding-top: 0;
}
/* форма вплотную к media-box сверху (убираем зазор от padding) */
.task-check:has(> .media-box--inside-task-check) > .control-row{
  margin-top: -12px;
}
.task-check .input{
  width: 180px;
  padding: 9px 10px;
  border-radius: 999px;
}
.task-check > form.control-row{
  /* выравниваем левый край input с кружком .task-no-pill (14px vs 44px) */
  padding-left: 10px;
  transform: translateX(-30px);
  width: calc(100% + 30px);
}
.task-check .answer-pill{
  display: inline-block;
  min-width: 60px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.12);
  background: #fff;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.task-check .answer-pill--empty{
  font-weight: normal;
  color: var(--muted-color, #666);
}
.task-check .btn{ padding: 9px 12px; }

html.invert-images .task-check{
  background: rgba(62, 62, 62, 1);
  border-color: rgba(255,255,255,.14);
  color: rgba(245,245,245,.92);
}
html.invert-images .task-check .muted,
html.invert-images .task-check .task-check-login-msg{
  color: rgba(245,245,245,.66);
}
html.invert-images .task-check a{ color: rgba(255,255,255,.92); }

/* controls inside task-check */
html.invert-images .task-check .input,
html.invert-images .task-check .textarea,
html.invert-images .task-check .select{
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.14);
  color: rgba(245,245,245,.92);
}
html.invert-images .task-check .input::placeholder,
html.invert-images .task-check .textarea::placeholder{
  color: rgba(255,255,255,.45);
}
html.invert-images .task-check .btn{
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.16);
  color: rgba(245,245,245,.92);
}
html.invert-images .task-check .btn--primary{
  background: rgba(58, 58, 58, 1);
  color: rgba(233, 233, 233, 1);
}

/* top strip with attempts/buttons */
html.invert-images .card-actions{
  background: rgba(66, 64, 70, 0.01) !important;
  border-color: rgba(74, 74, 73, 1) !important;
  color: rgba(245,245,245,.92);
}
html.invert-images .card-actions .btn,
html.invert-images .card-actions .chip,
html.invert-images .attempts-badge{
  background: rgba(255,255,255,.06) !important;
  border-color: rgba(255,255,255,.14) !important;
  color: rgba(245,245,245,.90) !important;
}
html.invert-images .card-actions .btn--secondary{
  background: rgba(233, 233, 233, 1) !important;
  color: rgba(81, 81, 81, 1) !important;
}
html.invert-images .attempts-tooltip{
  background: rgba(62, 62, 62, 0.98);
  border-color: rgba(255,255,255,.14);
  color: rgba(245,245,245,.92);
}

/* video title in “night mode” */
html.invert-images .video-title__text{
  color: rgba(188, 188, 188, 1);
}

/* QA “подсказка GPT” button in “night mode” */
html.invert-images .qa-details .qa-summary{
  color: rgba(233, 233, 233, 1) !important;
  border-color: rgba(233, 233, 233, 0.14) !important;
}

/* Night look for the whole card in invert mode */
html.invert-images .items-list .task-item,
html.invert-images .items-list .video-item{
  background: rgba(62, 62, 62, 0.95);
  color: rgba(245,245,245,.92);
  box-shadow: 0 16px 42px rgba(0,0,0,.22);
}
html.invert-images .items-list .task-item > .liquid-glass-bg,
html.invert-images .items-list .video-item > .liquid-glass-bg{
  display: none; /* в “ночном” виде делаем как на твоём примере: без glass */
}


/* ===== TopicBlock (GLASS, like left-bottom) ===== */
.topic-block{
  position: relative;
  padding: 16px;  /* чуть воздуха слева */
  border-radius: var(--r-xl);
  border: 1px solid rgba(255,255,255,.46);

  /* “стекло” + цветные рефракции */
  background:
    radial-gradient(260px 160px at 14% 12%, rgba(255,221,45,.22), rgba(255,221,45,0) 70%),
    radial-gradient(280px 200px at 86% 16%, rgba(111,44,255,.20), rgba(111,44,255,0) 72%),
    radial-gradient(260px 180px at 62% 82%, rgba(255,43,71,.14), rgba(255,43,71,0) 72%),
    linear-gradient(135deg, rgba(255,255,255,.72), rgba(255,255,255,.44));

  backdrop-filter: blur(14px) saturate(1.45);
  box-shadow: 0 16px 42px rgba(0,0,0,.10);
  overflow: hidden;
}

/* фирменная полоска слева */
/* .topic-block::before{
  content:"";
  position:absolute;
  left:12px;
  top:14px;
  bottom:14px;
  width:6px;
  border-radius:999px;
  background: linear-gradient(180deg, var(--c-red), var(--c-yellow), var(--c-purple));
  opacity:.95;
} */

/* “блик” */
.topic-block::after{
  content:"";
  position:absolute;
  top:-80px;
  right:-120px;
  width:320px;
  height:320px;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.65), rgba(255,255,255,0) 68%);
  transform: rotate(18deg);
  pointer-events:none;
}

/* Night mode: dim topic glass (reduce top-right brightness) */
html.invert-images .topic-block{
  border-color: rgba(233, 233, 233, 0.14);
  background:
    radial-gradient(260px 160px at 14% 12%, rgba(255,221,45,.12), rgba(255,221,45,0) 70%),
    radial-gradient(280px 200px at 86% 16%, rgba(111,44,255,.10), rgba(111,44,255,0) 72%),
    radial-gradient(260px 180px at 62% 82%, rgba(255,43,71,.07), rgba(255,43,71,0) 72%),
    linear-gradient(135deg, rgba(18,18,22,.66), rgba(18,18,22,.46));
  box-shadow: 0 16px 42px rgba(0,0,0,.22);
}
html.invert-images .topic-block::after{
  opacity: 0.30;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.35), rgba(255,255,255,0) 68%);
}

.topic-block.is-hidden{
  opacity: .45;
}

.topic-block__head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
}

.topic-block__left{
  width: 120px;
  display:flex;
  align-items:center;
  gap:8px;
}

.topic-block__center{
  flex:1;
  text-align:center;
}

.topic-block__title{
  margin:0;
  font-weight: 900;
  font-size: 20px;
}

/* Topic title color tweak in “night mode” */
html.invert-images .topic-block__title{
  color: rgba(188, 188, 188, 1);
}

.topic-block__desc{
  margin-top: 6px;
  color: rgba(18,18,18,.65);
  font-size: 13px;
  white-space: pre-wrap;
}

.topic-block__right{
  display:flex;
  align-items:center;
  gap:10px;
  white-space:nowrap;
}

/* процент — компактный “пузырь” */
.topic-block__percent{
  font-weight: 900;
  color: rgba(62, 62, 62, 1);
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(10px);
}

/* ===== QA (стиль как в Telegram) ===== */
.qa-details{ margin-top: 12px; position: relative; }
.task-check .qa-details--inside-task-check{ margin-top: 10px; }
/* без нижнего отступа, когда последний элемент — подсказка GPT, чтобы не было зазора */
.task-check:has(> .qa-details--inside-task-check){ padding-bottom: 0; }
.task-check .qa-details--inside-task-check .qa-panel{
  padding-bottom: 15px;
  padding-left: 12px;
  border-radius: 25px;
  margin-top: 0;
  margin-bottom: 15px;
}
.qa-summary{ list-style:none; user-select:none; }
.qa-summary::-webkit-details-marker{ display:none; }
/* Заглушка summary, когда настоящий перенесён в строку — нулевой размер, без полоски при открытии/закрытии */
.qa-summary-placeholder{
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  border: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
.qa-details:has(.qa-summary-placeholder){ min-height: 0; }
.qa-details:has(.qa-summary-placeholder) .qa-panel-wrapper{ margin: 0; }
/* Крестик в строке — не резервируем место под него в панели, без полоски */
.qa-details:has(.qa-summary-placeholder)[open] .qa-panel-wrapper .qa-panel{ padding-top: 10px; }

/* Кнопка «подсказка GPT» → при открытии превращается в крестик (×) на том же месте, без скачков */
.qa-summary{ position: relative; display: inline-block; overflow: hidden; width: max-content; max-width: 160px; box-sizing: border-box; text-align: left; white-space: nowrap; transition: max-width .4s cubic-bezier(0.4, 0, 0.2, 1); }
/* Когда закрыто — отступ как у крестика при открытии (top:8px), чтобы центры кнопок по вертикали совпадали */
.qa-details:not([open]) .qa-summary{ margin-top: 8px; }
.qa-summary .qa-open,
.qa-summary .qa-close{ transition: opacity .35s ease; }
.qa-summary .qa-close{ position: absolute; left: 0; top: 0; opacity: 0; pointer-events: none; }
.qa-summary .qa-close-icon{ display: none; }
.qa-details[open] .qa-summary .qa-open{ opacity: 0; position: absolute; pointer-events: none; left: 0; top: 0; }
.qa-details[open] .qa-summary .qa-close{ opacity: 0; position: absolute; pointer-events: none; visibility: hidden; }
.qa-details[open] .qa-summary .qa-close-icon{ display: inline; }
.qa-details:not([open]) .qa-summary .qa-close{ visibility: hidden; }
.qa-details[open] .qa-summary .qa-open{ visibility: hidden; }

/* При открытии: кнопка сужается до крестика, висит ВНУТРИ рамки панели; по вертикали — по центру верхней зоны */
.qa-details[open] .qa-summary{
  position: absolute;
  top: 8px;
  left: 12px;
  z-index: 2;
  width: 36px;
  height: 36px;
  max-width: 36px;
  min-width: 36px;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.qa-details[open] .qa-summary .qa-close-icon{
  font-size: 20px;
  line-height: 1;
  font-weight: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(0);
}

/* Когда summary перенесён в строку (форма/видео): плавное превращение «подсказка GPT» ↔ × */
.qa-summary.qa-summary--inline-btn .qa-open,
.qa-summary.qa-summary--inline-btn .qa-close-icon{ transition: opacity .3s ease; }
.qa-summary.qa-summary--inline-btn .qa-close-icon{
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  pointer-events: none;
  font-size: 20px;
  line-height: 1;
  font-weight: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(0);
}
.qa-summary.qa-summary--inline-btn{ transition: max-width .4s cubic-bezier(0.4, 0, 0.2, 1); }
.qa-summary.qa-summary--open .qa-open{ opacity: 0; position: absolute; pointer-events: none; left: 0; top: 0; visibility: hidden; }
.qa-summary.qa-summary--open .qa-close{ opacity: 0; position: absolute; pointer-events: none; visibility: hidden; }
.qa-summary.qa-summary--open .qa-close-icon{
  display: flex !important;
  align-items: center;
  justify-content: center;
  opacity: 1;
  font-size: 20px;
  line-height: 1;
  font-weight: 400;
  transform: translateY(0);
}
.qa-summary.qa-summary--open{
  width: 36px;
  height: 36px;
  max-width: 36px;
  min-width: 36px;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* Кнопка — нейтральная, в тон карточке */
.qa-details .qa-summary{
  background: var(--c-surface) !important;
  color: var(--c-text) !important;
  border: 1px solid var(--c-border) !important;
  box-shadow: var(--shadow-sm);
  font-weight: 600;
  transition: background .2s, border-color .2s, box-shadow .2s, max-width .4s cubic-bezier(0.4, 0, 0.2, 1);
}
.qa-details .qa-summary:hover{
  background: rgba(255,255,255,.98) !important;
  border-color: rgba(111,44,255,.2) !important;
  box-shadow: 0 4px 14px rgba(0,0,0,.06);
}

/* В строке с «Проверить»: кнопка «подсказка GPT» того же размера, что и кнопка */
.qa-summary--inline-btn{
  padding: 9px 12px !important;
  min-height: 35px;
  box-sizing: border-box;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

/* Панель сразу под карточкой; при открытии summary не в потоке — панель идёт от верха details */
.qa-details[open] .qa-panel-wrapper{ padding-top: 0; }
.qa-details[open] .qa-panel-wrapper .qa-panel{ margin-top: 0; padding-top: 48px; }

/* Обёртка для плавного раскрытия/сворачивания панели вниз */
.qa-panel-wrapper{
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.65s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}
.qa-details[open] .qa-panel-wrapper{
  grid-template-rows: 1fr;
  transition: grid-template-rows 2s cubic-bezier(0.05, 0.7, 0.2, 1);
}
/* Плавное закрытие: JS добавляет .qa-closing, потом снимает [open] */
.qa-details.qa-closing .qa-panel-wrapper{
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}
/* При закрытии убираем отступ/бордер панели, чтобы схлопывалось до нуля без полоски */
.qa-details.qa-closing .qa-panel{
  margin-top: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
  box-shadow: none;
  transition: margin .65s cubic-bezier(0.22, 1, 0.36, 1), padding .65s cubic-bezier(0.22, 1, 0.36, 1), border-width .65s cubic-bezier(0.22, 1, 0.36, 1), box-shadow .65s cubic-bezier(0.22, 1, 0.36, 1);
}
/* Панель чата — продолжение карточки; контур рисуется при открытии */
.qa-panel{
  margin-top: 10px;
  padding: 10px 12px 14px 16px;
  border-radius: var(--r-md);
  background: rgba(255,255,255,.85);
  border: 1px solid var(--c-border);
  box-shadow: 0 2px 10px rgba(0,0,0,.04);
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* === Особый режим для Today/Cart, где summary перенесён в строку (есть .qa-summary-placeholder):
   вместо grid-анимации используем max-height, чтобы не было рывков в начале/конце === */
.qa-details:has(.qa-summary-placeholder) .qa-panel-wrapper{
  display: block;
  grid-template-rows: none;
  max-height: 0;
  transition: max-height 0.65s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}
.qa-details:has(.qa-summary-placeholder)[open] .qa-panel-wrapper{
  max-height: 800px; /* запас по высоте диалога */
  transition: max-height 2s cubic-bezier(0.05, 0.7, 0.2, 1);
}
.qa-details.qa-closing:has(.qa-summary-placeholder) .qa-panel-wrapper{
  max-height: 0;
  transition: max-height 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}
/* Контур «рисуется» по периметру — анимация вешается через класс .qa-contour-run (JS), чтобы каждый раз перезапускалась */
.qa-details[open] .qa-panel.qa-contour-run{
  animation: qa-panel-contour .5s cubic-bezier(0.32, 0.72, 0.38, 1) forwards;
}
@keyframes qa-panel-contour {
  0%   { border-color: transparent; border-top-color: var(--c-border); }
  33%  { border-color: transparent; border-top-color: var(--c-border); border-right-color: var(--c-border); }
  66%  { border-color: transparent; border-top-color: var(--c-border); border-right-color: var(--c-border); border-bottom-color: var(--c-border); }
  100% { border-color: var(--c-border); }
}


/* Лента сообщений — block, центр для дат, выравнивание пузырей через дочерние .qa-msg */
.qa-messages{
  display: block;
  margin-bottom: 12px;
  text-align: center;
  padding-left: 18px;
  padding-right: 18px;
}
.qa-messages > .qa-msg{
  text-align: left;
}
.qa-messages > .qa-msg.qa-msg--out{
  text-align: right;
}

/* Разделитель даты — полупрозрачная таблетка по центру, контур только вокруг текста */
.qa-date-sep{
  display: block;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
  font-size: 12px;
  line-height: 1.2;
  color: rgba(0,0,0,.6);
  background: rgba(0,0,0,.08);
  padding: 5px 14px;
  border-radius: 14px;
  margin-top: 12px;
  margin-bottom: 8px;
  box-sizing: border-box;
}
.qa-date-sep:first-child{
  margin-top: 0;
}

/* Каждое сообщение — block + text-align. Без flex пузырь не растягивается по высоте. */
.qa-panel .qa-msg{
  display: block;
  max-width: 88%;
  margin-bottom: 6px;
}
.qa-panel .qa-msg:last-child{ margin-bottom: 0; }
.qa-panel .qa-msg--out{
  margin-left: auto;
  text-align: right;
}
.qa-panel .qa-msg--in{
  margin-right: auto;
  margin-left: 0;
  text-align: left;
}

.qa-panel .qa-bubble{
  display: inline-flex !important;
  flex-direction: column;
  align-items: flex-start;
  padding: 5px 10px 4px !important;
  border-radius: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  max-width: min(280px, 100%);
  width: max-content !important;
  min-width: 0;
  min-height: 0 !important;
  height: fit-content !important;
  line-height: 1.32;
  flex: none !important;
  align-self: flex-start !important;
  box-sizing: border-box;
}
/* Дети пузырька — только по контенту, без растягивания и без min-height из других правил */
.qa-panel .qa-bubble .qa-text,
.qa-panel .qa-bubble .qa-meta{
  min-height: 0 !important;
  flex: 0 0 auto;
  flex-shrink: 0;
}
.qa-panel .qa-msg--out .qa-bubble{
  background: #e1f3fe;
  border-radius: 10px 10px 2px 10px;
  color: #0d1a26;
}
.qa-panel .qa-msg--in .qa-bubble{
  background: #fff;
  border-radius: 10px 10px 10px 2px;
  color: #222;
}

/* Строка времени (и галочек) — как в Telegram: компактный блок справа внизу */
.qa-panel .qa-meta{
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: rgba(0,0,0,.4);
  margin: 0;
  padding: 0;
  line-height: 1.2;
  width: max-content;
}
.qa-panel .qa-msg--out .qa-bubble .qa-meta{
  align-self: flex-end;
  color: rgba(0,60,120,.6);
}
.qa-panel .qa-msg--in .qa-bubble .qa-meta{
  align-self: flex-end;
}
/* Галочки как в Telegram: справа от времени, одна — доставлено, две — прочитано */
.qa-panel .qa-checks{
  display: inline-flex;
  align-items: center;
  margin-left: 3px;
  flex-shrink: 0;
  color: inherit;
  opacity: .92;
  vertical-align: middle;
}
/* Прочитано — подсвеченные двойные галочки, как в Telegram */
.qa-panel .qa-msg--out .qa-bubble .qa-checks--read{
  opacity: 1;
  color: #0d6ab8;
}
.qa-panel .qa-checks__svg{
  display: block;
  width: auto;
  height: 1em;
  min-width: 8px;
}
.qa-panel .qa-checks--read .qa-checks__svg{
  min-width: 14px;
}
.qa-panel .qa-text{
  font-size: 14px;
  line-height: 1.35;
  margin: 0;
  padding: 0;
  min-height: 0 !important; /* перебить любой min-height из base/student */
}

/* Пустое состояние */
.qa-empty{
  padding: 12px 0;
  font-size: 14px;
  color: rgba(0,0,0,.45);
  text-align: center;
  margin-bottom: 8px;
}

/* Строка ввода — как в Telegram: поле + кнопка в одну линию */
.qa-reply{
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}
.qa-reply .textarea,
.qa-reply .input{
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 10px 14px;
  border-radius: 20px;
  border: 1px solid rgba(0,0,0,.12);
  background: #fff;
  font-size: 15px;
  line-height: 1.35;
  resize: none;
  min-height: 42px;
  max-height: 160px;
  overflow-y: auto;
}
.qa-reply .textarea{
  min-height: 42px;
  /* высота подстраивается под контент в qa_live.js (как в Telegram) */
  /* без видимого ползунка, прокрутка колёсиком/тачем сохраняется */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.qa-reply .textarea::-webkit-scrollbar{
  display: none;
  width: 0;
  height: 0;
}
.qa-reply .qa-emoji-btn{
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 50%;
  background: #fff;
  color: rgba(0,0,0,.55);
  line-height: 1;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qa-reply .qa-emoji-btn:hover{
  background: #f5f5f5;
  border-color: rgba(0,0,0,.2);
  color: rgba(0,0,0,.75);
}
.qa-reply .qa-emoji-btn__icon{
  width: 22px;
  height: 22px;
  display: block;
}

.qa-emoji-picker{
  position: fixed;
  z-index: 1000;
  display: none;
  flex-wrap: wrap;
  gap: 4px;
  width: 280px;
  max-height: 220px;
  overflow-y: auto;
  padding: 10px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  border: 1px solid rgba(0,0,0,.08);
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.qa-emoji-picker::-webkit-scrollbar{ display: none; width: 0; height: 0; }
.qa-emoji-picker.is-open{
  display: flex;
}
.qa-emoji-picker__item{
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background .12s;
}
.qa-emoji-picker__item:hover{
  background: rgba(0,0,0,.08);
}

.qa-reply .btn{
  flex-shrink: 0;
  margin: 0;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
}

.qa-dot{
  display:inline-block;
  width:8px; height:8px;
  border-radius:999px;
  background: var(--c-red);
  margin-left:8px;
  vertical-align:middle;
}

/* ===== Richdoc bits ===== */
.richdoc .rd-p{ margin: 6px 0; }
.richdoc .math-block{ margin: 10px 0; }

.rd-table{ border-collapse: collapse; width: 100%; background:#fff; }
.rd-table th, .rd-table td{ border: 1px solid rgba(0,0,0,.12); padding: 8px; vertical-align: top; }
.rd-caption{ caption-side: bottom; color: var(--c-muted); padding-top: 6px; font-size: 13px; }

@media (max-width: 720px){
  .card-top{ flex-direction:column; align-items:stretch; }
  .card-actions{ justify-content:flex-start; }
  .topic-block__left{ width:auto; }
}


/* ================================
   TOPIC: continuous numbering
   ================================ */
   #items-list .task-item,
   #items-list .video-item{
     position: relative;
   }
   
   /* номер рисуем псевдо-элементом, текст карточки не ломаем */
   /* #items-list .task-item[data-no]::after,
   #items-list .video-item[data-no]::after{
     content: attr(data-no);
     position: absolute;
     top: 10px;
     left: 18px;
   
     font-weight: 900;
     font-size: 22px;
     line-height: 1;
     letter-spacing: -0.02em;
   
     color: rgba(18,18,18,.58);
     text-shadow: 0 1px 0 rgba(255,255,255,.9);
     z-index: 2;
     pointer-events: none;
   } */
  /* ================================
   TOPIC: continuous numbering (OLD LOOK)
   IMPORTANT: uses ::after so it DOES NOT break accent-rail ::before
   ================================ */
#items-list .task-item,
#items-list .video-item{
  position: relative;
}

/* номер рисуем псевдо-элементом, полоска accent-rail остаётся */
#items-list .task-item[data-no]::after,
#items-list .video-item[data-no]::after{
  content: attr(data-no);
  position: absolute;
  top: 4px;
  left: 25px;

  font-weight: 900;
  font-size: 22px;
  line-height: 1;
  letter-spacing: -0.02em;

  color: rgba(18,18,18,.58);
  text-shadow: 0 1px 0 rgba(255,255,255,.9);
  z-index: 2;
  pointer-events: none;
} 


   /* ================================
      TOPIC BLOCK: collapse
      ================================ */
   .topic-block__meta{
     display:flex;
     align-items:center;
     gap:10px;
     flex-wrap:wrap;
   }
   
   /* счетчик элементов */
   .topic-block__count{
     display:inline-flex;
     align-items:center;
     gap:8px;
     padding: 7px 12px;
     border-radius: 999px;
     border: 1px solid rgba(18,18,18,.12);
     background: rgba(255,255,255,.72);
     backdrop-filter: blur(10px);
     font-weight: 800;
     font-size: 12px;
     color: rgba(18,18,18,.70);
   }
   
   /* кнопка свернуть/развернуть */
   .topic-block__toggle{
    appearance:none;
    border: 1px solid rgba(18,18,18,.12);
    background: rgba(255,255,255,.72);
    border-radius: 999px;
    padding: 7px 12px;
    font-weight: 800;
    font-size: 12px;
    color: rgba(69, 67, 69, 1);
    cursor: pointer;
    backdrop-filter: blur(10px);
  
    /* ДОБАВИЛ: чтобы не прыгало при "свернуть/развернуть" */
    min-width: 116px;        /* подгони, если хочешь */
    text-align: center;
  
    /* ДОБАВИЛ: чтобы высота была стабильной на всех браузерах */
    line-height: 1.1;
    min-height: 34px;
    box-sizing: border-box;
  }
  
  .topic-block__toggle:hover{
    box-shadow: 0 10px 26px rgba(0,0,0,.10);
  }
  
  .topic-block__toggle:focus{
    outline: none;
    box-shadow: 0 0 0 3px rgba(111,44,255,.22);
  }
  
  /* ДОБАВИЛ: чтобы мета-строка (счетчик + toggle) не скакала */
  .topic-block__meta{
    display: inline-flex;
    align-items: center;
    gap: 10px;
  }
  
   
   
   /* тело блока */
   .topic-block__body{
     margin-top: 12px;
   }
   
   /* когда свернули — прячем содержимое */
   .topic-block.is-collapsed .topic-block__body{
     display:none;
   }
   

.task-solved-emoji{
  position: absolute;

  /* держим эмодзи ВНУТРИ блока, чтобы его не срезало overflow:hidden у .accent-rail */
  right: 8px;
  bottom: 26px;    /* сильно выше */

  font-size: 110px;
  line-height: 1;
  transform: rotate(-10deg);
  filter: drop-shadow(0 22px 30px rgba(0,0,0,.22));
  pointer-events: none;
  user-select: none;
  z-index: 3;
  animation: solved-float 2.6s ease-in-out infinite;
}



@keyframes solved-float{
  0%,100% { transform: rotate(-10deg) translateY(0px); }
  50%     { transform: rotate(-10deg) translateY(-6px); }
}


/* ====== Красивый номер задачи/видео (плашка) ====== */
.task-item,
.video-item{
  position: relative; /* чтобы плашка позиционировалась внутри карточки */
}

.item-no-badge{
  position: absolute;
  left: 14px;
  top: 14px;

  padding: 8px 10px;
  border-radius: 999px;

  font-weight: 900;
  font-size: 14px;
  line-height: 1;
  letter-spacing: 0.2px;

  background: rgba(255,255,255,.62);
  border: 1px solid rgba(255,255,255,.40);
  box-shadow: 0 16px 30px rgba(0,0,0,.14);

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  color: rgba(0,0,0,.70);
  pointer-events: none;
  z-index: 6;
}

/* На всякий случай: если где-то остались маркеры OL */
.task-item::marker,
.video-item::marker{
  content: "";
}





/* номер задачи без овала — просто цифра */
.items-list .task-item[data-no]::after,
.items-list .video-item[data-no]::after{
  content: attr(data-no);
  position: absolute;
  top: 12px;
  left: 18px;

  font-weight: 900;
  font-size: 14px;
  line-height: 1;
  color: rgba(18,18,18,.72);

  z-index: 6;
  pointer-events: none;
}

/* ===== Homework detail: единый блок метаданных ===== */
.hw-detail-meta__main{
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.hw-detail-meta__dates{
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
}
.hw-detail-meta__row{
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.hw-detail-meta__row--comment{
  align-items: flex-start;
}
.hw-detail-meta__row--comment .hw-detail-meta__label{ margin-top: 2px; }
.hw-detail-meta__label{
  color: var(--c-muted);
  font-size: 14px;
  flex: 0 0 auto;
  min-width: 80px;
}
.hw-detail-meta__value{
  font-weight: 650;
}

/* ===== Homework detail: полоска прогресса под блоком (как .hw-pill по цветам) ===== */
.hw-detail-progress{
  --p: 0%;
  --pnum: 0;
  --fill: hsl(calc(var(--pnum) * 1.2), 85%, 45%);

  margin-top: 12px;
  position: relative;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: var(--r-lg);
  background: rgba(255,255,255,0.25);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
  overflow: hidden;
}
.hw-detail-progress::before{
  content: "";
  position: absolute;
  inset: 0;
  width: var(--p);
  background: var(--fill);
  opacity: 0.35;
  z-index: 0;
  transition: width .25s ease;
}
.hw-detail-progress__label{
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  font-weight: 850;
  font-size: 34px;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255,255,255,.5);
  white-space: nowrap;
}
/* Отступ от центра: должен очищать проценты (34px, до "100%" ~48px от центра) — ch у count = 14px, давал бы наезд */
.hw-detail-progress__count{
  position: absolute;
  left: 50%;
  margin-left: 54px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  font-size: 14px;
  line-height: 1;
  color: var(--c-muted);
  white-space: nowrap;
}

/* Плавающая плашка прогресса при верном ответе, когда основной блок не в зоне видимости */
.hw-detail-progress--floating {
  pointer-events: none;
  background: rgba(255, 255, 255, 0.96) !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18), inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

/* ===== История попыток: контейнер по центру с ограничением ширины ===== */
.attempt-history-list{
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

/* ===== История попыток: карточка по вердикту + источник ===== */
.attempt-card__source{
  font-weight: 700;
}
.attempt-card__source a{
  color: inherit;
  text-decoration: underline;
}
.attempt-card--correct{
  background: #e6f4ea;
  border: none;
}
.attempt-card--wrong{
  background: #fce8e6;
  border: none;
}
.attempt-card--partial{
  background: #fef7e0;
  border: none;
}
.attempt-card--pending{
  background: #f1f3f4;
  border: none;
}