:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --panel: #ffffff;
  --text: #17212b;
  --muted: #647184;
  --line: #d8e0e8;
  --blue: #2367b1;
  --green: #16845b;
  --red: #d5222f;
  --red-dark: #99131d;
  --yellow: #b97610;
  --shadow: 0 18px 45px rgba(32, 43, 56, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

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

h1 {
  font-size: 32px;
  line-height: 1.15;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 16px;
}

.home-layout,
.app-layout {
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0;
}

.home-layout {
  display: grid;
  place-items: center;
}

.home-panel {
  display: grid;
  gap: 22px;
  width: 100%;
}

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

.role-link {
  display: grid;
  gap: 8px;
  min-height: 150px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 20px;
  text-decoration: none;
}

.role-link span {
  font-size: 24px;
  font-weight: 900;
}

.role-link small,
.muted,
.hint {
  color: var(--muted);
}

.private-role {
  border-color: #c6d7ea;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-pill {
  min-width: 132px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.status-pill[data-state="ok"] {
  border-color: #b9e0cf;
  background: #edf9f3;
  color: var(--green);
}

.status-pill[data-state="live"] {
  border-color: #f0c1c5;
  background: #fff1f2;
  color: var(--red-dark);
}

.status-pill[data-state="pending"] {
  border-color: #f0d59f;
  background: #fff8e8;
  color: var(--yellow);
}

.status-pill[data-state="error"] {
  border-color: #f0c1c5;
  background: #fff1f2;
  color: var(--red-dark);
}

.join-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.join-panel .hint,
.join-panel .muted {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  background: var(--panel);
  color: var(--text);
}

.primary-button {
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #ffffff;
  cursor: pointer;
  font-weight: 900;
  padding: 14px 18px;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.radio-stage {
  display: grid;
  place-items: center;
  gap: 24px;
  min-height: 58vh;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #eef3f7);
  box-shadow: var(--shadow);
  padding: 32px;
}

.instructor-dashboard {
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(420px, 1.18fr);
  gap: 18px;
  align-items: start;
}

.compact-radio {
  min-height: 620px;
}

.instructor-ptt {
  width: clamp(210px, 24vw, 290px);
}

.radio-stage.disabled {
  opacity: 0.62;
}

.channel-info {
  display: grid;
  gap: 8px;
  text-align: center;
}

.ptt-button {
  display: grid;
  place-items: center;
  gap: 14px;
  width: clamp(220px, 34vw, 330px);
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #ff6a73, var(--red) 48%, var(--red-dark));
  color: #ffffff;
  box-shadow: 0 22px 0 #711019, 0 32px 42px rgba(120, 18, 25, 0.3);
  cursor: pointer;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0;
  text-align: center;
  user-select: none;
}

.ptt-button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.4);
}

.ptt-button:active,
.is-transmitting .ptt-button {
  transform: translateY(12px);
  box-shadow: 0 10px 0 #711019, 0 18px 30px rgba(120, 18, 25, 0.34);
}

.ptt-light {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.78);
}

.is-transmitting .ptt-light {
  background: #fff1a8;
  box-shadow: 0 0 28px rgba(255, 241, 168, 0.9);
}

.transmit-state {
  min-width: 180px;
  border-radius: 999px;
  padding: 12px 18px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 900;
  text-align: center;
}

.is-transmitting .transmit-state {
  color: var(--green);
}

.audio-meter {
  display: grid;
  gap: 10px;
  width: min(100%, 320px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  padding: 12px;
}

.meter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.meter-header strong {
  color: var(--text);
}

.meter-track {
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ebf1;
}

.meter-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), #e0a51c, var(--red));
  transition: width 80ms linear;
}

.help-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.compact-panel {
  display: grid;
  gap: 4px;
  align-content: center;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px 16px;
}

.roster-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

.compact-count {
  display: grid;
  justify-items: end;
}

.student-list {
  display: grid;
}

.student-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
}

.student-row:last-child {
  border-bottom: 0;
}

.student-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #eef3f7;
  color: var(--blue);
  font-weight: 900;
}

.live-text {
  color: var(--green);
  font-weight: 800;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.secondary-button,
.danger-button {
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  padding: 10px 12px;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
}

.danger-button {
  border: 1px solid #efb8bd;
  background: #fff1f2;
  color: var(--red-dark);
}

.empty-state {
  color: var(--muted);
  padding: 18px;
}

.metric {
  color: var(--text);
  font-size: 28px;
  font-weight: 900;
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .home-layout,
  .app-layout {
    width: min(100% - 20px, 1120px);
    padding: 12px 0;
  }

  .topbar,
  .join-panel {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .role-grid,
  .help-row,
  .instructor-dashboard {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 26px;
  }

  .radio-stage {
    min-height: 54vh;
    padding: 24px 14px;
  }

  .ptt-button {
    width: min(72vw, 280px);
    font-size: 19px;
  }

  .student-row,
  .panel-title {
    align-items: stretch;
    flex-direction: column;
  }

  .row-actions {
    justify-content: stretch;
  }

  .row-actions button {
    flex: 1;
  }
}
