* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 232, 240, 0.95), transparent 32%),
    linear-gradient(135deg, #fff7fb 0%, #f7f0ff 48%, #eef7ff 100%);
  color: #281f2f;
}

button,
input {
  font: inherit;
}

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

.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(85, 63, 104, 0.14);
  box-shadow: 0 18px 48px rgba(49, 31, 72, 0.13);
  border-radius: 28px;
  padding: clamp(18px, 4vw, 36px);
  margin: 16px 0;
}

.hero {
  min-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 7px 12px;
  border-radius: 999px;
  background: #eee4ff;
  color: #4c287c;
  font-weight: 700;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
}

.badge.danger {
  background: #ffe2e2;
  color: #8c1d1d;
}

.badge.success {
  background: #e4ffe9;
  color: #17622b;
}

h1 {
  margin: 14px 0 10px;
  font-size: clamp(2rem, 7vw, 4rem);
  line-height: 1;
}

h2 {
  margin: 0 0 10px;
}

.lead {
  font-size: clamp(1rem, 2.6vw, 1.25rem);
  line-height: 1.55;
  max-width: 720px;
}

.warning-card,
.result-box,
.question-card,
.timer-card,
.student-chip {
  border: 1px solid rgba(85, 63, 104, 0.14);
  border-radius: 22px;
  background: #fff;
}

.warning-card {
  padding: 18px;
  margin: 22px 0;
}

.warning-card ul {
  margin: 0;
  padding-left: 22px;
  line-height: 1.7;
}

.student-form {
  display: grid;
  gap: 14px;
  max-width: 540px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

input[type="text"] {
  min-height: 48px;
  border: 1px solid rgba(85, 63, 104, 0.25);
  border-radius: 16px;
  padding: 12px 14px;
  background: #fff;
}

.primary-btn,
.ghost-btn {
  min-height: 50px;
  border: 0;
  border-radius: 16px;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 800;
}

.primary-btn {
  background: #6f3fd4;
  color: white;
  box-shadow: 0 12px 24px rgba(111, 63, 212, 0.25);
}

.ghost-btn {
  background: transparent;
  color: #6f3fd4;
  margin-top: 10px;
  border: 1px dashed rgba(111, 63, 212, 0.35);
}

.wide {
  width: 100%;
  margin-top: 20px;
}

.test-header {
  display: flex;
  gap: 18px;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
}

.test-header h1 {
  font-size: clamp(1.7rem, 5vw, 3.2rem);
}

.timer-card {
  padding: 14px 18px;
  min-width: 126px;
  text-align: center;
}

.timer-card span {
  display: block;
  font-size: 0.85rem;
  color: #6b5b73;
}

.timer-card strong {
  font-size: 1.45rem;
}

.student-chip {
  padding: 12px 14px;
  margin: 18px 0;
  font-weight: 700;
  background: #fff9fd;
}

.questions {
  display: grid;
  gap: 16px;
}

.question-card {
  padding: 18px;
}

.question-title {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 1.05rem;
  line-height: 1.45;
  font-weight: 800;
}

.question-number {
  flex: 0 0 auto;
  background: #f0e8ff;
  color: #4c287c;
  border-radius: 12px;
  padding: 5px 9px;
  font-size: 0.9rem;
}

.options {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(85, 63, 104, 0.13);
  border-radius: 16px;
  cursor: pointer;
  background: #faf8ff;
  font-weight: 600;
  line-height: 1.35;
}

.option input {
  margin-top: 2px;
  accent-color: #6f3fd4;
}

.result-box {
  padding: 18px;
  margin: 18px 0;
  line-height: 1.7;
}

.danger-box {
  border-color: rgba(140, 29, 29, 0.28);
  background: #fff5f5;
}

.result-line {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid rgba(85, 63, 104, 0.12);
  padding: 8px 0;
}

.result-line:last-child {
  border-bottom: 0;
}

.small-note {
  color: #6b5b73;
}

.hidden {
  display: none !important;
}

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

  .panel {
    border-radius: 22px;
    padding: 18px;
  }

  .hero {
    min-height: calc(100vh - 20px);
  }

  .question-card {
    padding: 14px;
  }

  .option {
    padding: 12px 10px;
  }
}


.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.result-actions .primary-btn,
.result-actions .ghost-btn {
  flex: 1 1 210px;
}

.official-result-card {
  text-align: center;
  border: 2px solid rgba(111, 63, 212, 0.38);
  background:
    radial-gradient(circle at top left, rgba(238, 228, 255, 0.95), transparent 34%),
    #fff;
}

.official-score {
  font-size: clamp(3rem, 13vw, 5.2rem);
  font-weight: 900;
  line-height: 1;
  color: #6f3fd4;
  margin: 10px 0 4px;
}

.official-percent {
  font-size: 1.65rem;
  font-weight: 900;
  color: #281f2f;
}

.official-code {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #faf8ff;
  border: 1px solid rgba(85, 63, 104, 0.13);
  font-weight: 900;
}


.corrected-review {
  margin-top: 22px;
}

.review-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.review-item {
  border: 1px solid rgba(85, 63, 104, 0.14);
  border-radius: 18px;
  padding: 14px;
  background: #fff;
}

.review-item.correct {
  border-color: rgba(23, 98, 43, 0.28);
  background: #f6fff8;
}

.review-item.wrong {
  border-color: rgba(140, 29, 29, 0.26);
  background: #fff7f7;
}

.review-status {
  font-weight: 900;
  margin-bottom: 8px;
}

.review-status.correct {
  color: #17622b;
}

.review-status.wrong {
  color: #8c1d1d;
}

.review-line {
  line-height: 1.55;
  margin: 6px 0;
}

.review-explanation {
  margin-top: 10px;
  padding: 10px;
  border-radius: 14px;
  background: #faf8ff;
  border: 1px solid rgba(85, 63, 104, 0.12);
  line-height: 1.5;
}

.release-note {
  margin-top: 14px;
  padding: 12px;
  border-radius: 14px;
  background: #fff8e6;
  border: 1px solid rgba(159, 108, 0, 0.2);
  color: #684600;
  font-weight: 800;
}
.success-note {
  background: #f1fff4;
  border-color: rgba(23, 98, 43, 0.22);
  color: #17622b;
}
.teacher-only { border-style: dashed; }
code { font-family: Consolas, Monaco, monospace; background: #f5f0ff; border-radius: 8px; padding: 2px 6px; }

.session-status {
  min-height: 1.2em;
  margin: 0;
  font-weight: 800;
  line-height: 1.4;
}

.session-status.info { color: #4c287c; }
.session-status.success { color: #17622b; }
.session-status.error { color: #8c1d1d; }

select,
input[type="email"],
input[type="password"] {
  min-height: 48px;
  border: 1px solid rgba(85, 63, 104, 0.25);
  border-radius: 16px;
  padding: 12px 14px;
  background: #fff;
}

.teacher-list {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.teacher-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 16px;
  border: 1px solid rgba(85, 63, 104, 0.14);
  border-radius: 18px;
  background: #fff;
}

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

.teacher-actions .ghost-btn,
.teacher-actions .primary-btn {
  margin-top: 0;
  min-height: 42px;
}

.teacher-table {
  display: grid;
  border: 1px solid rgba(85, 63, 104, 0.14);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
}

.teacher-row {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr 0.8fr 1fr;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid rgba(85, 63, 104, 0.1);
}

.teacher-row:last-child { border-bottom: 0; }
.teacher-row.head { font-weight: 900; background: #faf8ff; }

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

@media (max-width: 760px) {
  .teacher-item {
    grid-template-columns: 1fr;
  }
  .teacher-actions {
    justify-content: flex-start;
  }
  .teacher-row {
    grid-template-columns: 1fr;
  }
}

.attempts-table .teacher-row {
  grid-template-columns: 1.1fr 0.55fr 0.7fr 0.8fr 1.65fr;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-pill.started {
  background: #eef3ff;
  color: #29458f;
}

.status-pill.locked {
  background: #ffe2e2;
  color: #8c1d1d;
}

.status-pill.submitted {
  background: #e4ffe9;
  color: #17622b;
}

@media (max-width: 760px) {
  .attempts-table .teacher-row {
    grid-template-columns: 1fr;
  }
}

.badge.muted {
  background: #f1eef4;
  color: #63596b;
}

.danger-btn {
  min-height: 42px;
  border: 1px solid rgba(140, 29, 29, 0.28);
  border-radius: 16px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 800;
  background: #fff5f5;
  color: #8c1d1d;
}

.teacher-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin: 10px 0;
}

.compact-label {
  width: min(260px, 100%);
}

.teacher-item.archived {
  background: #faf8fc;
  opacity: 0.88;
}

.session-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.summary-card {
  border: 1px solid rgba(85, 63, 104, 0.14);
  border-radius: 16px;
  background: #faf8ff;
  padding: 12px;
}

.summary-card span {
  display: block;
  color: #6b5b73;
  font-size: 0.85rem;
  font-weight: 700;
}

.summary-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1.35rem;
}

@media (max-width: 760px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Teacher dashboard v2 */
.teacher-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

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

.teacher-dashboard-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.6fr);
  gap: 18px;
  align-items: start;
}

.teacher-sidebar,
.teacher-main-dashboard {
  display: grid;
  gap: 16px;
}

.teacher-create-card,
.teacher-sessions-card,
.teacher-main-dashboard .warning-card {
  margin-top: 0;
}

.compact-form {
  gap: 10px;
}

.compact-form label,
.search-label {
  display: grid;
  gap: 6px;
  font-weight: 800;
}

.section-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.compact-toolbar {
  margin: 8px 0 4px;
}

.compact-session-list {
  max-height: 620px;
  overflow: auto;
  padding-right: 4px;
}

.session-card {
  grid-template-columns: 1fr;
  gap: 12px;
  border-radius: 18px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.session-card.selected {
  border-color: rgba(124, 58, 237, 0.42);
  box-shadow: 0 10px 30px rgba(124, 58, 237, 0.14);
}

.session-card:hover {
  transform: translateY(-1px);
}

.session-card-main {
  min-width: 0;
}

.session-card-actions {
  justify-content: flex-start;
}

.session-card-actions .primary-btn,
.session-card-actions .ghost-btn,
.session-card-actions .danger-btn,
.dashboard-actions .primary-btn,
.dashboard-actions .ghost-btn,
.dashboard-actions .danger-btn {
  min-height: 38px;
  padding: 8px 11px;
  font-size: 0.9rem;
}

.compact-code {
  width: fit-content;
  max-width: 100%;
  font-size: 0.95rem;
  padding: 8px 10px;
  overflow-wrap: anywhere;
}

.empty-dashboard {
  min-height: 260px;
  display: grid;
  align-content: center;
}

.selected-session-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.dashboard-actions {
  max-width: 380px;
}

.student-controls {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 14px;
  align-items: end;
  margin: 14px 0;
}

.search-label input[type="search"] {
  min-height: 46px;
  border: 1px solid rgba(85, 63, 104, 0.25);
  border-radius: 16px;
  padding: 12px 14px;
  background: #fff;
}

.status-filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.filter-tab {
  min-height: 40px;
  border: 1px solid rgba(85, 63, 104, 0.16);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  color: #453052;
  font-weight: 900;
  cursor: pointer;
}

.filter-tab.active {
  background: #2f1f3a;
  color: #fff;
  border-color: #2f1f3a;
}

.table-scroll {
  overflow-x: auto;
  border-radius: 16px;
}

.compact-attempts-table {
  min-width: 760px;
}

.compact-attempts-table .teacher-row {
  align-items: center;
  padding: 10px 12px;
}

.table-count {
  margin-top: 8px;
}

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

.dashboard-students-root {
  margin-top: 0;
}

@media (max-width: 980px) {
  .teacher-dashboard-layout {
    grid-template-columns: 1fr;
  }

  .compact-session-list {
    max-height: none;
  }

  .selected-session-header,
  .student-controls {
    grid-template-columns: 1fr;
  }

  .status-filter-tabs,
  .dashboard-actions,
  .teacher-topbar-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .teacher-topbar {
    display: grid;
  }

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

.teacher-alert {
  grid-column: 1 / -1;
  border-radius: 18px;
  padding: 0.85rem 1rem;
  font-weight: 800;
  line-height: 1.45;
}

.duplicate-alert {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
}

.warning-summary {
  background: #fff7ed;
  border-color: #fed7aa;
}

.warning-summary strong {
  color: #9a3412;
}

.duplicate-row {
  background: #fff7ed;
}

.mini-warning {
  display: inline-flex;
  align-items: center;
  margin-left: 0.35rem;
  padding: 0.12rem 0.42rem;
  border-radius: 999px;
  background: #fed7aa;
  color: #9a3412;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}


.instructions-card {
  background: #fffdf7;
  border-color: rgba(159, 108, 0, 0.18);
}

.confirm-rules {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(85, 63, 104, 0.14);
  border-radius: 16px;
  background: #faf8ff;
  font-weight: 800;
  line-height: 1.35;
}

.confirm-rules input {
  margin-top: 2px;
  accent-color: #6f3fd4;
  width: 18px;
  height: 18px;
}

.submit-note {
  margin: 18px 0 0;
  font-weight: 800;
}

.result-after-submit-note {
  margin-top: 12px;
}

.needs-attention-alert {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
}

.all-clear-alert {
  background: #f1fff4;
  border: 1px solid rgba(23, 98, 43, 0.22);
  color: #17622b;
}
