:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e3e8f2;
  --text: #16203a;
  --text-soft: #5d6b8a;
  --accent: #2f5fe0;
  --accent-soft: #e8effd;
  --accent-strong: #1f47b8;
  --ok: #1c9c62;
  --ok-soft: #e4f6ec;
  --warn: #b7791f;
  --warn-soft: #fdf3e0;
  --danger: #cf3f4b;
  --danger-soft: #fdeaec;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(22, 32, 58, 0.07);
  --shadow-soft: 0 2px 10px rgba(22, 32, 58, 0.05);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: "Montserrat", "Segoe UI", Arial, sans-serif;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 0.4em;
}

h1 {
  font-size: 1.9rem;
}

h2 {
  font-size: 1.3rem;
}

h3 {
  font-size: 1.05rem;
}

p {
  margin: 0 0 0.8em;
  color: var(--text-soft);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-strong);
}

/* --- каркас --- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 26px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: -0.03em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.brand-text strong {
  font-weight: 800;
}

.brand-text small {
  color: var(--text-soft);
  font-weight: 600;
  font-size: 0.78rem;
}

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

.page {
  flex: 1;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 26px 40px;
}

.footer {
  padding: 18px 26px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.8rem;
}

/* --- элементы --- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 22px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease, color 0.15s ease;
}

.btn:hover {
  background: var(--accent-strong);
  color: #fff;
}

.btn:active {
  transform: translateY(1px);
}

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

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--accent-soft);
  border-color: var(--accent-soft);
  color: var(--accent-strong);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

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

.btn-sm {
  padding: 7px 12px;
  font-size: 0.8rem;
  border-radius: 10px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
}

textarea {
  resize: vertical;
  font-family: "SFMono-Regular", "JetBrains Mono", Consolas, monospace;
  font-weight: 500;
  line-height: 1.55;
}

select:disabled {
  color: var(--text-soft);
  background: var(--surface-muted);
  cursor: not-allowed;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

label.field {
  display: block;
  margin-bottom: 14px;
}

label.field span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  color: var(--text-soft);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  background: var(--surface-muted);
  color: var(--text-soft);
}

.chip-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.chip-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.chip-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.chip-accent {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.88rem;
  margin-bottom: 16px;
}

.alert-info {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.muted {
  color: var(--text-soft);
  font-size: 0.85rem;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

/* --- вход ученика --- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 26px;
  align-items: start;
}

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

.hero-card {
  padding: 32px;
}

.hero-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.hero-list li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.hero-list b {
  display: grid;
  place-items: center;
  flex: 0 0 26px;
  height: 26px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.8rem;
}

/* --- ожидание --- */

#waiting-view {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.wait-wrap {
  max-width: 620px;
  margin: 6vh auto 0;
  text-align: center;
}

.wait-card {
  padding: 34px;
}

.pulse {
  width: 74px;
  height: 74px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 1.6rem;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(47, 95, 224, 0.25);
  }
  50% {
    box-shadow: 0 0 0 14px rgba(47, 95, 224, 0);
  }
}

.queue-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
  margin-bottom: 6px;
}

.queue-badge strong {
  font-size: 1.6rem;
}

/* --- полноэкранная панель ученика --- */

body.panel-mode {
  overflow: hidden;
}

.panel-shell {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  background: #fff;
  z-index: 50;
}

.panel-shell.active {
  display: flex;
}

.panel-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.panel-bar .who {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}

.panel-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #ebecec;
}

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

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

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

.robot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

.robot-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.robot-card.busy {
  border-color: #c9d8fb;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.robot-card.offline {
  opacity: 0.75;
}

.robot-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.robot-head h3 {
  margin: 0;
}

.robot-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.robot-occupant {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  font-size: 0.85rem;
}

.robot-occupant.empty {
  color: var(--text-soft);
}

.robot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.assign-row {
  display: flex;
  gap: 8px;
}

.assign-row select {
  flex: 1;
  padding: 8px 10px;
  font-size: 0.82rem;
  border-radius: 10px;
}

.preview {
  position: relative;
  height: 168px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  background: #ebecec;
}

.preview iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 1440px;
  height: 900px;
  border: 0;
  transform: scale(0.2);
  transform-origin: top left;
  pointer-events: none;
}

.preview .preview-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-soft);
  font-size: 0.78rem;
  text-align: center;
  padding: 10px;
}

.queue-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.queue-item .who {
  display: flex;
  flex-direction: column;
}

.queue-item .who strong {
  font-weight: 700;
}

.queue-item.offline {
  opacity: 0.6;
}

.queue-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.queue-actions select {
  padding: 7px 10px;
  font-size: 0.8rem;
  border-radius: 10px;
  max-width: 190px;
}

.empty-state {
  padding: 22px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  color: var(--text-soft);
  font-size: 0.86rem;
}

/* --- запуск кода --- */

.run-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

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

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-muted);
  border-radius: 12px;
  margin-bottom: 14px;
}

.tab {
  padding: 8px 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.84rem;
  color: var(--text-soft);
  cursor: pointer;
}

.tab.active {
  background: var(--surface);
  color: var(--accent-strong);
  box-shadow: var(--shadow-soft);
}

.robot-picks {
  display: grid;
  gap: 8px;
}

.robot-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.88rem;
}

.robot-pick input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.robot-pick.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.result {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--surface);
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.result pre {
  margin: 6px 0 0;
  padding: 10px 12px;
  background: var(--surface-muted);
  border-radius: 10px;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow: auto;
}

.result pre.err {
  background: var(--danger-soft);
  color: var(--danger);
}

.code-hint {
  font-size: 0.8rem;
  color: var(--text-soft);
}

.code-hint code {
  background: var(--surface-muted);
  padding: 1px 5px;
  border-radius: 6px;
  font-size: 0.78rem;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: -4px 0 12px;
}

/* --- вход учителя --- */

.login-wrap {
  max-width: 380px;
  margin: 10vh auto 0;
}

/* --- ошибка --- */

.error-wrap {
  max-width: 520px;
  margin: 8vh auto 0;
  text-align: center;
}

.error-code {
  font-size: 3.4rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

/* --- камера в углу --- */

.camera-dock {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  width: min(300px, calc(100vw - 24px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.camera-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px 8px 14px;
  font-size: 0.78rem;
  font-weight: 700;
}

.camera-toggle {
  border: 0;
  background: var(--surface-muted);
  color: var(--text-soft);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.72rem;
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
}

.camera-body {
  position: relative;
  background: #0f1728;
  aspect-ratio: 16 / 10;
}

.camera-dock.collapsed .camera-body {
  display: none;
}

.camera-frame {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-error {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.8rem;
  background: rgba(15, 23, 40, 0.72);
}
