:root {
  --bg: #0f1319;
  --surface: #171d26;
  --surface-2: #1f2734;
  --border: #2a3446;
  --text: #e6ebf2;
  --muted: #93a0b4;
  --primary: #4f8cff;
  --primary-dark: #3a6fd8;
  --danger: #ff5f5f;
  --ok: #43d17c;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}

h1 {
  font-size: 24px;
  margin: 0 0 8px;
}

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

.small {
  font-size: 13px;
}

.hidden,
[hidden] {
  display: none !important;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card--center {
  text-align: center;
  margin-top: 12vh;
}

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

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  min-height: 50px;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

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

.btn--primary:not(:disabled):active {
  background: var(--primary-dark);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
  font-weight: 500;
}

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

.btn--record,
.btn--stop {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 18px;
  font-size: 18px;
}

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

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

.btn--record .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
}

.btn--stop .square {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: #fff;
}

.linkbtn {
  background: none;
  border: none;
  color: var(--primary);
  font: inherit;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}

.row {
  display: flex;
  gap: 10px;
}

.row .btn {
  flex: 1;
}

/* ------------------------------------------------------------- ввод кода */

#token-form {
  margin-top: 20px;
  display: grid;
  gap: 12px;
}

.token-input {
  width: 100%;
  padding: 16px;
  font-size: 26px;
  letter-spacing: 6px;
  text-align: center;
  text-transform: uppercase;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.token-input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

/* -------------------------------------------------------------- прогресс */

.topbar {
  margin-bottom: 12px;
}

.topbar__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}

.progress-label {
  font-weight: 600;
}

.progress {
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  width: 0;
  background: var(--primary);
  transition: width 0.25s;
}

.qnav {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.qnav .btn {
  min-height: 42px;
  padding: 8px 14px;
  font-size: 14px;
}

/* --------------------------------------------------------------- вопрос */

.banner {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
}

.banner .linkbtn {
  display: block;
  margin-top: 6px;
}

.question-number {
  margin: 0 0 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.question-text {
  margin: 0 0 24px;
  font-size: 20px;
  line-height: 1.4;
  /* Вопросы бывают в несколько абзацев — переносы должны сохраняться. */
  white-space: pre-wrap;
}

.rec {
  display: grid;
  gap: 12px;
}

.player {
  width: 100%;
}

/* ------------------------------------------------------- части ответа */

.parts {
  display: grid;
  gap: 8px;
}

.part {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
}

.part__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.part__name {
  font-size: 14px;
  font-weight: 600;
}

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

.part .player {
  margin-top: 10px;
}

.part .btn {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 14px;
}

/* --------------------------------------------------------- индикатор звука */

.meter {
  height: 10px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.meter__bar {
  height: 100%;
  width: 0;
  background: var(--ok);
  transition: width 0.08s linear;
}

.timer {
  margin: 0;
  text-align: center;
  font-size: 34px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* --------------------------------------------------------------- статусы */

.error {
  margin: 16px 0 0;
  padding: 12px;
  border-radius: 10px;
  background: rgba(255, 95, 95, 0.12);
  border: 1px solid rgba(255, 95, 95, 0.35);
  color: #ffb4b4;
  font-size: 14px;
}

.ok {
  margin: 0;
  color: var(--ok);
  font-weight: 600;
}

/* Предупреждение под кнопкой записи, когда не удалось удержать экран. */
.warn {
  color: #ffcc66;
  font-weight: 600;
}

.uploading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--muted);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.bigcheck {
  font-size: 56px;
  color: var(--ok);
  margin: 0 0 8px;
}

.footer {
  margin-top: 16px;
}

/* ---------------------------------------------------------------- админка */

.admin {
  max-width: 900px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tabs .btn {
  min-height: 40px;
  padding: 8px 16px;
  font-size: 14px;
}

.tabs .btn[aria-selected="true"] {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
}

.qrow {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.qrow textarea {
  flex: 1;
  min-height: 62px;
  resize: vertical;
  padding: 10px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.qrow__tools {
  display: grid;
  gap: 4px;
}

.iconbtn {
  width: 34px;
  height: 28px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}

.iconbtn:hover:not(:disabled) {
  color: var(--text);
}

.iconbtn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 500;
  font-size: 13px;
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  letter-spacing: 2px;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--surface-2);
  color: var(--muted);
}

.tag--ok {
  background: rgba(67, 209, 124, 0.15);
  color: var(--ok);
}

.tag--off {
  background: rgba(255, 95, 95, 0.15);
  color: #ffb4b4;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field input,
.text-input {
  padding: 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.stack {
  display: grid;
  gap: 16px;
}

.answer {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: var(--surface-2);
}

.answer h3 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
  white-space: pre-wrap;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

@media (max-width: 520px) {
  .admin table,
  .admin thead,
  .admin tbody,
  .admin tr,
  .admin td,
  .admin th {
    display: block;
  }

  .admin thead {
    display: none;
  }

  .admin tr {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    margin-bottom: 10px;
  }

  .admin td {
    border: none;
    padding: 4px 6px;
  }
}

/* Переключатель «общий код» в панели выдачи. */
.checkline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
}

.checkline input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.tag--shared {
  background: rgba(79, 140, 255, 0.18);
  color: #9cc0ff;
}

/* ------------------------------------------------------ фото и видео */

.files {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.files__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.files__title {
  font-weight: 600;
}

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

.files__list:empty {
  display: none;
}

/* Ярлык поверх скрытого input: на телефоне открывает камеру или галерею. */
.files__add {
  display: block;
  text-align: center;
  cursor: pointer;
}

.files__add.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.files__camera {
  display: flex;
  gap: 10px;
}

.files__camera > .files__add {
  flex: 1;
}

/* display у этих блоков задан явно и перебивает атрибут hidden: без этого
   правила кнопки оставались бы на месте, когда их надо спрятать. */
.files__camera[hidden],
.files__add[hidden] {
  display: none;
}

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

/* Ограничение по высоте: снимок с телефона иначе занимает весь экран,
   и до кнопок под ним приходится прокручивать. */
.files__view {
  display: block;
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
  margin-top: 10px;
  border-radius: 10px;
  background: var(--bg);
}

/* --------------------------------------------- вопросы с вариантами */

.qgroup {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.impact {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--primary);
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
}

.qref {
  margin: 8px 0 0;
}

.materials {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.materials a {
  flex: 1 1 100%;
  text-align: center;
  text-decoration: none;
}

/* Раскрывающийся блок легко принять за обычный текст и не тронуть.
   Поэтому он выглядит как кнопка: рамка, стрелка, отступы под палец. */
.why {
  margin-top: 12px;
}

.why summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--primary);
  user-select: none;
}

.why summary::-webkit-details-marker {
  display: none;
}

.why summary::before {
  content: '▸';
  display: inline-block;
  transition: transform 0.15s;
}

.why[open] summary::before {
  transform: rotate(90deg);
}

.why summary:hover {
  border-color: var(--primary);
}

.why p {
  margin: 10px 2px 0;
  color: var(--muted);
}

.warn {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

/* Единственный вопрос, где неверный ответ стоит переделки, а не денег.
   Поэтому он и выделен цветом — остальные предупреждения обычные. */
.warn--critical {
  border-color: var(--danger);
  color: var(--text);
}

.pick {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

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

.option--picked {
  border-color: var(--primary);
  background: rgba(79, 140, 255, 0.12);
}

.option__mark {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  border: 2px solid var(--border);
  border-radius: 50%;
}

.option--picked .option__mark {
  border-color: var(--primary);
  background:
    radial-gradient(circle at center, var(--primary) 0 5px, transparent 6px);
}

.option__label {
  flex: 1;
}

.pick__number {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pick__input {
  flex: 1 1 120px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

.pick__unit {
  flex: none;
}

.response {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.response__value {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

/* Вопрос в списке-оглавлении: по ввезённой анкете к нему можно перейти. */
.answer--clickable {
  cursor: pointer;
}

.answer--clickable:hover {
  border-color: var(--primary);
}
