/* Цвета и размеры в одном месте */
:root {
  --ground: #F3F5F9;
  --surface: #FFFFFF;
  --ink: #16203A;
  --muted: #566176;
  --line: #DCE1EA;
  --line-strong: #C5CCDA;
  --blue: #2747D8;
  --blue-dark: #1B34A8;
  --blue-tint: #E9EDFD;
  --orange: #A8480A;
  --orange-tint: #FFF0E3;
  --grey-tint: #EEF1F6;
  --red: #B3261E;
  --mono: ui-monospace, 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
a:hover { color: var(--blue-dark); }
h1 { margin: 0; font-size: 26px; line-height: 1.2; }
h2 { margin: 0; font-size: 18px; }
p { margin: 0; }
img { max-width: 100%; }
code { font-family: var(--mono); background: var(--grey-tint); padding: 1px 6px; border-radius: 4px; }

/* Шапка */
.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 24px;
  padding: 8px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; }
.top nav { display: flex; flex-wrap: wrap; gap: 4px; flex-grow: 1; }
.top nav a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px;
  border-radius: 8px; text-decoration: none; font-weight: 500; color: var(--ink);
}
.top nav a[aria-current] { background: var(--blue-tint); color: var(--blue-dark); font-weight: 600; }
.top .who { margin-left: auto; color: var(--muted); font-size: 14px; }
.count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px;
  padding: 0 6px; border-radius: 11px; background: var(--orange-tint); color: var(--orange);
  font-size: 13px; font-weight: 600;
}

/* Основная колонка */
main {
  display: flex; flex-direction: column; gap: 18px;
  max-width: 1200px; margin: 0 auto; padding: 24px 20px 48px;
}
main.medium { max-width: 860px; }
main.narrow { max-width: 440px; }
main.phone { max-width: 560px; padding: 16px 16px 40px; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.grow { flex: 1 1 220px; min-width: 0; }
.row > input[type=text], .row > select { flex: 1 1 200px; width: auto; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 18px; }
.split { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 20px; }
.split > section { flex: 999 1 520px; min-width: 0; }
.split > aside { flex: 1 1 300px; min-width: 0; position: sticky; top: 12px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.mono { font-family: var(--mono); }
.big { font-size: 20px; font-weight: 500; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.empty { padding: 24px; border: 1.5px dashed var(--line-strong); border-radius: 12px; color: var(--muted); text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.back { align-self: flex-start; display: inline-flex; align-items: center; min-height: 44px; font-weight: 500; text-decoration: none; }
.back::before { content: '\2039'; margin-right: 6px; font-size: 22px; line-height: 1; }

/* Сообщения */
.flash { padding: 12px 14px; border-radius: 8px; font-weight: 500; }
.flash-ok { background: var(--blue-tint); color: var(--blue-dark); }
.flash-error { background: var(--orange-tint); color: var(--orange); }

/* Поля */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field > label, .field > legend, .label { font-size: 14px; font-weight: 500; color: var(--muted); padding: 0; }
input[type=text], input[type=password], input[type=url], input[type=date], select, textarea {
  min-height: 44px; width: 100%; padding: 8px 12px; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 8px;
}
select { min-width: 180px; }
input[type=file] { max-width: 100%; min-height: 44px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 2px;
}
.check { display: flex; align-items: center; gap: 10px; min-height: 36px; font-size: 15px; cursor: pointer; }
.check input, .pick-box { width: 20px; height: 20px; margin: 0; flex-shrink: 0; accent-color: var(--blue); }
.big-input { font-size: 20px; min-height: 52px; }
.answer-input { min-width: 160px; }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px;
  font-weight: 500; color: var(--ink); text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--blue); color: var(--ink); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #FFFFFF; font-weight: 600; }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: #FFFFFF; }
.btn-wide { width: 100%; min-height: 52px; font-size: 17px; }
.btn-text {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; background: none; border: 0;
  color: var(--blue-dark); font-weight: 500; text-decoration: none; cursor: pointer;
}
.btn-text.danger { color: var(--red); }

/* Переключатели и фильтры */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tabs a, .tabs button {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 22px;
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink);
  font-weight: 500; text-decoration: none; cursor: pointer;
}
.tabs a[aria-current], .tabs button[aria-pressed=true] { background: var(--blue); border-color: var(--blue); color: #FFFFFF; }

/* Списки */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.item-link { color: var(--ink); text-decoration: none; min-height: 64px; }
.item-link:hover { border-color: var(--blue); color: var(--ink); }
.item-body { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.item-body.row { flex-direction: row; }
.item-title { font-weight: 600; overflow-wrap: anywhere; }
.item-text { overflow-wrap: anywhere; }
.item-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.item.pick:has(.pick-box:checked) { border-color: var(--blue); }
.item.pick[hidden] { display: none; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.code { font-family: var(--mono); font-size: 14px; font-weight: 500; color: var(--blue-dark); }
.chip, .badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px; background: var(--grey-tint); color: #3D4759; font-size: 13px; font-weight: 500; text-decoration: none; }
.badge-ok { background: var(--blue-tint); color: var(--blue-dark); }
.badge-warn { background: var(--orange-tint); color: var(--orange); }
.link-text { overflow-wrap: anywhere; color: var(--muted); }

/* Картинки */
.thumb {
  display: flex; align-items: center; justify-content: center; width: 96px; height: 72px; flex-shrink: 0;
  border: 1px solid var(--line); border-radius: 8px; background: var(--ground); overflow: hidden;
  color: #3D4759; font-size: 13px; font-weight: 500; text-decoration: none;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-big { width: 260px; height: 160px; }
.thumb-big img { object-fit: contain; }
.preview { display: block; max-height: 220px; border: 1px solid var(--line); border-radius: 8px; }
.photo { display: block; width: 100%; max-height: 70vh; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.task-text { font-size: 18px; }

/* Баллы */
.scores { display: flex; flex-wrap: wrap; gap: 8px; }
.score { position: relative; }
.score input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.score span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 56px; min-height: 44px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface);
  font-family: var(--mono); font-size: 17px; font-weight: 500;
}
.score input:checked + span { background: var(--blue); border-color: var(--blue); color: #FFFFFF; }
.score input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Таблица результатов */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
thead th { font-size: 14px; color: var(--muted); font-weight: 500; }
tbody th { font-weight: 400; }
