:root {
  color-scheme: light dark;
  --accent: #2f6f4f;
  --muted: #7a7a7a;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
}
.card {
  width: 100%;
  max-width: 40rem;
}
h1 { font-size: 1.4rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.stats { color: var(--muted); }
.error { color: #b3403a; }
form { display: flex; gap: 0.5rem; }
input[type="text"] {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--muted);
  border-radius: 6px;
  font: inherit;
}
button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font: inherit;
  cursor: pointer;
}
button.quiet { background: none; color: var(--muted); padding: 0; }
ul.sections { list-style: none; padding: 0; margin: 0; }
ul.sections li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(128, 128, 128, 0.25);
}
.status { color: var(--muted); white-space: nowrap; }
ul.sections a { color: var(--accent); text-decoration: none; }
ul.sections a:hover { text-decoration: underline; }
.question { line-height: 1.4; }
textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--muted);
  border-radius: 6px;
  font: inherit;
  resize: vertical;
}
#answer-form { flex-direction: column; align-items: stretch; }
#timer.overtime { color: #b98a00; font-weight: bold; }
.voice-row { display: flex; gap: 0.75rem; align-items: center; }
#rec-stop { background: #b3403a; }
/* полоса уровня микрофона во время записи */
.meter {
  width: 6rem;
  height: 0.5rem;
  border-radius: 4px;
  background: rgba(128, 128, 128, 0.25);
  overflow: hidden;
}
#rec-meter {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.1s linear;
}
/* крутилка долгих ожиданий: распознавание записи, оценка ответа */
.spinner {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  border: 2px solid rgba(128, 128, 128, 0.35);
  border-top-color: var(--accent);
  border-radius: 50%;
  vertical-align: -0.15em;
  animation: spin 0.8s linear infinite;
}
.spinner.light {
  border-color: rgba(255, 255, 255, 0.4);
  border-top-color: white;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skip-form { margin-top: 0.75rem; justify-content: flex-end; }
#overtime-note { color: #b98a00; }
.example {
  background: rgba(47, 111, 79, 0.08);
  border-left: 3px solid var(--accent);
  padding: 0.6rem 0.9rem;
  border-radius: 0 6px 6px 0;
}
.score { font-size: 1.1rem; }
table.criteria { border-collapse: collapse; width: 100%; }
table.criteria td { padding: 0.45rem 0.5rem; border-bottom: 1px solid rgba(128,128,128,0.25); vertical-align: top; }
td.crit-name { white-space: nowrap; color: var(--muted); }
td.crit-score { font-weight: bold; white-space: nowrap; }
a.quiet { color: var(--muted); text-decoration: none; }
a.quiet:hover { text-decoration: underline; }
.feedback-item { padding: 0.75rem 0; border-bottom: 1px solid rgba(128, 128, 128, 0.25); }
.actions-row { justify-content: flex-start; margin: 0.75rem 0; }
ul.stories { list-style: none; padding: 0; margin: 0; }
/* название и компетенции двумя строками: в две колонки длинное название
   сжимается в столбик по слову на строку */
ul.stories li {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(128, 128, 128, 0.25);
}
ul.stories a { color: var(--accent); text-decoration: none; }
ul.stories a:hover { text-decoration: underline; }
ul.stories a.quiet { color: var(--muted); }
ul.stories .status { white-space: normal; }
.dialogue { display: flex; flex-direction: column; gap: 0.5rem; margin: 1rem 0; }
.dialogue .msg {
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  max-width: 85%;
  white-space: pre-wrap;
}
.dialogue .interviewer { background: rgba(128, 128, 128, 0.12); align-self: flex-start; }
.dialogue .candidate { background: rgba(47, 111, 79, 0.12); align-self: flex-end; }
#reply-form { flex-direction: column; align-items: stretch; }
.story-form { flex-direction: column; align-items: stretch; }
.story-form > label { display: flex; flex-direction: column; gap: 0.25rem; color: var(--muted); }
fieldset.competences {
  border: 1px solid rgba(128, 128, 128, 0.25);
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
}
fieldset.competences legend { color: var(--muted); padding: 0 0.3rem; }
label.comp { display: flex; gap: 0.35rem; align-items: baseline; white-space: nowrap; }
.accept-form { flex-direction: column; align-items: stretch; }
.accept-form .actions { display: flex; gap: 0.5rem; }
.decision-row { margin-top: 0.4rem; }
button.danger { background: #b3403a; }
button.undo { background: #3a6ea5; }

/* языковая секция: постановка с переносами из банка, редактор кода слева и
   условие справа, блоки ввода-вывода примеров и упавших тестов */
.statement { white-space: pre-line; line-height: 1.5; }
.card.wide { max-width: 64rem; }
.code-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}
/* на узком экране колонки в стопку: редактор над условием */
@media (max-width: 52rem) {
  .code-layout { grid-template-columns: 1fr; }
}
.editor-col, .task-col { min-width: 0; }
.task-col h2 { margin-top: 0; }
#code-form { flex-direction: column; align-items: stretch; margin: 0; }
pre.io {
  background: rgba(128, 128, 128, 0.12);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0.25rem 0 0.5rem;
}
pre.build-error { border-left: 3px solid #b3403a; }
.test-fail {
  border-left: 3px solid #b3403a;
  padding: 0.4rem 0.9rem;
  margin: 0.6rem 0;
  border-radius: 0 6px 6px 0;
}

/* редактор кода: textarea с прозрачным текстом поверх слоя <pre>, в котором
   тот же код разобран на токены и раскрашен. Оба слоя обязаны совпадать по
   метрикам (шрифт, кегль, интерлиньяж, отступы, перенос), иначе подсветка
   уползёт от букв. Свой набор цветов для светлой и тёмной темы. */
.editor {
  position: relative;
  height: 28rem;
  border: 1px solid var(--muted);
  border-radius: 6px;
  overflow: hidden;
  background: #fbfbf9;
}
.editor-hl,
.editor textarea {
  margin: 0;
  border: 0;
  position: absolute;
  inset: 0;
  padding: 0.6rem 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  tab-size: 4;
  white-space: pre;
  overflow: auto;
  word-wrap: normal;
}
.editor-hl { z-index: 1; pointer-events: none; color: #1a1a1a; }
.editor textarea {
  z-index: 2;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: #1a1a1a;
}
.c-kw { color: #a2258f; }
.c-typ { color: #1d5fbf; }
.c-str { color: #3a7d1e; }
.c-num { color: #b7601a; }
.c-com { color: #8a8a80; font-style: italic; }
@media (prefers-color-scheme: dark) {
  .editor { background: #1e1e21; }
  .editor-hl { color: #d6d6d6; }
  .editor textarea { caret-color: #d6d6d6; }
  .editor textarea::selection { background: #33384a; }
  .c-kw { color: #d08ad0; }
  .c-typ { color: #78b6ff; }
  .c-str { color: #9ed07a; }
  .c-num { color: #e0a060; }
  .c-com { color: #8a8a86; }
}
