:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #5f6d67;
  --line: #cfd8d3;
  --panel: #ffffff;
  --wash: #eef3f1;
  --accent: #1b7f6b;
  --accent-dark: #0e5a4c;
  --good: #1d7a3f;
  --bad: #b72c2c;
  --warn: #9a6a08;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(202, 243, 255, 0.95) 0%, rgba(234, 247, 255, 0.72) 30%, rgba(255, 249, 238, 0.84) 100%),
    linear-gradient(135deg, #d7f6ff 0%, #eef7fb 52%, #fff3df 100%);
}

main {
  width: min(980px, calc(100vw - 108px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.portalRail {
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 20;
  width: 42px;
  padding: 10px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.54);
  border-color: rgba(23, 33, 27, 0.12);
}

.portalRailLeft {
  left: 0;
  border-right: 1px solid rgba(23, 33, 27, 0.12);
}

.portalRailRight {
  right: 0;
  border-left: 1px solid rgba(23, 33, 27, 0.12);
}

.railIcon {
  width: 30px;
  min-height: 30px;
  border: 1px solid rgba(27, 127, 107, 0.18);
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: #05243f;
  background: #ffffff;
  box-shadow: 0 6px 14px rgba(23, 33, 27, 0.1);
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
}

.railIcon:nth-child(3n + 1) {
  background: #33d6bd;
}

.railIcon:nth-child(3n + 2) {
  background: #39b7ff;
}

.railIcon:nth-child(3n) {
  background: #ff9b45;
}

.railIcon.active {
  outline: 2px solid rgba(255, 155, 69, 0.45);
  background: #ff9b45;
}

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

.portalHeader h1 {
  margin-bottom: 0;
  font-size: clamp(42px, 6vw, 64px);
}

.portalHome {
  border: 1px solid rgba(40, 198, 218, 0.4);
  border-radius: 8px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.72);
  color: #00a6bd;
  font-weight: 800;
  text-decoration: none;
}

.embedded body {
  background: transparent;
}

.embedded .portalRail,
.embedded .portalHeader {
  display: none;
}

.embedded main {
  width: min(980px, calc(100vw - 32px));
  padding: 22px 0 32px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 50px rgba(23, 33, 27, 0.08);
}

.brand {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1, h2, p {
  margin-top: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  margin-bottom: 14px;
}

h2 {
  font-size: 24px;
  margin: 4px 0 0;
}

.subtle {
  color: var(--muted);
}

.welcomeCopy {
  max-width: 760px;
  font-size: 18px;
  line-height: 1.5;
}

.welcomeCopy p {
  margin: 0 0 12px;
}

.welcomeCopy p:last-child {
  margin-bottom: 0;
}

form {
  display: grid;
  gap: 16px;
  max-width: 560px;
  margin-top: 28px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 13px;
  font: inherit;
}

.check {
  grid-template-columns: 22px 1fr;
  align-items: start;
  font-weight: 400;
  color: var(--muted);
}

.check input {
  width: auto;
  margin-top: 2px;
}

.pledge {
  margin: 22px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--wash);
}

.pledge p {
  margin-bottom: 12px;
}

.quizChoices {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.quizChoice {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 400;
}

.quizChoice input {
  width: auto;
  margin-top: 3px;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 13px 18px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  background: #94aaa3;
}

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

.timer {
  min-width: 96px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: center;
  font-weight: 700;
  background: var(--wash);
}

.progressMeta {
  margin-top: 24px;
  color: var(--muted);
  font-size: 14px;
  flex-wrap: wrap;
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--wash);
  margin: 10px 0 26px;
}

.progress div {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 180ms ease;
}

.options {
  display: grid;
  gap: 12px;
  margin: 24px 0;
}

.option {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: start;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.option:hover {
  border-color: var(--accent);
}

.option input {
  width: auto;
  margin-top: 2px;
}

.option.correct {
  border-color: rgba(29, 122, 63, 0.55);
  background: rgba(29, 122, 63, 0.08);
}

.option.wrong {
  border-color: rgba(183, 44, 44, 0.55);
  background: rgba(183, 44, 44, 0.08);
}

.feedback {
  min-height: 24px;
  font-weight: 800;
}

.reason {
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
  background: var(--wash);
  color: #26352e;
}

.flags {
  color: var(--muted);
  font-size: 13px;
}

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

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

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

.score {
  font-size: 56px;
  font-weight: 800;
  color: var(--accent-dark);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
}

.tableWrap {
  overflow-x: auto;
}

.adminActions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0;
}

.adminActions button {
  width: auto;
}

.adminLink {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.adminSummary {
  color: var(--muted);
  font-weight: 700;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

@media (max-width: 680px) {
  .portalRailRight {
    display: none;
  }

  .portalRail {
    width: 36px;
    padding: 8px 4px;
  }

  .railIcon {
    width: 27px;
    min-height: 27px;
    font-size: 10px;
  }

  main {
    width: calc(100vw - 48px);
    margin-left: 42px;
    padding: 9px 0;
  }

  .portalHeader {
    display: block;
  }

  .portalHome {
    display: inline-block;
    margin-top: 8px;
  }

  .panel {
    padding: 18px;
  }

  .quizHeader,
  footer {
    align-items: stretch;
    flex-direction: column;
  }

  button {
    width: 100%;
  }
}
