:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #5d6a85;
  --border: #d8dfeb;
  --shadow: 0 22px 55px rgba(25, 40, 72, 0.12);
  --primary: #315efb;
  --primary-strong: #274ad0;
  --success: #0f9d58;
  --success-soft: #eaf8f0;
  --warning: #cf7a00;
  --warning-soft: #fff4de;
  --error: #c53d2f;
  --error-soft: #fdeceb;
  --neutral-soft: #eef3ff;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(49, 94, 251, 0.1), transparent 35%),
    linear-gradient(180deg, #f7f9fd 0%, var(--bg) 100%);
}

body {
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.panel {
  width: min(920px, 100%);
  background: var(--panel);
  border: 1px solid rgba(216, 223, 235, 0.8);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px;
}

.loading-state {
  min-height: 360px;
  display: grid;
  place-items: center;
  gap: 14px;
  color: var(--muted);
}

.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(49, 94, 251, 0.18);
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

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

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--primary-strong);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.panel-title {
  margin: 0 0 10px;
  font-size: clamp(2rem, 4vw, 2.8rem);
  line-height: 1.05;
}

.compact-title {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
}

.panel-copy {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 1rem;
}

.compact-copy {
  max-width: 56ch;
}

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

.narrow-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 520px;
}

.info-card,
.stat-card,
.summary-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  background: #fbfcff;
}

.info-label,
.stat-label,
.summary-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.info-value,
.stat-value,
.summary-value {
  font-size: clamp(1.1rem, 3vw, 1.65rem);
  font-weight: 700;
}

.callout {
  margin-top: 18px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fafcff;
  line-height: 1.65;
}

.subtle-callout {
  background: #f9fbff;
}

.success-callout {
  background: var(--success-soft);
  border-color: rgba(15, 157, 88, 0.25);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 14px 20px;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

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

.btn:focus-visible,
.answer-input:focus-visible {
  outline: 3px solid rgba(49, 94, 251, 0.25);
  outline-offset: 2px;
}

.btn:disabled {
  cursor: wait;
  opacity: 0.7;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(49, 94, 251, 0.22);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-strong);
}

.btn-secondary {
  background: #ffffff;
  border-color: var(--border);
  color: var(--text);
}

.task-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 108px;
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--primary-strong);
  font-weight: 700;
}

.status-pill.is-active {
  background: rgba(49, 94, 251, 0.14);
}

.status-pill.is-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-pill.is-neutral {
  background: #edf2f7;
  color: #516079;
}

.target-panel {
  margin: 18px 0 22px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fbfcff;
}

.target-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 600;
}

.target-track {
  height: 12px;
  border-radius: 999px;
  background: #e6ecfb;
  overflow: hidden;
}

.target-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #6586ff);
  transition: width 180ms ease;
}

.trial-panel {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.trial-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  color: var(--muted);
  font-weight: 600;
}

.equation {
  margin: 0 0 20px;
  text-align: center;
  font-size: clamp(2rem, 6vw, 3.4rem);
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1.15;
  word-break: break-word;
}

.answer-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.answer-input {
  width: 100%;
  min-width: 0;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #ffffff;
  font-size: 1.15rem;
}

.answer-input:disabled {
  background: #f2f5fb;
}

.input-help {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.feedback {
  min-height: 28px;
  margin-top: 14px;
  font-weight: 700;
}

.feedback.is-correct {
  color: var(--success);
}

.feedback.is-incorrect {
  color: var(--error);
}

.summary-card.is-success {
  background: var(--success-soft);
  border-color: rgba(15, 157, 88, 0.25);
}

.summary-card.is-neutral {
  background: #fbfcff;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.is-hidden {
  display: none !important;
}

.noscript-warning {
  position: fixed;
  inset: 24px;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  font-weight: 700;
  color: var(--error);
  background: #ffffff;
  border: 1px solid rgba(197, 61, 47, 0.25);
  border-radius: var(--radius-md);
}

@media (max-width: 860px) {
  .panel {
    padding: 24px;
  }

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

  .task-header {
    flex-direction: column;
    align-items: stretch;
  }

  .status-pill {
    align-self: flex-start;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 14px;
  }

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

  .info-grid,
  .stats-grid,
  .summary-grid,
  .narrow-grid {
    grid-template-columns: 1fr;
  }

  .answer-form {
    grid-template-columns: 1fr;
  }

  .trial-panel {
    padding: 20px;
  }

  .trial-meta,
  .target-row {
    flex-direction: column;
  }
}
