:root {
  --bg: #f4f7fb;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-strong: #ffffff;
  --surface-soft: #f8fbff;
  --text: #0f172a;
  --text-soft: #334155;
  --muted: #64748b;
  --line: rgba(15, 23, 42, 0.08);
  --primary: #5b7cff;
  --primary-strong: #4267f6;
  --success: #16a34a;
  --success-bg: rgba(22, 163, 74, 0.1);
  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.1);
  --shadow-lg: 0 24px 80px rgba(15, 23, 42, 0.1);
  --shadow-md: 0 12px 32px rgba(15, 23, 42, 0.08);
  --radius-xxl: 32px;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --container: 1180px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at top left, rgba(91, 124, 255, 0.14), transparent 26%),
    radial-gradient(circle at bottom right, rgba(91, 124, 255, 0.1), transparent 24%),
    linear-gradient(180deg, #f8fbff 0%, #f3f6fb 100%);
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

.bg-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
}

.orb-1 {
  width: 380px;
  height: 380px;
  background: #9eb6ff;
  top: -140px;
  left: -100px;
}

.orb-2 {
  width: 420px;
  height: 420px;
  background: #d7e2ff;
  right: -140px;
  bottom: -120px;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.03) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.35), transparent 88%);
  pointer-events: none;
  z-index: 0;
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(calc(100vw - 32px), var(--container));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.hero-screen,
.loading-screen,
.exam-screen,
.results-screen {
  animation: fadeUp 0.42s ease;
}

.hero-screen {
  min-height: calc(100vh - 48px);
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 24px;
  align-items: stretch;
}

.hero-panel,
.hero-side,
.loading-panel,
.task-card,
.result-card,
.sticky-submit-bar,
.stats-card,
.ticket-shell,
.picker-dialog {
  background: var(--surface);
  backdrop-filter: blur(24px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}

.hero-panel,
.hero-side,
.loading-panel,
.exam-screen,
.results-screen,
.picker-dialog {
  border-radius: var(--radius-xxl);
}

.hero-panel {
  padding: 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 640px;
}

.hero-side {
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(91, 124, 255, 0.12);
  color: var(--primary-strong);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.eyebrow-success {
  background: var(--success-bg);
  color: var(--success);
}

.hero-title,
.screen-title,
.loading-panel h2 {
  margin: 16px 0 0;
  font-size: clamp(2.2rem, 4vw, 4.4rem);
  line-height: 1.03;
  letter-spacing: -0.05em;
}

.hero-text,
.screen-subtitle,
.loading-panel p,
.hero-status,
.picker-subtitle {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.75;
}

.hero-actions,
.results-actions,
.header-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

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

.hero-status {
  margin-top: 24px;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
}

.feature-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.feature-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(91, 124, 255, 0.16), rgba(91, 124, 255, 0.08));
  color: var(--primary-strong);
  font-weight: 800;
}

.feature-title {
  font-size: 0.98rem;
  font-weight: 700;
}

.feature-text {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  border-radius: 18px;
  padding: 14px 22px;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease,
    opacity 0.18s ease;
}

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

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #87a1ff);
  box-shadow: 0 16px 32px rgba(91, 124, 255, 0.26);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-strong), #7592ff);
}

.btn-secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
}

.loading-screen {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
}

.loading-panel {
  width: min(560px, 100%);
  padding: 42px;
  text-align: center;
}

.spinner {
  width: 72px;
  height: 72px;
  margin: 0 auto 22px;
  border-radius: 999px;
  border: 6px solid rgba(91, 124, 255, 0.14);
  border-top-color: var(--primary);
  animation: spin 1s linear infinite;
}

.exam-screen,
.results-screen {
  padding: 28px;
}

.screen-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 24px;
}

.tickets-stack {
  display: grid;
  gap: 24px;
}

.ticket-shell {
  border-radius: 28px;
  padding: 22px;
}

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

.ticket-title {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.ticket-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.ticket-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.task-card {
  border-radius: 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.task-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.48));
}

.task-chip,
.task-ticket-badge,
.header-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(91, 124, 255, 0.11);
  color: var(--primary-strong);
  font-size: 0.8rem;
  font-weight: 700;
}

.task-ticket-badge,
.header-badge {
  background: rgba(15, 23, 42, 0.05);
  color: var(--text-soft);
}

.task-body {
  padding: 18px;
  display: grid;
  gap: 16px;
}

.task-section {
  display: grid;
  gap: 8px;
}

.task-section-label,
.result-label,
.progress-label {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #64748b;
}

.task-text,
.task-options,
.result-student-answer,
.result-canonical-answer,
.result-explanation {
  margin: 0;
  line-height: 1.72;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.task-text {
  font-size: 0.97rem;
}

.task-options-wrap {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
  overflow: hidden;
}

.task-options-wrap summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-soft);
}

.task-options-wrap summary::-webkit-details-marker {
  display: none;
}

.task-options {
  padding: 0 16px 16px;
  color: var(--text-soft);
  font-size: 0.94rem;
}

.task-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 220px));
  gap: 12px;
  justify-content: start;
}

.task-image {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #eef4ff;
  cursor: zoom-in;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.task-image:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.answer-input {
  width: 100%;
  min-height: 128px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  padding: 16px 18px;
  color: var(--text);
  font: inherit;
  line-height: 1.65;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.answer-input:focus {
  border-color: rgba(91, 124, 255, 0.55);
  box-shadow: 0 0 0 6px rgba(91, 124, 255, 0.08);
  background: #fff;
}

.sticky-submit-bar {
  position: sticky;
  bottom: 18px;
  margin-top: 28px;
  border-radius: 24px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.submit-bar-left {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 10px;
}

.progress-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.progress-count {
  color: var(--text-soft);
  font-weight: 700;
  font-size: 0.95rem;
}

.progress-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #89a3ff);
  transition: width 0.24s ease;
}

.btn-submit {
  min-width: 280px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stats-card {
  border-radius: 22px;
  padding: 20px;
}

.stats-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  color: var(--text);
}

.stats-label {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.95rem;
}

.results-list {
  display: grid;
  gap: 18px;
}

.result-card {
  border-radius: 24px;
  padding: 22px;
}

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

.result-ticket {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 6px;
}

.result-verdict {
  margin: 0;
  font-size: 1.08rem;
  letter-spacing: -0.02em;
}

.result-badge {
  min-width: 110px;
  min-height: 38px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
}

.result-badge.correct {
  background: var(--success-bg);
  color: var(--success);
}

.result-badge.wrong {
  background: var(--danger-bg);
  color: var(--danger);
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.result-block {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
}

.image-modal,
.picker-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
}

.image-modal {
  background: rgba(15, 23, 42, 0.84);
  display: grid;
  place-items: center;
  padding: 24px;
}

.image-modal img {
  max-width: min(1300px, 94vw);
  max-height: 88vh;
  border-radius: 22px;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.35);
}

.image-modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: white;
  font-size: 2rem;
  cursor: pointer;
}

.picker-modal {
  display: grid;
  place-items: center;
  padding: 24px;
}

.picker-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
}

.picker-dialog {
  position: relative;
  z-index: 1;
  width: min(860px, 96vw);
  max-height: min(88vh, 920px);
  padding: 24px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 16px;
}

.picker-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.picker-title {
  margin: 10px 0 0;
  font-size: 1.6rem;
  letter-spacing: -0.04em;
}

.picker-close {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  color: var(--text);
  font-size: 1.9rem;
  cursor: pointer;
  flex: 0 0 auto;
}

.picker-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.picker-small-btn {
  padding: 10px 14px;
  border-radius: 14px;
}

.picker-list {
  overflow: auto;
  display: grid;
  gap: 12px;
  padding-right: 4px;
}

.picker-ticket {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.picker-ticket:hover {
  transform: translateY(-1px);
  border-color: rgba(91, 124, 255, 0.24);
  box-shadow: var(--shadow-md);
}

.picker-ticket input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex: 0 0 auto;
}

.picker-ticket-main {
  min-width: 0;
}

.picker-ticket-title {
  font-weight: 700;
  color: var(--text);
  font-size: 1rem;
}

.picker-ticket-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.92rem;
}

.picker-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.picker-selection-info {
  color: var(--text-soft);
  font-weight: 700;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1179px) {
  .hero-screen {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    min-height: auto;
  }
}

@media (max-width: 820px) {
  .page-shell {
    width: min(calc(100vw - 18px), var(--container));
    padding-top: 12px;
    padding-bottom: 28px;
  }

  .hero-panel,
  .hero-side,
  .loading-panel,
  .exam-screen,
  .results-screen,
  .picker-dialog {
    border-radius: 24px;
  }

  .hero-panel,
  .hero-side,
  .loading-panel,
  .exam-screen,
  .results-screen,
  .picker-dialog {
    padding: 20px;
  }

  .screen-header,
  .sticky-submit-bar,
  .result-head,
  .picker-head,
  .picker-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .ticket-shell {
    padding: 16px;
    border-radius: 22px;
  }

  .stats-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .btn-submit {
    min-width: 100%;
  }

  .task-images {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .task-image {
    height: 140px;
  }
}

@media (max-width: 560px) {
  .hero-title,
  .screen-title,
  .loading-panel h2 {
    font-size: clamp(1.8rem, 9vw, 2.4rem);
  }

  .task-card,
  .result-card {
    border-radius: 20px;
  }

  .task-card-top,
  .task-body,
  .result-card {
    padding: 16px;
  }

  .task-image {
    height: 120px;
  }

  .answer-input {
    min-height: 110px;
    padding: 14px 16px;
  }

  .picker-dialog {
    width: min(96vw, 96vw);
    max-height: 92vh;
  }
}