:root {
  --bg: #f3ede2;
  --paper: #fffdf8;
  --ink: #1f2937;
  --muted: #6b7280;
  --accent: #8a3b12;
  --accent-dark: #5f2508;
  --accent-soft: #f5e0c6;
  --success: #146c43;
  --warning: #b45309;
  --danger: #b42318;
  --navy: #243b53;
  --navy-soft: #d7e3f1;
  --shadow: 0 18px 50px rgba(78, 53, 22, 0.12);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at top right, rgba(138, 59, 18, 0.16), transparent 24%),
    linear-gradient(180deg, #efe5d4 0%, #f8f4ec 26%, #f3ede2 100%);
  color: var(--ink);
  min-height: 100vh;
}

a { color: inherit; }
button, input, textarea, select { font: inherit; }
button { border: none; cursor: pointer; }

.shell {
  width: min(1260px, calc(100% - 32px));
  margin: 20px auto 48px;
}

.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(36, 59, 83, 0.98), rgba(58, 45, 34, 0.92));
  color: #fdf6ea;
  border-radius: 34px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -120px -120px auto;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 229, 180, 0.24), transparent 64%);
  pointer-events: none;
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 243, 224, 0.12);
  border: 1px solid rgba(255, 243, 224, 0.24);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 14px 0 12px;
  font-size: clamp(2rem, 3.8vw, 3.6rem);
  line-height: 1.05;
  max-width: 760px;
}

.hero p {
  margin: 0;
  max-width: 760px;
  color: rgba(253, 246, 234, 0.86);
  font-size: clamp(1rem, 1.8vw, 1.14rem);
}

.hero-actions, .toolbar, .badge-row, .meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.hero-actions { margin-top: 22px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 14px;
  padding: 12px 18px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn:disabled { cursor: not-allowed; opacity: 0.65; transform: none; }
.btn-primary { background: linear-gradient(180deg, #e2a55f, #bd6f29); color: #fff; box-shadow: 0 12px 30px rgba(195, 120, 42, 0.24); }
.btn-secondary { background: rgba(255, 248, 240, 0.12); color: #fffdf8; border: 1px solid rgba(255, 248, 240, 0.2); }
.btn-soft { background: #f3e7d4; color: var(--accent-dark); border: 1px solid #e6d1b3; }
.btn-danger { background: #fff1f1; color: var(--danger); border: 1px solid #efc0c0; }

.status-panel {
  min-width: 280px;
  padding: 16px 18px;
  border-radius: 22px;
  background: rgba(255, 248, 240, 0.1);
  border: 1px solid rgba(255, 248, 240, 0.16);
  backdrop-filter: blur(10px);
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  font-size: 0.94rem;
  padding: 7px 0;
  border-bottom: 1px dashed rgba(255, 248, 240, 0.16);
}

.status-row:last-child { border-bottom: none; padding-bottom: 0; }
.status-value { font-weight: 700; text-align: right; }

.layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 22px;
  margin-top: 22px;
}

.panel, .exam-paper, .exam-sidebar {
  background: var(--paper);
  border-radius: var(--radius);
  border: 1px solid rgba(143, 111, 75, 0.14);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.slim-panel { box-shadow: none; }

.panel-header, .exam-header, .sidebar-block, .panel-body, .exam-content {
  padding-left: 22px;
  padding-right: 22px;
}

.panel-header, .exam-header, .sidebar-block {
  padding-top: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(143, 111, 75, 0.14);
  background: linear-gradient(180deg, rgba(255, 250, 243, 0.95), rgba(248, 241, 229, 0.92));
}

.panel-body, .exam-content { padding-top: 22px; padding-bottom: 22px; }
.sidebar-block:last-child { border-bottom: none; }
.panel-title { margin: 0; font-size: 1.24rem; color: var(--navy); }
.panel-title-small { font-size: 1.08rem; }
.panel-subtitle { margin: 6px 0 0; color: var(--muted); font-size: 0.95rem; line-height: 1.5; }

.switcher {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  background: rgba(255, 247, 236, 0.9);
  padding: 8px;
  border-radius: 18px;
  margin: 22px 0 0;
  width: min(420px, 100%);
}

.switcher button {
  border-radius: 12px;
  padding: 11px 14px;
  font-weight: 700;
  color: var(--navy);
  background: transparent;
}

.switcher button.active {
  background: linear-gradient(180deg, #fff9ef, #f6e7cf);
  box-shadow: inset 0 0 0 1px rgba(138, 59, 18, 0.15), 0 10px 20px rgba(143, 111, 75, 0.12);
  color: var(--accent-dark);
}

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

.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--navy);
}

.field input, .field textarea, .field select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid #d5c5af;
  background: #fffdfa;
  padding: 12px 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field textarea { min-height: 110px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: rgba(138, 59, 18, 0.5); box-shadow: 0 0 0 4px rgba(138, 59, 18, 0.1); }

.note, .footer-note {
  margin-top: 10px;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.5;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.84rem;
  font-weight: 700;
}

.badge.navy { background: var(--navy-soft); color: var(--navy); }
.badge.success { background: #e2f8ea; color: var(--success); }
.badge.warning { background: #fff0d6; color: var(--warning); }

.message {
  display: none;
  margin-top: 18px;
  padding: 13px 16px;
  border-radius: 14px;
  line-height: 1.5;
  border: 1px solid transparent;
  font-size: 0.95rem;
}

.message.show { display: block; }
.message.info { background: #eef5ff; color: #123a67; border-color: #b8d3f2; }
.message.success { background: #e8f7ef; color: #0d5d37; border-color: #b5e0c7; }
.message.error { background: #fff0f0; color: #8c1d18; border-color: #efc4c4; }
.message.warning { background: #fff6e8; color: #9a5b00; border-color: #f1d8a6; }

.exam-list, .review-list, .list-stack, .choice-editor, .statement-editor { display: grid; gap: 12px; }
.student-view, .teacher-view, .exam-stage, .result-stage, .admin-app, .admin-login, .empty-state { display: none; }
.student-view.active, .teacher-view.active, .exam-stage.active, .result-stage.active, .admin-app.active, .admin-login.active, .empty-state.show { display: block; }

.exam-card, .question-card, .result-card, .stat-card, .attempt-card, .admin-exam {
  border-radius: 18px;
  border: 1px solid rgba(143, 111, 75, 0.18);
  background: linear-gradient(180deg, #fffefb, #f9f3e8);
  padding: 18px;
}

.exam-card h3, .question-card h3, .result-card h3, .admin-exam h4, .attempt-card h4 {
  margin: 0 0 10px;
  color: var(--navy);
}

.exam-card p, .question-card p, .admin-exam p, .attempt-card p { margin: 0; color: var(--muted); line-height: 1.5; }
.admin-exam.active { border-color: #a85d28; box-shadow: inset 0 0 0 1px rgba(168, 93, 40, 0.18); }

.exam-stage { margin-top: 24px; }
.exam-shell, .admin-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 18px;
  align-items: start;
}

.admin-shell { grid-template-columns: 340px minmax(0, 1fr); }
.exam-header { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 14px; }
.exam-header h2 { margin: 0 0 8px; color: var(--navy); font-size: 1.42rem; }

.timer-box {
  min-width: 210px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #fff7e7;
  border: 1px solid #efd3a3;
  text-align: right;
}

.timer-label { font-size: 0.85rem; text-transform: uppercase; color: var(--warning); letter-spacing: 0.08em; margin-bottom: 6px; }
.timer-value { font-size: 1.8rem; font-weight: 700; color: var(--accent-dark); }
.timer-value.danger { color: var(--danger); }

.question-heading { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.question-number { font-size: 0.95rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.question-text { font-size: 1.18rem; line-height: 1.7; color: var(--ink); margin-bottom: 18px; white-space: pre-line; }
.choice-list, .statement-list { display: grid; gap: 12px; }

.choice {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid #d9cdb8;
  background: #fffdf8;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.choice:hover { border-color: #c49a6c; transform: translateY(-1px); }
.choice input { margin-top: 4px; accent-color: var(--accent); }
.choice.active { border-color: #a85d28; background: #fff2e2; }

.choice-key {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #f2e7d6;
  color: var(--accent-dark);
  font-weight: 700;
  flex-shrink: 0;
}

.statement { padding: 16px; border-radius: 16px; border: 1px solid #d9cdb8; background: #fffdf8; }
.statement-top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.statement-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  background: #f7efe2;
  border-radius: 12px;
  padding: 6px;
}

.statement-toggle button, .pill-toggle button {
  padding: 9px 12px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.statement-toggle button.active.true, .pill-toggle button.active.true { background: #e3f7eb; color: var(--success); }
.statement-toggle button.active.false, .pill-toggle button.active.false { background: #fff0f0; color: var(--danger); }

.sidebar-title { margin: 0 0 10px; font-size: 1rem; color: var(--navy); }
.nav-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.nav-item {
  border-radius: 10px;
  padding: 10px 0;
  background: #f6ede0;
  color: var(--ink);
  border: 1px solid transparent;
  font-weight: 700;
}

.nav-item.current { background: #243b53; color: #fff; }
.nav-item.answered { border-color: #7b4b24; color: var(--accent-dark); background: #fdebd6; }
.nav-item.current.answered { background: #8a3b12; color: #fff; }

.sidebar-actions { display: grid; gap: 10px; }
.sidebar-actions .btn { width: 100%; }

.progress-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; color: var(--muted); font-size: 0.92rem; }
.progress-track { width: 100%; height: 10px; border-radius: 999px; background: #eee4d6; overflow: hidden; margin-top: 10px; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #c27431, #8a3b12); transition: width 0.2s ease; }

.result-grid, .stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.result-card strong, .stat-card strong { display: block; font-size: 1.72rem; color: var(--accent-dark); margin-top: 10px; }

.review-choice, .review-statement {
  padding: 12px 14px;
  border-radius: 14px;
  background: #f9f3e8;
  border: 1px solid #e0d1bb;
}

.review-choice.correct, .review-statement.correct { background: #ebf8ef; border-color: #b2dfc1; }
.review-choice.wrong, .review-statement.wrong { background: #fff0f0; border-color: #efc4c4; }
.review-explanation { margin-top: 12px; padding-top: 12px; border-top: 1px dashed #d6c1a4; color: var(--muted); line-height: 1.55; }

.mini-grid { display: grid; grid-template-columns: 78px minmax(0, 1fr) 128px; gap: 10px; align-items: center; }
.mini-grid.tf { grid-template-columns: 78px minmax(0, 1fr) 142px auto; }
.table-wrap { overflow: auto; border-radius: 18px; border: 1px solid #dccbb5; background: #fffdf9; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 12px 14px; border-bottom: 1px solid #ebdecb; text-align: left; vertical-align: top; font-size: 0.95rem; }
th { background: #f6ecdf; color: var(--navy); position: sticky; top: 0; }
tr:hover td { background: #fff7ed; }

.hint-box {
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px dashed #d4c0a5;
  background: #fffaf2;
  color: var(--muted);
  line-height: 1.55;
}

.footer-note { margin-top: 18px; text-align: center; }

@media (max-width: 1040px) {
  .layout, .exam-shell, .admin-shell { grid-template-columns: 1fr; }
  .exam-sidebar { position: static; }
  .status-panel { width: 100%; }
}

@media (max-width: 760px) {
  .shell { width: min(100% - 18px, 1260px); margin: 10px auto 28px; }
  .hero { border-radius: 26px; padding: 20px; }
  .panel-header, .exam-header, .sidebar-block, .panel-body, .exam-content { padding-left: 16px; padding-right: 16px; }
  .grid.two, .result-grid, .stats-grid, .mini-grid, .mini-grid.tf { grid-template-columns: 1fr; }
  .nav-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .statement-top { flex-direction: column; }
  table { min-width: 620px; }
}
