:root {
  color-scheme: dark;
  --ink: #120e0d;
  --ink-soft: #1b1513;
  --ink-raised: #251b18;
  --paper: #f2eadc;
  --paper-deep: #e1d3bd;
  --paper-ink: #28201c;
  --paper-muted: #73665a;
  --gold: #d5ae68;
  --gold-bright: #f0d7a0;
  --crimson: #9f2725;
  --crimson-bright: #c83b35;
  --line: rgba(213, 174, 104, 0.25);
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --content: 1240px;
  --reading: 760px;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 0; background: var(--ink); color: var(--paper); line-height: 1.7; line-break: strict; font-feature-settings: "palt" 1; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
img { max-width: 100%; }
noscript { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; display: block; left: 16px; top: -80px; z-index: 200; padding: 12px 18px; background: var(--paper); color: var(--paper-ink); border-radius: 8px; }
.skip-link:focus { top: 16px; }
:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 3px; }

.page-progress { position: fixed; inset: 0 0 auto; z-index: 110; height: 3px; background: rgba(255,255,255,.05); }
.page-progress span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--crimson-bright), var(--gold-bright)); transition: width .12s linear; }
.site-header { position: fixed; inset: 0 0 auto; z-index: 100; height: 78px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(20px, calc((100vw - var(--content))/2)); border-bottom: 1px solid rgba(213,174,104,.14); background: rgba(18,14,13,.82); backdrop-filter: blur(18px); }
.brand { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-seal { display: grid; place-items: center; width: 39px; aspect-ratio: 1; border: 1px solid var(--gold); border-radius: 50%; color: var(--gold-bright); font-family: Georgia, serif; font-size: 21px; box-shadow: inset 0 0 0 4px var(--ink), inset 0 0 0 5px rgba(213,174,104,.26); }
.brand b { display: block; font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; letter-spacing: .05em; font-size: 16px; white-space: nowrap; }
.brand small { display: block; margin-top: 3px; color: var(--gold); font-family: Georgia, serif; font-size: 8px; letter-spacing: .22em; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.ghost-button, .menu-button, .icon-button { border: 0; color: inherit; background: transparent; cursor: pointer; }
.ghost-button { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 12px; border-radius: 10px; color: #e7dbc8; }
.ghost-button:hover { background: rgba(255,255,255,.07); }
.ghost-button svg, .search-field svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.menu-button { display: none; width: 44px; height: 44px; border-radius: 10px; }
.menu-button i { display: block; width: 22px; height: 1px; margin: 6px auto; background: currentColor; }

#main-content { min-height: 100vh; }
.loading-state { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--gold); }
.loading-state span { width: 38px; height: 38px; border: 1px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }
.loading-state p { margin: 0; font-family: "Yu Mincho", serif; letter-spacing: .16em; font-size: 13px; }
@keyframes spin { to { rotate: 1turn; } }

.hero { position: relative; min-height: 760px; display: grid; align-items: center; overflow: hidden; background: #0b0908 url("assets/儀式の講堂.webp") center / cover no-repeat; }
.hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(8,6,6,.98) 0%, rgba(8,6,6,.85) 33%, rgba(8,6,6,.2) 68%, rgba(8,6,6,.35) 100%), linear-gradient(0deg, var(--ink), transparent 32%); }
.hero-content { position: relative; width: min(var(--content), calc(100% - 40px)); margin: 70px auto 0; }
.hero-copy { width: min(650px, 56vw); padding: 70px 0; }
.eyebrow { margin: 0 0 18px; color: var(--gold); font-family: Georgia, serif; font-size: 11px; font-weight: 700; letter-spacing: .28em; }
.hero h1 { margin: 0; font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; font-size: clamp(46px, 6.2vw, 92px); font-weight: 500; line-height: 1.12; letter-spacing: -.03em; text-wrap: balance; }
.hero h1 em { color: var(--gold-bright); font-style: normal; }
.hero-lead { max-width: 560px; margin: 28px 0 0; color: #d9cebf; font-size: clamp(16px, 1.5vw, 20px); line-height: 2; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 38px; }
.primary-button, .secondary-button { min-height: 52px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 0 22px; border-radius: 999px; text-decoration: none; font-weight: 700; cursor: pointer; transition: transform .2s ease, background .2s ease, border-color .2s ease; }
.primary-button { border: 1px solid var(--gold-bright); background: var(--gold-bright); color: #25160f; box-shadow: 0 8px 28px rgba(213,174,104,.2); }
.secondary-button { border: 1px solid rgba(242,234,220,.35); color: var(--paper); background: rgba(18,14,13,.42); backdrop-filter: blur(10px); }
.primary-button:hover, .secondary-button:hover { transform: translateY(-2px); }
.secondary-button:hover { border-color: var(--gold); }
.hero-meta { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 52px; padding-top: 22px; border-top: 1px solid var(--line); color: #b8aa99; font-size: 12px; }
.hero-meta b { color: var(--paper); font-size: 18px; font-family: Georgia, serif; }

.home-section { width: min(var(--content), calc(100% - 40px)); margin: 0 auto; padding: 92px 0; }
.section-heading { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 24px; margin-bottom: 34px; }
.section-heading h2 { max-width: 760px; margin: 0; font-family: "Yu Mincho", serif; font-size: clamp(30px, 4vw, 54px); font-weight: 500; line-height: 1.3; }
.section-heading p:last-child { max-width: 440px; margin: 0; color: #bbae9c; line-height: 1.9; }
.roadmap-card { position: relative; min-height: 560px; overflow: hidden; border: 1px solid var(--line); border-radius: 28px; background: #110f0e url("assets/六つの門.webp") center / cover no-repeat; box-shadow: var(--shadow); }
.roadmap-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(12,10,9,.42), transparent 45%, rgba(12,10,9,.18)); pointer-events: none; }
.roadmap-links { position: absolute; z-index: 2; inset: 24px; display: grid; grid-template-columns: repeat(3, 1fr); align-content: end; gap: 10px; pointer-events: none; }
.roadmap-link { min-height: 74px; display: flex; align-items: center; gap: 13px; padding: 12px 14px; border: 1px solid rgba(240,215,160,.28); border-radius: 14px; background: rgba(16,12,11,.82); backdrop-filter: blur(12px); text-decoration: none; pointer-events: auto; transition: border-color .2s ease, transform .2s ease; }
.roadmap-link:hover { border-color: var(--gold-bright); transform: translateY(-3px); }
.roadmap-link span { flex: 0 0 34px; display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--gold); border-radius: 50%; color: var(--gold-bright); font-family: Georgia, serif; }
.roadmap-link b { font-family: "Yu Mincho", serif; font-size: 14px; line-height: 1.5; }
.principles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.principle { padding: 26px; border-top: 1px solid var(--gold); background: var(--ink-soft); }
.principle span { color: var(--gold); font-family: Georgia, serif; font-size: 12px; letter-spacing: .2em; }
.principle h3 { margin: 16px 0 10px; font-family: "Yu Mincho", serif; font-size: 22px; font-weight: 500; }
.principle p { margin: 0; color: #b9aa99; line-height: 1.8; }

.course-layout { width: min(var(--content), calc(100% - 40px)); display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 48px; margin: 0 auto; padding: 128px 0 90px; }
.course-sidebar { position: sticky; top: 108px; align-self: start; max-height: calc(100vh - 132px); overflow: auto; padding-right: 12px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.course-sidebar .progress-ring { display: grid; grid-template-columns: 54px 1fr; align-items: center; gap: 14px; padding: 14px; margin-bottom: 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--ink-soft); }
.ring { --value: 0deg; display: grid; place-items: center; width: 54px; aspect-ratio: 1; border-radius: 50%; background: conic-gradient(var(--gold) var(--value), rgba(255,255,255,.08) 0); }
.ring::after { content: ""; width: 42px; aspect-ratio: 1; border-radius: 50%; background: var(--ink-soft); }
.progress-ring b { display: block; font-family: Georgia, serif; font-size: 18px; }
.progress-ring small { color: #ad9d8b; }
.nav-group { margin-bottom: 18px; }
.nav-group-title, .nav-child { display: block; width: 100%; border: 0; text-align: left; text-decoration: none; cursor: pointer; }
.nav-group-title { padding: 11px 10px; border-radius: 9px; color: #f0e6d8; background: transparent; font-family: "Yu Mincho", serif; line-height: 1.5; }
.nav-group-title:hover, .nav-group-title.active { background: rgba(213,174,104,.1); color: var(--gold-bright); }
.nav-child { position: relative; padding: 8px 10px 8px 29px; color: #9f9282; font-size: 12px; line-height: 1.6; }
.nav-child::before { content: ""; position: absolute; left: 14px; top: 17px; width: 5px; height: 5px; border: 1px solid currentColor; border-radius: 50%; }
.nav-child.done::before { background: var(--gold); border-color: var(--gold); }
.nav-child:hover, .nav-child.active { color: var(--paper); }

.lesson { min-width: 0; }
.lesson-header { max-width: var(--reading); margin: 0 auto 34px; }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 26px; color: #a99a88; font-size: 12px; }
.breadcrumbs a { text-decoration: none; }
.lesson-number { color: var(--gold); font-family: Georgia, serif; font-size: 11px; letter-spacing: .22em; }
.lesson h1 { margin: 12px 0 20px; font-family: "Yu Mincho", serif; font-size: clamp(34px, 5vw, 62px); font-weight: 500; line-height: 1.25; text-wrap: balance; }
.lesson-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.complete-button, .source-button { min-height: 44px; display: inline-flex; align-items: center; gap: 8px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--ink-soft); color: var(--paper); text-decoration: none; cursor: pointer; }
.complete-button[aria-pressed="true"] { border-color: var(--gold); background: rgba(213,174,104,.14); color: var(--gold-bright); }
.lesson-document { max-width: 920px; margin: 0 auto; padding: clamp(26px, 5vw, 68px); border-radius: 22px; background: var(--paper); color: var(--paper-ink); box-shadow: var(--shadow); }
.document-inner { max-width: var(--reading); margin: 0 auto; }
.document-inner > :first-child { margin-top: 0; }
.document-inner h2, .document-inner h3, .document-inner h4 { font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; line-height: 1.45; letter-spacing: .015em; }
.document-inner h2 { margin: 2.4em 0 .8em; padding-bottom: .45em; border-bottom: 1px solid #c9b99e; font-size: clamp(25px, 3.2vw, 36px); }
.document-inner h3 { margin: 2.1em 0 .7em; font-size: 25px; }
.document-inner h4 { margin: 1.8em 0 .65em; font-size: 20px; }
.document-inner p, .document-inner li { font-size: 16px; line-height: 2; }
.document-inner p { white-space: pre-wrap; overflow-wrap: anywhere; }
.document-inner strong { color: #20120e; }
.document-inner a { color: #7e221f; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.document-inner ul, .document-inner ol { margin: .5em 0; padding-left: 1.5em; }
.source-divider { height: 1px; margin: 32px 0; background: #cdbda5; }
.source-quote { margin: 28px 0; padding: 18px 22px; border-left: 3px solid var(--crimson); background: #e9decc; }
.source-callout { margin: 22px 0; padding: 18px 20px; border: 1px solid #c9b99e; border-radius: 12px; background: #ece2d2; }
.todo-item { display: flex; align-items: flex-start; gap: 12px; margin: 12px 0; padding: 15px 16px; border-radius: 10px; background: #e9decc; }
.todo-item input { flex: 0 0 auto; width: 21px; height: 21px; margin-top: 5px; accent-color: var(--crimson); cursor: pointer; }
.todo-item span { line-height: 1.9; }
.lesson-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; margin: 14px 0; padding: 18px; border: 1px solid #c9b99e; border-radius: 13px; color: var(--paper-ink); text-decoration: none; }
.lesson-card:hover { border-color: var(--crimson); }
.lesson-card-index { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--paper-ink); color: var(--gold-bright); font-family: Georgia, serif; }
.lesson-card b { line-height: 1.6; }
.lesson-card svg { width: 20px; fill: none; stroke: currentColor; }
.source-image { margin: 28px 0; }
.source-image img { display: block; width: 100%; height: auto; border-radius: 10px; border: 1px solid #c8b89e; background: #ddd1bf; }
.source-image figcaption { margin-top: 8px; color: var(--paper-muted); font-size: 12px; overflow-wrap: anywhere; }
.bookmark-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 20px; margin: 16px 0; padding: 18px 20px; border: 1px solid #c8b89e; border-radius: 12px; color: var(--paper-ink); text-decoration: none; }
.bookmark-card:hover { border-color: var(--crimson); }
.bookmark-card b { display: block; margin-bottom: 5px; }
.bookmark-card small { display: block; color: var(--paper-muted); line-height: 1.5; }
.bookmark-card span { color: var(--crimson); font-size: 12px; font-weight: 700; }
.table-scroll { margin: 24px 0; overflow-x: auto; border: 1px solid #c8b89e; border-radius: 10px; }
.source-table { width: 100%; min-width: 620px; border-collapse: collapse; }
.source-table td { padding: 13px 14px; border-right: 1px solid #c8b89e; border-bottom: 1px solid #c8b89e; vertical-align: top; line-height: 1.75; white-space: pre-wrap; }
.source-table tr:first-child td { background: #dfd1ba; font-weight: 700; }
.source-table tr:last-child td { border-bottom: 0; }
.source-table td:last-child { border-right: 0; }
.columns { display: grid; grid-template-columns: repeat(var(--columns, 2), minmax(0, 1fr)); gap: 20px; }
.column { min-width: 0; }

.lesson-pagination { max-width: 920px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 24px auto 0; }
.page-link { min-height: 88px; display: flex; flex-direction: column; justify-content: center; padding: 16px 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--ink-soft); text-decoration: none; }
.page-link.next { text-align: right; }
.page-link small { color: var(--gold); }
.page-link b { margin-top: 6px; line-height: 1.5; }
.page-link:hover { border-color: var(--gold); }
.integrity-note { max-width: 920px; display: flex; justify-content: space-between; gap: 20px; margin: 18px auto 0; padding: 0 4px; color: #8f8172; font-size: 11px; }

dialog { color: var(--paper); }
dialog::backdrop { background: rgba(4,3,3,.72); backdrop-filter: blur(8px); }
.search-dialog { width: min(760px, calc(100% - 30px)); max-height: min(720px, calc(100vh - 30px)); padding: 0; border: 1px solid var(--line); border-radius: 20px; background: var(--ink-soft); box-shadow: var(--shadow); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-family: "Yu Mincho", serif; font-weight: 500; }
.dialog-head .eyebrow { margin-bottom: 7px; }
.icon-button { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; font-size: 28px; }
.icon-button:hover { background: rgba(255,255,255,.08); }
.search-field { display: flex; align-items: center; gap: 12px; margin: 22px 24px; padding: 0 15px; border: 1px solid var(--line); border-radius: 12px; background: #120e0d; }
.search-field input { width: 100%; min-height: 52px; border: 0; outline: 0; color: var(--paper); background: transparent; }
.search-results { padding: 0 24px 24px; overflow: auto; }
.search-result { display: block; padding: 16px 0; border-top: 1px solid var(--line); text-decoration: none; }
.search-result small { color: var(--gold); }
.search-result b { display: block; margin: 5px 0; }
.search-result p { margin: 0; color: #aa9d8e; font-size: 13px; line-height: 1.7; }
.empty-search { padding: 50px 0; color: #aa9d8e; text-align: center; }
.mobile-navigation { width: min(420px, 100%); max-width: none; height: 100%; max-height: none; margin: 0 0 0 auto; padding: 0; border: 0; border-left: 1px solid var(--line); background: var(--ink); }
.mobile-navigation nav { padding: 20px; }

@media (max-width: 1024px) {
  .site-header { height: 68px; padding: 0 18px; }
  .ghost-button span { display: none; }
  .menu-button { display: block; }
  .hero { min-height: 720px; background-position: 62% center; }
  .hero::before { background: linear-gradient(90deg, rgba(8,6,6,.96), rgba(8,6,6,.62) 70%, rgba(8,6,6,.34)), linear-gradient(0deg, var(--ink), transparent 35%); }
  .hero-copy { width: min(600px, 88vw); }
  .section-heading { grid-template-columns: 1fr; align-items: start; }
  .roadmap-links { grid-template-columns: repeat(2, 1fr); }
  .principles { grid-template-columns: 1fr; }
  .course-layout { grid-template-columns: 1fr; padding-top: 106px; }
  .course-sidebar { display: none; }
}

@media (max-width: 640px) {
  .brand b { font-size: 14px; }
  .brand > span:last-child { display: none; }
  .hero { min-height: 680px; background-position: 68% center; }
  .hero::before { background: linear-gradient(0deg, var(--ink) 0%, rgba(8,6,6,.65) 50%, rgba(8,6,6,.5)), linear-gradient(90deg, rgba(8,6,6,.92), rgba(8,6,6,.2)); }
  .hero-content { width: calc(100% - 32px); }
  .hero-copy { width: 100%; padding: 80px 0 42px; }
  .hero h1 { max-width: 360px; font-size: clamp(42px, 14vw, 64px); }
  .hero-lead { font-size: 15px; line-height: 1.85; }
  .hero-actions { display: grid; }
  .hero-meta { gap: 14px 20px; }
  .home-section { width: calc(100% - 32px); padding: 68px 0; }
  .roadmap-card { min-height: 650px; background-position: 64% center; }
  .roadmap-links { inset: auto 14px 14px; grid-template-columns: 1fr; max-height: 360px; overflow: auto; }
  .roadmap-link { min-height: 59px; }
  .roadmap-link span { width: 30px; height: 30px; }
  .course-layout { width: calc(100% - 20px); }
  .lesson-header { padding: 0 8px; }
  .lesson h1 { font-size: 34px; }
  .lesson-document { padding: 30px 20px; border-radius: 16px; }
  .document-inner p, .document-inner li { font-size: 15px; line-height: 1.95; }
  .columns { grid-template-columns: 1fr; }
  .lesson-pagination { grid-template-columns: 1fr; }
  .integrity-note { display: block; line-height: 1.8; }
  .lesson-card { grid-template-columns: auto 1fr; }
  .lesson-card svg { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
