:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #1a2035;
  --muted: #6b7590;
  --line: #e3e7f0;
  --accent: #5b57d9;
  --accent-2: #7c5cf0;
  --ok: #1f9d63;
  --warn: #b97614;
  --danger: #c8384a;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.site { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 22px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .2px; }
.brand span { color: var(--accent); }

.page { width: min(980px, 100% - 32px); margin: 26px auto; flex: 1; }
.page-narrow { width: min(520px, 100% - 32px); }

footer { text-align: center; color: var(--muted); font-size: 13px; padding: 18px 0 26px; }

h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: -.3px; }
h2 { font-size: 18px; margin: 0 0 10px; }
p { margin: 0 0 10px; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
  box-shadow: 0 1px 2px rgba(20, 30, 60, .04);
}
.panel + .panel { margin-top: 18px; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }

button, .button {
  font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid transparent;
  padding: 9px 14px; background: var(--accent); color: #fff; font-weight: 600;
  transition: filter .15s ease, background .15s ease;
}
button:hover:not(:disabled) { filter: brightness(1.07); }
button:disabled { opacity: .5; cursor: default; }
button.secondary { background: #eef0f8; color: var(--text); }
button.ghost { background: transparent; color: var(--accent); border-color: var(--line); padding: 6px 10px; font-weight: 500; }
button.ghost.danger { color: var(--danger); }
button.small { padding: 5px 9px; font-size: 13px; }

input, textarea {
  font: inherit; width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: #fbfbfe; color: var(--text);
}
input:focus, textarea:focus { outline: 2px solid #c9c6ff; outline-offset: 1px; }
textarea { min-height: 110px; resize: vertical; }

label { font-size: 14px; font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }

.error-box {
  background: #fff0f2; border: 1px solid #f3c7ce; color: var(--danger);
  padding: 10px 12px; border-radius: 10px; font-size: 14px;
}
.ok-box { background: #eefaf3; border: 1px solid #bfe8d3; color: var(--ok); padding: 10px 12px; border-radius: 10px; font-size: 14px; }

.stats { display: flex; gap: 14px; flex-wrap: wrap; margin: 14px 0 18px; }
.stat { background: #f4f5fb; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; min-width: 130px; }
.stat strong { display: block; font-size: 20px; }
.stat span { color: var(--muted); font-size: 13px; }

.students { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.student {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: #fdfdff;
}
.student.in-lesson { border-color: #cfc9ff; background: #f7f6ff; }
.student .who { flex: 1; min-width: 0; }
.student .who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.student .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.student input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #eef0f8; color: var(--muted); }
.chip.on { background: #e6f7ee; color: var(--ok); }
.chip.off { background: #f1f2f7; color: var(--muted); }
.chip.warn { background: #fdf3e2; color: var(--warn); }

.empty { text-align: center; color: var(--muted); padding: 26px 10px; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(10px);
  background: #1a2035; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
  max-width: min(90vw, 480px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

.hero { text-align: center; padding: 40px 20px; }
.hero .logo { font-size: 42px; margin-bottom: 10px; }
.hero h1 { font-size: 30px; }
.hero .actions { display: flex; gap: 10px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }

.divider { height: 1px; background: var(--line); margin: 18px 0; }
.hint { color: var(--muted); font-size: 13px; }

@media (max-width: 620px) {
  .page { width: calc(100% - 22px); margin: 16px auto; }
  .panel { padding: 16px; }
  .student { flex-wrap: wrap; }
  .student .actions { width: 100%; justify-content: flex-start; }
}

/* ------------------------------------------------------------ audio: общее */

.warn-btn {
  background: #f0a11a; color: #23180a;
}
.warn-btn.wide { width: 100%; }

.student { align-items: center; }
.student .pick { flex: 0 0 auto; display: flex; align-items: center; }
.student.speaking { border-color: #9de3bd; background: #f6fffa; }

.avatar {
  position: relative;
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #eceafe;
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  overflow: hidden;
}
.avatar .ini { position: relative; z-index: 1; }
.avatar .lvl {
  position: absolute; left: 0; right: 0; bottom: 0; height: 5px;
  background: #e2e0fb;
}
.avatar .lvl i {
  display: block; height: 100%; width: 0;
  background: var(--ok);
  transition: width .12s linear;
}
.student.speaking .avatar { box-shadow: 0 0 0 3px #c8f2dc; }

.chip.hand {
  border: 1px solid #f0d5a8;
  background: #fff6e6;
  color: #a5640a;
  cursor: pointer;
  font-family: inherit;
}
.chip.talk { background: #efe9ff; color: var(--accent); }

.student .vol {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px;
}
.student .vol input[type="range"] {
  width: 84px; padding: 0; accent-color: var(--accent); background: transparent;
}

button.ghost.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* --------------------------------------------------------- панель урока */

.lesson-bar {
  display: flex; flex-direction: column; gap: 10px;
  background: #f7f6ff; border: 1px solid #ded9ff;
  border-radius: 12px; padding: 12px 14px;
}
.lesson-state { display: flex; align-items: center; gap: 8px; }
.lesson-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.lesson-controls button { padding: 8px 12px; }
.dot {
  width: 9px; height: 9px; border-radius: 50%; background: #b9bdd0; display: inline-block;
}
.dot.live { background: var(--ok); box-shadow: 0 0 0 3px rgba(31, 157, 99, .18); }
.mic-meter {
  height: 6px; border-radius: 3px; background: #e6e3fa; overflow: hidden;
}
.mic-meter i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, #7c5cf0, #1f9d63);
  transition: width .12s linear;
}

.diag .row { align-items: flex-start; }

/* --------------------------------------------------------------- ученик */

.student-state {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; background: #fbfbff;
}
.student-state.personal { border-color: #cfc9ff; background: #f6f4ff; }
.ss-dot {
  width: 40px; height: 40px; border-radius: 50%;
  background: #eef0f8; display: flex; align-items: center; justify-content: center;
}
.t-speaking {
  width: 14px; height: 14px; border-radius: 50%;
  background: #c9cddd; display: inline-block;
  transition: background .15s, box-shadow .15s;
}
.t-speaking.on { background: var(--ok); box-shadow: 0 0 0 5px rgba(31, 157, 99, .16); }

.student-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.student-actions button { width: 100%; padding: 12px; }
button.hand-on { background: #f0a11a; color: #23180a; }
button.wide { width: 100%; }

/* -------------------------------------------------------------- мини-пульт */

.mini-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.mini-list { display: flex; flex-direction: column; gap: 5px; max-height: 190px; overflow: auto; }
.mini-st {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: #fff; color: var(--text); border: 1px solid var(--line);
  border-radius: 9px; padding: 7px 9px; font-weight: 500; font-size: 13px; text-align: left;
}
.mini-st .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-st.talking { border-color: var(--accent); background: #f3f1ff; }
.mini-st .hh { color: #a5640a; }
.mini-foot { display: flex; gap: 6px; margin-top: 9px; }
.mini-foot button { flex: 1; padding: 8px 6px; font-size: 13px; }
