:root {
  --bg: #efe4cf;
  --panel: rgba(255, 250, 240, 0.92);
  --panel-strong: rgba(255, 252, 247, 0.98);
  --line: rgba(72, 47, 24, 0.14);
  --ink: #25170d;
  --muted: #6b5646;
  --accent: #bb6a2f;
  --accent-soft: rgba(187, 106, 47, 0.14);
  --warning: #8d3d16;
  --warning-soft: rgba(141, 61, 22, 0.15);
  --shadow: 0 24px 60px rgba(60, 33, 13, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.55), transparent 30%),
    linear-gradient(145deg, #f2e8d6 0%, #e6d6b8 45%, #dbc39d 100%);
  color: var(--ink);
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
}

a {
  color: var(--accent);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  min-height: 100vh;
  gap: 1.25rem;
  padding: 1.25rem;
}

.sidebar,
.content-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.sidebar {
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
}

.sidebar-header {
  display: grid;
  gap: 0.85rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.project-switcher-block {
  display: grid;
  gap: 0.35rem;
  justify-items: start;
}

.project-switcher {
  width: 100%;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 248, 238, 0.92));
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  padding: 0.8rem 2.6rem 0.8rem 0.95rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 248, 238, 0.92)),
    linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position:
    0 0,
    calc(100% - 1.15rem) calc(50% - 0.15rem),
    calc(100% - 0.8rem) calc(50% - 0.15rem);
  background-size:
    auto,
    0.38rem 0.38rem,
    0.38rem 0.38rem;
  background-repeat: no-repeat;
}

.project-switcher:hover,
.project-switcher:focus-visible {
  outline: none;
  border-color: rgba(187, 106, 47, 0.45);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    0 0 0 4px rgba(187, 106, 47, 0.12);
}

.eyebrow,
.empty-kicker,
.lesson-path {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--muted);
}

.sidebar-header h1,
.empty-state h2,
.section-header h2,
.group-header h3,
.group-header h4,
.lesson-card h3 {
  margin: 0.25rem 0 0;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-weight: 600;
  line-height: 1.05;
}

.sidebar-copy,
.empty-state p,
.asset-card p,
.asset-list,
.section-copy,
.group-note {
  margin: 0.6rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.tree {
  overflow: auto;
  padding-right: 0.25rem;
}

.tree-empty {
  margin: 0;
  color: var(--muted);
}

.tree-folder {
  border-left: 1px solid rgba(72, 47, 24, 0.09);
  margin-left: 0.45rem;
  padding-left: 0.7rem;
}

.tree-folder-root {
  border-left: 0;
  margin-left: 0;
  padding-left: 0;
}

.tree-folder.is-active > .tree-summary {
  background: rgba(255, 255, 255, 0.55);
}

.tree-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  list-style: none;
  padding: 0.45rem 0.55rem;
  border-radius: 14px;
}

.tree-summary:hover,
.tree-summary:focus-visible {
  background: rgba(255, 255, 255, 0.4);
  outline: none;
}

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

.tree-summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.45rem;
  transition: transform 120ms ease;
}

.tree-folder[open] > .tree-summary::before {
  transform: rotate(90deg);
}

.tree-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  min-width: 0;
}

.tree-meta {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.3rem;
}

.tree-badge {
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--warning);
  font-size: 0.72rem;
  white-space: nowrap;
}

.tree-badge-warning {
  background: var(--warning-soft);
}

.tree-badge-muted {
  background: rgba(72, 47, 24, 0.08);
  color: var(--muted);
}

.tree-children {
  display: grid;
  gap: 0.2rem;
  margin-bottom: 0.4rem;
}

.tree-lesson {
  appearance: none;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  color: var(--ink);
  padding: 0.5rem 0.65rem;
  border-radius: 14px;
  cursor: pointer;
  font: inherit;
  transition:
    background-color 120ms ease,
    transform 120ms ease;
}

.tree-lesson:hover,
.tree-lesson:focus-visible {
  background: rgba(255, 255, 255, 0.55);
  outline: none;
}

.tree-lesson.is-active {
  background: var(--accent-soft);
  color: var(--warning);
  transform: translateX(2px);
}

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

.content-panel {
  height: 100%;
  padding: 1.25rem;
  overflow: auto;
}

.section-view {
  display: grid;
  gap: 1rem;
}

.section-header,
.lesson-card,
.section-group,
.empty-state,
.markdown-card,
.asset-card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 20px;
}

.section-header,
.empty-state {
  padding: 1.2rem 1.35rem;
}

.lesson-card,
.section-group,
.asset-card {
  padding: 1rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.section-flow {
  display: grid;
  gap: 1rem;
}

.section-group {
  display: grid;
  gap: 1rem;
}

.section-depth-1 {
  margin-top: 0.25rem;
}

.lesson-card {
  display: grid;
  gap: 0.85rem;
}

.lesson-card-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  background: var(--accent-soft);
  color: var(--warning);
  white-space: nowrap;
}

.chip-muted {
  background: rgba(72, 47, 24, 0.08);
  color: var(--muted);
}

.chip-warning {
  background: var(--warning-soft);
}

.markdown-card {
  padding: 1.1rem 1.2rem;
}

.markdown-body {
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  line-height: 1.75;
  font-size: 1.04rem;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body > :last-child {
  margin-bottom: 0;
}

.markdown-body code {
  font-family: "Berkeley Mono", "SFMono-Regular", monospace;
  background: rgba(72, 47, 24, 0.08);
  border-radius: 6px;
  padding: 0.08rem 0.28rem;
}

.markdown-body pre {
  overflow: auto;
  background: rgba(72, 47, 24, 0.08);
  border-radius: 14px;
  padding: 0.9rem;
}

.assets-stack {
  display: grid;
  gap: 0.85rem;
}

.asset-card h3 {
  margin: 0;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.asset-card-missing {
  border-style: dashed;
}

.asset-list {
  padding-left: 1.1rem;
}

.lazy-media {
  margin-top: 0.85rem;
}

.lazy-placeholder {
  margin: 0;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  background: rgba(72, 47, 24, 0.06);
  color: var(--muted);
}

.lazy-poster {
  display: block;
  width: 100%;
  border-radius: 16px;
  object-fit: cover;
  background: rgba(72, 47, 24, 0.08);
  max-height: 28rem;
}

.lazy-media video,
.lazy-media iframe {
  display: none;
  width: 100%;
  border: 0;
  border-radius: 16px;
  background: #000;
}

.lazy-media.is-loaded .lazy-placeholder {
  display: none;
}

.lazy-media.is-loaded .lazy-poster {
  display: none;
}

.lazy-media.is-loaded video,
.lazy-media.is-loaded iframe {
  display: block;
}

.lazy-media video {
  max-height: 72vh;
}

.lazy-media iframe {
  min-height: 72vh;
}

.empty-inline {
  margin-top: 0;
}

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

  .sidebar {
    max-height: 42vh;
  }

  .section-header,
  .lesson-card-header {
    flex-direction: column;
  }

  .chip-row {
    justify-content: flex-start;
  }

  .lazy-media iframe,
  .lazy-media video {
    min-height: 38vh;
  }
}
