:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #5b6673;
  --faint: #eef1f4;
  --line: #d9e0e7;
  --paper: #fbfcfd;
  --panel: #ffffff;
  --accent: #147a72;
  --accent-strong: #0b5d56;
  --accent-soft: #dff4f1;
  --gold: #b7791f;
  --coral: #c7503f;
  --shadow: 0 18px 50px rgba(28, 40, 52, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(251, 252, 253, 0.92);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand small {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.8rem;
}

.tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.tab {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.tab.is-active {
  background: var(--ink);
  color: white;
}

main {
  width: 100%;
}

[hidden] {
  display: none !important;
}

.course-view {
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
  min-height: calc(100vh - 75px);
}

.day-rail {
  border-right: 1px solid var(--line);
  background: #f6f8fa;
  padding: 24px;
}

.progress-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 68px;
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 34px rgba(28, 40, 52, 0.06);
}

.progress-kicker {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.progress-card > div:first-child strong {
  display: block;
  font-size: 1.25rem;
}

.completion-ring {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) 0deg, var(--faint) 0deg);
}

.completion-ring span {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--panel);
  color: var(--accent-strong);
  font-size: 0.86rem;
  font-weight: 900;
}

.mini-stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mini-stats span {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: #f6f8fa;
  color: var(--muted);
  font-size: 0.75rem;
}

.mini-stats strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-button {
  grid-column: 1 / -1;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.text-button:hover,
.text-button:focus-visible {
  border-color: var(--coral);
  color: var(--coral);
  outline: none;
}

.rail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.rail-heading strong {
  color: var(--accent-strong);
  text-transform: none;
}

.day-list {
  display: grid;
  gap: 8px;
}

.day-button {
  width: 100%;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.day-button:hover,
.day-button:focus-visible {
  border-color: var(--line);
  background: var(--panel);
  outline: none;
}

.day-button.is-active {
  border-color: rgba(20, 122, 114, 0.25);
  background: var(--accent-soft);
}

.day-number {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent-strong);
  font-weight: 800;
}

.day-button.is-active .day-number {
  background: var(--accent);
  color: white;
}

.day-title {
  display: block;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.day-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--faint);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.status-pill.is-started {
  background: #edf5ff;
  color: #2e5f92;
}

.status-pill.is-complete {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.reader {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: clamp(20px, 5vw, 56px);
}

.reader-toolbar {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover:not(:disabled),
.icon-button:focus-visible:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-strong);
  outline: none;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.progress-block {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--faint);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 180ms ease;
}

.lesson-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 34px rgba(28, 40, 52, 0.06);
}

.tracking-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.lesson-actions strong {
  display: block;
  color: var(--ink);
  line-height: 1.35;
}

.complete-button {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 800;
}

.complete-button:hover,
.complete-button:focus-visible {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  outline: none;
}

.complete-button.is-complete {
  border-color: var(--line);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.content-status {
  color: var(--muted);
  min-height: 24px;
}

.content-status:empty {
  display: none;
}

.markdown-body {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(22px, 4vw, 46px);
}

.markdown-body:empty {
  display: none;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  line-height: 1.15;
  letter-spacing: 0;
}

.markdown-body h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4vw, 3.75rem);
}

.markdown-body h2 {
  margin: 34px 0 12px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  font-size: clamp(1.25rem, 2.4vw, 1.8rem);
}

.markdown-body h3 {
  margin: 22px 0 8px;
  color: var(--accent-strong);
  font-size: 1.05rem;
}

.markdown-body p,
.markdown-body li {
  color: #26323f;
  line-height: 1.72;
}

.markdown-body p {
  margin: 0 0 16px;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.35rem;
  margin: 0 0 18px;
}

.markdown-body li + li {
  margin-top: 6px;
}

.markdown-body blockquote {
  margin: 22px 0;
  padding: 16px 18px;
  border-left: 4px solid var(--coral);
  background: #fff7f4;
  color: #56342d;
}

.markdown-body blockquote p {
  margin: 0;
  color: inherit;
}

.markdown-body a {
  color: var(--accent-strong);
  font-weight: 700;
}

.markdown-body code {
  padding: 0.18em 0.35em;
  border-radius: 5px;
  background: var(--faint);
}

.notes-panel {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.notes-panel label {
  display: block;
  margin-bottom: 10px;
  color: var(--ink);
  font-weight: 800;
}

.notes-panel textarea {
  width: 100%;
  resize: vertical;
  min-height: 112px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
}

.notes-panel textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(20, 122, 114, 0.15);
}

.notes-panel span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}


.about-profile {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  margin-bottom: 18px;
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.profile-photo-wrap {
  position: relative;
  width: 160px;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent-soft);
}

.profile-photo-wrap img,
.profile-photo-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.profile-photo-wrap img {
  z-index: 2;
  object-fit: cover;
}

.profile-photo-fallback {
  display: grid;
  place-items: center;
  color: var(--accent-strong);
  font-size: 2.4rem;
  font-weight: 900;
}

.profile-kicker {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.profile-copy h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 1;
  letter-spacing: 0;
}

.profile-copy p {
  margin: 10px 0 0;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.45;
}

.profile-location {
  color: var(--muted) !important;
}

.contact-panel {
  margin-bottom: 18px;
  padding: clamp(18px, 3vw, 26px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.contact-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.contact-heading span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.contact-heading strong {
  font-size: 1.15rem;
}

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

.contact-link {
  min-width: 0;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  text-decoration: none;
}

.contact-link:hover,
.contact-link:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

.contact-link.is-empty {
  cursor: default;
  opacity: 0.56;
}

.contact-link.is-empty:hover,
.contact-link.is-empty:focus-visible {
  border-color: var(--line);
  background: #fbfcfd;
}

.contact-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
}

.contact-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.contact-link strong,
.contact-link small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-link strong {
  font-size: 0.9rem;
}

.contact-link small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.about-view {
  min-height: calc(100vh - 75px);
}

.about-reader {
  max-width: 880px;
}

@media (max-width: 820px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
  }

  .course-view {
    grid-template-columns: 1fr;
  }

  .day-rail {
    position: sticky;
    top: 118px;
    z-index: 3;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 14px 16px;
  }

  .rail-heading {
    margin-bottom: 10px;
  }

  .progress-card {
    grid-template-columns: minmax(220px, 1fr) 68px;
    min-width: 520px;
    margin-bottom: 12px;
  }

  .day-list {
    display: flex;
    gap: 8px;
    min-width: max-content;
  }

  .day-button {
    width: 235px;
  }

  .reader {
    padding: 18px 16px 36px;
  }

  .reader-toolbar {
    margin-bottom: 16px;
  }

  .lesson-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .complete-button {
    width: 100%;
  }

  .about-profile {
    grid-template-columns: 120px minmax(0, 1fr);
  }

  .profile-photo-wrap {
    width: 120px;
  }

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

  .brand small {
    white-space: normal;
  }
}

@media (max-width: 480px) {
  .brand {
    align-items: flex-start;
  }

  .brand strong {
    white-space: normal;
  }

  .day-rail {
    top: 142px;
  }

  .day-button {
    width: 210px;
  }

  .about-profile {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .contact-heading {
    align-items: start;
    flex-direction: column;
  }

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

  .markdown-body {
    padding: 20px;
  }
}
