/* ============================================================
   Диктант · тренажёр музыкального слуха
   Тема — единая с сайтом «Сольфеджио.онлайн» (с 1.06):
   сине-фиолетовый градиент, стеклянные карточки, виолет-акцент,
   золото #ffd166 — для волны и мелких акцентов.
   ============================================================ */
:root {
  --bg: #0d1024;
  --card: rgba(255, 255, 255, 0.055);
  --card-2: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.13);
  --text: #eef1ff;
  --muted: #9aa4cc;
  --accent: #a78bfa;
  --accent-2: #8b5cf6;
  --gold: #ffd166;
  --good: #4ade80;
  --bad: #fb7185;
  --warn: #fbbf24;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  background:
    radial-gradient(1100px 700px at 85% -10%, #2b2154 0%, transparent 60%),
    radial-gradient(900px 700px at -10% 110%, #123a52 0%, transparent 55%),
    linear-gradient(165deg, #0d1024, #191e3f);
  background-attachment: fixed;
  min-height: 100dvh;
}

/* ---------- Шапка приложения (под шапкой сайта) ---------- */
header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  position: sticky;
  top: 51px; /* сразу под шапкой сайта (10+30+10+1) */
  background: rgba(13, 16, 36, 0.72);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.logo {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.2px;
}

#levels { display: flex; gap: 8px; }

.level-chip {
  min-width: 36px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.level-chip:hover { border-color: var(--accent); }
.level-chip.active {
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
}
.level-chip.locked { opacity: 0.45; cursor: not-allowed; }

.stats { margin-left: auto; display: flex; gap: 14px; color: var(--muted); font-size: 14px; }

/* ---------- Основное ---------- */
main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 16px 80px;
}

/* Двухколоночная раскладка как на guido.study:
   слева плеер + проверка, справа стан + длительности + клавиши */
.layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 16px 18px;
}

.step-label {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}
.step-num {
  background: rgba(139, 92, 246, 0.16);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 8px;
  padding: 2px 9px;
  font-size: 13px;
  color: #c4b5fd;
  font-weight: 700;
}
.step-title { font-weight: 700; font-size: 16px; }

/* Мета */
.meta-title { font-size: 19px; font-weight: 700; }
.meta-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 6px; }
.chip {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 13px;
  color: var(--muted);
}
.meta-hint { color: var(--muted); font-size: 13px; }

/* ---------- Плеер ---------- */
.player-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.btn {
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s, filter 0.15s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.35);
}
.btn.primary:hover { filter: brightness(1.12); }
.btn.ghost { background: transparent; }
.btn.active { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

#audioStatus { color: var(--muted); font-size: 13px; }
.status-right { margin-left: auto; color: var(--muted); font-size: 13px; }
.player-hint { color: var(--muted); font-size: 13px; margin-top: 10px; }

/* Круглые кнопки плеера: плей строго по центру, тоника слева, скорость справа */
.player-center {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 64px;
  margin: 4px 0 12px;
}
.round-btn {
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.05s;
}
.round-btn:hover { border-color: var(--accent); }
.round-btn:active { transform: scale(0.95); }
.round-btn.play {
  width: 64px;
  height: 64px;
  background: var(--card);
  color: #c9d2ea;
  border: 1px solid rgba(255, 255, 255, 0.35);
  font-size: 22px;
  line-height: 1;
  z-index: 1;
}
.round-btn.play:hover { border-color: rgba(255, 255, 255, 0.55); color: #eef1ff; }
.round-btn.small { width: 40px; height: 40px; font-size: 10.5px; font-weight: 700; }
.round-btn.small.active { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
/* боковые кнопки прижаты к центру симметрично: 32px (радиус плей) + 14px зазор */
#tonicBtn {
  position: absolute;
  right: calc(50% + 46px);
  top: 50%;
  transform: translateY(-50%);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 17px;
  font-weight: 400;
}
#tonicBtn:active { transform: translateY(-50%) scale(0.95); }
#slowBtn {
  position: absolute;
  left: calc(50% + 46px);
  top: 50%;
  transform: translateY(-50%);
}
#slowBtn:active { transform: translateY(-50%) scale(0.95); }

/* Волна-таймлайн: без рамки, фон сливается с карточкой, сегменты-прямоугольники */
#wave {
  width: 100%;
  height: 60px;
  border: none;
  cursor: pointer;
  touch-action: none;
  display: block;
}
.player-time {
  display: flex;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.wave-hint { margin-left: auto; }

/* ---------- Стан ---------- */
#staff {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 12px;
  padding: 6px 4px;
  min-height: 160px;
  overflow-x: auto;
}

/* VexFlow рисует чёрным по умолчанию — перекрашиваем в светлый.
   Цвета ошибок заданы атрибутами fill/stroke — их возвращаем селекторами. */
#staff svg path, #staff svg text, #staff svg rect, #staff svg g {
  fill: #e9edf7;
  stroke: #e9edf7;
}
#staff svg [fill="#e5484d"] { fill: #fb7185; stroke: #fb7185; }
#staff svg [stroke="#e5484d"] { stroke: #fb7185; fill: #fb7185; }
#staff svg [fill="#f5a623"] { fill: #fbbf24; stroke: #fbbf24; }
#staff svg [stroke="#f5a623"] { stroke: #fbbf24; fill: #fbbf24; }
#staff svg [fill="#8b7cf7"] { fill: #c4b5fd; stroke: #c4b5fd; }
#staff svg [stroke="#8b7cf7"] { stroke: #c4b5fd; fill: #c4b5fd; }

.measure-cell {
  cursor: pointer;
  line-height: 0;
  border-radius: 8px;
  transition: background 0.12s;
}
#staff svg { display: block; }
.measure-cell:hover { background: rgba(139, 92, 246, 0.08); }
.measure-cell.current {
  background: rgba(139, 92, 246, 0.12);
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}
.measure-cell.answer { background: rgba(74, 222, 128, 0.05); }
.staff-warn { color: var(--warn); padding: 12px; }

#fillStatus { color: var(--muted); font-size: 13px; margin: 8px 2px; }

/* ---------- Длительности ---------- */
.durations-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
.dur-label { color: var(--muted); font-size: 13px; margin-right: 4px; }

.dur-btn {
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  min-width: 46px;
  padding: 8px 10px;
  font-size: 17px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dur-btn:hover { border-color: var(--accent); }
.dur-btn.active {
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  border-color: transparent;
  color: #fff;
}
.dur-btn.rest-btn { font-size: 20px; }
.durations-note { color: var(--muted); font-size: 12.5px; margin-top: 8px; }

/* ---------- Клавиатура ---------- */
#piano {
  position: relative;
  height: 150px;
  max-width: 600px;
  margin: 14px auto 0;
  user-select: none;
}
.key {
  position: absolute;
  top: 0;
  cursor: pointer;
  transition: background 0.08s, box-shadow 0.08s;
}
.key.white {
  background: linear-gradient(180deg, #f7f9fe 0%, #eef1f8 70%, #e2e7f2 100%);
  color: #23262e;
  height: 100%;
  border: 1px solid #262e3d;
  border-radius: 0 0 7px 7px;
  z-index: 1;
  box-shadow: inset 0 -10px 12px -8px rgba(13, 16, 36, 0.35);
}
.key.white:hover {
  background: #e4ddff;
  box-shadow: inset 0 -10px 12px -8px rgba(124, 58, 237, 0.4);
}
.key.black {
  background: linear-gradient(180deg, #232b40 0%, #141a28 100%);
  height: 63%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0 0 5px 5px;
  z-index: 2;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}
.key.black:hover { background: #2a3350; }
.key:active { background: var(--accent-2); }
.key:active .key-label { color: #fff; }
.key-label {
  position: absolute;
  bottom: 8px;
  left: 0; right: 0;
  text-align: center;
  font-size: 12px;
  color: #6b7280;
}
.edit-hint { color: var(--muted); font-size: 12.5px; margin-top: 6px; }

/* ---------- Результаты ---------- */
.result-head {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 12px;
}
.result-head.great { background: rgba(74, 222, 128, 0.1); }
.result-head.good  { background: rgba(74, 222, 128, 0.07); }
.result-head.mid   { background: rgba(251, 191, 36, 0.08); }
.result-head.bad   { background: rgba(251, 113, 133, 0.09); }

.score { font-size: 34px; font-weight: 800; }
.result-head.great .score, .result-head.good .score { color: var(--good); }
.result-head.mid .score { color: var(--warn); }
.result-head.bad .score { color: var(--bad); }
.verdict { font-weight: 700; }
.result-head .sub { color: var(--muted); font-size: 13px; }
.unlock { color: var(--gold); font-weight: 700; margin-top: 4px; }

.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 12.5px; }
.legend i {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 3px;
  margin-right: 5px;
}

/* ---------- Разное ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  background: #1a2033;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

#errline {
  color: var(--bad);
  font-size: 12.5px;
  padding: 4px 16px 14px;
  text-align: center;
  min-height: 18px;
}

.testbar {
  position: fixed;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 8px;
  z-index: 60;
}
.testbar button {
  background: #2a2140;
  color: #cdb9ff;
  border: 1px solid #4b3a77;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

footer {
  text-align: center;
  color: #6c76a3;
  font-size: 12.5px;
  padding: 22px 16px 30px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 26px;
}
footer a { color: var(--muted); }

/* ============================================================
   Шапка сайта «Сольфеджио.онлайн» (интеграция)
   Стили 1:1 с assets/style.css каркаса
   ============================================================ */
.site-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(13, 16, 36, 0.72);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.site-bar-in {
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 16.5px;
  letter-spacing: .3px;
}
.site-logo b { color: #ffd166; }
.site-mark {
  flex: none;
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: #fff;
  box-shadow: 0 4px 14px rgba(124,58,237,.35);
}
.site-nav { margin-left: auto; display: flex; gap: 6px; }
.site-nav a {
  color: #9aa4cc;
  text-decoration: none;
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 10px;
  transition: .2s;
}
.site-nav a:hover { color: var(--text); background: rgba(255,255,255,.06); }
.site-nav a.active { color: var(--text); background: rgba(139,92,246,.18); font-weight: 600; }

@media (max-width: 640px) {
  .site-bar-in { gap: 8px; padding: 9px 12px; }
  .site-logo { font-size: 15px; }
  .site-logo-text { display: none; }
  .site-nav { gap: 2px; }
  .site-nav a { padding: 7px 8px; font-size: 13px; }
  header { top: 49px; padding: 10px 14px; }
}
