:root {
  --ink: #132c3d;
  --muted: #607381;
  --navy: #173f5f;
  --blue: #2374ab;
  --teal: #2a9d8f;
  --coral: #ed765e;
  --cream: #f6f2e9;
  --paper: #fffdfa;
  --line: #d8e0e5;
  --soft-blue: #eaf3f8;
  --green-bg: #e6f5ef;
  --green: #17684e;
  --amber-bg: #fff3d8;
  --amber: #8b5a00;
  --red-bg: #fde9e5;
  --red: #9a3525;
  --shadow: 0 18px 45px rgba(19, 44, 61, 0.10);
  --radius: 20px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 92% 8%, rgba(42, 157, 143, 0.13), transparent 30rem),
    radial-gradient(circle at 4% 70%, rgba(237, 118, 94, 0.12), transparent 32rem),
    var(--cream);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(35, 116, 171, 0.35);
  outline-offset: 3px;
}

a { color: var(--blue); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0.7rem; font-size: clamp(2rem, 5vw, 4.6rem); line-height: 0.98; letter-spacing: -0.045em; }
h2 { margin-bottom: 0.6rem; font-size: 1.35rem; line-height: 1.2; }

.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  width: min(1180px, calc(100% - 2rem));
  min-height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: white;
  background: var(--navy);
  font-size: 0.83rem;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 18px rgba(23, 63, 95, 0.22);
}

.teacher-link {
  color: var(--navy);
  font-size: 0.92rem;
  font-weight: 750;
  text-decoration: none;
}

.student-shell,
.dashboard-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3rem 0 5rem;
}

.hero-grid {
  min-height: calc(100vh - 150px);
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(330px, 0.75fr);
  align-items: center;
  gap: clamp(3rem, 8vw, 8rem);
}

.hero-copy { padding-bottom: 2rem; }
.hero-copy h1 { max-width: 780px; }
.lede { max-width: 620px; color: var(--muted); font-size: clamp(1.08rem, 2vw, 1.35rem); }

.eyebrow {
  margin-bottom: 0.6rem;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.feature-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 2rem;
}

.feature-row span,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 31px;
  padding: 0.35rem 0.75rem;
  border: 1px solid rgba(23, 63, 95, 0.13);
  border-radius: 999px;
  color: var(--navy);
  background: rgba(255, 255, 255, 0.55);
  font-size: 0.8rem;
  font-weight: 750;
}

.card {
  border: 1px solid rgba(19, 44, 61, 0.09);
  border-radius: var(--radius);
  background: rgba(255, 253, 250, 0.95);
  box-shadow: var(--shadow);
}

.join-card,
.login-card {
  padding: clamp(1.5rem, 4vw, 2.25rem);
}

.step-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.8rem;
  color: var(--navy);
  font-weight: 800;
}

.step-label span {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--coral);
  font-size: 0.84rem;
}

label {
  display: block;
  margin: 1rem 0 0.42rem;
  color: var(--navy);
  font-size: 0.85rem;
  font-weight: 780;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c7d3da;
  border-radius: 11px;
  color: var(--ink);
  background: white;
}

input,
select { min-height: 48px; padding: 0.65rem 0.8rem; }
textarea { padding: 1rem; resize: vertical; }
input:disabled, select:disabled { cursor: not-allowed; color: #8a999f; background: #f0f2f2; }

.primary-button,
.secondary-button,
.danger-button,
.text-button {
  min-height: 44px;
  border-radius: 11px;
  padding: 0.68rem 1rem;
  font-weight: 800;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.primary-button {
  border: 1px solid var(--navy);
  color: white;
  background: var(--navy);
  box-shadow: 0 8px 18px rgba(23, 63, 95, 0.18);
}

.secondary-button {
  border: 1px solid #b8c8d1;
  color: var(--navy);
  background: white;
}

.danger-button {
  border: 1px solid #e0a59a;
  color: var(--red);
  background: white;
}

.text-button {
  min-height: auto;
  border: 0;
  color: var(--blue);
  background: transparent;
  box-shadow: none;
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(19, 44, 61, 0.12); }
button:disabled { cursor: not-allowed; opacity: 0.5; transform: none !important; box-shadow: none !important; }
.full-width { width: 100%; margin-top: 1.3rem; }

.status-message { min-height: 1.4rem; margin: 0.8rem 0 0; color: var(--muted); font-size: 0.88rem; }
.error-text { color: var(--red) !important; }
.success-text { color: var(--green) !important; }
.muted { color: var(--muted); }

.quiz-view { max-width: 900px; margin: 0 auto; }
.quiz-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 2rem; margin-bottom: 1.5rem; }
.quiz-topline h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); }
.progress-track { height: 9px; overflow: hidden; border-radius: 999px; background: rgba(23, 63, 95, 0.10); }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), #64c2b5); transition: width 220ms ease; }
.question-meta { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0.9rem 0; color: var(--muted); font-size: 0.9rem; font-weight: 700; }
.question-card { min-height: 390px; padding: clamp(1.4rem, 4vw, 2.5rem); }
.question-card h2 { max-width: 760px; margin-bottom: 0.8rem; font-size: clamp(1.35rem, 3vw, 2rem); }
.long-answer { min-height: 190px; margin-top: 1.1rem; font-size: 1rem; }

.choice-grid { display: grid; gap: 0.8rem; margin-top: 1.5rem; }
.choice-button {
  width: 100%;
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border: 2px solid #d2dde3;
  border-radius: 14px;
  color: var(--ink);
  background: white;
  text-align: left;
  font-weight: 650;
}

.choice-button:hover { border-color: #8db4ca; background: #f8fcfe; }
.choice-button.selected { border-color: var(--blue); background: var(--soft-blue); box-shadow: 0 0 0 3px rgba(35, 116, 171, 0.09); }
.choice-key { flex: 0 0 34px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: var(--navy); background: #edf2f4; font-size: 0.86rem; font-weight: 850; }
.choice-button.selected .choice-key { color: white; background: var(--blue); }

.matching-grid { display: grid; gap: 0.7rem; margin-top: 1.4rem; }
.matching-row { display: grid; grid-template-columns: minmax(170px, 1fr) minmax(190px, 0.8fr); align-items: center; gap: 1rem; padding: 0.8rem; border: 1px solid var(--line); border-radius: 12px; background: white; }
.matching-row label { margin: 0; font-size: 0.95rem; }

.feedback { margin-top: 1.2rem; padding: 0.9rem 1rem; border-radius: 12px; font-weight: 700; }
.feedback-correct { color: var(--green); background: var(--green-bg); }
.feedback-review { color: var(--red); background: var(--red-bg); }
.feedback-recorded { color: var(--navy); background: var(--soft-blue); }
.question-actions { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 0.8rem; margin-top: 1rem; }

.login-wrap { min-height: calc(100vh - 180px); display: grid; place-items: center; }
.login-card { width: min(430px, 100%); }
.login-card h1 { font-size: 2.8rem; }
.dashboard-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.7rem; }
.dashboard-heading h1 { font-size: clamp(2.4rem, 5vw, 4rem); }
.heading-actions { display: flex; align-items: center; gap: 0.4rem; padding-bottom: 0.5rem; }

.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat-card { min-height: 110px; padding: 1.15rem 1.3rem; border: 1px solid rgba(19, 44, 61, 0.09); border-radius: 16px; background: rgba(255, 253, 250, 0.85); }
.stat-card span { display: block; color: var(--muted); font-size: 0.8rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.08em; }
.stat-card strong { display: block; margin-top: 0.25rem; color: var(--navy); font-size: 2.2rem; line-height: 1.1; }

.dashboard-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); align-items: start; gap: 1rem; }
.dashboard-sidebar { display: grid; gap: 1rem; }
.panel { padding: 1.25rem; box-shadow: 0 10px 28px rgba(19, 44, 61, 0.07); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel-heading h2 { margin: 0; }
.format-help { margin-top: 1rem; color: var(--muted); font-size: 0.85rem; }
.format-help summary { cursor: pointer; color: var(--navy); font-weight: 800; }
.format-help p { margin: 0.65rem 0; }
code { padding: 0.12rem 0.3rem; border-radius: 5px; color: #5a3342; background: #f4e9ed; font-size: 0.9em; }

.response-heading { align-items: center; }
.response-actions { display: flex; gap: 0.6rem; }
.filters { display: grid; grid-template-columns: 180px minmax(260px, 1fr); gap: 0.8rem; padding: 1rem 0; border-top: 1px solid var(--line); }
.filters label { margin: 0; }
.filters select { margin-top: 0.35rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; }
table { width: 100%; min-width: 760px; border-collapse: collapse; }
th, td { padding: 0.85rem 0.8rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 0.88rem; }
th { color: var(--muted); background: #f5f8f9; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; }
tbody tr:last-child td { border-bottom: 0; }
.cell-meta { display: block; margin-top: 0.2rem; color: var(--muted); font-size: 0.76rem; }
.answer-cell { min-width: 260px; white-space: pre-wrap; }
.check-badge { display: inline-flex; align-items: center; padding: 0.25rem 0.52rem; border-radius: 999px; font-size: 0.72rem; font-weight: 850; }
.check-correct { color: var(--green); background: var(--green-bg); }
.check-review { color: var(--red); background: var(--red-bg); }
.check-open { color: var(--amber); background: var(--amber-bg); }
.empty-state { margin: 0; padding: 2.6rem 1rem; color: var(--muted); text-align: center; }
.danger-zone { display: flex; justify-content: flex-end; padding-top: 1rem; }

.presentation-open { overflow: hidden; }
.presentation-view {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow-y: auto;
  padding: clamp(1rem, 3vw, 2rem);
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 10%, rgba(42, 157, 143, 0.2), transparent 32rem),
    #f4efe5;
}
.presentation-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 2rem; max-width: 1500px; margin: 0 auto 1.5rem; }
.presentation-header h1 { max-width: 850px; font-size: clamp(2.4rem, 6vw, 5rem); }
.presentation-header p:last-child { max-width: 900px; color: var(--muted); font-size: clamp(1rem, 2vw, 1.4rem); }
.presentation-controls { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }
.presentation-grid { max-width: 1500px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; padding-bottom: 3rem; }
.presentation-card { min-height: 170px; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 1.1rem; padding: 1.3rem; border: 2px solid rgba(23, 63, 95, 0.1); border-radius: 18px; background: white; box-shadow: 0 12px 30px rgba(19, 44, 61, 0.08); }
.presentation-card p { margin: 0; font-size: clamp(1.05rem, 2vw, 1.35rem); white-space: pre-wrap; }
.anonymous-label { color: var(--blue); font-size: 0.75rem; font-weight: 850; letter-spacing: 0.08em; text-transform: uppercase; }
.presentation-correct { border-color: #78bda7; background: #f2fbf7; }
.presentation-review { border-color: #dfa093; background: #fff7f5; }
.presentation-open-answer { border-color: #e3bf6b; background: #fffaf0; }

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; gap: 1rem; padding-top: 2rem; }
  .hero-copy { padding-bottom: 0; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .presentation-header { flex-direction: column; }
  .presentation-controls { justify-content: flex-start; }
}

@media (max-width: 650px) {
  .student-shell, .dashboard-shell { width: min(100% - 1rem, 1180px); padding-top: 1.4rem; }
  .site-header { width: min(100% - 1rem, 1180px); }
  .hero-grid { min-height: auto; }
  .feature-row { display: none; }
  .quiz-topline, .dashboard-heading { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .question-card { min-height: 0; }
  .question-actions { grid-template-columns: 1fr 1fr; }
  .question-actions .primary-button { grid-column: 1 / -1; grid-row: 1; }
  .matching-row { grid-template-columns: 1fr; gap: 0.4rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 86px; }
  .dashboard-sidebar { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .response-heading { flex-direction: column; align-items: stretch; }
  .response-actions .primary-button { width: 100%; }
  .presentation-view { padding: 0.8rem; }
  .presentation-controls > button { flex: 1 1 140px; }
}
