:root {
  color-scheme: light;
  --paper: #fcfcfb;
  --grid: #c9d6e6;
  --ink: #1e2229;
  --ink-2: #4b5360;
  --mute: #7d8591;
  --blue: #1f5fbf;
  --red: #d03a2f;
  --green: #2e8b3e;
  --t0: #1f5fbf;
  --t1: #d97000;
  --t2: #7b45b8;
  --t3: #2e8b3e;
  --t4: #c8467f;
  --t5: #008c9e;
  --t6: #d03a2f;
  --t7: #5b5fd6;
  --hand: "Caveat", "Segoe Print", cursive;
  --body: "Kalam", "Segoe Print", cursive;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}

* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
}
body {
  margin: 0;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.5;
}
button,
select,
input {
  font: inherit;
  color: inherit;
}
a {
  color: var(--blue);
  text-underline-offset: 3px;
}
h1,
h2,
h3 {
  margin: 0;
}
h1,
h2 {
  font-family: var(--hand);
  font-weight: 700;
  line-height: 1.05;
}
h1 {
  font-size: clamp(38px, 7vw, 68px);
}
h2 {
  font-size: clamp(32px, 5vw, 48px);
}
h2 u {
  text-decoration: none;
  background: linear-gradient(
    transparent 62%,
    #ffe38a 62%,
    #ffe38a 92%,
    transparent 92%
  );
}
h3 {
  font-family: var(--hand);
  font-size: 27px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  padding: 8px max(20px, calc((100vw - 1420px) / 2));
  background: rgba(252, 252, 251, 0.97);
  border-bottom: 2px solid var(--ink);
}
.brand {
  font-weight: 700;
  min-width: 145px;
}
.section-nav {
  display: flex;
  gap: 6px;
  align-items: center;
}
.section-nav a {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  color: var(--ink);
  font: 13px var(--mono);
  text-decoration: none;
}
.section-nav a[aria-current="location"] {
  color: white;
  background: var(--ink);
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.top-actions .btn {
  font-size: 15px;
}
.author {
  color: var(--mute);
  font: 11px var(--mono);
  text-align: right;
  white-space: nowrap;
}
.lang-switch {
  display: inline-flex;
  gap: 4px;
  white-space: nowrap;
  font: 13px var(--mono);
}
.lang-switch a[aria-current="page"] {
  font-weight: 700;
  color: var(--ink);
}

.btn {
  cursor: pointer;
  padding: 6px 14px;
  background: #ffe38a;
  border: 2px solid var(--ink);
  border-radius: 3px;
  box-shadow: 3px 3px 0 var(--ink);
  font-weight: 700;
}
.btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
}
.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}
.btn.alt {
  background: #fff;
}
.btn:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid var(--t7);
  outline-offset: 3px;
}

.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 850px);
  gap: 42px;
  max-width: 1420px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}
.toc {
  position: sticky;
  top: 90px;
  align-self: start;
  max-height: calc(100vh - 112px);
  overflow-y: auto;
  padding: 12px 8px;
}
.toc h2 {
  font: 13px var(--mono);
  color: var(--mute);
  margin: 0 0 12px;
}
.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 5px;
}
.toc a {
  display: block;
  overflow: hidden;
  padding: 4px 8px;
  border-left: 3px solid transparent;
  color: var(--ink-2);
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toc a[aria-current="location"] {
  color: var(--ink);
  border-left-color: var(--blue);
  background: #eaf1fa;
  font-weight: 700;
}
.toc .toc-num {
  display: inline-block;
  width: 30px;
  font: 12px var(--mono);
  color: var(--mute);
}
main {
  min-width: 0;
}
.board {
  display: grid;
  gap: 20px;
  padding: 36px 0 66px;
  margin-bottom: 28px;
  border-bottom: 2px dashed #8793a3;
  scroll-margin-top: 92px;
}
.board:first-child {
  padding-top: 20px;
}
.board:last-child {
  border-bottom: 0;
}
.board-no {
  color: var(--mute);
  font: 13px var(--mono);
}
.board > p,
.prose {
  max-width: 72ch;
}
.prose {
  display: grid;
  gap: 14px;
  font-size: 18px;
  line-height: 1.65;
}
.prose p,
.board > p {
  margin: 0;
}
.callout {
  display: grid;
  gap: 6px;
  max-width: 72ch;
  padding: 12px 16px;
  background: #fff;
  border-left: 6px solid var(--c, var(--blue));
  box-shadow: 3px 3px 0 var(--c, var(--blue));
}
.callout > b:first-child {
  color: var(--c);
  font: 700 24px var(--hand);
}
.callout.def {
  --c: var(--t2);
}
.callout.warn {
  --c: var(--red);
}
.callout.key {
  --c: var(--green);
}
.callout.ex {
  --c: var(--t1);
}
.callout.book {
  --c: var(--t5);
}
.src {
  color: var(--mute);
  font: 11px var(--mono);
}
.extra {
  padding: 14px 18px;
  background: #fffdf3;
  border: 2px dashed var(--ink-2);
}
.extra-tag {
  display: flex;
  gap: 10px;
  align-items: baseline;
  color: var(--mute);
  font: 12px var(--mono);
}
.visual {
  max-width: 72ch;
  padding: 16px;
  background: #fff;
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}
.pattern {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.pattern .piece {
  padding: 6px 12px;
  border: 2px solid var(--ink);
  background: #f8fbff;
  font-weight: 700;
  text-align: center;
}
.piece.blue {
  background: #eaf1fa;
  border-color: var(--t0);
}
.piece.orange {
  background: #fff1df;
  border-color: var(--t1);
}
.piece.purple {
  background: #f2eafa;
  border-color: var(--t2);
}
.piece.green {
  background: #e8f4e9;
  border-color: var(--t3);
}
.piece.pink {
  background: #f9eaf1;
  border-color: var(--t4);
}
.piece.teal {
  background: #e6f6f7;
  border-color: var(--t5);
}
.piece.red {
  background: #fbe9e7;
  border-color: var(--t6);
}
.piece.indigo {
  background: #ededfa;
  border-color: var(--t7);
}
.arrow {
  color: var(--ink-2);
  font: 22px var(--hand);
}
.visual-note {
  flex-basis: 100%;
  margin: 2px 0 0;
  color: var(--ink-2);
  font-size: 15px;
  text-align: center;
}
.overview {
  width: 100%;
  height: auto;
  min-height: 160px;
  display: block;
}
.qa {
  max-width: 72ch;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
.qa-mark {
  color: var(--red);
  font: 700 54px/0.8 var(--hand);
}
.qa-body {
  display: grid;
  justify-items: start;
  gap: 10px;
}
.qa-body p {
  margin: 0;
}
.qa-answer {
  padding: 10px 14px;
  background: #fff;
  border: 2px dashed var(--green);
}
.qa[hidden],
[hidden] {
  display: none !important;
}
.summary {
  padding: 16px 20px;
  background: #fffdf3;
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}
.summary ul {
  margin: 8px 0 0;
  padding-left: 22px;
}
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}
th,
td {
  padding: 9px 11px;
  text-align: left;
  vertical-align: top;
  border: 2px dashed #9aa4b1;
}
th {
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  background: #f2f6fb;
}
.gloss {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 18px;
  max-width: 72ch;
}
.gloss dt {
  font-weight: 700;
}
.gloss dd {
  margin: 0;
  color: var(--ink-2);
}
.source-only .extra {
  display: none;
}
.source-status {
  color: var(--mute);
  font-size: 13px;
}
.footer-link {
  display: inline-block;
}
.quiz-intro {
  padding: 14px 16px;
  background: #fff;
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}

.assessment-shell {
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}
.assessment-title {
  display: grid;
  gap: 10px;
  margin-bottom: 24px;
}
.progress-wrap {
  display: grid;
  gap: 6px;
  margin: 18px 0;
}
.progress-bar {
  height: 14px;
  background: #fff;
  border: 2px solid var(--ink);
}
.progress-fill {
  height: 100%;
  width: 0;
  background: #ffe38a;
  transition: width 0.2s ease;
}
.quiz-list {
  display: grid;
  gap: 20px;
}
.question-card {
  min-width: 0;
  padding: 16px;
  background: #fff;
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}
.question-card h2 {
  margin-bottom: 10px;
  font: 700 24px var(--hand);
}
.question-meta {
  color: var(--mute);
  font: 11px var(--mono);
}
.options {
  display: grid;
  gap: 7px;
  margin: 12px 0;
}
.option {
  display: flex;
  gap: 9px;
  align-items: flex-start;
}
.option input {
  margin-top: 7px;
  accent-color: var(--blue);
}
.order-controls {
  display: grid;
  gap: 7px;
  margin: 12px 0;
}
.order-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.order-row select,
.match-row select,
.answer-input {
  min-width: 0;
  padding: 6px 9px;
  background: #fff;
  border: 2px solid var(--ink);
}
.answer-input {
  width: 100%;
  max-width: 320px;
}
.match-grid {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}
.match-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(140px, 1.2fr);
  gap: 10px;
  align-items: center;
}
.match-row select {
  width: 100%;
}
.tf-list {
  display: grid;
  gap: 10px;
}
.tf-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}
.tf-row label {
  display: flex;
  gap: 7px;
  white-space: nowrap;
}
.result {
  margin-top: 14px;
  padding: 12px;
  border: 2px solid var(--ink);
  background: #fffdf3;
}
.result.correct {
  border-color: var(--green);
}
.result.partial {
  border-color: var(--t1);
}
.result.wrong {
  border-color: var(--red);
}
.results-summary {
  margin: 20px 0;
  padding: 18px;
  background: #fff;
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}
.quiz-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.source-link {
  font: 14px var(--mono);
}

@media (max-width: 1100px) {
  .topbar {
    flex-wrap: wrap;
  }
  .brand {
    min-width: auto;
  }
  .top-actions {
    flex-wrap: wrap;
  }
}
@media (max-width: 959px) {
  .layout {
    display: block;
    max-width: 850px;
  }
  .toc {
    display: none;
  }
}
@media (max-width: 620px) {
  body {
    font-size: 17px;
  }
  .topbar {
    gap: 8px;
    padding: 8px 12px;
  }
  .section-nav {
    order: 3;
    flex-basis: 100%;
    overflow-x: auto;
    padding: 2px 0 4px;
  }
  .top-actions {
    gap: 6px;
  }
  .top-actions .btn {
    padding: 5px 8px;
    font-size: 13px;
  }
  .author {
    display: none;
  }
  .layout,
  .assessment-shell {
    padding: 18px 16px 60px;
  }
  .board {
    padding: 26px 0 46px;
    gap: 16px;
    margin-bottom: 12px;
  }
  .visual {
    padding: 12px;
  }
  .gloss {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .match-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .tf-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .qa {
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 8px;
  }
  .qa-mark {
    font-size: 42px;
  }
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
/* Stiluri pentru progresul de citire */
.toc a.completed-sec {
  color: var(--green);
  font-weight: 700;
}
.toc a.completed-sec::after {
  content: " ✓";
  color: var(--green);
  font-weight: 700;
}
.section-nav a.completed-sec {
  border-color: var(--green);
  background: #e8f4e9;
  color: var(--green);
  font-weight: 700;
}
.section-nav a.completed-sec[aria-current="location"] {
  background: var(--green);
  color: #fff;
}
.resume-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 72ch;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: #eaf1fa;
  border: 2px solid var(--blue);
  box-shadow: 3px 3px 0 var(--blue);
}
.mark-done-btn {
  justify-self: start;
  margin-top: 8px;
}
.mark-done-btn.is-done {
  background: #e8f4e9;
  border-color: var(--green);
  color: var(--green);
}
