*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f3f6fa;
  color: #17283c;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

button, input, textarea, select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.6;
}

a {
  color: #184f91;
  overflow-wrap: anywhere;
}

a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible,
select:focus-visible, .dump:focus-visible {
  outline: 3px solid #e38120;
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  top: -5rem;
  left: 1rem;
  z-index: 10;
  padding: 0.5rem 0.75rem;
  background: #fff;
}

.skip-link:focus {
  top: 0.5rem;
}

.page {
  width: min(100%, 76rem);
  margin: 0 auto;
  padding: 1rem 0.75rem 3rem;
}

.hero {
  padding: 1.5rem;
  border-radius: 1.25rem;
  background: #102238;
  color: #fff;
  text-align: center;
}

.hero-top {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.eyebrow {
  margin: 0;
  color: #c5d7ef;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.language-button {
  min-height: 2.75rem;
  padding: 0.35rem 0.8rem;
  border: 1px solid #c5d7ef;
  border-radius: 0.6rem;
  background: transparent;
  color: #fff;
}

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

h1 {
  margin-bottom: 0.75rem;
  font-size: clamp(2rem, 8vw, 3.5rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.lead {
  margin-bottom: 0;
  color: #e3ebf7;
  font-size: 1.1rem;
}

.main-tabs {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  max-width: 60rem;
  margin: 1rem auto 0;
}

.main-tab {
  flex: 1 1 0;
  min-width: 0;
  max-width: 9rem;
  min-height: 2.75rem;
  padding: 0.55rem 1rem;
  border: 1px solid #b8c9dd;
  border-radius: 0.65rem;
  background: #fff;
  color: #184f91;
  font-weight: 700;
}

.main-tab[aria-selected="true"] {
  border-color: #184f91;
  background: #184f91;
  color: #fff;
}

.guide {
  margin: 1rem auto 0;
  text-align: center;
}

.guide, .workspace, .scope-note {
  max-width: 60rem;
}

.panel {
  min-width: 0;
  padding: 1.25rem;
  border: 1px solid #d7e0ec;
  border-radius: 1rem;
  background: #fff;
}

.panel h2 {
  margin-bottom: 0.75rem;
  font-size: 1.35rem;
  line-height: 1.3;
}

.guide p {
  max-width: 48rem;
  margin: 0 auto 0.6rem;
  text-align: left;
}

.workspace {
  display: grid;
  gap: 1rem;
  margin: 1rem auto 0;
}

.lessons, .exercise {
  text-align: center;
}

.small-note {
  color: #40556d;
  font-size: 0.9rem;
}

.lesson-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.lesson-button {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid #b8c9dd;
  border-radius: 0.6rem;
  background: #f6f9fd;
  color: #17283c;
  text-align: center;
}

.lesson-button[aria-current="true"] {
  border-color: #184f91;
  background: #e6f0ff;
  font-weight: 700;
}

.lesson-count {
  display: block;
  color: #40556d;
  font-size: 0.85rem;
  font-weight: 400;
}

.question-count {
  margin-bottom: 0.4rem;
  color: #40556d;
  font-size: 0.9rem;
}

.question-prompt {
  font-weight: 600;
}

.dump-heading {
  margin-top: 1.5rem;
}

.dump-heading h3 {
  margin-bottom: 0.25rem;
}

.comparison-reference {
  margin: 1rem 0 0.75rem;
}

.comparison-reference h4 {
  margin: 0.9rem 0 0.35rem;
}

.comparison-reference .small-note {
  margin-bottom: 0.5rem;
}

.dump {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  overflow-x: auto;
  padding: 0.75rem;
  border: 1px solid #b8c9dd;
  border-radius: 0.6rem;
  background: #f8fafc;
  text-align: left;
}

.dump-row {
  display: grid;
  grid-template-columns: 3.2rem max-content 5rem;
  align-items: center;
  gap: 0.55rem;
  width: max-content;
  margin-bottom: 0.4rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.dump-row:last-child {
  margin-bottom: 0;
}

.row-offset {
  color: #40556d;
  font-weight: 700;
}

.byte-list {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.15rem;
}

.byte-button {
  min-width: 2.35rem;
  min-height: 2.5rem;
  padding: 0.2rem;
  border: 1px solid #bdcbd9;
  border-radius: 0.3rem;
  background: #fff;
  color: #17283c;
  font-family: inherit;
  font-weight: 700;
}

.reference-byte {
  display: inline-grid;
  place-items: center;
  min-width: 2.35rem;
  min-height: 2.5rem;
  padding: 0.2rem;
  border: 1px solid #bdcbd9;
  border-radius: 0.3rem;
  background: #fff;
  color: #17283c;
  font-weight: 700;
}

.byte-button.is-selected {
  border-color: #184f91;
  background: #d9eaff;
}

.byte-button.is-start {
  outline: 2px solid #184f91;
  outline-offset: 1px;
}

.byte-button.is-solution {
  border-color: #236541;
  background: #d7f3df;
}

.byte-button:disabled {
  opacity: 1;
}

.ascii-cell {
  grid-column: auto;
  white-space: pre;
  color: #40556d;
}

.selection-preview {
  min-height: 1.5rem;
  margin: 0.75rem 0 1rem;
  font-size: 0.9rem;
}

.range-fields {
  display: grid;
  gap: 0.75rem;
  max-width: 32rem;
  margin: 0 auto;
}

.range-fields label, .value-field label {
  display: grid;
  gap: 0.25rem;
  font-weight: 600;
  text-align: left;
}

input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid #879bb3;
  border-radius: 0.45rem;
  background: #fff;
  color: #17283c;
}

.value-field {
  max-width: 32rem;
  margin: 0 auto;
}

.primary-button, .secondary-button, .text-button {
  min-height: 2.75rem;
  padding: 0.55rem 0.9rem;
  border-radius: 0.55rem;
  font-weight: 700;
}

.primary-button {
  border: 1px solid #184f91;
  background: #184f91;
  color: #fff;
}

.secondary-button {
  border: 1px solid #184f91;
  background: #fff;
  color: #184f91;
}

.text-button {
  border: 1px solid transparent;
  background: transparent;
  color: #184f91;
  text-decoration: underline;
}

#check-button {
  margin-top: 0.9rem;
}

.help-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.7rem;
}

.hint-text:empty, .feedback:empty {
  display: none;
}

.hint-text, .feedback {
  margin: 0.9rem 0 0;
  padding: 0.7rem 0.85rem;
  border-radius: 0.5rem;
  background: #eef4fb;
}

.feedback.is-error {
  background: #fff0ed;
  color: #8d2e1c;
}

.feedback.is-success {
  background: #e2f6e8;
  color: #155035;
}

.solution {
  max-width: 40rem;
  margin: 1rem auto 0;
  padding: 1rem;
  border: 1px solid #b5ddc0;
  border-radius: 0.6rem;
  background: #f3fbf5;
  text-align: left;
}

.solution h3 {
  margin-bottom: 0.65rem;
}

.solution dl, .solution dd {
  margin: 0;
}

.solution dl {
  display: grid;
  gap: 0.65rem;
}

.solution dt {
  color: #40556d;
  font-size: 0.85rem;
  font-weight: 700;
}

.solution dd {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.next-button {
  margin-top: 1rem;
}

.scope-note {
  margin: 1.25rem auto 0;
  color: #40556d;
  font-size: 0.9rem;
  text-align: center;
}

.custom-panel {
  max-width: 60rem;
  margin: 1rem auto 0;
  text-align: center;
}

.custom-form {
  display: grid;
  gap: 0.5rem;
  max-width: 48rem;
  margin: 1rem auto;
  text-align: left;
}

.custom-form label {
  font-weight: 700;
}

.custom-form select, .custom-form textarea {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.65rem;
  border: 1px solid #879bb3;
  border-radius: 0.45rem;
  background: #fff;
  color: #17283c;
}

.custom-form textarea {
  min-height: 10rem;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.9rem;
}

.custom-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.custom-results {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid #d7e0ec;
}

.custom-results h3 {
  margin: 1rem 0 0.5rem;
}

.custom-warnings {
  display: grid;
  gap: 0.4rem;
  max-width: 48rem;
  margin: 0.75rem auto;
  padding: 0;
  list-style: none;
  text-align: left;
}

.custom-warnings:empty {
  display: none;
}

.custom-warnings li {
  padding: 0.6rem 0.75rem;
  border-left: 4px solid #a86100;
  border-radius: 0.3rem;
  background: #fff2d9;
}

.custom-fields {
  display: grid;
  gap: 0.5rem;
  max-width: 48rem;
  margin: 0 auto;
}

.custom-field {
  display: grid;
  gap: 0.15rem;
  min-height: 3rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid #b8c9dd;
  border-radius: 0.55rem;
  background: #f6f9fd;
  color: #17283c;
  text-align: left;
}

.custom-field strong {
  color: #102238;
}

.custom-field code {
  overflow-wrap: anywhere;
}

.custom-field.is-active {
  border-color: #925a00;
  background: #fff0c8;
  box-shadow: inset 4px 0 #925a00;
}

.reference-byte.is-inspected {
  border-color: #925a00;
  background: #ffdc85;
  box-shadow: inset 0 0 0 1px #925a00;
}

.custom-privacy {
  margin: 1.5rem 0 0;
}

.learning-panel {
  max-width: 60rem;
  margin: 1rem auto 0;
}

.learning-panel h2 {
  margin-bottom: 0.5rem;
  text-align: center;
}

.learning-lead {
  max-width: 48rem;
  margin: 0 auto 1rem;
}

.learning-toc {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.learning-toc a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid #b8c9dd;
  border-radius: 0.55rem;
  background: #fff;
  font-weight: 700;
}

.learning-card {
  margin-top: 1rem;
}

.learning-card h3 {
  margin-bottom: 0.7rem;
  text-align: center;
}

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

.learning-card code {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.92em;
}

.learning-interaction-note {
  max-width: 60rem;
  margin: 0.75rem auto 1rem;
  color: #40556d;
  text-align: center;
}

.packet-stack {
  display: grid;
  gap: 0.5rem;
  margin: 1rem 0;
  padding: 0;
  list-style: none;
}

.packet-stack li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid #d7e0ec;
  border-radius: 0.55rem;
  background: #f8fafc;
}

.packet-stack code {
  min-width: 3.5rem;
  color: #184f91;
  font-weight: 700;
}

.packet-figure {
  margin: 1.1rem 0;
}

.packet-figure figcaption {
  margin-bottom: 0.45rem;
  font-size: 0.92rem;
  font-weight: 600;
}

.diagram-hint {
  display: block;
  color: #40556d;
  font-size: 0.85rem;
  font-weight: 400;
}

.diagram-scroll {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid #c5d5e7;
  border-radius: 0.55rem;
  background: #f8fafc;
}

.diagram-scroll:focus-visible {
  outline: 3px solid #e38120;
  outline-offset: 3px;
}

.diagram-layout {
  min-width: 44rem;
  padding: 0.45rem;
}

.diagram-row {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  align-items: stretch;
}

.diagram-offset {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #40556d;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 700;
}

.diagram-bit-axis,
.diagram-byte-axis {
  display: grid;
  color: #40556d;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.76rem;
  text-align: center;
}

.diagram-bit-axis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.diagram-byte-axis {
  grid-template-columns: repeat(14, minmax(0, 1fr));
}

.diagram-cells {
  display: grid;
  gap: 1px;
  padding: 1px;
  background: #aabed6;
}

.diagram-cells--bits {
  grid-template-columns: repeat(32, minmax(0, 1fr));
}

.diagram-cells--bytes {
  grid-template-columns: repeat(14, minmax(0, 1fr));
}

.diagram-field {
  display: flex;
  min-width: 0;
  min-height: 3.55rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.1rem;
  background: #eef4fb;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
}

.diagram-field.is-highlighted {
  background: #fff0c2;
  box-shadow: inset 0 0 0 2px #a35e00;
}

.diagram-field.is-selected {
  background: #ffdc83;
  box-shadow: inset 0 0 0 3px #805000;
}

.diagram-field:focus-visible {
  position: relative;
  z-index: 1;
  outline: 3px solid #a35e00;
  outline-offset: -3px;
}

.diagram-field strong {
  font-size: 0.78rem;
}

.diagram-field code {
  color: #17467c;
  font-size: 0.76rem;
  font-weight: 700;
}

.learning-dump-panel {
  margin: 1rem 0;
  padding: 0.8rem;
  border: 1px solid #d7e0ec;
  border-radius: 0.55rem;
  background: #f8fafc;
}

.learning-dump-panel h4 {
  margin: 0 0 0.4rem;
  text-align: center;
}

.learning-dump-note {
  margin: 0 0 0.65rem;
  color: #40556d;
  font-size: 0.9rem;
}

.learning-dump {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  overflow-x: auto;
  padding: 0.5rem;
  border: 1px solid #c5d5e7;
  border-radius: 0.4rem;
  background: #fff;
}

.learning-dump:focus-visible {
  outline: 3px solid #e38120;
  outline-offset: 3px;
}

.learning-dump-row {
  display: grid;
  grid-template-columns: 3.2rem repeat(8, 2.3rem);
  gap: 0.15rem;
  align-items: center;
  width: max-content;
  margin-bottom: 0.25rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.learning-dump-row:last-child {
  margin-bottom: 0;
}

.learning-row-offset {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fff;
  color: #40556d;
  font-weight: 700;
  box-shadow: 2px 0 0 #d7e0ec;
}

.learning-byte {
  display: inline-flex;
  min-height: 2rem;
  align-items: center;
  justify-content: center;
  border: 1px solid #bdcbd9;
  border-radius: 0.25rem;
  background: #fff;
  color: #17283c;
  font-size: 0.875rem;
  font-weight: 700;
}

.learning-byte.is-context {
  border-color: #d7e0ec;
  background: #edf2f7;
  color: #526478;
}

.learning-byte.is-highlighted {
  border-color: #a35e00;
  background: #fff0c2;
  box-shadow: inset 0 0 0 1px #a35e00;
}

.learning-byte.is-selected {
  border-color: #805000;
  background: #ffdc83;
  box-shadow: inset 0 0 0 2px #805000;
}

.learning-selection {
  min-height: 1.4rem;
  margin: 0.7rem 0 0;
  color: #28435f;
  font-size: 0.9rem;
}

.learning-nibble {
  margin-top: 0.75rem;
  padding-top: 0.7rem;
  border-top: 1px solid #d7e0ec;
}

.learning-nibble-title {
  margin: 0 0 0.35rem;
  font-weight: 700;
}

.learning-nibble-equation {
  margin: 0 0 0.5rem;
}

.learning-nibble-parts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.learning-nibble-part {
  display: flex;
  flex: 1 1 11rem;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.55rem;
  border: 1px solid #bdcbd9;
  border-radius: 0.4rem;
  background: #fff;
}

.learning-nibble-part.is-highlighted {
  border-color: #a35e00;
  background: #fff0c2;
}

.learning-nibble-part.is-selected {
  border-color: #805000;
  background: #ffdc83;
  box-shadow: inset 0 0 0 1px #805000;
}

.learning-nibble-part code {
  font-weight: 700;
}

.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-13 { grid-column: span 13; }
.span-16 { grid-column: span 16; }
.span-32 { grid-column: span 32; }

@media (max-width: 47.99rem) {
  .diagram-field.span-32 {
    align-items: flex-start;
    padding-left: 1rem;
  }
}

.learning-fields {
  margin: 1rem 0;
}

.learning-fields > div {
  display: grid;
  gap: 0.25rem;
  padding: 0.7rem 0.75rem;
  border-top: 1px solid #d7e0ec;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.learning-fields > div.is-highlighted {
  background: #fff3d0;
  box-shadow: inset 4px 0 0 #a35e00;
}

.learning-fields > div.is-selected {
  background: #ffe9ad;
  box-shadow: inset 5px 0 0 #805000;
}

.learning-fields > div:last-child {
  border-bottom: 1px solid #d7e0ec;
}

.learning-fields dt {
  font-weight: 700;
}

.learning-fields dd {
  min-width: 0;
  margin: 0;
}

.learning-reference {
  padding: 0.8rem;
  border-radius: 0.55rem;
  background: #eef4fb;
}

.back-to-practice {
  display: block;
  margin: 1.5rem auto 0;
}

[hidden] {
  display: none;
}

.footer {
  padding: 0 1rem 2rem;
  color: #40556d;
  font-size: 0.9rem;
  text-align: center;
}

@media (min-width: 48rem) {
  .page {
    padding: 2rem 1rem 3rem;
  }

  .hero {
    padding: 2.5rem;
    position: relative;
  }

  .language-button {
    position: absolute;
    top: 2.5rem;
    right: 2.5rem;
  }

  .lesson-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .range-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .custom-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .packet-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .learning-fields > div {
    grid-template-columns: minmax(11rem, 13rem) minmax(0, 1fr);
    gap: 1rem;
  }

}

@media (min-width: 60rem) {
  .diagram-hint {
    display: none;
  }
}
