:root {
  color-scheme: light;
  --ink: #162235;
  --muted: #5d6878;
  --line: #d7e0eb;
  --paper: #f6f8fb;
  --panel: #ffffff;
  --blue: #1463ff;
  --teal: #08786f;
  --yellow: #f3c542;
  --topbar: #0b4f5f;
  --topbar-deep: #07313b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.55;
}

a {
  color: inherit;
}

.reader-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px clamp(14px, 3vw, 34px);
  background: linear-gradient(90deg, var(--topbar-deep), var(--topbar));
  border-bottom: 3px solid var(--yellow);
  color: #ffffff;
}

.brand {
  display: inline-flex;
  flex: 0 0 auto;
}

.brand-logo {
  width: 94px;
  height: 62px;
  object-fit: contain;
  display: block;
  background: #ffffff;
  border-radius: 8px;
  padding: 4px;
}

.reader-title {
  min-width: 0;
  flex: 1;
}

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

.reader-title h1 {
  margin-bottom: 2px;
  font-size: clamp(28px, 4vw, 46px);
  letter-spacing: 0;
}

.reader-title p {
  margin-bottom: 0;
  color: #d7f0f3;
  font-weight: 700;
}

.reader-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.reader-nav a {
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 8px;
  padding: 8px 12px;
  text-decoration: none;
  font-weight: 800;
}

.reader-header .wordwise-control {
  flex: 0 0 230px;
  margin-left: 0;
  border-right: 0;
  border-radius: 0;
}

.reader-header .reading-age-control {
  flex: 0 0 210px;
  margin-left: auto;
  border-right: 0;
  border-radius: 8px 0 0 8px;
}

.reader-header .reading-age-control + .wordwise-control {
  border-radius: 0;
}

.reader-header .layout-control {
  flex: 0 0 auto;
  border-right: 0;
  border-radius: 0;
}

.reader-header .print-control {
  flex: 0 0 auto;
  border-radius: 0 8px 8px 0;
}

.library-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 22px auto 48px;
}

.library-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 180px;
  gap: 10px;
  align-items: end;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.library-tools label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.library-tools input,
.library-tools select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

.library-summary {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: baseline;
  margin: 22px 0 14px;
}

.library-summary h2 {
  margin-bottom: 0;
  font-size: 28px;
}

#result-count {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 800;
}

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

.article-card {
  min-width: 0;
  background: var(--panel);
  border: 2px solid #7893b5;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(22, 34, 53, 0.12);
}

.article-card a {
  display: grid;
  grid-template-rows: 170px 1fr;
  min-height: 100%;
  text-decoration: none;
}

.thumb {
  position: relative;
  background: #ffffff;
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb img:not([src]) {
  display: none;
}

.placeholder-thumb {
  display: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background:
    linear-gradient(90deg, rgba(20, 99, 255, 0.12) 1px, transparent 1px),
    linear-gradient(rgba(20, 99, 255, 0.12) 1px, transparent 1px),
    #ffffff;
  background-size: 24px 24px;
  color: var(--teal);
  font-size: 30px;
  font-weight: 900;
}

.thumb img:not([src]) + .placeholder-thumb {
  display: flex;
}

.article-card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.subject {
  color: var(--teal);
}

.audience {
  color: var(--ink);
}

.tags {
  color: var(--teal);
  font-size: 13px;
  font-weight: 900;
}

.article-card h3 {
  margin-bottom: 8px;
  font-size: 21px;
  line-height: 1.2;
}

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

.open-label {
  margin-top: auto;
  color: var(--blue);
  font-weight: 900;
}

.article-shell {
  width: min(900px, calc(100% - 28px));
  margin: 26px auto 56px;
}

.reading-article {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: clamp(18px, 4vw, 42px);
  overflow-wrap: anywhere;
}

.reading-article h1 {
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1.08;
  letter-spacing: 0;
}

.print-meta {
  display: none;
}

.print-logo {
  display: none;
}

.kicker,
.source-note {
  color: var(--muted);
  font-weight: 800;
}

.source-note a {
  color: var(--blue);
}

.wordwise-control,
.reading-age-control,
.layout-control,
.print-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  align-items: center;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(251, 252, 255, 0.96);
  box-shadow: 0 10px 24px rgba(22, 34, 53, 0.12);
  backdrop-filter: blur(8px);
}

.wordwise-control label,
.reading-age-control label,
.layout-control label {
  color: var(--teal);
  font-size: 13px;
  font-weight: 900;
}

.wordwise-control input,
.reading-age-control input {
  grid-column: 1 / -1;
  width: 100%;
}

#wordwise-value,
#reading-age-value {
  min-width: 54px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  text-align: right;
}

.layout-control {
  align-content: center;
  min-height: 62px;
}

.layout-control label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.layout-control input {
  width: 18px;
  height: 18px;
}

.print-control {
  align-content: center;
  min-height: 62px;
}

.print-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--teal);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.print-button:hover,
.print-button:focus-visible {
  border-color: var(--teal);
  outline: 0;
}

.reading-age {
  display: none;
}

body[data-reading-age="7"] .reading-age.age-7,
body[data-reading-age="8"] .reading-age.age-8,
body[data-reading-age="9"] .reading-age.age-9,
body[data-reading-age="10"] .reading-age.age-10,
body[data-reading-age="11"] .reading-age.age-11 {
  display: block;
}

.article-text {
  font-size: 19px;
}

.article-text p {
  margin-bottom: 20px;
}

body[data-article-layout="columns"] .article-shell {
  width: min(1500px, calc(100% - 28px));
}

body[data-article-layout="columns"] .article-text {
  column-count: 3;
  column-gap: 34px;
  column-rule: 1px solid var(--line);
}

body[data-article-layout="columns"] .article-text p {
  break-inside: avoid;
}

.ww {
  position: relative;
  display: inline-block;
  margin: 0 2px;
  padding-top: 1.15em;
  line-height: 1.1;
  vertical-align: baseline;
}

.ww-note {
  position: absolute;
  top: 0;
  left: 50%;
  width: max-content;
  max-width: 160px;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  overflow-wrap: normal;
  white-space: nowrap;
}

.ww-word {
  display: inline;
  border-top: 1px solid rgba(8, 120, 111, 0.65);
  box-shadow: inset 0 2px 0 rgba(8, 120, 111, 0.08);
}

body[data-wordwise-level="0"] .ww {
  display: inline;
  margin: 0;
  padding-top: 0;
}

body[data-wordwise-level="0"] .ww-note {
  display: none;
}

body[data-wordwise-level="0"] .ww-word {
  border-top: 0;
  box-shadow: none;
}

body[data-wordwise-level="1"] .ww.level-1,
body[data-wordwise-level="1"] .ww.level-2,
body[data-wordwise-level="1"] .ww.level-3,
body[data-wordwise-level="2"] .ww.level-1,
body[data-wordwise-level="2"] .ww.level-2,
body[data-wordwise-level="3"] .ww.level-1 {
  display: inline;
  margin: 0;
  padding-top: 0;
}

body[data-wordwise-level="1"] .ww.level-1 .ww-note,
body[data-wordwise-level="1"] .ww.level-2 .ww-note,
body[data-wordwise-level="1"] .ww.level-3 .ww-note,
body[data-wordwise-level="2"] .ww.level-1 .ww-note,
body[data-wordwise-level="2"] .ww.level-2 .ww-note,
body[data-wordwise-level="3"] .ww.level-1 .ww-note {
  display: none;
}

body[data-wordwise-level="1"] .ww.level-1 .ww-word,
body[data-wordwise-level="1"] .ww.level-2 .ww-word,
body[data-wordwise-level="1"] .ww.level-3 .ww-word,
body[data-wordwise-level="2"] .ww.level-1 .ww-word,
body[data-wordwise-level="2"] .ww.level-2 .ww-word,
body[data-wordwise-level="3"] .ww.level-1 .ww-word {
  border-top: 0;
  box-shadow: none;
}

.questions li,
.answers li {
  margin-bottom: 14px;
}

.questions li::after {
  content: "";
  display: block;
  height: 84px;
  margin: 12px 0 22px;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 25px,
    #6f7f90 26px,
    transparent 27px
  );
}

.vocab-task,
.vocab-answers,
.vocab-answer-key {
  margin: 22px 0;
}

.vocab-task h3,
.vocab-answers h3,
.vocab-answer-key h3 {
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 19px;
}

.vocab-task table,
.vocab-answers table,
.vocab-answer-key table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  table-layout: fixed;
}

.vocab-task th:first-child,
.vocab-task td:first-child,
.vocab-answers th:first-child,
.vocab-answers td:first-child,
.vocab-answer-key th:first-child,
.vocab-answer-key td:first-child {
  width: 24%;
}

.vocab-task th:first-child,
.vocab-answers th:first-child,
.vocab-answer-key th:first-child {
  font-weight: 800;
}

.vocab-task td:first-child,
.vocab-answers td:first-child,
.vocab-answer-key td:first-child {
  font-weight: 400;
}

.vocab-task th,
.vocab-task td,
.vocab-answers th,
.vocab-answers td,
.vocab-answer-key th,
.vocab-answer-key td {
  border: 2px solid #2c3a4a;
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.vocab-task td:last-child {
  height: 44px;
}

.answer-example {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.answer-question {
  margin: 0 0 8px;
  font-weight: 900;
}

.answer-text {
  margin: 0;
}

.source-note {
  border-top: 1px solid var(--line);
  margin: 28px 0 0;
  padding-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.wordwise,
.vocab-task,
.questions,
.answers,
.vocab-answer-key {
  margin: 22px 0;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcff;
}

.article-image {
  margin: 24px 0;
}

.article-image img {
  display: block;
  width: 100%;
  max-height: 460px;
  object-fit: cover;
  border-radius: 8px;
}

details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  margin: -4px -4px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px 8px 36px;
  background: #ffffff;
  cursor: pointer;
  color: var(--teal);
  font-size: 20px;
  font-weight: 900;
}

details summary::marker,
details summary::-webkit-details-marker {
  display: none;
  content: "";
}

details summary::before {
  content: "▾";
  position: absolute;
  left: 12px;
  top: 50%;
  color: var(--teal);
  font-size: 18px;
  line-height: 1;
  transform: translateY(-50%) rotate(-90deg);
  transition: transform 0.15s ease;
}

details[open] > summary::before {
  transform: translateY(-50%) rotate(0deg);
}

.score-box {
  flex: 0 0 auto;
  border: 2px solid #2c3a4a;
  border-radius: 6px;
  padding: 3px 9px;
  background: #ffffff;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}

.reflection-box {
  margin: 18px 0 0;
  border: 2px solid #2c3a4a;
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
  break-inside: avoid;
}

.reflection-box h3 {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 18px;
}

.reflection-box p {
  margin: 0 0 8px;
  font-weight: 800;
}

.strategy-checklist {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  margin: 10px 0 12px;
  padding: 0;
  list-style: none;
}

.strategy-checklist li {
  position: relative;
  min-height: 24px;
  padding-left: 28px;
  font-weight: 700;
}

.strategy-checklist li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 2px;
  width: 17px;
  height: 17px;
  border: 2px solid #2c3a4a;
  background: #ffffff;
}

.next-target {
  margin-top: 10px;
}

.reflection-lines {
  height: 90px;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 27px,
    #6f7f90 28px,
    transparent 29px
  );
}

dt {
  font-weight: 900;
}

dd {
  margin: 0 0 10px;
}

@media print {
  @page {
    size: A4;
    margin: 0;
  }

  .reader-header {
    display: none;
  }

  html,
  body {
    background: #ffffff;
    margin: 0;
    padding: 0;
  }

  body::before {
    content: "";
    position: fixed;
    inset: 5mm;
    z-index: 999;
    border: 2px solid #0b4f5f;
    pointer-events: none;
  }

  .article-shell {
    width: 100%;
    margin: 0;
  }

  .reading-article {
    border: 0;
    border-radius: 0;
    padding: 10mm 11mm;
  }

  .print-logo {
    display: block;
    width: 34mm;
    height: auto;
    margin: 0 0 5mm;
  }

  .print-meta {
    display: block;
    margin: 0 0 12px;
    color: #333333;
    font-size: 11px;
    font-weight: 800;
  }

  details {
    break-inside: avoid;
  }

  details:not([open]) {
    display: none;
  }

  details[open] {
    border: 1px solid #111111;
    padding: 4mm;
    background: transparent;
  }

  details summary {
    margin: 0 0 4mm;
    border: 0;
    padding: 0;
    background: transparent;
  }

  details summary::before {
    display: none;
  }

  .wordwise-control,
  .reading-age-control,
  .layout-control,
  .print-control {
    display: none;
  }

  .ww-note {
    color: #333333;
    margin-bottom: 1mm;
    font-size: 7.5pt;
    line-height: 1.05;
  }

  body:not([data-wordwise-level="0"]) .article-text p,
  body:not([data-wordwise-level="0"]) .questions li,
  body:not([data-wordwise-level="0"]) .answers li,
  body:not([data-wordwise-level="0"]) .reflection-box p,
  body:not([data-wordwise-level="0"]) .strategy-checklist li {
    line-height: 2.15;
  }

  body:not([data-wordwise-level="0"]) .ww {
    margin-top: 1mm;
    margin-bottom: 0.5mm;
    padding-top: 1.35em;
    vertical-align: baseline;
  }

  .source-note {
    font-size: 9px;
  }

  .questions li::after {
    height: 90px;
    margin-bottom: 18px;
    background: repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 27px,
      #444444 28px,
      transparent 29px
    );
  }

  .score-box,
  .reflection-box {
    border-color: #111111;
  }

  .reflection-box {
    padding-top: 6mm;
  }

  .reflection-lines {
    background: repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 27px,
      #444444 28px,
      transparent 29px
    );
  }

  .vocab-task th,
  .vocab-task td,
  .vocab-answers th,
  .vocab-answers td,
  .vocab-answer-key th,
  .vocab-answer-key td {
    border-color: #111111;
  }
}

@media (max-width: 820px) {
  .reader-header,
  .library-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .library-tools,
  .article-grid {
    grid-template-columns: 1fr;
  }

  .wordwise-control,
  .reading-age-control,
  .layout-control,
  .print-control {
    width: min(210px, 58vw);
  }

  .reader-header .wordwise-control,
  .reader-header .reading-age-control,
  .reader-header .layout-control,
  .reader-header .print-control {
    flex-basis: auto;
    width: 100%;
    margin-left: 0;
    border: 2px solid var(--line);
    border-radius: 8px;
  }

  body[data-article-layout="columns"] .article-text {
    column-count: 1;
  }
}
