:root {
  --navy: #102a43;
  --navy-2: #173f67;
  --blue: #2563eb;
  --blue-pale: #eef5ff;
  --yellow: #f4c84a;
  --ink: #1b2733;
  --muted: #627283;
  --line: #d8e1e8;
  --surface: #ffffff;
  --canvas: #f5f7fa;
  --article-font: 16px;
  --article-line: 1.9;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  overflow-wrap: break-word;
  line-break: strict;
}

body.is-locked { overflow: hidden; }

.access-lock {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
  color: var(--ink);
  background: var(--navy);
}

.access-lock[hidden] { display: none; }

.access-lock-card {
  width: min(100%, 440px);
  padding: 40px;
  background: white;
  border-top: 6px solid var(--yellow);
}

.access-lock-eyebrow {
  margin-bottom: 12px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .1em;
}

.access-lock h1 {
  margin: 0 0 10px;
  color: var(--navy);
  font-size: 30px;
  line-height: 1.35;
}

.access-lock p { margin: 0 0 28px; color: var(--muted); line-height: 1.7; }
.access-lock label { display: block; margin-bottom: 8px; color: var(--navy); font-size: 14px; font-weight: 800; }
.access-lock input {
  width: 100%;
  min-height: 50px;
  padding: 10px 13px;
  border: 1px solid #9dafbd;
  border-radius: 0;
  background: white;
  font-size: 18px;
}
.access-lock button {
  width: 100%;
  min-height: 50px;
  margin-top: 14px;
  color: white;
  background: var(--blue);
  border: 0;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}
.access-lock button:hover { background: #174db5; }
.access-lock-error { min-height: 27px; margin: 10px 0 0 !important; color: #b42318 !important; font-size: 14px; font-weight: 700; }

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

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

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: white;
  background: var(--navy);
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky;
  z-index: 30;
  top: 0;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  color: white;
  background: var(--navy);
  border-bottom: 4px solid var(--yellow);
}

.header-brand { display: flex; align-items: center; gap: 12px; }
.eyebrow { color: #bcd3ea; font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.site-title { margin-top: 2px; font-size: 20px; font-weight: 800; letter-spacing: .03em; }
.header-tools { display: flex; align-items: center; gap: 6px; }
.tool-label { margin-right: 2px; color: #dce8f4; font-size: 12px; }

.text-size-button, .icon-button {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid #557494;
  color: white;
  background: transparent;
  cursor: pointer;
}
.text-size-button:hover, .text-size-button.is-active { color: var(--navy); background: var(--yellow); border-color: var(--yellow); }
.menu-button { display: none; font-size: 22px; }

.app-shell {
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr) 240px;
  min-height: calc(100vh - 72px);
}

.sidebar {
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  padding: 24px 18px 40px;
  background: #edf2f6;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.sidebar-intro { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.sidebar-intro strong { color: var(--navy); font-size: 17px; }
.sidebar-intro span { color: var(--muted); font-size: 12px; }
.search-label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.day-search { width: 100%; min-height: 44px; margin-bottom: 20px; padding: 10px 12px; border: 1px solid #b9c8d5; border-radius: 4px; background: white; }
.chapter-label { margin: 22px 8px 8px; color: var(--muted); font-size: 11px; font-weight: 800; line-height: 1.5; letter-spacing: .03em; }
.day-link {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: start;
  min-height: 52px;
  margin: 3px 0;
  padding: 9px 10px;
  color: var(--ink);
  border-left: 4px solid transparent;
  text-decoration: none;
}
.day-link:hover { background: white; }
.day-link.is-active { color: var(--navy); background: white; border-left-color: var(--blue); }
.day-number { color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.day-title { font-size: 13px; font-weight: 700; line-height: 1.55; }
.no-results { padding: 20px 8px; color: var(--muted); font-size: 13px; }

.content-column { min-width: 0; padding: 50px clamp(24px, 4vw, 64px) 80px; }
.article, .pager { width: min(100%, 880px); margin-inline: auto; }
.loading-state { width: min(100%, 880px); margin: 80px auto; color: var(--muted); text-align: center; }
.article { font-size: var(--article-font); line-height: var(--article-line); }
.article > h1:first-child {
  margin: 0 0 32px;
  padding: 0 0 22px;
  color: var(--navy);
  border-bottom: 3px solid var(--navy);
  font-size: clamp(28px, 3.2vw, 42px);
  line-height: 1.35;
  letter-spacing: .015em;
}
.article h3 { margin: 70px 0 20px; padding: 13px 16px; color: white; background: var(--navy-2); font-size: 23px; line-height: 1.45; }
.article h4 { margin: 38px 0 12px; padding-left: 13px; color: var(--navy); border-left: 5px solid var(--yellow); font-size: 19px; line-height: 1.5; }
.article h5, .article h6 { margin-top: 30px; color: var(--navy); }
.article p { margin: 0 0 22px; }
.article ul, .article ol { margin: 0 0 26px; padding-left: 1.7em; }
.article li { margin: 7px 0; padding-left: .2em; }
.article strong { color: #0d3f70; }
.article a { color: #1558c0; text-underline-offset: 3px; }
.article blockquote { margin: 26px 0; padding: 16px 20px; color: #334b60; background: #eef3f7; border-left: 5px solid #8fa9be; }

.lesson-guide { margin: 0 0 38px; border: 2px solid var(--blue); background: white; }
.lesson-guide-title { padding: 11px 16px; color: white; background: var(--blue); font-size: 15px; font-weight: 800; }
.lesson-guide-body { padding: 18px 20px 4px; }
.lesson-guide-body p, .lesson-guide-body ul { margin-bottom: 14px; }

.table-scroll { margin: 24px 0 32px; overflow-x: auto; border: 1px solid #c9d5df; }
table { width: 100%; min-width: 600px; border-collapse: collapse; background: white; font-size: .94em; line-height: 1.65; }
th, td { padding: 13px 15px; border-right: 1px solid #dce4ea; border-bottom: 1px solid #dce4ea; text-align: left; vertical-align: top; }
th { color: white; background: var(--navy-2); font-weight: 800; }
tr:last-child td { border-bottom: 0; }
td:last-child, th:last-child { border-right: 0; }
tbody tr:nth-child(even) { background: #f6f9fb; }

.code-block { position: relative; margin: 26px 0 34px; color: #eef5fb; background: #142535; border-left: 5px solid var(--yellow); }
.code-label { padding: 9px 14px; color: #b9c9d8; background: #0b1824; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.code-block pre { margin: 0; padding: 20px; overflow-x: auto; white-space: pre-wrap; overflow-wrap: break-word; }
.code-block code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; line-height: 1.7; }
.copy-code { position: absolute; top: 6px; right: 7px; min-height: 32px; padding: 4px 10px; color: white; background: #29445d; border: 1px solid #61788e; cursor: pointer; }

.article-figure { margin: 30px 0 42px; }
.article-figure img { display: block; width: 100%; height: auto; max-height: 760px; object-fit: contain; background: white; border: 1px solid #d4dde5; cursor: zoom-in; }
.article-figure figcaption { margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.5; text-align: center; }

.video-figure { margin: 30px 0 42px; }
.video-embed { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; background: #08131e; border: 1px solid #d4dde5; }
.video-embed iframe, .video-embed video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-figure figcaption { margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.5; text-align: center; }
.released-examples { margin: 34px 0 48px; }
.released-media + .released-media { margin-top: 24px; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 72px; padding-top: 26px; border-top: 1px solid var(--line); }
.pager-link { min-height: 74px; padding: 14px 17px; color: var(--navy); background: white; border: 1px solid var(--line); text-decoration: none; line-height: 1.45; }
.pager-link:hover { border-color: var(--blue); }
.pager-next { text-align: right; }
.pager-kicker { display: block; margin-bottom: 4px; color: var(--blue); font-size: 11px; font-weight: 800; }
.pager-link.is-disabled { visibility: hidden; pointer-events: none; }

.toc-panel {
  position: sticky;
  top: 72px;
  height: calc(100vh - 72px);
  padding: 42px 20px;
  border-left: 1px solid var(--line);
  overflow-y: auto;
}
.toc-heading { margin-bottom: 13px; color: var(--navy); font-size: 13px; font-weight: 800; }
.toc-link { display: block; padding: 6px 0; color: var(--muted); font-size: 12px; line-height: 1.5; text-decoration: none; }
.toc-link:hover { color: var(--blue); }
.toc-link.level-3 { padding-left: 12px; border-left: 1px solid var(--line); }

.image-dialog { width: min(94vw, 1400px); max-height: 94vh; padding: 44px 20px 16px; border: 0; background: #0c1824; }
.image-dialog::backdrop { background: rgba(3, 10, 18, .88); }
.image-dialog img { display: block; width: 100%; max-height: 78vh; object-fit: contain; }
.image-dialog p { margin: 10px 0 0; color: white; text-align: center; }
.dialog-close { position: absolute; top: 5px; right: 8px; width: 40px; height: 40px; color: white; background: transparent; border: 1px solid #8294a5; font-size: 25px; cursor: pointer; }

body[data-text-size="compact"] { --article-font: 15px; --article-line: 1.8; }
body[data-text-size="large"] { --article-font: 18px; --article-line: 2; }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 270px minmax(0, 1fr); }
  .toc-panel { display: none; }
}

@media (max-width: 760px) {
  .access-lock { padding: 18px; }
  .access-lock-card { padding: 30px 24px 24px; }
  .access-lock h1 { font-size: 26px; }
  .site-header { height: 68px; padding: 0 12px; }
  .site-title { font-size: 17px; }
  .eyebrow { font-size: 9px; }
  .tool-label { display: none; }
  .text-size-button { min-width: 40px; min-height: 40px; }
  .menu-button { display: block; }
  .app-shell { display: block; min-height: calc(100vh - 68px); }
  .sidebar {
    position: fixed;
    z-index: 50;
    top: 68px;
    left: 0;
    width: min(88vw, 340px);
    height: calc(100vh - 68px);
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform .18s ease;
  }
  .sidebar.is-open { transform: translateX(0); visibility: visible; }
  .sidebar-backdrop { position: fixed; z-index: 45; inset: 68px 0 0; background: rgba(5, 18, 31, .55); }
  .content-column { padding: 34px 18px 60px; }
  .article > h1:first-child { font-size: 27px; }
  .article h3 { margin-top: 56px; font-size: 20px; }
  .article h4 { font-size: 18px; }
  .lesson-guide-body { padding-inline: 15px; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { text-align: left; }
  .article-figure { margin-inline: -18px; }
  .article-figure figcaption { padding-inline: 18px; }
  .video-figure { margin-inline: -18px; }
  .video-figure figcaption { padding-inline: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .sidebar { transition: none; }
}
