:root {
  color-scheme: light;
  --ink: #173039;
  --muted: #5e747a;
  --paper: #fbfcfa;
  --paper-deep: #f1f6f3;
  --line: #d4e1dd;
  --court: #067a70;
  --court-deep: #102f35;
  --court-light: #d9f0e9;
  --ball: #d7f67d;
  --gold: #b77712;
  --danger: #bb5143;
  --sidebar-width: 21rem;
  --reading-width: 53rem;
  --shadow: 0 14px 34px rgba(16, 47, 53, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  margin: 0;
  min-width: 20rem;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(6, 122, 112, 0.035) 1px, transparent 1px) 0 0 / 3.75rem 3.75rem,
    var(--paper);
  font-size: 1rem;
  line-height: 1.68;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--court);
  text-underline-offset: 0.2em;
}

a:hover {
  color: #035d56;
}

:focus-visible {
  outline: 3px solid var(--ball);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  transform: translateY(-180%);
  padding: 0.65rem 0.9rem;
  border-radius: 0.35rem;
  color: var(--court-deep);
  background: var(--ball);
  font-weight: 750;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.course-sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  color: #effaf6;
  background:
    linear-gradient(rgba(215, 246, 125, 0.05) 1px, transparent 1px) 0 0 / 3.25rem 3.25rem,
    linear-gradient(90deg, rgba(215, 246, 125, 0.05) 1px, transparent 1px) 0 0 / 3.25rem 3.25rem,
    var(--court-deep);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 5.5rem;
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  color: white;
  text-decoration: none;
}

.brand:hover {
  color: white;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1.06rem;
  letter-spacing: -0.015em;
}

.brand small {
  margin-top: 0.05rem;
  color: #b8d1cc;
  font-size: 0.8rem;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: end center;
  width: 2.05rem;
  height: 2.55rem;
  border: 1px solid rgba(215, 246, 125, 0.72);
  border-radius: 0.18rem;
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  background: rgba(215, 246, 125, 0.72);
}

.brand-mark::before {
  top: 50%;
  left: -0.2rem;
  width: 2.45rem;
  height: 1px;
}

.brand-mark::after {
  top: 0.48rem;
  left: 50%;
  width: 1px;
  height: 1.56rem;
}

.brand-mark span {
  z-index: 1;
  width: 0.42rem;
  height: 0.42rem;
  margin-bottom: 0.2rem;
  border-radius: 50%;
  background: var(--ball);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 0.4rem;
  color: currentColor;
  background: transparent;
  cursor: pointer;
}

.icon-button:hover {
  background: rgba(6, 122, 112, 0.08);
}

.sidebar-close {
  display: none;
  color: #d9ece7;
  font-size: 1.85rem;
}

.course-tools {
  padding: 1rem 1.25rem 0.95rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.8rem;
  padding: 0 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 0.45rem;
  background: rgba(255, 255, 255, 0.07);
}

.search-icon {
  width: 0.8rem;
  height: 0.8rem;
  border: 1.8px solid #afc8c3;
  border-radius: 50%;
}

.search-icon::after {
  content: "";
  display: block;
  width: 0.42rem;
  height: 1.8px;
  margin: 0.62rem 0 0 0.57rem;
  transform: rotate(45deg);
  background: #afc8c3;
}

.search-box input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  color: white;
  background: transparent;
  font-size: 0.94rem;
}

.search-box input::placeholder {
  color: #aec5c1;
}

.search-box:focus-within {
  border-color: var(--ball);
  box-shadow: 0 0 0 3px rgba(215, 246, 125, 0.13);
}

.progress-summary {
  margin-top: 1rem;
}

.progress-summary > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.45rem;
  color: #c4d8d4;
  font-size: 0.82rem;
}

.progress-summary strong {
  color: var(--ball);
}

progress {
  display: block;
  width: 100%;
  height: 0.36rem;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  color: var(--ball);
  background: rgba(255, 255, 255, 0.14);
}

progress::-webkit-progress-bar {
  background: rgba(255, 255, 255, 0.14);
}

progress::-webkit-progress-value {
  background: var(--ball);
}

progress::-moz-progress-bar {
  background: var(--ball);
}

.course-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.65rem 1.25rem;
  scrollbar-color: #5e7d79 transparent;
}

.course-section {
  margin: 0.2rem 0;
}

.course-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 2.5rem;
  padding: 0.55rem 0.7rem;
  color: #9fbab5;
  list-style: none;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.065em;
  text-transform: uppercase;
}

.course-section summary::-webkit-details-marker {
  display: none;
}

.course-section summary::after {
  content: "+";
  color: #83a59f;
  font-size: 1rem;
  font-weight: 500;
}

.course-section[open] summary::after {
  content: "−";
}

.nav-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-item {
  display: grid;
  grid-template-columns: 2.85rem 1fr 1.25rem;
  align-items: start;
  gap: 0.15rem;
  min-height: 2.65rem;
  padding: 0.58rem 0.65rem;
  border-radius: 0.35rem;
  color: #d7e7e3;
  text-decoration: none;
  font-size: 0.86rem;
  line-height: 1.35;
}

.nav-item:hover {
  color: white;
  background: rgba(255, 255, 255, 0.07);
}

.nav-item[aria-current="page"] {
  color: white;
  background: #086f68;
  box-shadow: inset 3px 0 var(--ball);
}

.nav-code {
  color: #8eb3ad;
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.nav-item[aria-current="page"] .nav-code {
  color: var(--ball);
}

.nav-complete {
  display: grid;
  place-items: center;
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 0.05rem;
  border: 1px solid #557973;
  border-radius: 50%;
  color: transparent;
  font-size: 0.68rem;
}

.nav-complete.is-complete {
  border-color: var(--ball);
  color: var(--court-deep);
  background: var(--ball);
}

.no-results {
  padding: 1.25rem 0.8rem;
  color: #bfd2ce;
  font-size: 0.9rem;
}

.sidebar-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer a {
  padding: 0.35rem 0.2rem;
  color: #cfe2de;
  text-align: center;
  text-decoration: none;
  font-size: 0.8rem;
}

.sidebar-footer a:hover {
  color: var(--ball);
}

.reading-shell {
  min-width: 0;
}

.lesson-toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 4.4rem;
  padding: 0.6rem clamp(1.2rem, 4vw, 3.6rem);
  border-bottom: 1px solid rgba(16, 47, 53, 0.1);
  background: rgba(251, 252, 250, 0.93);
  backdrop-filter: blur(12px);
}

.menu-button {
  display: none;
}

.menu-button span {
  display: block;
  width: 1.25rem;
  height: 2px;
  margin: 0.16rem 0;
  background: currentColor;
}

.breadcrumb {
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.completion-button {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.65rem;
  padding: 0.52rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  color: var(--ink);
  background: white;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 720;
}

.completion-button:hover {
  border-color: #a8c2bc;
  background: var(--paper-deep);
}

.completion-icon {
  display: grid;
  place-items: center;
  width: 1.2rem;
  height: 1.2rem;
  border: 1px solid #8ba9a2;
  border-radius: 50%;
  color: transparent;
  font-size: 0.72rem;
}

.completion-button[aria-pressed="true"] .completion-icon {
  border-color: var(--court);
  color: white;
  background: var(--court);
}

main {
  width: min(var(--reading-width), calc(100% - 2.5rem));
  min-height: calc(100vh - 12rem);
  margin: 0 auto;
  padding: clamp(2.25rem, 5vw, 4.7rem) 0 4.5rem;
}

.lesson-header {
  position: relative;
  margin-bottom: 2.2rem;
  padding-bottom: 1.7rem;
  border-bottom: 1px solid var(--line);
}

.lesson-code {
  display: inline-flex;
  align-items: center;
  min-height: 1.8rem;
  margin-bottom: 0.65rem;
  color: var(--court);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.lesson-code::before {
  content: "";
  width: 1.9rem;
  height: 2px;
  margin-right: 0.65rem;
  background: var(--court);
}

h1,
h2,
h3 {
  color: var(--ink);
  line-height: 1.15;
  text-wrap: balance;
}

h1 {
  max-width: 48rem;
  margin: 0;
  font-size: clamp(2.25rem, 6vw, 4.5rem);
  letter-spacing: -0.055em;
}

.lesson-deck {
  max-width: 46rem;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: clamp(1.08rem, 2vw, 1.28rem);
  line-height: 1.55;
}

.lesson-body {
  max-width: 49rem;
}

.lesson-body h2 {
  margin: 2.25rem 0 0.65rem;
  color: var(--court);
  font-size: 1.22rem;
  letter-spacing: -0.02em;
}

.lesson-body h2[id] {
  scroll-margin-top: 6rem;
}

.lesson-body p {
  margin: 0 0 1.15rem;
}

.lesson-body strong {
  font-weight: 780;
}

.citation {
  display: inline-block;
  margin-left: 0.12em;
  color: var(--court);
  text-decoration: none;
  font-size: 0.78em;
  font-weight: 800;
  vertical-align: 0.1em;
}

.cue-card {
  position: relative;
  margin: 2.5rem 0 0;
  padding: 1.05rem 1.15rem 1.05rem 1.35rem;
  border-left: 0.28rem solid var(--court);
  color: #124f4a;
  background: var(--court-light);
  font-weight: 760;
}

.cue-card::after {
  content: "";
  position: absolute;
  right: 1rem;
  bottom: -0.35rem;
  width: 2.1rem;
  height: 0.7rem;
  border-bottom: 1px solid rgba(6, 122, 112, 0.28);
  border-radius: 50%;
}

.course-table-wrap {
  margin: 1.5rem 0 2rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: white;
  box-shadow: 0 6px 18px rgba(16, 47, 53, 0.05);
}

.course-table {
  width: 100%;
  min-width: 37rem;
  border-collapse: collapse;
  line-height: 1.45;
}

.course-table th,
.course-table td {
  padding: 0.82rem 0.9rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.course-table th {
  color: white;
  background: var(--court);
  font-size: 0.88rem;
}

.course-table td {
  font-size: 0.94rem;
}

.course-table tbody tr:nth-child(even) {
  background: var(--paper-deep);
}

.course-table tr:last-child td {
  border-bottom: 0;
}

.worksheet {
  display: grid;
  gap: 0.9rem;
  margin: 1.1rem 0;
}

.worksheet-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.85rem;
}

.worksheet-field {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.worksheet-field input,
.worksheet-field textarea {
  width: 100%;
  min-height: 2.65rem;
  padding: 0.55rem 0.65rem;
  resize: vertical;
  border: 0;
  border-bottom: 1.5px solid #9bb9b2;
  border-radius: 0;
  outline: none;
  color: var(--ink);
  background: rgba(239, 246, 243, 0.55);
}

.worksheet-field textarea {
  min-height: 4.5rem;
}

.worksheet-field input:focus,
.worksheet-field textarea:focus {
  border-color: var(--court);
  box-shadow: inset 0 -2px var(--court);
}

.diagram-card {
  margin: 1.8rem 0 2.25rem;
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: #f3f8f5;
  box-shadow: var(--shadow);
}

.diagram-layout {
  display: grid;
  grid-template-columns: minmax(13rem, 0.75fr) minmax(15rem, 1.25fr);
  align-items: center;
  gap: clamp(1rem, 4vw, 2.4rem);
}

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

.diagram-panel {
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: white;
}

.diagram-panel h3,
.diagram-notes h3 {
  margin: 0 0 0.65rem;
  color: var(--court);
  font-size: 0.94rem;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.diagram-notes p,
.diagram-panel p {
  margin: 0.35rem 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

.court-svg {
  display: block;
  width: 100%;
  max-height: 25rem;
  margin: auto;
}

.court-fill {
  fill: #dfeee9;
}

.court-line {
  fill: none;
  stroke: #496b69;
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
}

.court-net {
  stroke: #173f43;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.shot-arrow,
.reply-arrow,
.move-arrow {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.shot-arrow { stroke: var(--court); }
.reply-arrow { stroke: #397ea6; stroke-dasharray: 7 6; }
.move-arrow { stroke: var(--gold); stroke-dasharray: 5 5; }

.target-zone {
  fill: rgba(6, 122, 112, 0.18);
  stroke: var(--court);
  stroke-width: 1.2;
}

.player-dot {
  stroke: white;
  stroke-width: 2;
}

.player-you { fill: var(--court); }
.player-opponent { fill: #397ea6; }

.player-label {
  fill: white;
  font-size: 12px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: central;
}

.svg-label {
  fill: #46666a;
  font-size: 12px;
  font-weight: 700;
}

.diagram-card figcaption {
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.no-script {
  padding: 2rem;
  border: 1px solid var(--line);
  background: white;
}

.lesson-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(var(--reading-width), calc(100% - 2.5rem));
  margin: 0 auto 5rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.pager-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  padding: 1.25rem 0;
  color: var(--ink);
  text-decoration: none;
}

.pager-link:hover {
  color: var(--court);
}

.pager-link.next {
  justify-content: flex-end;
  padding-left: 1rem;
  border-left: 1px solid var(--line);
  text-align: right;
}

.pager-link.previous {
  padding-right: 1rem;
}

.pager-link small,
.pager-link strong {
  display: block;
}

.pager-link small {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 760;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.pager-link strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.92rem;
}

.pager-link.is-hidden {
  visibility: hidden;
}

.sidebar-scrim {
  display: none;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 1rem;
  bottom: 1rem;
  margin: 0;
  padding: 0.72rem 0.95rem;
  transform: translateY(7rem);
  border-radius: 0.35rem;
  color: white;
  background: var(--court-deep);
  box-shadow: var(--shadow);
  opacity: 0;
  transition: transform 180ms ease, opacity 180ms ease;
  font-size: 0.9rem;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 960px) {
  .app-shell {
    display: block;
  }

  .course-sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-105%);
    width: min(23rem, calc(100vw - 2.5rem));
    transition: transform 180ms ease;
    box-shadow: 1.25rem 0 3rem rgba(6, 29, 33, 0.3);
  }

  .sidebar-open .course-sidebar {
    transform: translateX(0);
  }

  .sidebar-close,
  .menu-button {
    display: inline-grid;
  }

  .sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 15;
    display: block;
    border: 0;
    pointer-events: none;
    background: rgba(10, 34, 38, 0.48);
    opacity: 0;
    transition: opacity 180ms ease;
  }

  .sidebar-open .sidebar-scrim {
    pointer-events: auto;
    opacity: 1;
  }

  .lesson-toolbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
}

@media (max-width: 680px) {
  .lesson-toolbar {
    min-height: 4rem;
    padding: 0.45rem 0.7rem;
  }

  .breadcrumb {
    font-size: 0.75rem;
  }

  .completion-button {
    width: 2.75rem;
    padding: 0;
    justify-content: center;
  }

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

  main,
  .lesson-pager {
    width: min(100% - 1.5rem, var(--reading-width));
  }

  main {
    padding-top: 2.2rem;
  }

  h1 {
    font-size: clamp(2.2rem, 13vw, 3.4rem);
  }

  .diagram-layout,
  .diagram-grid {
    grid-template-columns: 1fr;
  }

  .diagram-layout .court-svg {
    max-height: 20rem;
  }

  .lesson-pager {
    grid-template-columns: 1fr;
  }

  .pager-link.next {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .course-table-wrap {
    margin-right: -0.75rem;
    margin-left: -0.75rem;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  body {
    background: white;
    font-size: 11pt;
  }

  .course-sidebar,
  .lesson-toolbar,
  .lesson-pager,
  .toast,
  .sidebar-scrim {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  main {
    width: auto;
    max-width: none;
    min-height: 0;
    margin: 0;
    padding: 0;
  }

  .lesson-body {
    max-width: none;
  }

  .diagram-card,
  .course-table-wrap {
    break-inside: avoid;
    box-shadow: none;
  }
}
