/* Домашка — стили. Цвета заданы токенами; тёмная тема берётся из настроек телефона. */

:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #ffffff;
  --field: #f7f7f5;
  --seg-bg: #e9e8e3;
  --hover: rgba(11, 11, 11, 0.04);
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #6b6a65;
  --chart-muted: #898781;
  --border: rgba(11, 11, 11, 0.1);
  --border-strong: rgba(11, 11, 11, 0.16);
  --grid: #e1e0d9;
  --axis: #c3c2b7;

  --accent: #2a78d6;
  --accent-hover: #256abf;
  --accent-soft: #e6f0fc;
  --accent-text: #1c5cab;
  --series-1: #2a78d6;
  --track: #cde2fb;

  --good: #0ca30c;
  --good-icon: #0a7f0a;
  --good-soft: #e4f4e2;
  --warn-icon: #a86b00;
  --warn-soft: #fdf1d6;
  --serious-icon: #c4501f;
  --serious-soft: #fde8df;
  --bad: #d03b3b;
  --bad-text: #b42f2f;
  --bad-soft: #fbe5e5;

  --tip-bg: #1f1f1e;
  --tip-text: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --field: #232321;
    --seg-bg: #232321;
    --hover: rgba(255, 255, 255, 0.05);
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #a3a29b;
    --chart-muted: #898781;
    --border: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.16);
    --grid: #2c2c2a;
    --axis: #383835;

    --accent: #3987e5;
    --accent-hover: #5598e7;
    --accent-soft: rgba(57, 135, 229, 0.16);
    --accent-text: #86b6ef;
    --series-1: #3987e5;
    --track: #184f95;

    --good: #0ca30c;
    --good-icon: #2fbf2f;
    --good-soft: rgba(12, 163, 12, 0.16);
    --warn-icon: #fab219;
    --warn-soft: rgba(250, 178, 25, 0.14);
    --serious-icon: #ec835a;
    --serious-soft: rgba(236, 131, 90, 0.15);
    --bad: #e66767;
    --bad-text: #f08a8a;
    --bad-soft: rgba(230, 103, 103, 0.15);

    --tip-bg: #f2f2ef;
    --tip-text: #0b0b0b;
    --shadow: none;
  }
}

/* ---------- основа ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent-text);
}

code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

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

.icon {
  flex: none;
}

.boot {
  min-height: 100dvh;
  display: grid;
  place-items: center;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--track);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes up {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

#app.is-loading::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  height: 3px;
  width: 40%;
  background: var(--accent);
  animation: loadbar 1s ease-in-out infinite;
}

#app.is-loading .content {
  opacity: 0.55;
  pointer-events: none;
}

@keyframes loadbar {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(250%);
  }
}

/* ---------- каркас ---------- */

.shell {
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: calc(56px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right), calc((100vw - 720px) / 2 + 4px)) 0
    max(8px, env(safe-area-inset-left), calc((100vw - 720px) / 2 + 4px));
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
}

.topbar-title {
  flex: 1;
  min-width: 0;
  margin: 0 8px;
  font-size: 19px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .back {
  margin-right: -6px;
}

.topbar-actions {
  display: flex;
  gap: 2px;
}

.content {
  max-width: 720px;
  margin: 0 auto;
  padding: 6px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.with-tabs .content {
  padding-bottom: calc(92px + env(safe-area-inset-bottom));
}

.with-bar .content {
  padding-bottom: calc(110px + env(safe-area-inset-bottom));
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11.5px;
  font-weight: 600;
}

.tab.active {
  color: var(--accent);
}

.action-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px max(16px, calc((100vw - 720px) / 2 + 16px)) calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.action-info {
  display: flex;
  flex-direction: column;
  font-size: 14px;
}

.action-bar.wrap {
  flex-wrap: wrap;
}

@media (max-width: 520px) {
  .action-bar.wrap .action-info {
    flex-basis: 100%;
  }
  .action-bar.wrap .btn {
    flex: 1;
  }
}

/* ---------- кнопки и поля ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background-color 0.15s, transform 0.06s;
}

.btn:active {
  transform: scale(0.98);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: var(--accent-hover);
}

.btn.secondary {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.btn.ghost {
  background: transparent;
  color: var(--text-2);
}

.btn.ghost:hover,
.btn.secondary:hover {
  background: var(--hover);
}

.btn.secondary:hover {
  background: color-mix(in srgb, var(--accent-soft) 80%, var(--accent) 20%);
}

.btn.danger {
  background: var(--bad);
  color: #fff;
}

.btn.block {
  display: flex;
  width: 100%;
}

.btn.big {
  min-height: 54px;
  font-size: 16px;
  border-radius: 14px;
}

.btn.small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
  border-radius: 10px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn.loading,
.btn.loading .icon {
  position: relative;
  color: transparent !important;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2.5px solid currentColor;
  border-color: var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.btn.primary.loading::after {
  border-color: rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  text-decoration: none;
}

.icon-btn:hover {
  background: var(--hover);
}

.icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.danger-text {
  color: var(--bad) !important;
}

.input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--field);
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input:disabled {
  opacity: 1;
  color: var(--text);
  -webkit-text-fill-color: var(--text);
}

.input::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

.textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.45;
}

.input-wrap {
  position: relative;
}

.input-wrap .input {
  padding-right: 48px;
}

.input-addon {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
}

.field-hint {
  font-size: 13px;
  color: var(--muted);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-error {
  color: var(--bad-text);
  font-size: 14px;
}

.form-error:empty {
  display: none;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

/* ---------- карточки и списки ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.card.pad {
  padding: 16px;
}

.list {
  overflow: hidden;
}

.list > .row + .row {
  border-top: 1px solid var(--border);
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 12px 14px;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.row:hover {
  background: var(--hover);
}

.row.static {
  cursor: default;
  align-items: flex-start;
}

.row.static:hover {
  background: none;
}

.row > .icon:last-child,
.hw-card > .icon:last-child {
  color: var(--muted);
}

.row-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.row-sub {
  margin-top: 2px;
  font-size: 13.5px;
  color: var(--text-2);
}

.grow {
  flex: 1;
  min-width: 0;
}

.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button-row .btn {
  flex: 1 1 auto;
}

.section-title {
  margin: 10px 2px 0;
  font-size: 17px;
  font-weight: 700;
}

.card .section-title {
  margin: 0;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.section-head .section-title {
  margin: 0 2px;
}

.link {
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.link-plain {
  display: block;
  color: inherit;
  text-decoration: none;
}

.muted {
  color: var(--text-2);
}

.small {
  font-size: 13.5px;
}

.center {
  text-align: center;
}

.text-bad {
  color: var(--bad-text);
}

.rich {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 28px 16px;
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 4px;
  border-radius: 50%;
  background: var(--good-soft);
  color: var(--good-icon);
}

.empty-icon.bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.empty-title {
  font-size: 17px;
  font-weight: 650;
}

.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 700;
}

.account {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 2px;
}

.account .avatar {
  width: 52px;
  height: 52px;
  font-size: 18px;
}

.account-name {
  font-size: 19px;
  font-weight: 700;
}

.percent {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* ---------- чипы, переключатели, плитки ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--field);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.chip-neutral {
  background: var(--seg-bg);
}

.chip-good {
  background: var(--good-soft);
}

.chip-good .icon {
  color: var(--good-icon);
}

.chip-warn {
  background: var(--warn-soft);
}

.chip-warn .icon {
  color: var(--warn-icon);
}

.chip-serious {
  background: var(--serious-soft);
}

.chip-serious .icon {
  color: var(--serious-icon);
}

.chip-bad {
  background: var(--bad-soft);
}

.chip-bad .icon {
  color: var(--bad);
}

.seg {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 12px;
  background: var(--seg-bg);
}

.seg-item {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.seg-item.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chip {
  min-height: 36px;
  padding: 0 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.filter-chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

/* На телефоне (2 колонки) нечётная последняя плитка растягивается на всю ширину, чтобы не висела одна. */
@media (max-width: 599px) {
  .tiles > .tile:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}

.tile {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tile-label {
  font-size: 13px;
  color: var(--text-2);
}

.tile-value {
  margin-top: 2px;
  font-size: 24px;
  font-weight: 650;
}

.tile-sub {
  font-size: 12.5px;
  color: var(--muted);
}

.meter {
  height: 6px;
  border-radius: 3px;
  background: var(--track);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
}

/* ---------- статистика ---------- */

.stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hero {
  padding: 18px 16px;
}

.hero-label {
  font-size: 14px;
  color: var(--text-2);
}

.hero-value {
  margin: 4px 0;
  font-size: 52px;
  font-weight: 650;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.hero-sub {
  font-size: 13.5px;
  color: var(--muted);
}

.chart {
  padding: 16px 16px 12px;
}

.chart-title {
  font-weight: 650;
}

.chart-sub {
  font-size: 13px;
  color: var(--muted);
}

.chart-plot {
  position: relative;
  height: 160px;
  margin: 26px 0 0 38px;
}

.chart-grid {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid var(--grid);
}

.chart-base {
  border-top-color: var(--axis);
}

.chart-tick {
  position: absolute;
  right: 100%;
  margin-right: 8px;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--chart-muted);
  font-variant-numeric: tabular-nums;
}

.chart-cols {
  position: absolute;
  inset: 0;
  display: flex;
  gap: 2px;
}

.chart-col {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 6px 6px 0 0;
  background: transparent;
  cursor: pointer;
}

.chart-col:hover,
.chart-col:focus-visible {
  background: var(--hover);
  outline: none;
}

.chart-bar {
  width: 100%;
  max-width: 24px;
  border-radius: 4px 4px 0 0;
  background: var(--series-1);
}

.chart-cap {
  position: absolute;
  left: 50%;
  transform: translate(-50%, -4px);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}

.chart-tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 2;
  max-width: 220px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--tip-bg);
  color: var(--tip-text);
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
}

.chart-tip.show {
  opacity: 1;
}

.chart-tip-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-tip-value {
  font-weight: 700;
}

.chart-tip-value span {
  font-weight: 400;
  opacity: 0.75;
}

.chart-x {
  display: flex;
  justify-content: space-between;
  margin: 6px 0 0 38px;
  font-size: 11px;
  color: var(--chart-muted);
}

/* ---------- домашки ---------- */

.hw-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  color: inherit;
  text-decoration: none;
}

.hw-card:hover {
  border-color: var(--border-strong);
}

.hw-title {
  font-size: 16px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.hw-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin-top: 3px;
  font-size: 13.5px;
  color: var(--text-2);
}

.hw-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.hw-progress .meter {
  flex: 1;
  max-width: 200px;
}

.hw-head {
  padding: 4px 2px;
}

.hw-head-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.hw-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  font-size: 14px;
  color: var(--text-2);
}

.hw-info > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--accent-soft);
  font-size: 14.5px;
}

.notice > .icon {
  margin-top: 1px;
  color: var(--accent-text);
}

.notice-warn {
  background: var(--warn-soft);
}

.notice-warn > .icon {
  color: var(--warn-icon);
}

.notice-serious {
  background: var(--serious-soft);
}

.notice-serious > .icon {
  color: var(--serious-icon);
}

.notice-bad {
  background: var(--bad-soft);
}

.notice-bad > .icon {
  color: var(--bad);
}

.result {
  padding: 16px;
}

.result-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.result-score {
  font-size: 20px;
  font-weight: 650;
}

.result-percent {
  font-size: 40px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.teacher-comment {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--field);
  font-size: 14.5px;
}

.teacher-comment .icon {
  margin-top: 2px;
  color: var(--accent);
}

.teacher-comment span {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.task {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.task .teacher-comment {
  margin-top: 0;
}

.task > .btn,
.task > label.btn {
  align-self: flex-start;
}

.task.is-wrong {
  border-color: color-mix(in srgb, var(--bad) 45%, transparent);
}

.task.is-locked .input,
.task.is-locked .option {
  opacity: 0.75;
}

.retry {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

.text-accent {
  color: var(--accent-text);
  font-weight: 600;
}

.attempts-line {
  margin-top: -4px;
}

.task.is-partial {
  border-color: color-mix(in srgb, var(--serious-icon) 45%, transparent);
}

.task-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.task-num {
  font-size: 15px;
  font-weight: 700;
}

.task-text {
  font-size: 16px;
}

.task-image {
  align-self: flex-start;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.task-image img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.task-badge {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 8px;
  background: var(--field);
  font-size: 13px;
  font-weight: 700;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 12px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
}

.option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option-mark {
  width: 22px;
  height: 22px;
  flex: none;
  border: 2px solid var(--axis);
  border-radius: 50%;
}

.option:has(input[type='checkbox']) .option-mark {
  border-radius: 6px;
}

.option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option:has(input:checked) .option-mark {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--surface);
}

.option:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.option:has(input:disabled) {
  cursor: default;
}

.option.correct {
  border-color: var(--good);
  background: var(--good-soft);
}

.option.wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
}

.option-text {
  overflow-wrap: anywhere;
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.thumb {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--field);
}

.thumb-img {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.thumb-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-file {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 100%;
  padding: 8px;
  color: var(--text-2);
  font-size: 12px;
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  cursor: pointer;
}

.upload-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 4px;
  background: var(--accent);
  transition: width 0.2s;
}

.answer-label {
  margin-bottom: -6px;
}

.answer-box {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--field);
}

.empty-answer {
  color: var(--muted);
  font-style: italic;
}

.auto-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.grade-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.score-input {
  width: 76px;
  min-height: 42px;
  text-align: center;
}

.check-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.total {
  font-weight: 650;
}

.save-state:empty {
  display: none;
}

/* ---------- конструктор ---------- */

.type-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

/* На узком телефоне пять вариантов не помещаются в строку — 3 + 2. */
@media (max-width: 400px) {
  .type-picker {
    grid-template-columns: repeat(3, 1fr);
  }
}

.type-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 9px 4px;
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.type-option.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.task-tools {
  display: flex;
  gap: 2px;
}

.task-tools .icon-btn {
  width: 36px;
  height: 36px;
}

.editor > .btn.ghost,
.editor > label.btn {
  align-self: flex-start;
}

.option-edit {
  display: flex;
  align-items: center;
  gap: 8px;
}

.correct-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border: 2px solid var(--axis);
  border-radius: 50%;
  background: var(--surface);
  color: transparent;
  cursor: pointer;
}

.correct-toggle.on {
  border-color: var(--good);
  background: var(--good);
  color: #fff;
}

.check-row input {
  width: 20px;
  height: 20px;
  flex: none;
  accent-color: var(--accent);
}

.checklist {
  display: flex;
  flex-direction: column;
  max-height: 380px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 12px;
  cursor: pointer;
}

.check-row + .check-row {
  border-top: 1px solid var(--border);
}

.flash {
  animation: flash 1.2s;
}

@keyframes flash {
  0%,
  100% {
    box-shadow: var(--shadow);
  }
  20% {
    box-shadow: 0 0 0 3px var(--bad);
  }
}

/* ---------- формулы ---------- */

/* Математический шрифт обязателен: без него браузер не растягивает скобки системы и корни. */
.math math {
  font-family: 'Cambria Math', 'STIX Two Math', 'Latin Modern Math', 'Noto Sans Math', math, serif;
  font-size: 1.08em;
}

/* В вариантах теста дроби крупные, как в учебнике, — чтобы на телефоне было легко прочитать и попасть пальцем. */
.option-text .math math {
  math-style: normal;
}

.math-display {
  display: block;
  margin: 6px 0;
  overflow-x: auto;
}

.math mtd {
  text-align: left;
}

.tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: -4px;
}

.btn.ghost.active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.formula-tools {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.formula-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.formula-btn {
  display: grid;
  place-items: center;
  flex: none;
  min-width: 44px;
  height: 44px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.formula-btn:hover {
  background: var(--hover);
}

.formula-next {
  position: sticky;
  left: 0;
  z-index: 1;
  padding: 0 12px;
  white-space: nowrap;
  box-shadow: 8px 0 8px -4px var(--surface);
  border-color: var(--accent);
  background: var(--surface);
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 600;
}

.formula-btn .math math {
  font-size: 0.95em;
}

.formula-preview {
  padding: 10px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  font-size: 16px;
}

.formula-preview.compact {
  padding: 6px 10px;
  font-size: 15px;
}

.formula-preview-label {
  margin-bottom: 4px;
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- вставка задач ---------- */

.paste-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1.5px dashed var(--accent);
  border-radius: 16px;
  background: var(--accent-soft);
}

.paste-icon {
  color: var(--accent-text);
}

.paste-card strong {
  display: block;
  margin-bottom: 2px;
}

.rich-field {
  position: relative;
  min-height: 46px;
  padding: 10px 12px 26px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--field);
  font-size: 16px;
  cursor: text;
}

.rich-field:hover {
  border-color: var(--accent);
}

.rich-field-edit {
  position: absolute;
  right: 10px;
  bottom: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12.5px;
}

.inline-img {
  max-width: 100%;
  vertical-align: middle;
}

.row-title .inline-img {
  max-height: 1.4em;
}

.task-picture {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.answer-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ---------- разделы и темы ---------- */

.subject-tabs {
  display: flex;
  gap: 6px;
  margin: 0 -16px;
  padding: 2px 16px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.subject-tabs::-webkit-scrollbar {
  display: none;
}

.subject-tab {
  flex: none;
  min-height: 40px;
  padding: 0 16px;
  font-size: 15px;
}

.add-chip {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 4px;
  border-style: dashed;
  color: var(--accent-text);
  text-decoration: none;
  line-height: 1;
}

.subject-tabs .add-chip {
  min-height: 40px;
}

.topics {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.topic {
  border-radius: 16px;
}

.topic-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 4px;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.topic-head::-webkit-details-marker {
  display: none;
}

.topic-name {
  font-size: 16px;
  font-weight: 700;
}

.topic-meta {
  flex: 1;
  color: var(--muted);
  font-size: 13.5px;
}

.topic-head .icon {
  color: var(--muted);
  transition: transform 0.15s;
}

.topic[open] > .topic-head .icon {
  transform: rotate(90deg);
}

.topic-head:hover .topic-name {
  color: var(--accent-text);
}

.topic-body {
  padding-bottom: 6px;
}

.subject-picker .chips-row .filter-chip {
  min-height: 38px;
}

.picker-gap {
  margin-top: 6px;
}

.inline-add {
  display: flex;
  align-items: center;
  gap: 6px;
}

.inline-add .input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
}

.hw-place {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 4px;
  color: var(--accent-text);
  font-size: 13.5px;
  font-weight: 600;
}

.hw-meta .place {
  color: var(--accent-text);
  font-weight: 600;
}

.subject-percents {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  margin-top: 2px;
  font-size: 13.5px;
  color: var(--text-2);
}

.subject-percents b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.subject-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.subject-row .row-title {
  font-size: 17px;
}

.topic-row {
  min-height: 52px;
  padding-left: 62px;
}

.add-row {
  min-height: 0;
  padding: 6px 10px 10px 54px;
}

.add-row > div {
  width: 100%;
}

/* ---------- задания из файла ---------- */

.entry-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 460px) {
  .entry-choice {
    grid-template-columns: 1fr;
  }
}

.entry-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, background-color 0.15s;
}

.entry-option:hover {
  border-color: var(--accent);
}

.entry-option.primary-option {
  border-style: dashed;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.entry-option:disabled {
  opacity: 0.7;
  cursor: default;
}

.entry-option.loading .entry-icon {
  animation: spin 1.2s linear infinite;
}

.entry-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 4px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--accent-text);
}

.entry-option:not(.primary-option) .entry-icon {
  background: var(--field);
}

.entry-title {
  font-size: 16px;
  font-weight: 700;
}

.entry-text {
  font-size: 13.5px;
  color: var(--text-2);
}

body.dragging-file .entry-option.primary-option,
body.dragging-file .paste-card {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.format-help summary {
  padding: 6px 2px;
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.format-body {
  padding: 4px 2px 0;
  font-size: 14px;
  color: var(--text-2);
}

.format-body ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.format-body li + li {
  margin-top: 3px;
}

.format-example {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: 14px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
}

.import-notice > .icon {
  color: var(--good-icon);
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font-weight: 600;
  cursor: pointer;
}

.link-btn .icon {
  color: var(--warn-icon);
}

.task.is-flagged {
  border-color: color-mix(in srgb, var(--warn-icon) 55%, transparent);
}

.task-flags {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-flag {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--warn-soft);
  font-size: 13.5px;
}

.task-flag .icon {
  margin-top: 1px;
  color: var(--warn-icon);
}

/* Таблица внутри условия (из Word или набранная «| a | b |»). */
.rich-table-wrap {
  max-width: 100%;
  margin: 6px 0;
  overflow-x: auto;
}

.rich-table {
  border-collapse: collapse;
  font-size: 15px;
  white-space: normal;
}

.rich-table th,
.rich-table td {
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  text-align: left;
  vertical-align: top;
}

.rich-table th {
  background: var(--field);
  font-weight: 650;
}

.row-title .rich-table-wrap {
  display: none;
}

/* ---------- полезные файлы ---------- */

.file-badge {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 10px;
  background: var(--field);
  color: var(--text-2);
}

.file-badge b {
  font-size: 11px;
  letter-spacing: 0.02em;
}

.file-badge.is-pdf {
  background: var(--bad-soft);
  color: var(--bad-text);
}

.file-badge.is-link {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.chosen-file {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chosen-file > .icon {
  color: var(--muted);
}

.chosen-file .input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
}

.nowrap {
  white-space: nowrap;
}

.row.static.center-row {
  align-items: center;
}

/* ---------- прочее ---------- */

.copy-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.copy-line code {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--field);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.creds {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow: auto;
}

.cred {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--field);
}

.cred-line {
  font-size: 14.5px;
}

.cred code {
  font-weight: 600;
  user-select: all;
}

.archived summary {
  padding: 8px 2px;
  color: var(--text-2);
  font-weight: 600;
  cursor: pointer;
}

.onboarding ol {
  margin: 8px 0 14px;
  padding-left: 20px;
  color: var(--text-2);
}

.onboarding li + li {
  margin-top: 4px;
}

.install-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--accent-soft);
}

.install-icon {
  color: var(--accent-text);
}

.install-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  font-size: 14px;
}

.install-text strong {
  font-size: 15px;
}

/* ---------- вход ---------- */

.auth {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 100dvh;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 28px 22px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.auth-card h1 {
  margin: 12px 0 4px;
  font-size: 26px;
}

.auth-card p {
  margin: 0;
}

.auth-card .form {
  margin-top: 22px;
  text-align: left;
}

.auth-card .notice {
  text-align: left;
}

.auth .install-card {
  width: 100%;
  max-width: 400px;
}

.logo {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto;
  border-radius: 18px;
  background: var(--accent);
  color: #fff;
}

/* ---------- окна и уведомления ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  animation: fade 0.16s;
}

.overlay.hide {
  opacity: 0;
  transition: opacity 0.16s;
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 92dvh;
  overflow: auto;
  padding: 0 18px calc(18px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  background: var(--surface);
  animation: up 0.2s ease-out;
  outline: none;
}

.modal-wide {
  max-width: 960px;
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 0 10px;
  background: var(--surface);
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-text {
  margin: 4px 0 18px;
  color: var(--text-2);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.modal-actions .btn {
  flex: 1 1 0;
}

.modal .seg {
  margin-bottom: 2px;
}

.lightbox-img {
  display: block;
  max-width: 100%;
  max-height: 80dvh;
  margin: 0 auto;
  border-radius: 12px;
}

@media (min-width: 600px) {
  .overlay {
    align-items: center;
    padding: 24px;
  }
  .modal {
    padding-bottom: 18px;
    border-radius: 20px;
  }
}

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--tip-bg);
  color: var(--tip-text);
  font-size: 14.5px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  animation: up 0.2s ease-out;
  transition: opacity 0.3s;
}

.toast.hide {
  opacity: 0;
}

.toast-good .icon {
  color: var(--good);
}

.toast-bad .icon {
  color: var(--bad);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
