:root {
  --color-bg: #faf9f6;
  --color-text: #2b2925;
  --color-heading: #1f3d2b;
  --color-accent: #4f7a5c;
  --color-accent-dark: #345040;
  --color-border: #dcd8cd;
  --color-panel: #ffffff;
  --max-width: 900px;
  --toc-width: 280px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  line-height: 1.9;
  word-break: normal;
  overflow-wrap: anywhere;
}

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

.site-header {
  background: var(--color-heading);
  color: #fff;
  padding: 1rem 1.25rem;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
}
.back-link {
  color: #cfe3d6;
  text-decoration: none;
  font-size: 0.85rem;
  display: inline-block;
  margin-bottom: 0.4rem;
}
.back-link:hover { color: #fff; text-decoration: underline; }
.site-header h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.hero {
  width: 100%;
  max-height: 46vh;
  overflow: hidden;
  background: #000;
}
.hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0.92;
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  padding: 1.5rem 1.25rem 4rem;
}

/* TOC */
.toc {
  flex: 0 0 var(--toc-width);
  position: sticky;
  top: 1rem;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}
.toc-header {
  display: none;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  font-weight: bold;
  border-bottom: 1px solid var(--color-border);
}
#toc-toggle {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--color-heading);
}
.toc-body {
  padding: 1rem 1.1rem;
  font-size: 0.92rem;
}
.toc-list {
  list-style: none;
  margin: 0;
  padding-left: 0;
}
.toc-list .toc-list {
  padding-left: 1.1rem;
  margin-top: 0.2rem;
}
.toc-list li {
  margin: 0.35rem 0;
}
.toc-list a {
  text-decoration: none;
  color: var(--color-text);
}
.toc-list a:hover {
  color: var(--color-accent-dark);
  text-decoration: underline;
}
.toc-level-1 > li > a {
  font-weight: 700;
  color: var(--color-heading);
}

/* Content */
.content {
  flex: 1 1 auto;
  min-width: 0;
  max-width: var(--max-width);
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 2rem 2.25rem;
}

.content h2, .content h3, .content h4, .content h5 {
  color: var(--color-heading);
  font-family: "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  line-height: 1.5;
  scroll-margin-top: 1rem;
}
.content h2.heading-l1 {
  font-size: 1.5rem;
  margin-top: 2.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 3px solid var(--color-accent);
}
.content h3.heading-l2 {
  font-size: 1.2rem;
  margin-top: 2rem;
  padding-left: 0.6rem;
  border-left: 5px solid var(--color-accent);
}
.content h4.heading-l3 {
  font-size: 1.05rem;
  margin-top: 1.5rem;
  color: var(--color-accent-dark);
}
.content > *:first-child { margin-top: 0; }

.content p {
  margin: 0 0 1.1em;
  text-align: justify;
}

.doc-list {
  margin: 0 0 1.2em;
  padding-left: 1.6em;
}
.doc-list li { margin: 0.4em 0; }

/* Figures / photos / tables */
figure.media {
  margin: 1.8em 0;
  text-align: center;
}
figure.media a.lightbox-trigger {
  display: inline-block;
  position: relative;
  max-width: 100%;
  cursor: zoom-in;
  border: 1px solid var(--color-border);
  background: #fff;
  border-radius: 4px;
  overflow: hidden;
}
figure.media img {
  display: block;
  max-width: 100%;
  height: auto;
}
.zoom-hint {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(31, 61, 43, 0.82);
  color: #fff;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: "Noto Sans JP", sans-serif;
  opacity: 0;
  transition: opacity 0.15s ease;
}
figure.media a.lightbox-trigger:hover .zoom-hint { opacity: 1; }
figure.media figcaption {
  margin-top: 0.6em;
  font-size: 0.88rem;
  color: #555;
  font-family: "Noto Sans JP", sans-serif;
}

.table-media { text-align: left; }
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: 4px;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
  font-family: "Noto Sans JP", sans-serif;
}
table th, table td {
  border: 1px solid var(--color-border);
  padding: 0.5em 0.7em;
  text-align: left;
  vertical-align: top;
}
table th {
  background: #eef2ec;
  font-weight: 700;
  white-space: nowrap;
}

.site-footer {
  text-align: center;
  padding: 2rem 1rem 3rem;
  font-size: 0.9rem;
  color: #666;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 12, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 1000;
  padding: 2rem;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 100%;
  max-height: 82vh;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  border-radius: 4px;
}
.lightbox-caption {
  color: #f0f0f0;
  margin-top: 1rem;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 0.95rem;
  text-align: center;
  max-width: 900px;
}
.lightbox-close {
  position: absolute;
  top: 1.2rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 2.2rem;
  cursor: pointer;
  line-height: 1;
}

/* Responsive */
@media (max-width: 880px) {
  :root { font-size: 15px; }
  .layout {
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
  }
  .toc {
    position: static;
    width: 100%;
    max-height: none;
  }
  .toc-header { display: flex; }
  .toc-body { display: none; }
  .toc-body.open { display: block; }
  .content { padding: 1.4rem 1.2rem; width: 100%; }
  .hero { max-height: 30vh; }
  .site-header h1 { font-size: 1.15rem; }
}

@media print {
  .toc, .lightbox, .hero, .site-header .back-link { display: none !important; }
  .layout { display: block; }
  .content { border: none; padding: 0; max-width: none; }
}
