:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --panel-soft: #fafafa;
  --ink: #14161a;
  --muted: #667085;
  --line: #d7dce2;
  --line-soft: #eceff3;
  --gold: #9a7118;
  --gold-dark: #755411;
  --green: #157347;
  --blue: #2364aa;
  --red: #b3261e;
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter,
    "Segoe UI",
    Arial,
    Helvetica,
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-weight: 750;
  padding: 10px 15px;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

button:hover {
  background: #2a2f38;
  box-shadow: 0 6px 16px rgba(16, 24, 40, 0.12);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(35, 100, 170, 0.18);
  outline-offset: 2px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(177, 138, 44, 0.28);
  background: #111;
  color: #fff;
  padding: 14px 22px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 9px;
  color: inherit;
  text-decoration: none;
}

.brand span {
  color: var(--gold);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0;
}

.brand strong {
  font-size: 18px;
}

nav {
  display: flex;
  gap: 14px;
}

nav a {
  color: #d8d0c2;
  font-size: 14px;
  text-decoration: none;
}

main {
  width: min(100%, 1360px);
  margin: 0 auto;
  padding: 18px 24px 42px;
}

.gate {
  display: grid;
  grid-template-columns: 1fr 390px;
  gap: 22px;
  align-items: stretch;
}

.gate-copy,
.login-card,
.quiz-sidebar,
.result,
.waiting-room,
.dashboard-head,
.class-state,
.stat,
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.gate-copy {
  min-height: 320px;
  padding: 32px;
}

.gate-copy h1,
.dashboard h1 {
  margin: 0 0 12px;
  font-size: clamp(34px, 4.6vw, 56px);
  line-height: 0.98;
}

.gate-copy p:not(.eyebrow) {
  max-width: 620px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.5;
}

.notice {
  border-left: 4px solid var(--gold);
  background: #fbf7ec;
  padding: 12px 14px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.login-card {
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 22px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 14px;
}

.quiz-view {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
}

.quiz-sidebar {
  position: sticky;
  top: 76px;
  align-self: start;
  display: grid;
  gap: 18px;
  padding: 16px;
}

.quiz-sidebar h2 {
  margin: 0;
  font-size: 22px;
}

.progress-box,
.save-box {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.save-box {
  min-height: 76px;
  background: var(--panel-soft);
  padding: 12px;
  text-align: center;
}

.timer-box {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf7ec;
  padding: 12px;
}

.timer-box span {
  font-size: 26px;
  font-weight: 800;
}

.timer-box small {
  color: var(--muted);
}

.save-box span {
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
}

.save-box small {
  color: var(--muted);
}

.save-box.saving span {
  color: var(--blue);
}

.save-box.saved span {
  color: var(--green);
}

.save-box.error span {
  color: var(--red);
}

.progress-box span {
  font-size: 34px;
  font-weight: 800;
}

.progress-box small,
.hint {
  color: var(--muted);
}

.hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
}

.pages {
  display: grid;
  gap: 18px;
}

.pdf-page {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(24, 20, 12, 0.08);
}

.pdf-page img {
  display: block;
  width: 100%;
  height: auto;
}

.overlay {
  position: absolute;
  inset: 0;
}

.choice-dot {
  position: absolute;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 999px;
  background: transparent;
  padding: 0;
  line-height: 0;
}

.choice-dot::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 17px;
  height: 17px;
  transform: translate(-50%, -50%);
  content: "";
  border: 2px solid transparent;
  border-radius: 999px;
  background: transparent;
}

.choice-dot:hover::after {
  border-color: rgba(35, 100, 170, 0.45);
  background: rgba(35, 100, 170, 0.08);
}

.choice-dot.selected {
  background: transparent;
}

.choice-dot.selected::after {
  border-color: var(--blue);
  background: rgba(35, 100, 170, 0.18);
  box-shadow:
    inset 0 0 0 3px rgba(255, 255, 255, 0.86),
    0 0 0 2px rgba(35, 100, 170, 0.16);
}

.choice-dot.readonly {
  opacity: 1;
}

.choice-dot.readonly:not(.selected) {
  display: none;
}

.result {
  margin-top: 18px;
  padding: 18px;
}

.result h2 {
  margin: 0 0 8px;
  font-size: 32px;
}

.dashboard {
  display: grid;
  gap: 14px;
}

.dashboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--panel);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.dashboard-head h1 {
  margin-bottom: 4px;
  font-size: clamp(34px, 4vw, 44px);
}

.dashboard-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.admin-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-badge {
  white-space: nowrap;
  border: 1px solid rgba(21, 115, 71, 0.22);
  border-radius: 999px;
  background: rgba(21, 115, 71, 0.08);
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  padding: 9px 14px;
}

.control-panel {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 20px;
  box-shadow: var(--shadow);
}

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

.control-status h2 {
  margin: 0;
  font-size: clamp(24px, 2.5vw, 32px);
  line-height: 1.1;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 118px;
  border-radius: 999px;
  padding: 8px 13px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.status-chip.closed {
  background: #6b6259;
}

.status-chip.waiting {
  background: var(--blue);
}

.status-chip.running {
  background: var(--green);
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(160px, 210px) minmax(360px, 1fr);
  gap: 16px;
  align-items: end;
}

.control-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 10px;
}

.control-actions button {
  width: 100%;
  min-height: 44px;
  white-space: nowrap;
}

.secondary-action {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ink);
}

.secondary-action:hover {
  border-color: #c4cbd4;
  background: #eef1f4;
}

.secondary-action.active {
  border-color: rgba(21, 115, 71, 0.25);
  background: rgba(21, 115, 71, 0.1);
  color: var(--green);
}

#setActiveTestButton {
  border-color: rgba(154, 113, 24, 0.28);
  background: #f4ead3;
  color: #4f3808;
}

#setActiveTestButton:hover {
  background: #ead9b2;
}

#openRoomButton,
#startClassButton {
  background: var(--green);
}

#openRoomButton:hover,
#startClassButton:hover {
  background: #105c39;
}

button.danger {
  background: var(--red);
}

button.danger:hover {
  background: #8f1d14;
}

.share-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1.35fr) minmax(180px, 0.75fr) auto;
  gap: 12px;
  align-items: stretch;
}

.share-panel > div {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px 14px;
}

.share-panel span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.share-panel strong {
  overflow-wrap: anywhere;
  font-size: 16px;
}

#copyStudentLinkButton {
  min-width: 130px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.dashboard-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 4px;
}

.filter-button {
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 7px 12px;
}

.filter-button:hover,
.filter-button.active {
  background: #111;
  color: #fff;
  box-shadow: none;
}

.class-state {
  border-color: var(--line-soft);
  background: var(--panel-soft);
  padding: 11px 13px;
  color: var(--muted);
  font-size: 15px;
}

.class-state strong {
  color: var(--ink);
}

.admin-feedback {
  min-height: 20px;
  margin: 0;
  color: var(--green);
  font-size: 14px;
  font-weight: 700;
}

.admin-feedback.info {
  color: var(--blue);
}

.admin-feedback.error {
  color: var(--red);
}

.waiting-room {
  max-width: 760px;
  margin: 0 auto;
  padding: 34px;
  text-align: center;
}

.waiting-room h1 {
  margin: 0 0 10px;
  font-size: clamp(32px, 6vw, 58px);
}

.waiting-room p:not(.eyebrow) {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.5;
}

.stat {
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat span {
  display: block;
  font-size: 32px;
  font-weight: 800;
  line-height: 1.1;
}

.stat small {
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th,
td {
  border-bottom: 1px solid var(--line-soft);
  padding: 13px 14px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  background: var(--panel-soft);
}

tbody tr:hover {
  background: #fbfcfd;
}

.answers-cell {
  max-width: 520px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.answer-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  margin: 2px 4px 2px 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 7px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

.answer-status.correct {
  border-color: rgba(20, 118, 75, 0.25);
  background: rgba(20, 118, 75, 0.09);
  color: var(--green);
}

.answer-status.wrong {
  border-color: rgba(180, 35, 24, 0.25);
  background: rgba(180, 35, 24, 0.08);
  color: var(--red);
}

.small-button {
  padding: 8px 10px;
  white-space: nowrap;
}

.danger-small {
  background: var(--red);
}

.danger-small:hover {
  background: #8f1d14;
}

.pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 9px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

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

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

.submission-viewer {
  display: grid;
  gap: 16px;
  margin-top: 14px;
}

.viewer-head {
  position: sticky;
  top: 58px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.viewer-head h2 {
  margin: 0;
}

.viewer-pages {
  display: grid;
  gap: 18px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 860px) {
  .gate,
  .quiz-view {
    grid-template-columns: 1fr;
  }

  .quiz-sidebar {
    position: static;
  }

  .dashboard-head,
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-login,
  .control-grid,
  .share-panel,
  .dashboard-grid {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .dashboard-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .control-actions {
    grid-template-columns: 1fr;
  }

  .control-actions button,
  #copyStudentLinkButton {
    min-width: 0;
  }

  .control-status {
    align-items: flex-start;
    flex-direction: column;
  }

  main {
    padding-inline: 8px;
  }

  .quiz-sidebar {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .progress-box {
    padding: 10px;
  }

  .progress-box span {
    font-size: 26px;
  }

  .quiz-sidebar button,
  .quiz-sidebar .hint {
    grid-column: 1 / -1;
  }

  .choice-dot {
    width: 34px;
    height: 34px;
  }
}
