:root {
  --bg: #f0eff4;
  --surface: #ffffff;
  --fg: #363a42;
  --muted: #7a7f88;
  --line: #dddbe3;
  --accent: #b9886e;
  --accent-dark: #9d6f56;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.top {
  max-width: 920px; margin: 0 auto; padding: 14px 0 6px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.brand { font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--fg); text-decoration: none; font-size: 15px; }
.tobot { color: var(--accent-dark); text-decoration: none; font-size: 14px; white-space: nowrap; }
.tobot:hover, .materials a:hover { text-decoration: underline; }
.wrap { max-width: 920px; margin: 0 auto; padding: 8px 0 32px; }
.eyebrow { margin: 10px 0 2px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
h1 { font-size: clamp(22px, 4.5vw, 30px); line-height: 1.2; margin: 0 0 18px; text-wrap: balance; }
h2 { font-size: 17px; margin: 18px 0 8px; color: var(--fg); }
.video-block + .video-block { margin-top: 10px; }
.player {
  background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9; max-width: 100%;
  box-shadow: 0 6px 24px rgba(54, 58, 66, .12);
}
.player video { width: 100%; height: 100%; display: block; background: #000; }
.player-msg { margin: 8px 2px 0; color: var(--accent-dark); font-size: 14px; }
.materials { margin-top: 26px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px 8px; }
.materials h2 { margin-top: 0; }
.materials ul { margin: 0; padding: 0 0 8px 18px; }
.materials li { margin: 6px 0; }
.materials a { color: var(--accent-dark); }
.notice { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px 20px; max-width: 65ch; }
.notice h1 { font-size: 24px; margin-bottom: 10px; }
.notice p { margin: 0 0 12px; }
.btn {
  display: inline-block; background: var(--accent); color: #fff; text-decoration: none; font-weight: 600;
  padding: 12px 20px; border-radius: 10px; margin-top: 6px;
}
.btn:hover { background: var(--accent-dark); }
.btn-secondary { background: transparent; color: var(--accent-dark); border: 1px solid var(--accent); }
.btn-secondary:hover { background: #fff; }
.back { margin-top: 28px; }
.foot { max-width: 920px; margin: 0 auto; padding: 10px 0 24px; color: var(--muted); font-size: 13px; }
a:focus-visible, video:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* layout with course navigation */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
@media (min-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr) 280px; align-items: start; }
  .toc { position: sticky; top: 16px; }
}
.lesson { min-width: 0; }
.toc { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 16px; }
.toc h2 { margin: 4px 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.toc ol, .toc ul { list-style: none; margin: 0 0 12px; padding: 0; }
.toc li { padding: 7px 10px; border-radius: 8px; font-size: 15px; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.toc li a { color: var(--fg); text-decoration: none; }
.toc li a:hover { color: var(--accent-dark); text-decoration: underline; }
.toc li.current { background: var(--bg); font-weight: 600; }
.toc li.soon { color: var(--muted); }
.toc li.soon a { color: var(--muted); }
.toc li small { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); white-space: nowrap; }
.tobot-wide { display: block; text-align: center; margin-top: 6px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 26px; }
.pager-link { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--fg); min-width: 0; }
.pager-link.next { text-align: right; border-color: var(--accent); }
.pager-link:hover { border-color: var(--accent-dark); }
.pager-link.empty { visibility: hidden; }
.pager-dir { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-dark); }
.pager-title { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.hint { color: var(--muted); font-size: 13px; }
@media (max-width: 480px) {
  .pager { grid-template-columns: 1fr; }
  .pager-link.empty { display: none; }
  .pager-link.next { text-align: left; }
}
.toc-materials li a { color: var(--accent-dark); }
.toc-materials li a::before { content: "↗ "; color: var(--muted); }

/* course menu: sidebar on desktop, bottom sheet on phones */
.toc-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.toc-head h2 { margin: 4px 0 8px; }
.toc-close { display: none; }
.toc-backdrop { display: none; }
.mobile-bar { display: none; }
@media (max-width: 899px) {
  body { padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  body.sheet-open { overflow: hidden; }
  .toc {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    max-height: 85vh; max-height: 85dvh; overflow: auto; -webkit-overflow-scrolling: touch;
    border-radius: 16px 16px 0 0; border-bottom: 0;
    padding: 12px max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
    box-shadow: 0 -10px 30px rgba(54, 58, 66, .18);
    transform: translateY(100%); visibility: hidden;
    transition: transform .25s ease, visibility 0s linear .25s;
  }
  .toc.open { transform: none; visibility: visible; transition: transform .25s ease, visibility 0s; }
  .toc-head { position: sticky; top: -12px; margin: -12px -16px 6px; padding: 12px 16px 8px; background: var(--surface); border-bottom: 1px solid var(--line); z-index: 1; }
  .toc-head h2 { margin: 0; font-size: 15px; }
  .toc-close {
    display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
    border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--fg); font-size: 22px; line-height: 1; cursor: pointer;
  }
  .toc-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(30, 28, 32, .45); }
  .toc-backdrop[hidden] { display: none; }
  .mobile-bar {
    display: flex; gap: 10px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .bar-btn {
    flex: 1 1 0; min-width: 0; text-align: center; font: 600 15px/1 var(--sans, inherit); padding: 13px 10px;
    border-radius: 10px; border: 1px solid var(--accent); background: var(--surface); color: var(--accent-dark);
    text-decoration: none; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .bar-btn.primary { background: var(--accent); color: #fff; }
  .pager { margin-top: 20px; }
}
@media (prefers-reduced-motion: reduce) { .toc { transition: none; } }

/* phones: the bottom bar already carries "next", so the pager keeps only "previous" */
@media (max-width: 899px) {
  .pager { grid-template-columns: 1fr; }
  .pager-link.next, .pager-link.empty { display: none; }
  .pager:not(:has(.pager-link.prev)) { display: none; }
  .bar-btn.primary small { display: block; font-weight: 500; font-size: 12px; opacity: .85; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .bar-btn { line-height: 1.15; padding: 10px 10px; }
}
