/* Слой интерфейса: телефон прежде всего, тёмная тема, единые кнопки, поля и меню.
   Подключается после styles.css и переопределяет общие элементы. */

/* ---------- Тёмная тема: по настройке телефона или выбору в подвале ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #171513;
    --paper-deep: #221f1b;
    --card: #1f1c19;
    --surface: #26221e;
    --ink: #ece5da;
    --ink-soft: #b2a99b;
    --line: #38332d;
    --accent: #e6a7ab;
    --accent-hover: #f2bdc0;
    --accent-soft: #3b2427;
    --forest: #a3cbb4;
    --gold: #dcbc7f;
    --ok: #8bd2a3;
    --ok-bg: #1a3126;
    --bad: #f2a8a8;
    --bad-bg: #3b1f1f;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    --accent-fill: #8e3a41;
    --accent-fill-hover: #a3464d;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #171513;
  --paper-deep: #221f1b;
  --card: #1f1c19;
  --surface: #26221e;
  --ink: #ece5da;
  --ink-soft: #b2a99b;
  --line: #38332d;
  --accent: #e6a7ab;
  --accent-hover: #f2bdc0;
  --accent-soft: #3b2427;
  --forest: #a3cbb4;
  --gold: #dcbc7f;
  --ok: #8bd2a3;
  --ok-bg: #1a3126;
  --bad: #f2a8a8;
  --bad-bg: #3b1f1f;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --accent-fill: #8e3a41;
  --accent-fill-hover: #a3464d;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body,
  :root:not([data-theme="light"]) html {
    background: var(--paper);
  }
}
:root[data-theme="dark"] body,
:root[data-theme="dark"] {
  background: var(--paper);
}

/* ---------- Общие элементы ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
body {
  -webkit-tap-highlight-color: transparent;
}
.brand-mark {
  background: var(--accent-fill);
  color: #f4efe4;
}

.btn {
  background: var(--accent-fill);
  color: var(--on-accent);
  box-shadow: none;
  border-radius: 14px;
  min-height: 48px;
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn:hover {
  background: var(--accent-fill-hover);
  color: var(--on-accent);
  transform: none;
  box-shadow: none;
}
.btn:active {
  transform: scale(0.98);
}
.btn.secondary {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--line);
  box-shadow: none;
}
.btn.secondary:hover {
  background: var(--paper-deep);
  color: var(--accent);
  box-shadow: none;
}
.btn.ghost {
  background: var(--accent-soft);
  color: var(--accent);
}
.btn[disabled] {
  opacity: 0.55;
  cursor: progress;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 14px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}
a.pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.pill.active,
a.pill.active:hover {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--on-accent);
}

input,
select,
textarea {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 44px;
  max-width: 100%;
}
input[type="checkbox"],
input[type="radio"] {
  min-height: 0;
  width: 20px;
  height: 20px;
  accent-color: var(--accent-fill);
}
input[type="file"] {
  min-height: 0;
  border: 0;
  background: none;
  padding: 0;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}
::placeholder {
  color: var(--ink-soft);
  opacity: 0.75;
}

/* Ничего не должно выходить за ширину экрана */
.card,
form,
fieldset,
label,
.stack,
.t-filter {
  min-width: 0;
}
.t-table-wrap,
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Подвал: выбор темы ---------- */
.footer-theme button {
  background: none;
  border: 0;
  padding: 4px 2px;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.footer-theme button.is-on {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

/* ---------- Нижнее меню и шторка «Ещё» (только телефон) ---------- */
.tabbar,
.sheet {
  display: none;
}
.ico {
  width: 24px;
  height: 24px;
  flex: none;
}

@media (max-width: 760px) {
  body {
    padding-bottom: calc(66px + env(safe-area-inset-bottom, 0px));
  }
  .tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--paper) 90%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(16px);
    backdrop-filter: saturate(1.4) blur(16px);
    border-top: 1px solid var(--line);
  }
  .tab {
    flex: 1;
    min-width: 0;
    min-height: 54px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px 2px;
    border: 0;
    border-radius: 14px;
    background: none;
    color: var(--ink-soft);
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
  }
  .tab:hover {
    color: var(--ink);
  }
  .tab.is-on {
    color: var(--accent);
  }
  .tab.is-on .ico {
    stroke-width: 2.3;
  }
  .tab:active {
    background: var(--accent-soft);
  }

  .sheet {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 60;
  }
  .sheet[hidden] {
    display: none;
  }
  .sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.38);
    opacity: 0;
    transition: opacity 0.2s ease;
  }
  .sheet-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    padding: 6px 12px calc(14px + env(safe-area-inset-bottom, 0px));
    background: var(--card);
    border-radius: 22px 22px 0 0;
    transform: translateY(100%);
    transition: transform 0.22s ease;
  }
  .sheet.is-open .sheet-backdrop {
    opacity: 1;
  }
  .sheet.is-open .sheet-panel {
    transform: none;
  }
  .sheet-grip {
    width: 40px;
    height: 4px;
    border-radius: 4px;
    background: var(--line);
    margin: 4px auto 8px;
  }
  .sheet-panel a {
    padding: 14px 12px;
    border-radius: 12px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
  }
  .sheet-panel a:active {
    background: var(--paper-deep);
  }

  /* Шапка на телефоне — только название: разделы в нижнем меню */
  .site-header .nav,
  .header-account,
  .teacher-tabs {
    display: none !important;
  }
  .header-inner {
    padding: 8px 0;
    min-height: 52px;
  }
  .brand-text span {
    display: none;
  }
  .site-footer {
    padding-bottom: 24px;
  }
  body.is-reading {
    padding-bottom: 0;
  }
  body.is-reading .tabbar {
    display: none;
  }

  /* 16px — чтобы iPhone не увеличивал страницу при вводе */
  input,
  select,
  textarea {
    font-size: 16px;
  }
  h1 {
    font-size: clamp(1.6rem, 7vw, 2.1rem);
    line-height: 1.15;
  }
  .btn {
    min-height: 50px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sheet-panel,
  .sheet-backdrop,
  .btn {
    transition: none;
  }
}

/* Подписи у флажков переносятся, а не растягивают страницу */
.t-inline {
  white-space: normal;
  align-items: flex-start;
}
.t-inline input {
  flex: none;
  margin-top: 2px;
}
@media (max-width: 760px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- Главная ученика ---------- */
.me-hello {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 14px;
}
.me-hello h1 {
  margin: 2px 0 0;
}
.me-hello .eyebrow::first-letter {
  text-transform: uppercase;
}
.me-streak {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}
.me-level {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  color: var(--ink);
  text-decoration: none;
}
.me-level-n {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-fill);
  color: #fff;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.2rem;
}
.me-level-body {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 8px;
}
.me-level-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.92rem;
}
.today-bar {
  display: block;
  height: 6px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--ink) 10%, transparent);
  overflow: hidden;
}
.today-bar > span {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: var(--accent-fill);
}
.me-today {
  display: grid;
  gap: 10px;
}
.me-today h2,
.me-section > h2 {
  margin-bottom: 4px;
}
.me-empty {
  margin: 0;
  padding: 14px 16px;
  border: 1px dashed var(--line);
  border-radius: 16px;
}
.today-card {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}
.today-card.is-live {
  border: 2px solid var(--accent);
}
.today-card strong {
  font-size: 1.05rem;
  line-height: 1.3;
}
.today-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--paper-deep);
  color: var(--ink-soft);
}
.chip.is-hot {
  background: var(--accent-soft);
  color: var(--accent);
}
.today-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--accent-fill);
  color: #fff;
  text-decoration: none;
}
.today-cta:hover {
  background: var(--accent-fill-hover);
  color: #fff;
}
.today-cta > span:first-child {
  display: grid;
  gap: 2px;
}
.today-cta strong {
  font-size: 1.08rem;
}
.today-cta > span:first-child > span {
  font-size: 0.85rem;
  opacity: 0.85;
}
.today-cta-n {
  position: relative;
  flex: none;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
}
.today-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(#fff calc(var(--p) * 1%), rgba(255, 255, 255, 0.25) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
}
.me-recs {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: var(--card);
}
.me-rec {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: var(--ink);
  text-decoration: none;
}
.me-rec + .me-rec {
  border-top: 1px solid var(--line);
}
.me-rec:active {
  background: var(--paper-deep);
}
.me-rec > span:nth-child(2) {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}
.me-rec .muted {
  font-size: 0.88rem;
  line-height: 1.4;
}
.me-rec-icon {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--paper-deep);
  font-size: 1.1rem;
}
.me-rec-go {
  color: var(--ink-soft);
  font-size: 1.4rem;
}
.me-quick {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.me-quick a {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.92rem;
}
.me-quick a > span {
  font-size: 1.2rem;
}
.me-quick b {
  color: var(--accent);
}
@media (min-width: 761px) {
  .me-quick {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .me-today {
    max-width: 720px;
  }
}

/* ---------- Экран задания ---------- */
.task-bar {
  display: none;
}
@media (max-width: 760px) {
  .task-bar {
    position: sticky;
    top: 53px;
    z-index: 14;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 -2px 10px;
    padding: 8px 2px;
    background: var(--paper);
  }
  .tb-btn {
    flex: none;
    width: 44px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font-size: 1.5rem;
    line-height: 1;
    text-decoration: none;
  }
  .tb-btn.is-off {
    opacity: 0.35;
  }
  .tb-mid {
    flex: 1;
    min-width: 0;
    display: grid;
    gap: 5px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--ink-soft);
  }
  /* Ответ — внизу, под пальцем, над нижним меню */
  .lit-check {
    position: sticky;
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    z-index: 15;
    margin: 14px -6px;
    padding: 12px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 -10px 30px rgba(20, 15, 10, 0.1);
  }
  .lit-check label {
    font-size: 0.82rem;
    margin-bottom: 6px;
  }
  .lit-check-row {
    flex-wrap: nowrap;
  }
  .lit-check-row .search {
    flex: 1 1 auto;
    min-width: 0;
  }
  .lit-check-row .btn {
    flex: none;
  }
  .lit-check .lit-result {
    margin-top: 8px;
    min-height: 0;
  }
  .lit-check .lit-result:empty {
    display: none;
  }
  .lit-check .pr-reveal small {
    display: none;
  }
  /* Номера заданий — одной прокручиваемой строкой */
  .lit-task-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 4px;
    -webkit-mask: linear-gradient(90deg, #000 85%, transparent);
    mask: linear-gradient(90deg, #000 85%, transparent);
  }
  .lit-task-nav::-webkit-scrollbar {
    display: none;
  }
  .lit-task-chip {
    flex: none;
  }
  .dash-badges {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .dash-badge {
    padding: 10px 6px;
  }
  .dash-badge span {
    font-size: 24px;
  }
  .dash-badge strong {
    font-size: 0.78rem;
    text-align: center;
  }
  .dash-badge small {
    display: none;
  }
}

/* Атрибут hidden всегда скрывает элемент, даже если у класса задан display */
[hidden] {
  display: none !important;
}
@media (max-width: 760px) {
  .lit-check .pr-reveal {
    margin: 8px 0 0;
  }
  .lit-check .pr-reveal .btn {
    min-height: 40px;
    padding: 8px 14px;
    font-size: 0.9rem;
  }
}
.me-hello-side {
  display: flex;
  align-items: center;
  gap: 10px;
}
@media (max-width: 760px) {
  .me-profile-link {
    display: none;
  }
}

/* ---------- Преподаватель: «Сегодня» ---------- */
.tt-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.tt-head h1 {
  margin: 2px 0 0;
}
.tt-head .eyebrow::first-letter {
  text-transform: uppercase;
}
.tt-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: var(--card);
}
.tt-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  min-height: 64px;
  color: var(--ink);
  text-decoration: none;
}
.tt-row + .tt-row {
  border-top: 1px solid var(--line);
}
.tt-row:hover {
  background: color-mix(in srgb, var(--paper-deep) 50%, transparent);
}
.tt-row:active {
  background: var(--paper-deep);
}
.tt-body {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 3px;
}
.tt-body .muted {
  font-size: 0.88rem;
}
.tt-go {
  color: var(--ink-soft);
  font-size: 1.4rem;
}
.tt-count {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--accent-fill);
  color: #fff;
  font-size: 0.8rem;
}
.tt-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.tt-stats > div {
  display: grid;
  gap: 2px;
  padding: 14px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--line);
}
.tt-stats strong {
  font-size: 1.4rem;
}
.tt-stats span {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

/* ---------- Новое занятие: «+» и шаги ---------- */
.fab {
  display: none;
}
.l-sheet-head,
.l-step-nav [data-step-prev],
.l-step-nav [data-step-next] {
  display: none;
}
.l-step {
  border: 0;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 14px;
  min-width: 0;
}
.l-step-title {
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 0;
  margin-bottom: 4px;
}
@media (min-width: 761px) {
  .l-new[hidden] {
    display: none !important;
  }
  .l-sheet-head {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .l-sheet-head .l-steps {
    display: none;
  }
  .l-x {
    margin-left: auto;
    border: 0;
    background: none;
    font-size: 1.6rem;
    color: var(--ink-soft);
    cursor: pointer;
  }
}
@media (max-width: 760px) {
  .l-open-desk {
    display: none;
  }
  .fab {
    display: grid;
    place-items: center;
    position: fixed;
    right: 16px;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    z-index: 30;
    width: 58px;
    height: 58px;
    border: 0;
    border-radius: 50%;
    background: var(--accent-fill);
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    box-shadow: 0 10px 26px rgba(60, 20, 25, 0.35);
    cursor: pointer;
  }
  body.is-sheet {
    overflow: hidden;
  }
  body.is-sheet .tabbar,
  body.is-sheet .fab {
    display: none;
  }
  .l-new {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 70;
    max-height: 92vh;
    overflow: auto;
    margin: 0;
    padding: 0 16px calc(16px + env(safe-area-inset-bottom, 0px));
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.3);
    transform: translateY(100%);
    transition: transform 0.22s ease;
  }
  .l-new.is-open {
    transform: none;
  }
  .l-sheet-head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 0 10px;
    background: var(--card);
  }
  .l-sheet-head strong {
    font-size: 1.1rem;
  }
  .l-x {
    margin-left: auto;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    font-size: 1.4rem;
    cursor: pointer;
  }
  .l-new .l-step {
    display: none;
  }
  .l-new[data-step="1"] .l-step[data-n="1"],
  .l-new[data-step="2"] .l-step[data-n="2"],
  .l-new[data-step="3"] .l-step[data-n="3"] {
    display: grid;
  }
  .l-step-nav {
    display: flex;
    gap: 10px;
    position: sticky;
    bottom: 0;
    padding-top: 10px;
    background: var(--card);
  }
  .l-step-nav .btn {
    flex: 1;
  }
  .l-new[data-step="1"] [data-step-prev] {
    visibility: hidden;
  }
  .l-new:not([data-step="3"]) [data-step-next],
  .l-new[data-step="2"] [data-step-prev],
  .l-new[data-step="3"] [data-step-prev] {
    display: inline-flex;
  }
  .l-new:not([data-step="3"]) button[type="submit"] {
    display: none;
  }
  .l-new[data-step="1"] [data-step-prev] {
    display: inline-flex;
  }
}

/* ---------- Проверка работы ---------- */
.rv-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 12px;
}
.rv-nav .tb-btn {
  flex: none;
  width: 44px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 1.5rem;
  text-decoration: none;
}
.rv-nav .tb-btn.is-off {
  opacity: 0.35;
}
.rv-nav .tb-mid {
  flex: 1;
  min-width: 0;
  display: grid;
  text-align: center;
  font-weight: 700;
}
.rv-nav .tb-mid .muted {
  font-weight: 500;
  font-size: 0.85rem;
}
.rv-dock {
  display: none;
}
@media (max-width: 760px) {
  .rv-dock {
    display: flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(62px + env(safe-area-inset-bottom, 0px));
    z-index: 35;
    padding: 10px 14px;
    background: color-mix(in srgb, var(--card) 94%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .rv-dock-total {
    font-size: 1.05rem;
    min-width: 56px;
  }
  .rv-dock-total b {
    font-size: 1.3rem;
  }
  .rv-dock .btn {
    flex: 1;
    min-height: 46px;
  }
  /* поле главы формы с кнопками внизу уже есть в доке — оставляем «Сохранить без отправки» */
  #t-grade .actions .btn:not([value="keep"]) {
    display: none;
  }
  #t-grade {
    margin-bottom: 70px;
  }
}
.l-step-title {
  text-transform: none;
  letter-spacing: 0;
  font-size: 1rem;
  color: var(--ink);
}
@media (max-width: 760px) {
  body.is-sheet::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 65;
    background: rgba(0, 0, 0, 0.38);
  }
}
.me-write {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  color: var(--ink);
  text-decoration: none;
}
.me-write > span:nth-child(2) {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 3px;
}
.me-write .muted {
  font-size: 0.88rem;
  line-height: 1.4;
}
.me-section h2 .muted {
  font-size: 0.62em;
  font-family: var(--sans);
  font-weight: 600;
}
.rv-origin {
  margin: 0 0 6px;
}
.rv-origin .chip {
  text-decoration: none;
}

/* Курсы */
.me-tracks {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 12px;
}
.me-tracks button {
  cursor: pointer;
  font: inherit;
}
.me-courses {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.me-req {
  margin: 4px 0;
}
.t-courses {
  display: grid;
  gap: 12px;
  padding: 16px;
}
.t-courses fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.t-courses legend {
  font-weight: 700;
  margin-bottom: 6px;
}
.t-course {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.92rem;
}
.tt-row .btn {
  min-height: 40px;
  padding: 8px 12px;
  flex: none;
}
.t-danger {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.btn.t-del,
.btn.t-del:hover {
  background: #9b2c2c;
  color: #fff;
}

/* ---------- Исходный текст к заданию ---------- */
.tb-text,
.passage-more {
  display: none;
}
.passage-sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
}
.ps-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.ps-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 88vh;
  height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  transform: translateY(100%);
  transition: transform 0.22s ease;
}
.passage-sheet.is-open .ps-backdrop {
  opacity: 1;
}
.passage-sheet.is-open .ps-panel {
  transform: none;
}
.ps-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--line);
}
.ps-head strong {
  font-size: 1.1rem;
}
.ps-body {
  flex: 1;
  overflow: auto;
  padding: 14px 18px calc(24px + env(safe-area-inset-bottom, 0px));
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.6;
  -webkit-overflow-scrolling: touch;
}
body.is-sheet-open {
  overflow: hidden;
}
@media (max-width: 760px) {
  .tb-text {
    display: inline-grid;
    place-items: center;
    flex: none;
    height: 40px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
    font: inherit;
    font-weight: 800;
    font-size: 0.85rem;
    cursor: pointer;
  }
  /* текст в задании свёрнут до нескольких строк — вопрос виден сразу */
  .has-passage .lit-passage {
    position: relative;
    max-height: 210px;
    overflow: hidden;
  }
  .has-passage .lit-passage::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 90px;
    background: linear-gradient(transparent, var(--card) 75%);
    pointer-events: none;
  }
  .passage-more {
    display: block;
    position: absolute;
    left: 50%;
    bottom: 10px;
    z-index: 1;
    transform: translateX(-50%);
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--accent);
    font: inherit;
    font-weight: 800;
    font-size: 0.88rem;
    cursor: pointer;
    white-space: nowrap;
  }
}
/* Широкий экран: текст слева (прокручивается сам), вопрос и ответ справа */
@media (min-width: 1000px) {
  .lit-problem.has-passage {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    column-gap: 28px;
    align-items: start;
  }
  .lit-problem.has-passage > * {
    grid-column: 2;
  }
  .lit-problem.has-passage > .lit-passage {
    grid-column: 1;
    grid-row: 1 / span 30;
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow: auto;
    margin: 0;
  }
}

/* Активность ученика в карточке */
.t-act-stats {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.t-act-stats strong {
  font-size: 1.05rem;
}
.t-days {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: 4px;
  align-items: end;
  height: 120px;
  margin-top: 14px;
}
.t-day {
  display: grid;
  gap: 4px;
  justify-items: center;
  height: 100%;
  grid-template-rows: 1fr auto;
}
.t-day small {
  font-size: 0.7rem;
  color: var(--ink-soft);
}
.t-bar {
  width: 100%;
  max-width: 22px;
  height: 100%;
  display: flex;
  flex-direction: column-reverse;
  border-radius: 6px;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  overflow: hidden;
}
.t-bar-a {
  background: var(--accent-fill);
}
.t-bar-v {
  background: var(--forest);
  opacity: 0.6;
}
.t-legend {
  font-size: 0.82rem;
}
.t-key {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  vertical-align: -1px;
}
.t-key-a {
  background: var(--accent-fill);
}
.t-key-v {
  background: var(--forest);
  opacity: 0.6;
}
.t-sections {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.me-join summary {
  cursor: pointer;
  font-weight: 700;
  padding: 4px 0;
}
.me-join form {
  margin-top: 10px;
}

/* ---------- «+10», комбо, следующий шаг ---------- */
.lit-check,
.lit-question {
  position: relative;
}
.xp-pop {
  position: absolute;
  right: 18px;
  top: 6px;
  z-index: 20;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--ok);
  color: #fff;
  font-weight: 800;
  font-size: 1.05rem;
  pointer-events: none;
  animation: xp-float 1.5s ease-out forwards;
}
:root[data-theme="dark"] .xp-pop {
  color: #10241a;
}
.xp-pop.is-combo {
  background: #c2591b;
  right: 90px;
}
@keyframes xp-float {
  0% { transform: translateY(8px) scale(0.6); opacity: 0; }
  20% { transform: translateY(0) scale(1.15); opacity: 1; }
  35% { transform: scale(1); }
  80% { opacity: 1; }
  100% { transform: translateY(-34px); opacity: 0; }
}
.lit-result.is-ok {
  animation: ok-pulse 0.5s ease-out;
}
@keyframes ok-pulse {
  0% { transform: scale(0.96); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}
.next-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0 0;
  font-weight: 700;
  font-size: 0.9rem;
}
.next-step .btn {
  min-height: 40px;
  padding: 8px 16px;
}

/* ---------- Финальный экран ---------- */
.celebrate {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: end center;
}
@media (min-width: 761px) {
  .celebrate {
    place-items: center;
  }
}
.cel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.cel-panel {
  position: relative;
  width: min(440px, 100%);
  padding: 28px 22px calc(22px + env(safe-area-inset-bottom, 0px));
  border-radius: 26px 26px 0 0;
  background: var(--card);
  text-align: center;
  overflow: hidden;
  transform: translateY(40px) scale(0.96);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.2, 1.3, 0.4, 1), opacity 0.2s ease;
}
@media (min-width: 761px) {
  .cel-panel {
    border-radius: 26px;
  }
}
.celebrate.is-open .cel-backdrop {
  opacity: 1;
}
.celebrate.is-open .cel-panel {
  transform: none;
  opacity: 1;
}
.cel-emoji {
  font-size: 3.4rem;
  line-height: 1;
  animation: cel-bounce 0.9s ease-out;
}
@keyframes cel-bounce {
  0% { transform: scale(0.2) rotate(-20deg); }
  60% { transform: scale(1.2) rotate(6deg); }
  100% { transform: scale(1); }
}
.cel-panel h2 {
  margin: 12px 0 6px;
}
.cel-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0;
}
.cel-stats > div {
  display: grid;
  gap: 2px;
  padding: 12px 6px;
  border-radius: 14px;
  background: var(--paper-deep);
}
.cel-stats strong {
  font-size: 1.3rem;
}
.cel-stats span {
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.cel-actions {
  display: grid;
  gap: 8px;
}
.cel-confetti i {
  position: absolute;
  top: -12px;
  left: calc(var(--i) * 5.6%);
  width: 8px;
  height: 14px;
  border-radius: 2px;
  background: hsl(calc(var(--i) * 37), 70%, 55%);
  animation: confetti 1.8s ease-in calc(var(--i) * 0.05s) forwards;
  opacity: 0;
}
@keyframes confetti {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(420px) rotate(540deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .xp-pop,
  .cel-emoji,
  .cel-confetti i,
  .lit-result.is-ok {
    animation: none;
  }
}

/* ---------- Подвал ---------- */
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 22px;
}
.footer-grid p {
  margin: 0 0 6px;
}
.footer-h {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.theme-switch {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.theme-switch button {
  border: 0;
  background: none;
  padding: 6px 12px;
  min-height: 34px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
}
.theme-switch button.is-on {
  background: var(--accent-fill);
  color: #fff;
}
.site-footer.is-compact {
  padding: 14px 0 18px;
  font-size: 0.85rem;
}
.footer-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--ink-soft);
}
.footer-line .footer-admin {
  color: var(--ink-soft);
  font-size: 0.8rem;
  margin: 0;
}
.sheet-theme {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 12px 4px;
}
@media (max-width: 760px) {
  /* в заданиях и кабинетах на телефоне подвала нет — меню внизу экрана */
  .site-footer.is-compact {
    display: none;
  }
}

/* ---------- «Проверь себя» к правилу ---------- */
.rule-quiz-host {
  margin: 22px 0 10px;
  scroll-margin-top: 70px;
}
.rq-card {
  padding: 18px 18px 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
}
.rq-card h2 {
  margin: 4px 0 6px;
}
.rq-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}
.rq-dots {
  display: flex;
  gap: 6px;
  margin: 8px 0 10px;
}
.rq-dots span {
  flex: 1;
  height: 6px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--ink) 10%, transparent);
}
.rq-dots .is-ok {
  background: var(--ok);
}
.rq-dots .is-bad {
  background: var(--bad);
}
.rq-dots .is-now {
  background: var(--accent-fill);
}
.rq-no {
  margin: 0 0 4px;
  font-size: 0.85rem;
}
.rq-q {
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.55;
  margin-bottom: 12px;
}
.rq-form {
  flex-wrap: nowrap;
}
.rq-form .search {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}
.rq-badge {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--ok);
  white-space: nowrap;
}
details.is-mastered {
  border-color: color-mix(in srgb, var(--ok) 45%, var(--line));
}

/* ---------- Задания ЕГЭ к тексту в библиотеке ---------- */
.reader-tasks {
  margin: 2em 0 1em;
  padding: 14px 14px 12px;
  border-radius: 16px;
  border: 1px solid var(--r-line, var(--line));
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  font-family: var(--sans);
}
.reader-tasks-h {
  margin: 0;
  font-weight: 800;
  font-size: 0.95rem;
  text-indent: 0;
}
.reader-tasks-sub {
  margin: 2px 0 10px;
  font-size: 0.8rem;
  opacity: 0.75;
  text-indent: 0;
}
.reader-tasks-list,
.wt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.rt-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 40px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.85rem;
}
.rt-chip b {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-fill);
  color: #fff;
  font-size: 0.8rem;
}
.rt-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rt-chip.is-written b {
  background: var(--forest);
}
.reader.theme-night .rt-chip {
  background: #26231f;
  color: var(--r-ink);
  border-color: var(--r-line);
}
.wt-group {
  margin-bottom: 10px;
  padding: 12px 14px;
}
.wt-group summary {
  cursor: pointer;
  padding: 2px 0 8px;
}
.wt-topics {
  margin: 0 0 8px;
  padding-left: 1.2em;
  display: grid;
  gap: 6px;
}

/* Выбор варианта в письменной работе */
.pr-choice {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 12px 12px;
  margin: 0 0 12px;
  display: grid;
  gap: 6px;
}
.pr-choice legend {
  font-weight: 800;
  padding: 0 6px;
}
.pr-choice-o {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
  line-height: 1.4;
}
.pr-choice-o input {
  margin-top: 3px;
  flex: none;
}
.pr-choice-o b {
  flex: none;
}
.pr-choice-o.is-on {
  background: var(--accent-soft);
}
.rv-task {
  padding: 14px 16px;
  margin-bottom: 10px;
}
.rv-choice {
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.45;
  margin: 4px 0 8px;
}
.rv-choice.is-missing {
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--bad);
}
.me-checked {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 2px solid var(--ok);
  color: var(--ink);
  text-decoration: none;
  margin-bottom: 8px;
}
.me-checked > span:nth-child(2) {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 3px;
}
.me-checked .muted {
  font-size: 0.88rem;
}
.lit-write .pr-choice-o {
  display: flex;
  margin: 0;
  font-weight: 400;
}

/* Уведомления в Telegram */
.tg-card { padding: 16px 18px; }
.tg-card p { margin: 0 0 8px; }
.tg-card .actions { margin: 4px 0 0; }

/* Черновик занятия */
.l-draft { padding: 14px 16px; margin: 10px 0; border-left: 4px solid var(--accent, #8b2c2c); }
.l-draft p { margin: 0 0 6px; }

/* ---------- Помощник «Перо» ---------- */
.lh-btn {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 45;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--accent);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  cursor: pointer;
}
.lh-btn svg { width: 26px; height: 26px; }
.lh-btn:hover { transform: translateY(-1px); }
body.is-reading .lh-btn { display: none; }
.lh-bubble {
  position: fixed;
  right: 18px;
  bottom: 82px;
  z-index: 46;
  max-width: 300px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px 16px 4px 16px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
  animation: lh-pop 0.25s ease;
}
.lh-bubble p { margin: 0 0 10px; }
.lh-bubble .actions { margin: 0; display: flex; gap: 8px; flex-wrap: wrap; }
@keyframes lh-pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.lh-sheet { position: fixed; inset: 0; z-index: 70; }
.lh-sheet[hidden] { display: none; }
.lh-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.38); opacity: 0; transition: opacity 0.2s ease; }
.lh-panel {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: min(420px, calc(100% - 36px));
  max-height: min(78vh, 640px);
  overflow: auto;
  padding: 14px 16px 16px;
  border-radius: 20px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  transform: translateY(16px);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
}
.lh-sheet.is-open .lh-backdrop { opacity: 1; }
.lh-sheet.is-open .lh-panel { transform: none; opacity: 1; }
.lh-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.lh-head > div { display: grid; flex: 1; }
.lh-face { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.lh-face svg { width: 22px; height: 22px; }
.lh-x { border: 0; background: none; font-size: 28px; line-height: 1; color: var(--ink-soft); cursor: pointer; padding: 4px 8px; }
.lh-item { border-top: 1px solid var(--line); padding: 10px 2px; }
.lh-item summary { font-weight: 700; cursor: pointer; }
.lh-item p { margin: 8px 0 0; }
.lh-foot { margin: 10px 0 0; font-size: 14px; }
@media (max-width: 760px) {
  .lh-btn { right: 12px; bottom: calc(78px + env(safe-area-inset-bottom, 0px)); width: 46px; height: 46px; }
  .lh-bubble { right: 66px; left: 12px; max-width: none; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); padding: 10px 12px; font-size: 14px; border-radius: 16px 16px 4px 16px; }
  .lh-bubble p { margin-bottom: 8px; }
  .lh-bubble .btn { padding: 6px 12px; min-height: 0; font-size: 14px; }
  .lh-panel { left: 0; right: 0; bottom: 0; width: auto; border-radius: 22px 22px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- Главная: «Что вы хотите сделать?» ---------- */
.landing-teacher-line { margin: 4px 0 14px; color: var(--ink-soft); }
.home-start { display: grid; gap: 10px; margin-top: 8px; max-width: 560px; }
.home-start-q { margin: 0 0 2px; font-weight: 700; font-size: 18px; }
.home-path {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.home-path:hover { border-color: var(--accent); transform: translateY(-1px); }
.home-path > span:nth-child(2) { display: grid; gap: 2px; flex: 1; }
.home-path > span:nth-child(2) span { color: var(--ink-soft); font-size: 14px; }
.home-path-ico { font-size: 24px; width: 32px; text-align: center; }
.home-path-go { font-size: 24px; color: var(--ink-soft); }
.home-path.is-main, .home-start > .home-path:first-of-type { border-color: var(--accent); background: var(--accent-soft); }
.home-start-note { margin: 2px 0 0; font-size: 14px; }
.home-back { padding: 16px 18px; margin-top: 10px; max-width: 560px; }
.home-back p { margin: 0 0 6px; }

/* ---------- Ученики под псевдонимами ---------- */
.t-new-student { padding: 0; border: 0; background: none; box-shadow: none; }
.t-new-student > summary { list-style: none; display: inline-flex; cursor: pointer; }
.t-new-student > summary::-webkit-details-marker { display: none; }
.t-new-student[open] > summary { margin-bottom: 12px; }
.t-new-student form, .t-creds { padding: 16px 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); max-width: 640px; }
.t-creds { border-color: var(--accent); background: var(--accent-soft); margin-top: 10px; }
.t-creds p { margin: 0 0 8px; }
.t-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.02em; }
.t-inline-set { border: 0; padding: 0; margin: 0; display: flex; gap: 16px; flex-wrap: wrap; }
.auth-help { max-width: 460px; margin-top: 16px; }
.auth-help p { margin: 0 0 10px; }
.t-msg { width: 100%; box-sizing: border-box; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font: inherit; font-size: 15px; line-height: 1.45; resize: vertical; }
