:root {
  --blue: #3bb1ff;
  --red: #ff5252;
  --ink: #000000;
  --paper: #f4f2ec;
  --white: #ffffff;
  --edge: 3px solid #000000;
  --hard: 7px 7px 0 #000000;
  --hard-sm: 3px 3px 0 #000000;
  --navh: 112px;
  --serif: 'Noto Serif JP', 'Songti SC', 'SimSun', serif;
  --sans: 'Noto Sans JP', system-ui, -apple-system, 'Hiragino Sans', 'Microsoft YaHei', sans-serif;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding-bottom: calc(var(--navh) + 2.5rem);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.8;
  color: var(--ink);
  background: var(--paper);
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; }

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

/* ---------- hero ---------- */
.hero {
  min-height: calc(100svh - var(--navh));
  display: flex;
  align-items: center;
  padding: clamp(2.4rem, 7vw, 5rem) clamp(1.1rem, 5vw, 3.2rem) clamp(3rem, 9vw, 6rem);
  border-bottom: var(--edge);
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(0, 0, 0, .07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, .07) 1px, transparent 1px);
  background-size: 34px 34px;
}

.hero-inner { max-width: 1000px; }

.hero-title {
  display: inline;
  margin: 0;
  padding: .08em .3em .16em;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(2.1rem, 7.6vw, 4.6rem);
  line-height: 1.18;
  letter-spacing: -.01em;
  background: var(--white);
  border: var(--edge);
  box-shadow: 8px 8px 0 var(--ink);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.hero-lead {
  max-width: 44ch;
  margin: clamp(1.5rem, 4vw, 2.2rem) 0 0;
  padding: .95rem 1.15rem;
  font-size: 1rem;
  line-height: 1.9;
  background: var(--white);
  border: var(--edge);
  border-left-width: 10px;
  border-left-color: var(--red);
  box-shadow: var(--hard-sm);
}

.spin {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin: 1.1rem 0 0;
  padding: .35rem .85rem;
  font-size: .95rem;
  font-weight: 700;
  background: var(--blue);
  border: var(--edge);
  box-shadow: var(--hard-sm);
}

.spin-dot {
  width: 10px;
  height: 10px;
  background: var(--ink);
  border-radius: 50%;
  animation: blink 1.6s ease-in-out infinite;
}

.spin-word {
  display: inline-block;
  min-width: 7em;
  transition: opacity .25s ease, transform .25s ease;
}

.spin-word.is-out {
  opacity: 0;
  transform: translateY(-5px);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .25; }
}

/* ---------- layout ---------- */
main { padding: clamp(1.6rem, 4vw, 3.2rem) clamp(1rem, 4vw, 2.5rem); }

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  gap: clamp(1.2rem, 2.6vw, 2rem);
}

/* ---------- aside / toc ---------- */
.toc {
  padding: 1.1rem 1.15rem 1.3rem;
  background: var(--white);
  border: var(--edge);
  border-radius: 28px;
  box-shadow: var(--hard-sm);
}

.toc > small {
  display: block;
  margin-bottom: .3rem;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .2em;
}

.toc-h {
  margin: 0 0 .85rem;
  font-family: var(--serif);
  font-size: 1.15rem;
  letter-spacing: .04em;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .35rem;
}

.toc-list a {
  display: flex;
  align-items: baseline;
  gap: .55rem;
  min-height: 40px;
  padding: .35rem .5rem;
  font-size: .95rem;
  line-height: 1.5;
  color: var(--ink);
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: 4px;
}

.toc-list a:hover,
.toc-list a:focus-visible {
  background: var(--blue);
  border-color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}

.toc-num {
  flex: 0 0 auto;
  padding: 0 .32rem;
  font-family: var(--serif);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  background: var(--red);
  border: 2px solid var(--ink);
}

/* ---------- section ---------- */
.prose {
  overflow: hidden;
  background: var(--white);
  border: var(--edge);
  border-radius: 28px;
  box-shadow: var(--hard);
}

.prose > article {
  padding: clamp(1.5rem, 3.6vw, 2.6rem);
  border-top: var(--edge);
  scroll-margin-top: 1.2rem;
}

.prose > article:first-child { border-top: 0; }
.prose > article:nth-child(even) { background: #eaf6ff; }

.prose small {
  display: block;
  margin-bottom: .4rem;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .18em;
}

.prose small::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 3px;
  margin-right: .5rem;
  vertical-align: middle;
  background: var(--red);
  transform: translateY(-2px);
}

.prose h2 {
  margin: 0 0 .9rem;
  font-family: var(--serif);
  font-size: clamp(1.45rem, 3.6vw, 2.05rem);
  line-height: 1.35;
  letter-spacing: .005em;
}

.prose h3 {
  margin: 1.8rem 0 .6rem;
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2.6vw, 1.4rem);
  line-height: 1.45;
}

.prose p { margin: 0 0 1.05rem; }
.prose p:last-child { margin-bottom: 0; }

.prose ul,
.prose ol { margin: 0 0 1.05rem; padding-left: 1.35rem; }
.prose li { margin-bottom: .5rem; }
.prose li::marker { color: var(--red); font-weight: 700; }

.prose a {
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--blue);
  text-decoration-thickness: 3px;
  text-underline-offset: 3px;
}

.prose a:hover { background: var(--blue); }

.prose strong { box-shadow: inset 0 -.55em 0 #bfe4ff; }

.prose blockquote {
  margin: 1.3rem 0;
  padding: 1rem 1.2rem;
  background: #ffeeee;
  border: var(--edge);
  border-left-width: 10px;
  border-left-color: var(--red);
  box-shadow: var(--hard-sm);
}

.prose blockquote p:last-child { margin-bottom: 0; }

.prose figure { margin: 1.3rem 0; }

.prose img {
  display: block;
  margin: 1.2rem 0;
  border: var(--edge);
  border-radius: 18px;
  box-shadow: var(--hard-sm);
}

.prose figcaption {
  margin-top: .5rem;
  font-size: .88rem;
  line-height: 1.6;
}

.prose table {
  width: 100%;
  margin: 1.3rem 0;
  border-collapse: collapse;
  font-size: .95rem;
}

.prose th,
.prose td {
  padding: .5rem .6rem;
  text-align: left;
  border: 2px solid var(--ink);
}

.prose th { background: var(--blue); }

.prose hr {
  margin: 1.6rem 0;
  border: 0;
  border-top: 3px dashed var(--ink);
}

.prose code {
  padding: .05em .35em;
  font-size: .92em;
  background: #ececec;
  border: 2px solid var(--ink);
}

/* ---------- footer ---------- */
.foot {
  display: grid;
  gap: 1.7rem;
  padding: clamp(1.8rem, 4vw, 3rem) clamp(1rem, 4vw, 2.5rem) 1.4rem;
  background: var(--ink);
  color: var(--white);
  border-top: var(--edge);
}

.foot small {
  display: block;
  margin-bottom: .4rem;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .2em;
  color: var(--blue);
}

.foot h2 {
  margin: 0 0 .8rem;
  font-family: var(--serif);
  font-size: 1.35rem;
  color: var(--white);
}

.foot p {
  margin: 0 0 1rem;
  font-size: .95rem;
  line-height: 1.75;
  color: #dcdcdc;
}

.foot ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .45rem;
}

.foot a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: .25rem .55rem;
  font-size: .95rem;
  color: var(--white);
  text-decoration: none;
  border: 2px solid #ffffff;
  border-radius: 3px;
}

.foot a:hover,
.foot a:focus-visible {
  color: var(--ink);
  background: var(--red);
  border-color: var(--ink);
  box-shadow: 2px 2px 0 #ffffff;
}

.foot-top { margin-top: .2rem; }

.foot-bottom {
  grid-column: 1 / -1;
  margin: 0;
  padding-top: 1.1rem;
  font-size: .9rem;
  letter-spacing: .06em;
  text-align: center;
  color: #bdbdbd;
  border-top: 2px solid #3a3a3a;
}

/* ---------- bottom navbar ---------- */
.navbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  padding: .45rem .7rem .55rem;
  background: var(--white);
  border-top: var(--edge);
}

.navbar .brand {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 40px;
  padding: .2rem .85rem;
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  background: var(--blue);
  border: var(--edge);
  box-shadow: 2px 2px 0 var(--ink);
}

.brand-mark {
  width: 12px;
  height: 12px;
  background: var(--red);
  border: 2px solid var(--ink);
  border-radius: 50%;
}

.navbar ol {
  list-style: none;
  margin: 0;
  padding: 0 .1rem .15rem;
  display: flex;
  gap: .3rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.navbar li { flex: 0 0 auto; }

.navbar ol a {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 44px;
  padding: .3rem .6rem;
  font-size: .92rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  background: var(--white);
  border: 2px solid var(--ink);
}

.navbar ol a .dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  background: var(--ink);
}

.navbar ol a:hover,
.navbar ol a:focus-visible {
  background: var(--blue);
  box-shadow: 2px 2px 0 var(--ink);
  transform: translate(-1px, -1px);
}

/* ---------- reveal ---------- */
.js .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .55s ease, transform .55s ease;
}

.js .reveal.is-in {
  opacity: 1;
  transform: none;
}

/* ---------- breakpoints ---------- */
@media (min-width: 861px) {
  :root { --navh: 76px; }

  body { font-size: 17px; }

  .navbar {
    flex-direction: row;
    align-items: center;
    gap: 0;
    padding: .55rem clamp(.9rem, 2vw, 1.7rem);
  }

  .navbar .brand {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    align-self: auto;
    min-height: 44px;
    font-size: 1.05rem;
  }

  .navbar ol {
    gap: .4rem;
    padding: 0;
    overflow: visible;
  }

  .navbar li:nth-child(5) { margin-left: auto; }

  .navbar ol a { font-size: .98rem; }

  .foot { grid-template-columns: 1.15fr 1fr; align-items: start; }
}

@media (min-width: 1000px) {
  .wrap {
    grid-template-columns: 268px minmax(0, 1fr);
    align-items: start;
  }

  .toc { position: sticky; top: 1.6rem; }
}

@media (max-width: 600px) {
  .hero-title { box-shadow: 5px 5px 0 var(--ink); }
  .prose { border-radius: 20px; box-shadow: 5px 5px 0 var(--ink); }
  .toc { border-radius: 20px; }
  .prose blockquote { padding: .85rem 1rem; }
  .prose table { font-size: .9rem; }
}

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

  .js .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .spin-dot { animation: none; }

  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

button[aria-expanded]{min-width:44px;min-height:44px}
