:root {
  color-scheme: light;
  --paper: #fbfaf7;
  --surface: #ffffff;
  --ink: #1d2327;
  --muted: #687076;
  --line: #d9d4cc;
  --line-strong: #b7afa3;
  --green: #245c4f;
  --green-soft: #e7f1ed;
  --blue: #204b7a;
  --amber: #b36b22;
  --danger: #a33a2e;
  --shadow: 0 14px 34px rgba(30, 35, 39, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(18px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 247, 0.96);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.book-signal {
  width: 48px;
  height: 64px;
  flex: 0 0 auto;
  border-radius: 4px;
  object-fit: cover;
  box-shadow: 0 10px 18px rgba(29, 35, 39, 0.18);
}

.eyebrow,
.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  letter-spacing: 0;
  line-height: 1.1;
}

.save-state {
  min-width: 142px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  font-size: 0.92rem;
}

.save-state.busy {
  color: var(--blue);
  border-color: rgba(32, 75, 122, 0.35);
}

.save-state.done {
  color: var(--green);
  border-color: rgba(36, 92, 79, 0.35);
}

.save-state.error {
  color: var(--danger);
  border-color: rgba(163, 58, 46, 0.35);
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: clamp(18px, 3vw, 36px);
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 38px);
  padding-bottom: 112px;
}

.nav-panel {
  align-self: start;
  position: sticky;
  top: 112px;
  display: grid;
  gap: 16px;
}

.progress-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
}

.progress-block span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #ece6de;
}

#progressFill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

#sectionNav {
  display: grid;
  gap: 6px;
}

.nav-button {
  width: 100%;
  min-height: 42px;
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.nav-button:hover {
  background: rgba(36, 92, 79, 0.08);
}

.nav-button.active {
  background: var(--green-soft);
  color: var(--green);
  font-weight: 700;
}

.form-panel {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.section-shell,
.success-shell {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.section-header {
  display: grid;
  gap: 10px;
  padding: clamp(20px, 3vw, 32px);
  border-bottom: 1px solid var(--line);
  background: #fffdf9;
}

.intro-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(260px, 36%) minmax(0, 1fr);
  gap: clamp(22px, 4vw, 42px);
  align-items: stretch;
  padding: clamp(20px, 3vw, 34px);
  overflow: hidden;
  background:
    linear-gradient(120deg, rgba(13, 13, 12, 0.82), rgba(29, 35, 39, 0.68)),
    url("/assets/de-achterkant-cover.jpg") center / cover;
}

.intro-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(1.5px);
}

.cover-frame,
.letter-panel {
  position: relative;
  z-index: 1;
}

.cover-frame {
  display: grid;
  place-items: center;
}

.cover-frame img {
  width: min(100%, 360px);
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: 0 24px 58px rgba(0, 0, 0, 0.46);
}

.letter-panel {
  align-self: center;
  display: grid;
  gap: 14px;
  max-width: 820px;
  color: #fff8ef;
}

.letter-panel .eyebrow {
  color: #e4ba80;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.letter-panel h2 {
  margin: 0;
  color: #fff8ef;
  font-size: clamp(1.75rem, 3.8vw, 3.2rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.letter-copy {
  display: grid;
  gap: 11px;
  max-width: 760px;
  font-size: clamp(1rem, 1.25vw, 1.1rem);
}

.letter-copy p {
  margin: 0;
}

.reader-section {
  padding: clamp(20px, 3vw, 32px) clamp(20px, 3vw, 32px) 0;
}

.reader-intro {
  display: grid;
  gap: 10px;
  max-width: 900px;
}

.reader-intro h3 {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.65rem);
  line-height: 1.18;
}

.section-header h2 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.35rem);
  line-height: 1.12;
  letter-spacing: 0;
}

.section-note,
.intro-copy p,
.question-help,
.field-help {
  margin: 0;
  color: var(--muted);
}

.intro-copy {
  display: grid;
  gap: 10px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: clamp(20px, 3vw, 32px);
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field.full {
  grid-column: 1 / -1;
}

label,
.score-title,
.chapter-title {
  font-weight: 750;
  letter-spacing: 0;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: var(--surface);
}

textarea {
  min-height: 144px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(32, 75, 122, 0.18);
  border-color: var(--blue);
}

.question-list {
  display: grid;
  gap: 18px;
  padding: clamp(20px, 3vw, 32px);
}

.question {
  display: grid;
  gap: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.question:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.question-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.core-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 9px;
  background: #fff3dc;
  color: #78420d;
  font-size: 0.82rem;
  font-weight: 750;
}

.textarea-wrap {
  display: grid;
  gap: 8px;
}

.field-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.dictate-button,
.small-button {
  min-height: 34px;
  border-radius: 8px;
  padding: 7px 11px;
  color: var(--blue);
  background: #eef5fb;
  font-weight: 700;
}

.dictate-button.recording {
  color: #fff;
  background: var(--danger);
}

.dictate-button.processing {
  color: var(--muted);
  background: #ece6de;
}

.score-list {
  display: grid;
  gap: 12px;
  padding: clamp(20px, 3vw, 32px);
}

.score-row {
  display: grid;
  grid-template-columns: minmax(210px, 1.2fr) 96px minmax(240px, 1fr);
  gap: 14px;
  align-items: start;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.score-row:last-child {
  border-bottom: 0;
}

.score-row textarea {
  min-height: 92px;
}

.score-input {
  text-align: center;
}

.chapter-list {
  display: grid;
  gap: 12px;
  padding: clamp(20px, 3vw, 32px);
}

.chapter-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 150px minmax(180px, 1fr) minmax(220px, 1.2fr);
  gap: 12px;
  align-items: start;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.chapter-row.part-heading {
  padding: 12px;
  border: 1px solid #d8c9af;
  border-radius: 8px;
  background: #fff7ea;
}

.chapter-row textarea {
  min-height: 82px;
}

.chapter-function {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.codes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 0 clamp(20px, 3vw, 32px) clamp(20px, 3vw, 32px);
}

.code-chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fffdf9;
  color: var(--muted);
  font-size: 0.9rem;
}

.code-chip strong {
  color: var(--ink);
}

.actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px clamp(18px, 4vw, 44px);
  border-top: 1px solid var(--line);
  background: rgba(251, 250, 247, 0.96);
  backdrop-filter: blur(12px);
}

.primary,
.secondary {
  min-height: 42px;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 760;
}

.primary {
  color: #fff;
  background: var(--green);
}

.primary:hover {
  background: #1f4f44;
}

.secondary {
  color: var(--ink);
  background: #ece6de;
}

.secondary:hover {
  background: #e2dbd0;
}

.hidden {
  display: none !important;
}

.success-shell {
  padding: clamp(24px, 4vw, 44px);
}

.success-shell h2 {
  margin: 0 0 10px;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
}

.success-shell p {
  max-width: 720px;
}

.status-line {
  min-height: 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

@media (max-width: 1020px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .nav-panel {
    position: static;
  }

  #sectionNav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-button {
    min-width: 210px;
  }

  .score-row,
  .chapter-row {
    grid-template-columns: 1fr;
  }

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

  .intro-hero {
    grid-template-columns: 1fr;
  }

  .cover-frame img {
    width: min(62vw, 300px);
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .save-state {
    width: 100%;
    text-align: left;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .actionbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .actionbar button {
    width: 100%;
  }

  .codes {
    grid-template-columns: 1fr;
  }
}
