:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --panel: #ffffff;
  --panel-soft: #f7faf9;
  --text: #202124;
  --muted: #667085;
  --border: #d9dee8;
  --primary: #1e6b5c;
  --primary-strong: #155247;
  --blue: #2563eb;
  --gold: #b7791f;
  --red: #c2410c;
  --danger: #b42318;
  --success: #027a48;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(30, 107, 92, 0.12), transparent 42%),
    var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

main {
  width: min(100%, 460px);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 45px rgba(16, 24, 40, 0.12);
}

h1 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

p {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.5;
}

form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 16px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 107, 92, 0.16);
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
}

button:hover {
  background: var(--primary-strong);
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.secondary-link {
  display: inline-block;
  margin-top: 18px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.secondary-link:hover {
  color: var(--primary-strong);
  text-decoration: underline;
}

.welcome {
  text-align: left;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 14px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.welcome h1 {
  max-width: 380px;
  font-size: 34px;
}

.welcome p {
  margin-bottom: 0;
  font-size: 17px;
}

.welcome-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 26px;
  flex-wrap: wrap;
}

.button-link {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 0 20px;
  background: var(--primary);
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
}

.button-link:hover {
  background: var(--primary-strong);
}

.welcome-actions .secondary-link {
  margin-top: 0;
}

#message {
  margin-top: 18px;
  min-height: 22px;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.success {
  color: var(--success);
}

.error {
  color: var(--danger);
}

.portal-page {
  display: block;
  padding: 0;
  background:
    linear-gradient(135deg, rgba(30, 107, 92, 0.1), transparent 34%),
    linear-gradient(315deg, rgba(183, 121, 31, 0.1), transparent 36%),
    var(--bg);
}

.portal {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 32px 24px 40px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.portal-header {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 240px) 220px minmax(280px, 300px);
  align-items: end;
  gap: 20px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 45px rgba(16, 24, 40, 0.1);
}

.portal-header h1 {
  margin-bottom: 0;
  font-size: 34px;
}

.score-target,
.level-target,
.streak-target {
  display: grid;
  gap: 6px;
  padding: 18px;
  border: 1px solid rgba(30, 107, 92, 0.24);
  border-radius: 8px;
  background: var(--panel-soft);
}

.score-target {
  min-width: 280px;
}

.level-target {
  min-width: 240px;
}

.streak-target {
  min-width: 220px;
}

.score-target-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.score-target span,
.level-target span,
.streak-target span,
.section-heading p,
.study-content span {
  color: var(--muted);
}

.score-target span,
.level-target > span,
.streak-target > span {
  font-size: 14px;
  font-weight: 700;
}

.score-target label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.score-target .portal-select-label {
  margin-top: 6px;
}

.score-target strong,
.level-target strong {
  color: var(--primary-strong);
  font-size: 30px;
  line-height: 1;
}

.level-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.level-progress-row span {
  font-size: 13px;
  font-weight: 700;
}

.level-progress-row span:last-child {
  text-align: right;
}

.level-progress-bar {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eeec;
}

.level-progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.streak-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.streak-day {
  display: grid;
  aspect-ratio: 1;
  min-width: 0;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.streak-day span {
  color: inherit;
  font-size: 12px;
}

.streak-day strong {
  min-height: 12px;
  color: inherit;
  font-size: 11px;
  line-height: 1;
}

.streak-day-earned {
  border-color: rgba(30, 107, 92, 0.56);
  background: var(--primary);
  color: #ffffff;
}

.streak-day-frozen {
  border-color: rgba(37, 99, 235, 0.52);
  background: #e9f0ff;
  color: var(--blue);
}

.streak-day-missed {
  border-color: rgba(180, 35, 24, 0.34);
  background: #fff4f2;
  color: var(--danger);
}

.streak-day-blocked {
  border-style: dashed;
  background: #edf2f7;
  color: #475467;
}

.streak-freezes {
  font-size: 13px;
  font-weight: 700;
}

.course-select {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.course-select:disabled {
  color: var(--muted);
  cursor: wait;
}

.portal-section {
  margin-top: 24px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.section-heading p {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

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

.matrix-card {
  display: grid;
  gap: 18px;
  min-height: 132px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.matrix-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 16px;
}

.matrix-card h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.matrix-card strong {
  color: var(--primary-strong);
  font-size: 18px;
  white-space: nowrap;
}

.score-bar {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eeec;
}

.score-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.score-bar-blue span {
  background: var(--blue);
}

.score-bar-gold span {
  background: var(--gold);
}

.score-bar-red span {
  background: var(--red);
}

.study-map {
  padding-bottom: 16px;
}

.study-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.study-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 76px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.required-study {
  border-color: rgba(30, 107, 92, 0.38);
  background: #f3fbf8;
}

.study-content {
  display: grid;
  gap: 4px;
  justify-items: center;
  min-width: 0;
  text-align: center;
  width: 100%;
}

.study-content strong {
  display: block;
  width: 100%;
  font-size: 16px;
  line-height: 1.35;
}

.study-content span {
  display: block;
  width: 100%;
  font-size: 14px;
  line-height: 1.35;
}

.study-action {
  min-width: 144px;
  min-height: 42px;
  padding: 0 16px;
  white-space: nowrap;
}

.study-action-panel {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.study-message {
  max-width: 220px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  text-align: right;
}

.course-confirm-dialog {
  width: min(100%, 520px);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 45px rgba(16, 24, 40, 0.2);
}

.course-confirm-dialog::backdrop {
  background: rgba(16, 24, 40, 0.48);
}

.course-confirm-dialog p {
  margin: 0 0 20px;
  color: var(--text);
  font-size: 16px;
}

.course-confirm-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.course-confirm-actions button {
  min-width: 96px;
  padding: 0 18px;
}

.course-confirm-secondary {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--primary);
}

.course-confirm-secondary:hover {
  background: var(--panel-soft);
  color: var(--primary-strong);
}

.training-page {
  display: block;
  padding: 0;
  background: var(--bg);
}

.training {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 32px 24px 40px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.training h1 {
  margin: 0;
  font-size: 34px;
}

.training-summary-card {
  display: grid;
  gap: 6px;
  min-width: 168px;
  padding: 18px;
  border: 1px solid rgba(30, 107, 92, 0.24);
  border-radius: 8px;
  background: var(--panel-soft);
}

.training-summary-card span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.training-summary-card strong {
  color: var(--primary-strong);
  font-size: 24px;
  line-height: 1;
}

.diagnostic-page {
  display: block;
  padding: 0;
  background:
    linear-gradient(135deg, rgba(30, 107, 92, 0.1), transparent 34%),
    linear-gradient(315deg, rgba(37, 99, 235, 0.08), transparent 38%),
    var(--bg);
}

.diagnostic {
  width: min(100%, 960px);
  margin: 0 auto;
  padding: 32px 24px 40px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.diagnostic-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 20px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 45px rgba(16, 24, 40, 0.1);
}

.diagnostic-header h1 {
  margin-bottom: 0;
  font-size: 34px;
}

.diagnostic-progress {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.diagnostic-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.diagnostic-progress-row strong {
  font-size: 18px;
}

.diagnostic-progress-row span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-align: right;
}

.diagnostic-progress-bar {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eeec;
}

.diagnostic-progress-bar span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 180ms ease;
}

.diagnostic-panel {
  margin-top: 18px;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 45px rgba(16, 24, 40, 0.08);
}

.question-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.question-meta span {
  border-radius: 999px;
  padding: 7px 10px;
  background: #edf2f7;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.diagnostic-panel h2 {
  margin: 0 0 22px;
  font-size: 24px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.diagnostic-start {
  display: grid;
  justify-items: start;
  gap: 18px;
}

.diagnostic-start h2 {
  max-width: 760px;
  margin-bottom: 0;
}

.diagnostic-start button {
  min-width: 136px;
}

.diagnostic-panel fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.diagnostic-panel legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.diagnostic-options {
  display: grid;
  gap: 10px;
}

.diagnostic-option {
  display: grid;
  grid-template-columns: 20px 38px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.diagnostic-option:hover,
.diagnostic-option:has(input:checked) {
  border-color: rgba(30, 107, 92, 0.48);
  background: #f3fbf8;
}

.diagnostic-option input {
  width: 20px;
  min-height: 20px;
  margin: 0;
  accent-color: var(--primary);
}

.option-letter {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: #edf2f7;
  color: #344054;
  font-weight: 700;
}

.diagnostic-option:has(input:checked) .option-letter {
  background: var(--primary);
  color: #ffffff;
}

.option-text {
  color: var(--text);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.diagnostic-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 22px;
}

.diagnostic-actions .secondary-link {
  margin-top: 0;
}

.diagnostic-actions button {
  min-width: 136px;
}

.diagnostic-actions button:disabled {
  cursor: not-allowed;
}

.diagnostic-finished {
  text-align: left;
}

.diagnostic-finished p {
  margin-bottom: 22px;
}

@media (max-width: 1120px) {
  .portal-header {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .score-target,
  .level-target,
  .streak-target {
    min-width: 0;
  }
}

@media (max-width: 980px) {
  .portal-header {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .score-target,
  .level-target,
  .streak-target {
    min-width: 0;
  }
}

@media (max-width: 760px) {
  .portal {
    padding: 20px 16px 28px;
  }

  .portal-header,
  .diagnostic-header,
  .matrix-grid,
  .matrix-row,
  .study-item {
    grid-template-columns: 1fr;
  }

  .diagnostic,
  .training,
  .portal {
    padding: 20px 16px 28px;
  }

  .portal-header {
    align-items: stretch;
    padding: 22px;
  }

  .diagnostic-header {
    align-items: stretch;
    padding: 22px;
  }

  .portal-header h1 {
    font-size: 29px;
  }

  .diagnostic-header h1 {
    font-size: 29px;
  }

  .score-target,
  .level-target,
  .streak-target {
    min-width: 0;
  }

  .training-summary-card {
    min-width: 0;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
    gap: 4px;
  }

  .study-item {
    align-items: start;
  }

  .study-action {
    justify-self: stretch;
    width: 100%;
  }

  .study-action-panel {
    justify-items: stretch;
    width: 100%;
  }

  .study-message {
    max-width: none;
    text-align: left;
  }

  .diagnostic-progress-row,
  .diagnostic-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .diagnostic-progress-row span {
    text-align: left;
  }

  .diagnostic-panel {
    padding: 20px;
  }

  .diagnostic-panel h2 {
    font-size: 21px;
  }

  .diagnostic-option {
    grid-template-columns: 20px 34px minmax(0, 1fr);
    padding: 12px;
  }

  .option-letter {
    width: 34px;
    height: 34px;
  }
}
