/* Учебный кабинет TutorEn. Токены — из design-system/DESIGN_SYSTEM.md сайта. */
:root {
  --color-ink: #071e3c;
  --color-text: #223e63;
  --color-text-muted: #526783;
  --color-accent: #2478e9;
  --color-link: #176bd0;
  --color-action: #0967c9;
  --color-surface: #fff;
  --color-surface-subtle: #f4f8ff;
  --color-surface-tint: #eaf3ff;
  --color-line: #cfe0f6;
  --color-line-strong: #7899c0;
  --color-error: #b3261e;
  --radius-control: 8px;
  --radius-item: 12px;
  --radius-card: 20px;
  --font: Arial, Helvetica, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 17px; line-height: 1.5; color: var(--color-text); background: var(--color-surface-subtle); }
a { color: var(--color-link); }
:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 3px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; background: var(--color-ink); color: #fff; }
.brand { color: #fff; font-weight: 700; text-decoration: none; }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.topbar-user form { margin: 0; }
.page { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
.card { background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius-card); padding: 24px; box-shadow: 0 4px 16px rgba(7, 30, 60, .06); }
.login-card { max-width: 420px; margin: 40px auto; }
h1 { color: var(--color-ink); font-size: 26px; margin: 0 0 16px; }
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; font-size: 15px; color: var(--color-text-muted); }
.field input { font: inherit; font-size: 17px; padding: 10px 12px; border: 1px solid var(--color-line-strong); border-radius: var(--radius-control); color: var(--color-text); }
.button { font: inherit; font-weight: 700; padding: 11px 18px; border: 0; border-radius: var(--radius-control); background: linear-gradient(180deg, var(--color-accent), var(--color-action)); color: #fff; cursor: pointer; }
.button-quiet { background: transparent; border: 1px solid rgba(255, 255, 255, .5); padding: 6px 12px; font-weight: 400; }
.notice { padding: 10px 12px; border-radius: var(--radius-item); background: var(--color-surface-tint); }
.notice-error { background: #fdecea; color: var(--color-error); }
.hint { color: var(--color-text-muted); font-size: 15px; margin-bottom: 0; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Общие вспомогательные ---------- */
[hidden] { display: none !important; }
.button-secondary { background: var(--color-surface); color: var(--color-action); border: 1px solid var(--color-line-strong); }
.topbar-heading { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }

/* ---------- Оболочка задания ---------- */
body.layout-shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.layout-shell .page { flex: 1; min-height: 0; max-width: none; padding: 0; margin: 0; width: 100%; }
.shell {
  height: 100%;
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 260px;
  grid-template-areas: "nav stage panel";
}
.nav-toggle { display: none; }

.task-nav { grid-area: nav; overflow-y: auto; background: var(--color-surface); border-right: 1px solid var(--color-line); padding: 8px 0; }
.nav-material { margin: 12px 16px 4px; font-weight: 700; color: var(--color-ink); }
/* Несколько материалов: каждый сворачивается, открыт материал текущего задания. */
.nav-group { border-bottom: 1px solid var(--color-line); }
.nav-group > summary { cursor: pointer; padding: 12px 16px; font-weight: 700; color: var(--color-ink); background: var(--color-surface-subtle); }
.nav-group-count { display: block; margin-left: 1.1em; font-size: 12px; font-weight: 400; color: var(--color-text-muted); }
.nav-group .nav-section summary { padding-left: 24px; }
.nav-section summary { cursor: pointer; padding: 10px 16px; font-weight: 700; color: var(--color-ink); }
.nav-section ul { list-style: none; margin: 0; padding: 0 0 8px; }
.nav-task { display: grid; grid-template-columns: 20px 1fr; gap: 0 8px; padding: 7px 16px 7px 20px; color: var(--color-text); text-decoration: none; font-size: 15px; line-height: 1.35; }
.nav-task:hover { background: var(--color-surface-subtle); }
.nav-task.is-current { background: var(--color-surface-tint); box-shadow: inset 3px 0 0 var(--color-accent); }
.state-icon { grid-row: span 2; font-size: 16px; line-height: 1.2; color: var(--color-text-muted); }
.state-done .state-icon { color: #1a7f4b; }
.state-opened .state-icon { color: var(--color-accent); }
.state-label { font-size: 12px; color: var(--color-text-muted); }

.task-stage { grid-area: stage; position: relative; min-height: 0; background: var(--color-surface-subtle); }
.task-frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.task-loading, .task-error {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; background: var(--color-surface-subtle); color: var(--color-text-muted); text-align: center; padding: 24px;
}

.task-panel { grid-area: panel; overflow-y: auto; background: var(--color-surface); border-left: 1px solid var(--color-line); padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.task-title { font-size: 20px; margin: 0; }
.done-button { width: 100%; }
.done-button[aria-pressed="true"] { background: #e7f5ee; color: #1a7f4b; border: 1px solid #1a7f4b; }
.done-button:disabled { opacity: .6; cursor: progress; }
.save-error { margin: 0; color: var(--color-error); font-size: 15px; }
.counters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.counters div { background: var(--color-surface-subtle); border-radius: var(--radius-item); padding: 8px; text-align: center; }
.counters dt { font-size: 12px; color: var(--color-text-muted); }
.counters dd { margin: 0; font-size: 20px; font-weight: 700; color: var(--color-ink); }
.all-done { margin: 0; font-size: 15px; }
.next-button { display: block; width: 100%; text-align: center; text-decoration: none; white-space: nowrap; padding-left: 10px; padding-right: 10px; }

/* ---------- Планшет и телефон ---------- */
@media (max-width: 1000px) {
  .shell {
    position: relative;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "panel" "stage";
  }
  .nav-toggle { display: inline-block; white-space: nowrap; }
  .task-panel { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 8px 12px; border-left: 0; border-bottom: 1px solid var(--color-line); overflow: visible; }
  .task-title { font-size: 15px; flex: 1 1 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .task-panel { gap: 6px 8px; }
  .done-button, .next-button { width: auto; font-size: 15px; padding: 8px 9px; }
  .done-button { order: 1; }
  .next-button { order: 2; }
  .save-error { order: 3; flex: 1 1 100%; }
  .counters { order: 4; }
  .all-done { order: 5; }
  .counters { grid-template-columns: repeat(3, auto); gap: 6px; }
  .counters div { padding: 2px 8px; display: flex; gap: 4px; align-items: baseline; }
  .counters dd { font-size: 15px; }
  .task-nav {
    grid-area: auto;
    position: absolute; top: 0; bottom: 0; left: 0; z-index: 20; width: min(320px, 85vw);
    transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility .2s;
    box-shadow: 0 0 24px rgba(7, 30, 60, .25);
  }
  .shell.nav-open .task-nav { transform: none; visibility: visible; }
}
@media (max-width: 650px) {
  .topbar-heading, .topbar-name, .brand-long { display: none; }
  .all-done { flex: 1 1 100%; }
  /* «Готово» и «Следующее задание» в одну строку на экранах от 360 px */
  .done-button, .next-button { font-size: 14px; padding: 8px 7px; }
}

/* ---------- Кабинет преподавателя ---------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .95em; }
.card + .card { margin-top: 20px; }
h2 { color: var(--color-ink); font-size: 20px; margin: 0 0 12px; }
.breadcrumbs { margin: 0 0 12px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--color-line); vertical-align: top; }
.table th { color: var(--color-text-muted); font-weight: 400; font-size: 13px; white-space: nowrap; }
.table-compact th, .table-compact td { padding: 6px 8px; font-size: 14px; }
.table-compact td:not(:first-child) { white-space: nowrap; }
.checkbox { display: inline-flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--color-action); }
.checkbox-strong { font-weight: 700; color: var(--color-ink); margin: 4px 0 12px; }
.form-narrow { max-width: 480px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 0 0 16px; }
.facts div { background: var(--color-surface-subtle); border-radius: var(--radius-item); padding: 8px 12px; }
.facts dt { font-size: 12px; color: var(--color-text-muted); }
.facts dd { margin: 0; font-weight: 700; color: var(--color-ink); }
.inline-form { margin: 0; }
.assign-material { --rail: 13px; border-top: 1px solid var(--color-line-strong); padding-left: var(--rail); }
.assign-material > summary { cursor: pointer; margin-left: calc(-1 * var(--rail)); padding: 12px 8px 12px 10px; border-left: 3px solid transparent; border-radius: 0 var(--radius-control) var(--radius-control) 0; font-size: 17px; font-weight: 700; color: var(--color-ink); }
.assign-material > summary .assign-count { display: block; margin-left: 1.1em; font-weight: 400; white-space: normal; }
.assign-material[open] { padding-bottom: 8px; }
.assign-material[data-state="none"] > summary { font-weight: 400; color: var(--color-text-muted); }
.assign-material:is([data-state="part"], [data-state="all"]) > summary { background: var(--color-surface-tint); border-left-color: var(--color-accent); }
.assign-material:is([data-state="part"], [data-state="all"]) > summary .assign-count { font-weight: 700; color: var(--color-action); }
.assign-badge { display: inline-block; margin-left: 8px; padding: 0 8px; border: 1px solid var(--color-accent); border-radius: var(--radius-control); background: var(--color-surface); font-size: 13px; font-weight: 700; line-height: 1.5; color: var(--color-action); vertical-align: 2px; white-space: nowrap; }
.assign-section { margin-left: calc(-1 * var(--rail)); border-top: 1px solid var(--color-line); border-left: 3px solid transparent; padding: 10px 8px 10px 10px; }
.assign-section:is([data-state="part"], [data-state="all"]) { background: var(--color-surface-tint); border-left-color: var(--color-accent); }
.assign-section:is([data-state="part"], [data-state="all"]) > .assign-section-head .assign-count { font-weight: 700; color: var(--color-action); }
.assign-section[data-state="none"] > .assign-section-head { color: var(--color-text-muted); }
.assign-section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.assign-count { font-size: 14px; color: var(--color-text-muted); white-space: nowrap; }
.assign-section summary { cursor: pointer; font-size: 14px; color: var(--color-link); margin: 6px 0 4px 26px; }
.is-hidden-task td { color: var(--color-text-muted); }
.credentials-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 16px 0; }
.credentials-list div { background: var(--color-surface-subtle); border-radius: var(--radius-item); padding: 10px 14px; }
.credentials-list dt { font-size: 12px; color: var(--color-text-muted); }
.credentials-list dd { margin: 0; font-size: 20px; color: var(--color-ink); }
.credentials textarea { font: inherit; font-size: 15px; padding: 10px 12px; border: 1px solid var(--color-line-strong); border-radius: var(--radius-control); color: var(--color-text); resize: vertical; }
.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.copy-status { color: #1a7f4b; }
.task-id { margin: 0; font-size: 14px; }
.task-id code { word-break: break-all; }

/* ---------- Архив учеников ---------- */
a.button { display: inline-block; text-decoration: none; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.tabs a { padding: 8px 14px; border: 1px solid var(--color-line); border-radius: var(--radius-control); background: var(--color-surface); color: var(--color-text); font-weight: 700; text-decoration: none; }
.tabs a[aria-current="page"] { border-color: var(--color-ink); background: var(--color-ink); color: #fff; }
.notice-warning { background: #fff4e0; color: #6b4200; }
.notice-warning a { color: inherit; font-weight: 700; }
.is-overdue td { background: #fff4e0; }
.overdue-label { display: block; color: #8a3a00; font-size: 13px; white-space: nowrap; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.button-small { padding: 6px 12px; font-size: 14px; }
.button-danger { border: 0; background: var(--color-error); color: #fff; }

/* Вход из Telegram */
#tg-app .form { margin-top: 12px; }
#tg-app .tg-status { color: var(--color-text-muted); }
