:root {
  --ink: #18233a;
  --ink-soft: #536078;
  --paper: #f8f4e9;
  --paper-deep: #eee6d3;
  --white: #fffdf8;
  --red: #d94b3f;
  --red-dark: #a8322b;
  --yellow: #f3c94b;
  --blue: #285d82;
  --line: rgba(24, 35, 58, 0.16);
  --shadow: 0 18px 50px rgba(44, 38, 25, 0.12);
  --font-body: "Noto Sans JP", sans-serif;
  --font-note: "Zen Kurenaido", cursive;
  --content-width: 1180px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(24, 35, 58, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 28px;
  font-family: "Noto Sans JP", sans-serif;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

a {
  color: var(--blue);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

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

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 4px;
  border-radius: 4px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 1rem;
  color: var(--white);
  background: var(--ink);
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: relative;
  z-index: 10;
  color: var(--white);
  background: var(--ink);
  border-bottom: 5px solid var(--yellow);
}

.header-inner,
.footer-inner {
  width: min(calc(100% - 2rem), var(--content-width));
  margin-inline: auto;
}

.header-inner {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--white);
  text-decoration: none;
}

.brand:hover {
  color: var(--white);
}

.brand-mark {
  width: 42px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: var(--yellow);
  border-radius: 50% 50% 48% 52% / 44% 48% 52% 56%;
  font-weight: 900;
  transform: rotate(-6deg);
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.25;
}

.brand strong {
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.brand small {
  margin-top: 0.2rem;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.72rem;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.88rem;
  font-weight: 700;
}

.site-nav a {
  color: var(--white);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--yellow);
}

.breadcrumbs {
  width: min(calc(100% - 2rem), var(--content-width));
  margin: 1.35rem auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.article-shell {
  width: min(calc(100% - 2rem), var(--content-width));
  margin: 1.2rem auto 5rem;
  background: var(--white);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.article-hero {
  position: relative;
  padding: clamp(2rem, 6vw, 5rem) clamp(1.25rem, 7vw, 6rem) clamp(2.2rem, 5vw, 4rem);
  background:
    linear-gradient(90deg, transparent 0 62px, rgba(217, 75, 63, 0.18) 62px 64px, transparent 64px),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(40, 93, 130, 0.08) 31px 32px),
    var(--white);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.article-hero::after {
  content: "";
  position: absolute;
  right: -50px;
  bottom: -85px;
  width: 220px;
  aspect-ratio: 1;
  border: 22px solid rgba(243, 201, 75, 0.48);
  border-radius: 50%;
  transform: rotate(-12deg);
}

.chapter-stamp {
  position: absolute;
  top: 0;
  right: clamp(1rem, 4vw, 3rem);
  width: min(170px, 28vw);
  padding: 0.7rem 0.8rem 1rem;
  color: var(--white);
  background: var(--red);
  text-align: center;
  clip-path: polygon(0 0, 100% 0, 100% 86%, 50% 100%, 0 86%);
}

.chapter-stamp span,
.chapter-stamp strong {
  display: block;
  line-height: 1.2;
}

.chapter-stamp span {
  font-size: 0.62rem;
  letter-spacing: 0.16em;
}

.chapter-stamp strong {
  margin-top: 0.3rem;
  font-size: clamp(0.72rem, 1.7vw, 1rem);
}

.chapter-name,
.eyebrow {
  margin: 0 0 1rem;
  color: var(--red-dark);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.article-hero h1 {
  max-width: 850px;
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 1.32;
  letter-spacing: -0.035em;
}

.article-lead {
  max-width: 770px;
  margin: 1.5rem 0 0;
  color: var(--ink-soft);
  font-size: clamp(1rem, 1.6vw, 1.15rem);
}

.article-meta {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 760px);
  justify-content: center;
  gap: clamp(2rem, 5vw, 5rem);
  padding: clamp(2rem, 6vw, 5rem) clamp(1.25rem, 5vw, 4rem);
}

.article-toc {
  align-self: start;
  position: sticky;
  top: 1.5rem;
  padding: 1.2rem;
  background: var(--paper);
  border-top: 5px solid var(--yellow);
}

.article-toc p {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 900;
}

.article-toc ol {
  margin: 0.8rem 0 0;
  padding-left: 1.15rem;
  font-size: 0.78rem;
  line-height: 1.55;
}

.article-toc li + li {
  margin-top: 0.48rem;
}

.article-toc a {
  color: var(--ink-soft);
  text-decoration: none;
}

.article-toc a:hover {
  color: var(--red-dark);
  text-decoration: underline;
}

.article-content {
  min-width: 0;
  font-size: 1rem;
}

.article-section {
  scroll-margin-top: 1.5rem;
}

.article-section + .article-section,
.article-section + .lab-example,
.lab-example + .article-section {
  margin-top: 3.3rem;
}

.article-content h2 {
  margin: 0 0 1.25rem;
  padding: 0.25rem 0 0.55rem 1rem;
  font-size: clamp(1.4rem, 2.5vw, 1.85rem);
  line-height: 1.45;
  border-left: 6px solid var(--red);
  border-bottom: 1px solid var(--line);
}

.article-content h3 {
  margin: 2rem 0 0.75rem;
  font-size: 1.14rem;
  line-height: 1.55;
}

.article-content p {
  margin: 0.9rem 0;
}

.article-content ul,
.article-content ol {
  margin: 1rem 0;
  padding: 1rem 1.25rem 1rem 2.4rem;
  background: rgba(238, 230, 211, 0.48);
  border-radius: 2px;
}

.article-content li + li {
  margin-top: 0.45rem;
}

.article-content strong {
  background: linear-gradient(transparent 62%, rgba(243, 201, 75, 0.48) 62%);
}

.article-content code {
  padding: 0.1em 0.35em;
  color: #96352e;
  background: #f4ece4;
  border-radius: 3px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.9em;
}

.article-content pre {
  margin: 1.3rem 0;
  padding: 1.2rem;
  overflow-x: auto;
  color: #edf4ff;
  background: #172033;
  border-left: 5px solid var(--yellow);
  border-radius: 3px;
  line-height: 1.65;
}

.article-content pre code {
  padding: 0;
  color: inherit;
  background: transparent;
}

.lab-example,
.editor-note {
  position: relative;
  padding: clamp(1.4rem, 4vw, 2.2rem);
  background: #fff7cf;
  border: 1px solid rgba(112, 86, 13, 0.24);
  box-shadow: 7px 8px 0 rgba(24, 35, 58, 0.08);
  transform: rotate(-0.35deg);
}

.lab-example::before,
.editor-note::before {
  content: "";
  position: absolute;
  top: -11px;
  left: 50%;
  width: 88px;
  height: 22px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(24, 35, 58, 0.06);
  transform: translateX(-50%) rotate(2deg);
}

.lab-example h2,
.editor-note h2 {
  padding: 0;
  border: 0;
}

.faq {
  padding: 1.5rem;
  background: var(--paper);
  border-top: 4px solid var(--blue);
}

.faq h2 {
  padding-left: 0;
  border-left: 0;
}

.references {
  font-size: 0.88rem;
}

.references a {
  word-break: break-word;
}

.chapter-nav {
  margin-top: 3rem;
  padding-top: 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  border-top: 1px solid var(--line);
}

.chapter-link {
  min-height: 84px;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid transparent;
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease;
}

.chapter-link:hover {
  color: var(--ink);
  border-color: var(--red);
  transform: translateY(-3px);
}

.chapter-link.next {
  text-align: right;
}

.chapter-link small {
  color: var(--ink-soft);
}

.chapter-link span {
  font-weight: 900;
}

.chapter-link.is-empty {
  visibility: hidden;
}

.site-footer {
  padding: 3rem 0 1.3rem;
  color: var(--white);
  background: var(--ink);
  border-top: 5px solid var(--yellow);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
}

.footer-inner p {
  margin: 0;
}

.footer-inner span,
.copyright {
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.78rem;
}

.footer-inner nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem 1rem;
}

.footer-inner a {
  color: var(--white);
  font-size: 0.82rem;
}

.copyright {
  width: min(calc(100% - 2rem), var(--content-width));
  margin: 2rem auto 0;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

/* 一覧ページ */
.hub-hero {
  padding: clamp(3rem, 8vw, 7rem) 1rem;
  background:
    radial-gradient(circle at 14% 28%, rgba(243, 201, 75, 0.28) 0 140px, transparent 141px),
    linear-gradient(120deg, var(--ink) 0 66%, #22314e 66% 100%);
  color: var(--white);
  overflow: hidden;
}

.hub-hero-inner {
  width: min(100%, var(--content-width));
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  align-items: center;
  gap: clamp(2rem, 7vw, 7rem);
}

.hub-hero .eyebrow {
  color: var(--yellow);
}

.hub-hero h1 {
  margin: 0;
  font-size: clamp(3rem, 8vw, 7.4rem);
  line-height: 1.05;
  letter-spacing: -0.06em;
}

.hub-hero h1 span {
  color: var(--yellow);
  font-family: var(--font-note);
  font-weight: 400;
  letter-spacing: 0;
}

.hub-lead {
  max-width: 700px;
  margin: 1.8rem 0 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: clamp(1rem, 1.8vw, 1.18rem);
}

.hub-meta {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.hub-meta span {
  padding: 0.35rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  font-size: 0.72rem;
}

.note-card {
  position: relative;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  color: var(--ink);
  background: #fff7cf;
  box-shadow: 14px 18px 0 rgba(0, 0, 0, 0.18);
  transform: rotate(2deg);
}

.note-card::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px dashed rgba(24, 35, 58, 0.22);
  pointer-events: none;
}

.note-card > * {
  position: relative;
  z-index: 1;
}

.tape {
  position: absolute;
  top: -15px;
  left: 50%;
  width: 110px;
  height: 30px;
  background: rgba(255, 255, 255, 0.58);
  transform: translateX(-50%) rotate(-4deg);
}

.handwritten {
  margin: 0;
  color: var(--red-dark);
  font-family: var(--font-note);
  font-size: 1.5rem;
}

.note-card h2 {
  margin: 0.5rem 0 1rem;
  font-size: clamp(1.25rem, 2.5vw, 1.75rem);
  line-height: 1.55;
}

.note-card p:last-child {
  margin-bottom: 0;
  font-size: 0.9rem;
}

.hub-content {
  width: min(calc(100% - 2rem), var(--content-width));
  margin: clamp(3rem, 7vw, 6rem) auto;
}

.chapter-block + .chapter-block {
  margin-top: 5rem;
}

.chapter-heading {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.chapter-heading > span {
  width: 74px;
  aspect-ratio: 1;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--white);
  background: var(--red);
  border-radius: 50%;
  font-size: 0.68rem;
  font-weight: 900;
  transform: rotate(-5deg);
}

.chapter-heading h2,
.chapter-heading p {
  margin: 0;
}

.chapter-heading h2 {
  font-size: clamp(1.55rem, 3vw, 2.3rem);
}

.chapter-heading p {
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.article-grid {
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  list-style: none;
}

.article-card {
  position: relative;
  min-height: 290px;
  padding: clamp(1.3rem, 3vw, 2rem);
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  box-shadow: 5px 6px 0 var(--paper-deep);
  text-decoration: none;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.article-card:hover {
  color: var(--ink);
  border-color: var(--red);
  box-shadow: 9px 11px 0 rgba(217, 75, 63, 0.15);
  transform: translate(-2px, -3px);
}

.card-number {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  color: var(--paper-deep);
  font-size: 3.7rem;
  font-weight: 900;
  line-height: 1;
}

.card-label {
  position: relative;
  z-index: 1;
  align-self: flex-start;
  padding: 0.25rem 0.5rem;
  color: var(--white);
  background: var(--ink);
  font-size: 0.67rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.article-card h3 {
  position: relative;
  z-index: 1;
  max-width: 80%;
  margin: 1.2rem 0 0.8rem;
  font-size: clamp(1.2rem, 2.2vw, 1.55rem);
  line-height: 1.5;
}

.article-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.card-action {
  margin-top: auto;
  padding-top: 1rem;
  color: var(--red-dark);
  font-size: 0.84rem;
  font-weight: 900;
}

.editor-note {
  max-width: 760px;
  margin: 5rem auto 0;
}

.editor-note a {
  font-weight: 900;
}

@media (max-width: 900px) {
  .article-layout {
    grid-template-columns: 1fr;
  }

  .article-toc {
    position: static;
  }

  .hub-hero-inner {
    grid-template-columns: 1fr;
  }

  .note-card {
    max-width: 560px;
    margin-inline: auto;
  }
}

@media (max-width: 720px) {
  .header-inner {
    min-height: 68px;
  }

  .site-nav a:not(:first-child) {
    display: none;
  }

  .article-shell {
    width: min(calc(100% - 1rem), var(--content-width));
    margin-bottom: 3rem;
  }

  .article-hero {
    padding-top: 6.2rem;
    background:
      linear-gradient(90deg, transparent 0 27px, rgba(217, 75, 63, 0.18) 27px 29px, transparent 29px),
      repeating-linear-gradient(0deg, transparent 0 31px, rgba(40, 93, 130, 0.08) 31px 32px),
      var(--white);
  }

  .chapter-stamp {
    right: 1rem;
    width: 145px;
  }

  .article-hero h1 {
    font-size: 1.7rem;
    line-height: 1.45;
    letter-spacing: -0.02em;
  }

  .article-layout {
    padding-inline: 1rem;
  }

  .article-content {
    font-size: 0.96rem;
  }

  .article-grid {
    grid-template-columns: 1fr;
  }

  .article-card {
    min-height: 260px;
  }

  .chapter-nav {
    grid-template-columns: 1fr;
  }

  .chapter-link.next {
    text-align: left;
  }

  .chapter-link.is-empty {
    display: none;
  }

  .footer-inner {
    flex-direction: column;
  }

  .footer-inner nav {
    justify-content: flex-start;
  }
}

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

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
