:root {
  --bg: #fbfbfa;
  --ink: #171717;
  --muted: #666;
  --line: #deded9;
  --panel: #fff;
  --accent: #7d1515;
  --accent-soft: #faf6f5;
  --max: 1120px;
}

* {
  box-sizing: border-box;
}

html {
  max-width: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
  -webkit-text-size-adjust: 100%;
}

article [id] {
  scroll-margin-top: 96px;
}

body {
  margin: 0;
  max-width: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Noto Sans", Arial, sans-serif;
  line-height: 1.68;
}

a {
  color: #641111;
  overflow-wrap: break-word;
  text-underline-offset: 0.18em;
}

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

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

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-160%);
}

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

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 18px;
  align-items: center;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 12px max(18px, calc((100vw - var(--max)) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(251, 251, 250, 0.94);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.025);
  backdrop-filter: blur(12px);
}

.top > * {
  min-width: 0;
}

.brand {
  color: var(--ink);
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  text-decoration: none;
}

.top > span,
.author-mark {
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.author-mark {
  text-decoration: none;
}

.author-mark:hover {
  color: var(--accent);
}

.top nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  margin-inline-start: auto;
}

.top nav a {
  position: relative;
  flex: 0 0 auto;
  padding: 7px 0;
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.2;
  text-decoration: none;
}

.top nav a:hover,
.top nav a.current,
.top nav a[aria-current="page"],
.top nav a[aria-current="location"] {
  color: var(--accent);
}

.top nav a.current,
.top nav a[aria-current="page"],
.top nav a[aria-current="location"] {
  font-weight: 800;
}

.top nav a.nav-featured {
  padding: 7px 11px;
  border: 1px solid rgba(125, 21, 21, 0.24);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 850;
}

.top nav a.nav-featured:hover,
.top nav a.nav-featured[aria-current="page"],
.top nav a.nav-featured[aria-current="location"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.top nav a[aria-current="page"]::after,
.top nav a[aria-current="location"]::after {
  position: absolute;
  right: 0;
  bottom: 2px;
  left: 0;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  content: "";
}

.lang-switch,
.header-lang-switch {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 36px;
  padding: 6px 10px !important;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--accent) !important;
  font-size: 0.78rem !important;
  font-weight: 850;
  line-height: 1;
  text-decoration: none;
}

.lang-switch:hover,
.header-lang-switch:hover {
  border-color: rgba(125, 21, 21, 0.38);
  background: var(--accent-soft);
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
}

.language-menu {
  position: relative;
  flex: 0 0 auto;
}

.language-menu summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1;
  list-style: none;
  cursor: pointer;
}

.language-menu summary::-webkit-details-marker {
  display: none;
}

.language-menu summary::before {
  margin-inline-end: 0.4em;
  content: "文";
  color: var(--accent);
}

.language-menu[open] summary,
.language-menu summary:hover {
  border-color: rgba(125, 21, 21, 0.5);
  background: var(--accent-soft);
}

.language-menu-panel {
  position: absolute;
  top: calc(100% + 9px);
  inset-inline-end: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  width: min(440px, calc(100vw - 28px));
  max-height: min(72vh, 620px);
  padding: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.16);
}

.language-menu-panel a {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 48px;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--ink);
  line-height: 1.2;
  text-decoration: none;
}

.language-menu-panel a:hover,
.language-menu-panel a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.language-menu-panel small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.67rem;
}

.language-menu-title {
  grid-column: 1 / -1;
  margin: 7px 7px 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.language-scope-link {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  font-weight: 800;
}

main {
  width: 100%;
  max-width: var(--max);
  min-width: 0;
  margin: auto;
  padding: 44px 22px 80px;
}

article {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: clamp(22px, 5vw, 58px);
  overflow-wrap: break-word;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.035);
}

article > *,
article section {
  max-width: 100%;
  min-width: 0;
}

.author-spotlight,
.author-hero {
  margin-top: 2.5rem;
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid rgba(125, 21, 21, 0.24);
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent-soft), #fff 68%);
}

.author-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: clamp(20px, 4vw, 42px);
  align-items: center;
  margin-top: 0;
}

.author-monogram {
  display: grid;
  width: clamp(100px, 17vw, 168px);
  aspect-ratio: 1;
  place-items: center;
  border-radius: 28px;
  background: var(--ink);
  color: #fff;
  font-size: clamp(1.7rem, 4vw, 3rem);
  font-weight: 950;
  letter-spacing: -0.08em;
}

.author-hero h1,
.author-spotlight h2 {
  margin-top: 0.15em;
}

.author-lead {
  font-size: clamp(1.05rem, 2vw, 1.3rem);
}

.eyebrow {
  margin-bottom: 0;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.primary-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  padding: 8px 13px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 850;
  text-decoration: none;
}

.primary-link:hover {
  background: #5f0f0f;
  color: #fff;
}

.identity-grid,
.language-grid,
.topic-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 1.25rem 0 2rem;
  padding: 0;
  list-style: none;
}

.home-directory {
  margin: 2.5rem 0;
}

.home-directory-intro {
  max-width: 72ch;
}

.home-directory-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
}

.home-directory-grid li {
  min-width: 0;
}

.home-directory-grid a {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  gap: 5px;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
}

.home-directory-grid a:hover {
  border-color: rgba(125, 21, 21, 0.36);
  background: var(--accent-soft);
}

.home-directory-grid strong {
  color: var(--accent);
  font-size: 1rem;
}

.home-directory-grid span {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.home-directory-grid .novel-entry {
  grid-column: span 2;
}

.home-directory-grid .novel-entry a {
  border-color: rgba(125, 21, 21, 0.34);
  background: linear-gradient(135deg, #fff 0%, var(--accent-soft) 100%);
  box-shadow: 0 14px 34px rgba(125, 21, 21, 0.08);
}

.system-snapshot {
  margin: 2.5rem 0;
}

.snapshot-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.snapshot-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f7f7f4;
}

.snapshot-card strong {
  display: block;
  color: var(--accent);
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1;
}

.snapshot-card span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.identity-grid section,
.language-grid li,
.topic-grid section {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.identity-grid h2 {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topic-entry-points {
  margin: 2.5rem 0;
}

.topic-grid h3 {
  margin-top: 0;
}

.identity-grid p {
  margin-bottom: 0;
  font-size: 1.08rem;
  font-weight: 850;
}

.language-grid li {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.language-grid a {
  font-size: 1.05rem;
  font-weight: 850;
}

.language-grid small {
  color: var(--muted);
}

.status-badge {
  align-self: flex-start;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f1f1ed;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
}

.status-ready {
  background: #e8f5ec;
  color: #175d32;
}

.status-core {
  background: #eaf0fb;
  color: #234f91;
}

.status-draft {
  background: #fff2d6;
  color: #7b4a00;
}

h1 {
  margin: 0.2em 0 0.6em;
  font-size: clamp(2.2rem, 6vw, 5rem);
  letter-spacing: -0.055em;
  line-height: 0.95;
  overflow-wrap: break-word;
}

h2 {
  margin-top: 2.2em;
  padding-top: 0.8em;
  border-top: 1px solid var(--line);
  font-size: clamp(1.45rem, 3vw, 2.3rem);
  letter-spacing: -0.025em;
  line-height: 1.15;
  overflow-wrap: break-word;
}

h3 {
  margin-top: 1.7em;
  font-size: 1.15rem;
  overflow-wrap: break-word;
}

p,
li {
  max-width: 82ch;
}

blockquote {
  max-width: 100%;
  min-width: 0;
  margin: 1.8em 0;
  padding: 1em 1.3em;
  border-left: 4px solid var(--accent);
  border-radius: 0 12px 12px 0;
  background: var(--accent-soft);
}

code {
  padding: 0.15em 0.35em;
  border-radius: 5px;
  background: #f2f2ef;
  font-family: "SFMono-Regular", Consolas, monospace;
}

:not(pre) > code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

pre {
  display: block;
  max-width: 100%;
  min-width: 0;
  padding: 18px;
  overflow-x: auto;
  border-radius: 12px;
  background: #161616;
  color: #eee;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  max-width: 100%;
  margin: 1.5em 0;
  border-collapse: collapse;
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  margin: 1.5em 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-inline: contain;
}

.table-scroll table {
  min-width: 620px;
  margin: 0;
}

th,
td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: break-word;
  word-break: normal;
}

th {
  background: #f7f7f4;
  font-size: 0.82rem;
  letter-spacing: 0.025em;
}

tr:last-child td {
  border-bottom: 0;
}

img,
video,
svg,
canvas,
iframe {
  max-width: 100%;
  height: auto;
}

.claim-grid {
  display: grid;
  gap: 16px;
  min-width: 0;
  max-width: 100%;
}

.claim {
  min-width: 0;
  max-width: 100%;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.claim h2 {
  margin: 0.7em 0;
  padding: 0;
  border: 0;
}

.claim-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.claim-meta span {
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--muted);
  font-size: 0.78rem;
}

.comments,
.comments-off {
  max-width: 100%;
  min-width: 0;
  margin-top: 36px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}

footer {
  width: 100%;
  max-width: var(--max);
  min-width: 0;
  margin: auto;
  padding: 0 22px 50px;
  color: var(--muted);
}

.callout {
  max-width: 100%;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f7f7f4;
}

.status {
  color: var(--accent);
  font-weight: 700;
}

@media (max-width: 900px) {
  .top {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto auto;
    gap: 8px;
    align-items: center;
    padding: 10px max(14px, env(safe-area-inset-right)) 10px
      max(14px, env(safe-area-inset-left));
  }

  .brand {
    grid-row: 1;
    grid-column: 1;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
  }

  .top > span,
  .author-mark {
    display: none;
  }

  .header-lang-switch {
    grid-row: 1;
    grid-column: 3;
    min-width: 44px;
    min-height: 42px;
  }

  .language-menu {
    position: static;
    grid-row: 1;
    grid-column: 4;
  }

  .language-menu-panel {
    top: calc(100% + 1px);
    inset-inline-start: max(10px, env(safe-area-inset-left));
    inset-inline-end: max(10px, env(safe-area-inset-right));
    width: auto;
    max-height: calc(100dvh - 76px);
  }

  .nav-toggle {
    display: inline-flex;
    grid-row: 1;
    grid-column: 5;
  }

  .top nav {
    grid-row: 2;
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding-top: 6px;
  }

  .top:not(.nav-ready) nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
  }

  .top:not(.nav-ready) nav::-webkit-scrollbar {
    display: none;
  }

  .top.nav-ready nav {
    display: none;
  }

  .top.nav-ready nav.is-open {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    max-height: calc(100dvh - 72px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .top.nav-ready nav a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 9px 11px;
    border-radius: 10px;
    white-space: normal;
  }

  .top.nav-ready nav a:hover,
  .top.nav-ready nav a[aria-current="page"],
  .top.nav-ready nav a[aria-current="location"] {
    background: var(--accent-soft);
  }

  .top.nav-ready nav a[aria-current="page"]::after,
  .top.nav-ready nav a[aria-current="location"]::after {
    display: none;
  }

  main {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 18px max(10px, env(safe-area-inset-right)) 60px
      max(10px, env(safe-area-inset-left));
  }

  article {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 22px 17px;
    border-radius: 16px;
  }

  .author-hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .identity-grid,
  .language-grid,
  .topic-grid,
  .home-directory-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .home-directory-grid .novel-entry {
    grid-column: auto;
  }

  .snapshot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  h1 {
    font-size: clamp(2rem, 10vw, 2.65rem);
    line-height: 1.02;
  }

  h2 {
    font-size: clamp(1.4rem, 6.4vw, 1.85rem);
    line-height: 1.18;
  }

  blockquote {
    margin-right: 0;
    margin-left: 0;
    padding-right: 1em;
    padding-left: 1em;
  }

  .table-scroll {
    margin: 1.25em 0;
    border-radius: 12px;
  }

  .shift-table,
  .shift-table tbody {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .table-scroll--stacked {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .table-scroll--stacked .shift-table {
    min-width: 0;
  }

  .shift-table tbody {
    display: grid;
    gap: 10px;
  }

  .shift-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
  }

  .shift-table tr:first-child {
    display: none;
  }

  .shift-table th,
  .shift-table td,
  .shift-table td:first-child {
    display: block;
    width: 100%;
    min-width: 0;
    padding: 11px 13px;
    border: 0;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
  }

  .shift-table td:first-child {
    background: #f7f7f4;
    color: var(--ink);
    font-size: 0.92rem;
    font-weight: 800;
  }

  .shift-table td:last-child {
    border-top: 1px solid var(--line);
  }

  .shift-table td:last-child::before {
    margin-right: 0.5em;
    color: var(--accent);
    content: "→";
    font-weight: 900;
  }

  footer {
    max-width: 100%;
    padding-right: max(12px, env(safe-area-inset-right));
    padding-left: max(12px, env(safe-area-inset-left));
  }
}

@media (max-width: 390px) {
  .top.nav-ready nav.is-open {
    grid-template-columns: minmax(0, 1fr);
  }

  .language-menu summary {
    width: 44px;
    padding-inline: 0;
    font-size: 0;
  }

  .language-menu summary::before {
    margin: 0;
    font-size: 0.9rem;
    content: "文+";
  }

  .language-menu-panel {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (pointer: coarse) and (min-width: 901px) {
  .top nav a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}

@media (forced-colors: active) {
  :focus-visible {
    outline: 3px solid CanvasText;
  }
}

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