:root {
  --ink: #20242a;
  --paper: #edf7f4;
  --panel: #fffdf8;
  --acid: #d8f5a2;
  --blue: #b8d7ff;
  --pink: #f6b6d5;
  --orange: #ffd38a;
  --green: #a8e6c1;
  --lavender: #d8cdfa;
  --muted: #5f6b73;
  --line: 3px solid var(--ink);
  --shadow: 8px 8px 0 var(--ink);
  --soft-shadow: 5px 5px 0 var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(32, 36, 42, 0.055) 1px, transparent 1px),
    linear-gradient(rgba(32, 36, 42, 0.055) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 12px;
  border: var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  min-width: 190px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: var(--line);
  background: var(--acid);
  font-weight: 950;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.kicker,
.panel-header span,
.timer-note {
  color: var(--muted);
  font-size: 0.82rem;
}

.main-nav,
.role-switch,
.top-actions,
.auth-box,
.feed-tabs,
.toolbar,
.hero-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.main-nav {
  justify-content: center;
}

.main-nav a,
.role-button,
.feed-tab,
.primary-action,
.secondary-action,
select,
input {
  border: var(--line);
  color: var(--ink);
  background: var(--panel);
  text-decoration: none;
  font-weight: 850;
}

.main-nav a {
  padding: 10px 12px;
}

.main-nav a.active,
.role-button.active,
.feed-tab.active {
  background: var(--blue);
  box-shadow: 4px 4px 0 var(--ink);
}

.role-button,
.feed-tab,
.primary-action,
.secondary-action {
  min-height: 42px;
  padding: 9px 13px;
}

.compact {
  min-height: 36px;
  padding: 7px 10px;
}

.top-actions {
  justify-content: flex-end;
}

.auth-box {
  padding-left: 10px;
  border-left: 3px solid var(--ink);
}

.auth-box span {
  max-width: 180px;
  font-size: 0.82rem;
  font-weight: 900;
}

.hidden {
  display: none !important;
}

.primary-action {
  background: var(--acid);
  box-shadow: var(--soft-shadow);
}

.secondary-action {
  background: var(--panel);
  box-shadow: 4px 4px 0 var(--ink);
}

.danger {
  background: #ffb4a2;
}

.full {
  width: 100%;
}

.hero-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: end;
  margin: 28px 0 22px;
  padding: 28px;
  border: var(--line);
  background: var(--orange);
  box-shadow: var(--shadow);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 820px;
  margin-bottom: 12px;
  font-size: clamp(2.2rem, 6vw, 5rem);
  line-height: 0.94;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 3vw, 2.8rem);
}

h3 {
  margin-bottom: 10px;
}

.hero-copy {
  max-width: 760px;
  margin-bottom: 0;
  font-size: 1.08rem;
  line-height: 1.45;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin: 26px 0 14px;
}

.search-box {
  display: grid;
  gap: 4px;
  font-weight: 850;
}

input,
select,
textarea {
  padding: 10px 12px;
  min-height: 42px;
}

.priority-strip {
  display: none;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px;
  border: var(--line);
  background: var(--lavender);
  box-shadow: var(--soft-shadow);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 18px;
}

.side-panel,
.feed-panel,
.session-panel,
.archive-item,
.rules-board {
  border: var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.side-panel,
.feed-panel,
.session-panel,
.rules-board {
  padding: 16px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.teacher-list,
.feed,
.archive-grid,
.metrics-grid {
  display: grid;
  gap: 14px;
}

.teacher-card,
.request-card,
.topic-card,
.slot-card {
  border: var(--line);
  background: var(--panel);
  padding: 14px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.teacher-card:hover,
.request-card:hover,
.topic-card:hover,
.slot-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--soft-shadow);
}

.teacher-card header,
.card-top,
.card-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.tag,
.status-pill,
.level-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border: 2px solid var(--ink);
  background: var(--acid);
  font-size: 0.78rem;
  font-weight: 900;
}

.level-pill {
  background: var(--blue);
}

.status-pill {
  background: var(--orange);
}

.status-pill.success {
  background: var(--green);
}

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

.request-card h3,
.topic-card h3,
.slot-card h3 {
  margin-bottom: 8px;
}

.request-card p,
.topic-card p,
.slot-card p,
.teacher-card p {
  margin-bottom: 10px;
  line-height: 1.45;
}

.feed-tabs {
  margin-bottom: 14px;
}

.session-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
}

.open-sessions {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.open-session-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: var(--line);
  background: var(--lavender);
  box-shadow: var(--soft-shadow);
}

.video-stage {
  position: relative;
  min-height: 580px;
  border: var(--line);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0)),
    #dceae8;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.live-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.live-video,
.local-video {
  overflow: hidden;
}

.video-placeholder {
  position: absolute;
  inset: 18px;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  pointer-events: none;
}

.main-video.has-stream .video-placeholder {
  display: none;
}

.video-tile {
  border: var(--line);
  background: var(--panel);
  padding: 18px;
}

.video-tile span,
.video-tile strong {
  display: block;
}

.main-video {
  position: absolute;
  inset: 24px;
  display: grid;
  align-content: center;
  min-height: 300px;
  background: #eaf2ff;
}

.main-video strong {
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1;
}

.floating-video {
  position: absolute;
  right: 36px;
  bottom: 36px;
  width: min(260px, 42%);
  background: var(--acid);
  box-shadow: var(--soft-shadow);
}

.local-video video {
  min-height: 120px;
  background: var(--panel);
}

#remoteAudio {
  display: none;
}

.session-controls,
.teacher-permissions,
.chat-form {
  display: grid;
  gap: 10px;
}

.session-controls {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 14px 0;
}

.session-controls button {
  transition: transform 0.12s ease, background 0.12s ease, opacity 0.12s ease;
}

.session-controls button.media-off {
  background: #ffb4a2;
}

.session-controls button.media-on {
  background: var(--green);
}

.session-controls button.media-blocked {
  background: #c9cdd1;
  opacity: 0.72;
}

.teacher-permissions {
  margin-bottom: 14px;
  padding: 10px;
  border: 2px solid var(--ink);
  background: var(--lavender);
}

.teacher-permissions.hidden {
  display: none;
}

.live-chat {
  min-height: 220px;
  max-height: 320px;
  overflow: auto;
  align-content: start;
}

.chat-message {
  padding: 8px;
  border: 2px solid var(--ink);
  background: var(--panel);
}

.chat-message.mine {
  background: var(--acid);
}

.chat-message img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  margin-top: 8px;
  border: 2px solid var(--ink);
}

.chat-form {
  grid-template-columns: minmax(0, 1fr);
}

.final-warning {
  position: absolute;
  left: 36px;
  right: 36px;
  bottom: 36px;
  width: fit-content;
  max-width: calc(100% - 72px);
  padding: 12px 14px;
  border: var(--line);
  background: var(--orange);
  font-weight: 950;
  box-shadow: var(--soft-shadow);
}

.timer {
  border: var(--line);
  background: var(--green);
  padding: 18px;
  font-size: clamp(2.6rem, 8vw, 4.6rem);
  line-height: 1;
  font-weight: 950;
  text-align: center;
}

.chat-box {
  display: grid;
  gap: 10px;
  margin: 16px 0;
  padding: 12px;
  border: var(--line);
  background: #f5f8ef;
}

pre {
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 2px solid var(--ink);
  background: #24313a;
  color: #fbfaf4;
}

code {
  font-family: "JetBrains Mono", Consolas, monospace;
}

.archive-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.archive-item {
  padding: 18px;
}

.metrics-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card {
  min-height: 150px;
  padding: 16px;
  border: var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card.hot {
  background: var(--acid);
}

.metric-card span {
  display: block;
  margin-bottom: 16px;
  font-size: clamp(2.2rem, 5vw, 4.5rem);
  line-height: 0.9;
  font-weight: 950;
}

.rules-board {
  margin-top: 18px;
}

.rules-table {
  display: grid;
  gap: 8px;
}

.rule-row {
  display: grid;
  grid-template-columns: 90px repeat(4, 1fr);
  gap: 8px;
  align-items: center;
}

.rule-row > * {
  min-height: 42px;
  padding: 9px;
  border: 2px solid var(--ink);
  background: #f7f1ff;
  font-weight: 800;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(32, 36, 42, 0.34);
}

.modal-root.active {
  display: grid;
}

.modal {
  width: min(860px, 100%);
  max-height: min(86vh, 900px);
  overflow: auto;
  border: var(--line);
  background: var(--panel);
  box-shadow: 12px 12px 0 var(--ink);
}

.modal header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-bottom: var(--line);
  background: var(--acid);
}

.modal-body {
  padding: 16px;
}

.close-button {
  width: 40px;
  height: 40px;
  border: var(--line);
  background: var(--panel);
  font-weight: 950;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  font-weight: 900;
}

textarea {
  min-height: 92px;
  resize: vertical;
  border: var(--line);
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.checkbox-line {
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 850;
}

.checkbox-line input {
  width: 22px;
  height: 22px;
  min-height: auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  display: none;
  max-width: 360px;
  padding: 14px;
  border: var(--line);
  background: var(--acid);
  box-shadow: var(--shadow);
  font-weight: 900;
}

.toast.active {
  display: block;
}

@media (max-width: 980px) {
  .topbar,
  .hero-band,
  .dashboard-grid,
  .session-layout,
  .archive-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .main-nav {
    justify-content: flex-start;
  }

  .section-heading,
  .priority-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .side-panel {
    order: 2;
  }

  .rule-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 10px;
  }

  .hero-band,
  .side-panel,
  .feed-panel,
  .session-panel,
  .rules-board {
    padding: 12px;
  }

  .topbar {
    top: 0;
  }

  .brand {
    min-width: 0;
  }

  .main-nav a,
  .role-button,
  .feed-tab,
  .primary-action,
  .secondary-action {
    width: 100%;
    text-align: center;
  }

  .toolbar,
  .role-switch,
  .top-actions,
  .auth-box,
  .hero-actions {
    width: 100%;
  }

  .toolbar > *,
  .auth-box > *,
  .hero-actions > * {
    width: 100%;
  }

  .auth-box {
    padding-left: 0;
    border-left: 0;
  }

  .video-stage {
    min-height: 460px;
  }
}
