/* Видеотека: рабочий инструмент отсмотра. Одна тема на страницу (тёмная или светлая по системе),
   один акцент, две ступени скругления: 8px у элементов управления, 12px у панелей. */
:root {
  color-scheme: dark;
  --bg: #111416;
  --surface: #181d20;
  --raised: #20272b;
  --line: #2c353a;
  --text: #e9ece8;
  --muted: #98a3a8;
  --accent: #cfe08f;
  --on-accent: #1c230e;
  --ok: #7fcf8d;
  --bad: #f08a80;
  --draft: #e2b76c;
  --unreal: #8fc3e6;
  --r-control: 8px;
  --r-panel: 12px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f3f4f1;
    --surface: #fdfdfc;
    --raised: #e9ebe6;
    --line: #d3d8d0;
    --text: #1b2022;
    --muted: #5a656a;
    --accent: #3d5a12;
    --on-accent: #fbfcf8;
    --ok: #1d7436;
    --bad: #b2362b;
    --draft: #855600;
    --unreal: #1b5f90;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
h1, h2, h3, p, ul { margin: 0; }
h1, h2, h3 { font-family: "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif; font-weight: 600; letter-spacing: -.01em; }
a { color: inherit; }
.muted { color: var(--muted); font-size: 13px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Элементы управления */
button, input, textarea { font: inherit; color: inherit; }
button {
  cursor: pointer; min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface);
  transition: border-color .12s var(--ease), background-color .12s var(--ease), transform .08s var(--ease);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.primary:hover:not(:disabled) { border-color: var(--accent); filter: brightness(1.06); }
button.quiet { border-color: transparent; background: none; color: var(--muted); padding: 8px 10px; }
button.quiet:hover:not(:disabled) { border-color: transparent; color: var(--text); }
input, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-control);
  background: var(--bg); line-height: 1.5;
}
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible, h2:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.text-link { color: var(--muted); font-size: 13px; text-underline-offset: 3px; }
.text-link:hover { color: var(--text); }
.form-message { min-height: 1.5em; font-size: 13px; color: var(--muted); }

/* Шапка */
.masthead, main { width: min(1560px, 100% - 48px); margin-inline: auto; }
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--r-control); background: var(--accent); color: var(--on-accent); font-weight: 700; }
.header-actions { display: flex; align-items: center; gap: 4px; min-width: 0; }
.who { display: inline-flex; align-items: center; gap: 2px; padding-left: 12px; margin-left: 8px; border-left: 1px solid var(--line); font-size: 14px; }

.limits { position: relative; font-size: 13px; }
.limits summary { cursor: pointer; padding: 8px 10px; border-radius: var(--r-control); color: var(--muted); list-style: none; max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.limits summary::-webkit-details-marker { display: none; }
.limits-good summary { color: var(--ok); }
.limits-warning summary { color: var(--draft); }
.limits-danger summary { color: var(--bad); }
.limits-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; width: min(420px, 90vw); padding: 14px; border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--surface); box-shadow: 0 12px 32px rgb(0 0 0 / .28); }
.limits-servers { max-height: 50vh; overflow-y: auto; }
.limits-server { padding: 8px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.limits-server p { margin: 2px 0; }
.limits-actions { display: flex; align-items: center; gap: 8px; margin: 12px 0 6px; }
.limits-actions button { min-height: 34px; padding: 5px 10px; font-size: 13px; }
.limits-spinner { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.notice { margin-top: 16px; padding: 12px 14px; border: 1px solid var(--draft); border-radius: var(--r-control); font-size: 14px; }

/* Вход */
.login { width: min(440px, 100% - 48px); margin: 14vh auto 0; }
.login h1 { font-size: 28px; margin-bottom: 20px; }
.login-users { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.login-user { min-height: 48px; font-size: 16px; }
.login-user[aria-pressed="true"] { border-color: var(--accent); background: var(--raised); }
.login-form { display: grid; gap: 6px; margin-top: 24px; font-size: 14px; }
.login-row { display: flex; gap: 8px; }
.login-row input { background: var(--surface); }
.login .form-message { margin-top: 12px; color: var(--bad); }

/* Просмотр: ролик слева, оценка и комментарии команды справа */
.viewer { padding: 20px 0 28px; border-bottom: 1px solid var(--line); scroll-margin-top: 8px; }
.viewer-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 24px; flex-wrap: wrap; margin-bottom: 14px; }
.viewer-heading h2 { font-size: 24px; border-radius: 4px; }
.viewer-meta { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; font-size: 13px; }
.video-status { font-weight: 600; }
.video-status.ready { color: var(--ok); }
.video-status.draft { color: var(--draft); }
.video-status.unreal { color: var(--unreal); }
.video-status.missing { color: var(--muted); }
.viewer-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
.viewer-main { min-width: 0; }
.screen { display: grid; place-items: center; aspect-ratio: 16 / 9; max-height: 72vh; width: 100%; background: #07090a; border-radius: var(--r-panel); overflow: hidden; }
video { width: 100%; height: 100%; object-fit: contain; }
.empty-player { padding: 24px; text-align: center; color: #98a3a8; }
.empty-player h3 { color: #e9ece8; font-size: 18px; margin-bottom: 6px; }
.empty-player p { font-size: 14px; max-width: 36ch; }
.question-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.video-options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.video-options details { flex-basis: 100%; }
.video-options summary { cursor: pointer; }
.video-choice { min-height: 34px; padding: 5px 10px; font-size: 13px; text-align: left; overflow-wrap: anywhere; }
.video-options details .video-choice { display: block; margin-top: 6px; }

.viewer-side { min-width: 0; }
.review h3 { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-bottom: 8px; }
.vote-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vote { min-height: 52px; font-size: 16px; font-weight: 600; }
.vote-like:hover:not(:disabled) { border-color: var(--ok); }
.vote-dislike:hover:not(:disabled) { border-color: var(--bad); }
.vote-like[aria-pressed="true"] { border-color: var(--ok); color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--surface)); }
.vote-dislike[aria-pressed="true"] { border-color: var(--bad); color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, var(--surface)); }
.review-form { display: grid; gap: 6px; margin-top: 14px; font-size: 14px; }
.review-form textarea { resize: vertical; min-height: 120px; background: var(--surface); }
.review-form-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.review-form-actions .primary { margin-right: 4px; }
.review-list-title { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.review-list { display: grid; gap: 14px; max-height: 46vh; overflow-y: auto; }
.review-item { min-width: 0; padding-left: 12px; border-left: 2px solid var(--line); }
.review-like { border-left-color: var(--ok); }
.review-dislike { border-left-color: var(--bad); }
.review-head { display: flex; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; font-size: 14px; }
.review-mark { font-size: 13px; font-weight: 600; }
.review-like .review-mark { color: var(--ok); }
.review-dislike .review-mark { color: var(--bad); }
.review-stale { font-size: 12px; color: var(--draft); }
.review-text { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.5; }

/* Каталог: 40 строк по 20 вопросов */
.catalog { padding: 24px 0 56px; }
.catalog-heading { display: flex; align-items: baseline; gap: 8px 24px; flex-wrap: wrap; margin-bottom: 16px; }
.catalog-heading h2 { font-size: 20px; }
.catalog-summary { color: var(--muted); font-size: 13px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-left: auto; padding: 0; list-style: none; font-size: 12px; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend li::before { content: ""; width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line); }
.legend .ready::before { background: color-mix(in srgb, var(--ok) 26%, var(--surface)); border-color: color-mix(in srgb, var(--ok) 50%, var(--surface)); }
.legend .draft::before { background: color-mix(in srgb, var(--draft) 24%, var(--surface)); border-color: color-mix(in srgb, var(--draft) 48%, var(--surface)); }
.legend .unreal::before { background: color-mix(in srgb, var(--unreal) 22%, var(--surface)); border-color: color-mix(in srgb, var(--unreal) 46%, var(--surface)); }
.legend .key-badge::before { border-radius: 50%; border: 0; }
.legend .bad::before { background: var(--bad); }
.legend .ok::before { background: var(--ok); }

.ticket-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(20, auto); grid-auto-flow: column; gap: 6px 40px; }
.ticket { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 12px; }
.ticket-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.ticket-count { font-size: 12px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.question-grid { display: grid; grid-template-columns: repeat(20, minmax(0, 1fr)); gap: 3px; }
.question {
  position: relative; display: grid; place-items: center; height: 30px;
  border: 1px solid var(--line); border-radius: 5px; background: transparent;
  color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; text-decoration: none;
  transition: border-color .12s var(--ease);
}
.question.ready { color: var(--text); background: color-mix(in srgb, var(--ok) 26%, var(--surface)); border-color: color-mix(in srgb, var(--ok) 50%, var(--surface)); }
.question.draft { color: var(--text); background: color-mix(in srgb, var(--draft) 24%, var(--surface)); border-color: color-mix(in srgb, var(--draft) 48%, var(--surface)); }
.question.unreal { color: var(--text); background: color-mix(in srgb, var(--unreal) 22%, var(--surface)); border-color: color-mix(in srgb, var(--unreal) 46%, var(--surface)); }
.question.missing { opacity: .55; }
.question:hover { border-color: var(--text); }
.question[aria-current="true"] { outline: 2px solid var(--accent); outline-offset: 1px; z-index: 1; }
.question.mine::after { content: ""; position: absolute; left: 3px; bottom: 3px; width: 4px; height: 4px; border-radius: 50%; background: var(--text); }
.badge { position: absolute; top: -5px; right: -4px; z-index: 2; min-width: 14px; height: 14px; padding: 0 3px; border-radius: 7px; font-size: 10px; font-weight: 700; line-height: 14px; text-align: center; color: var(--bg); box-shadow: 0 0 0 2px var(--bg); }
.badge-bad { background: var(--bad); }
.badge-ok { background: var(--ok); }

@media (max-width: 1280px) {
  .ticket-grid { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-flow: row; }
}
@media (max-width: 1000px) {
  .viewer-layout { grid-template-columns: 1fr; }
  .review-list { max-height: none; }
  .legend { margin-left: 0; }
}
@media (max-width: 720px) {
  .masthead, main { width: calc(100% - 28px); }
  .masthead { flex-wrap: wrap; padding: 10px 0; }
  .brand-name { display: none; }
  .ticket { grid-template-columns: 1fr; gap: 6px; margin-bottom: 10px; }
  .ticket-title { justify-content: flex-start; }
  .question-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
  .question { height: 38px; font-size: 13px; }
  .limits summary { max-width: 24ch; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .limits-spinner { animation: none; }
}
button { white-space: nowrap; }
@media (max-width: 720px) {
  .question-nav .muted { display: none; }
  .question-nav button { flex: 1; }
  .header-actions { flex-wrap: wrap; justify-content: flex-end; }
}
