/* =========================================================
   Document Template — Shared Styles
   ミニマル・モノクロ + ブルーアクセント / GitBook風レイアウト
   ========================================================= */

:root {
  /* Palette */
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --bg-code: #f6f6f5;
  --fg: #1a1a1a;
  --fg-muted: #5b6068;
  --fg-faint: #8a8f97;
  --border: #e7e7e5;
  --border-strong: #d4d4d2;
  --accent: #2563eb;
  --accent-soft: #eff4ff;

  /* Callout tints */
  --info-bg: #eff4ff;
  --info-bd: #c5d5ff;
  --warn-bg: #fff8e6;
  --warn-bd: #f0d68a;
  --danger-bg: #fdecec;
  --danger-bd: #f1bcbc;
  --ok-bg: #ecf6ee;
  --ok-bd: #b8dcbf;

  /* Typography */
  --font-sans:
    "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Helvetica Neue",
    "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  --font-mono:
    "JetBrains Mono", "SF Mono", Menlo, Consolas, "Roboto Mono",
    "Noto Sans Mono CJK JP", monospace;

  /* Layout */
  --sidebar-w: 280px;
  --toc-w: 220px;
  --content-w: 760px;
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.8;
  font-feature-settings: "palt" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 120ms ease;
}
a:hover {
  border-bottom-color: var(--accent);
}

::selection {
  background: var(--accent-soft);
  color: var(--fg);
}

/* =========================================================
   Layout shell — sidebar + main
   ========================================================= */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--bg-subtle);
  padding: 28px 22px 40px;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar__brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  background: var(--fg);
  color: var(--bg);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.sidebar__brand-text {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.01em;
}
.sidebar__brand-sub {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--fg-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar__section {
  margin-top: 24px;
}
.sidebar__section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-faint);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 8px 0;
  padding: 0 6px;
}
.sidebar__nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sidebar__nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--fg-muted);
  border: none;
}
.sidebar__nav a:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--fg);
}
.sidebar__nav a.is-active {
  background: var(--bg);
  color: var(--fg);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--border);
}
.sidebar__nav-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-faint);
  font-weight: 400;
}

/* ---------- Main ---------- */

.main {
  min-width: 0;
  display: flex;
  justify-content: center;
  padding: 56px 56px 120px;
}
.main__inner {
  width: 100%;
  max-width: var(--content-w);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}
.main--with-toc .main__inner {
  max-width: calc(var(--content-w) + var(--toc-w) + 60px);
  grid-template-columns: minmax(0, 1fr) var(--toc-w);
  gap: 60px;
}

/* =========================================================
   Document header
   ========================================================= */

.doc-header {
  margin-bottom: 40px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.doc-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 14px;
}
.doc-eyebrow::before {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--fg-faint);
}
.doc-title {
  font-size: 34px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 12px 0;
  text-wrap: pretty;
}
.doc-summary {
  font-size: 16px;
  line-height: 1.75;
  color: var(--fg-muted);
  margin: 0 0 24px 0;
  text-wrap: pretty;
}
.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 24px 32px;
  font-size: 12.5px;
  color: var(--fg-muted);
}
.doc-meta__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.doc-meta__label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.doc-meta__value {
  color: var(--fg);
}
.doc-meta__value--mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

/* =========================================================
   Prose — headings, paragraphs, lists, code, blockquote
   ========================================================= */

.prose {
  color: var(--fg);
}
.prose > * + * {
  margin-top: 1em;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  font-weight: 700;
  letter-spacing: -0.005em;
  text-wrap: balance;
  scroll-margin-top: 24px;
}
.prose h1 {
  font-size: 28px;
  line-height: 1.4;
  margin-top: 2em;
}
.prose h2 {
  font-size: 22px;
  line-height: 1.45;
  margin-top: 2.4em;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.prose h3 {
  font-size: 17.5px;
  line-height: 1.5;
  margin-top: 1.8em;
}
.prose h4 {
  font-size: 14px;
  line-height: 1.55;
  margin-top: 1.6em;
  color: var(--fg-muted);
}

.prose p {
  margin: 0;
}
.prose strong {
  font-weight: 700;
}
.prose em {
  font-style: normal;
  background: linear-gradient(transparent 65%, var(--accent-soft) 65%);
  padding: 0 2px;
}

.prose ul,
.prose ol {
  margin: 0;
  padding-left: 1.4em;
}
.prose ul {
  list-style: none;
}
.prose ul > li {
  position: relative;
  padding-left: 4px;
}
.prose ul > li::before {
  content: "";
  position: absolute;
  left: -1em;
  top: 0.75em;
  width: 5px;
  height: 5px;
  background: var(--fg-faint);
  border-radius: 50%;
}
.prose ol > li::marker {
  color: var(--fg-faint);
  font-family: var(--font-mono);
  font-size: 0.9em;
}
.prose li + li {
  margin-top: 6px;
}
.prose li > ul,
.prose li > ol {
  margin-top: 6px;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--fg);
}
.prose pre {
  margin: 1.4em 0;
  padding: 0;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.prose pre > .code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.025);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
  letter-spacing: 0.04em;
}
.prose pre > code,
.prose pre > .code-body {
  display: block;
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  background: none;
  border: none;
  border-radius: 0;
  color: var(--fg);
}
.prose pre .tk-c {
  color: #8a8f97;
  font-style: italic;
}
.prose pre .tk-k {
  color: #7c3aed;
}
.prose pre .tk-s {
  color: #047857;
}
.prose pre .tk-n {
  color: #b45309;
}
.prose pre .tk-f {
  color: #2563eb;
}

.prose blockquote {
  margin: 1.4em 0;
  padding: 4px 0 4px 18px;
  border-left: 2px solid var(--border-strong);
  color: var(--fg-muted);
}
.prose blockquote p + p {
  margin-top: 0.8em;
}

/* =========================================================
   Tables
   ========================================================= */

.prose .table-wrap {
  margin: 1.6em 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.prose th,
.prose td {
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.prose th {
  background: var(--bg-subtle);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
}
.prose tr:last-child td {
  border-bottom: none;
}
.prose td code {
  font-size: 12.5px;
}

/* =========================================================
   Callouts
   ========================================================= */

.callout {
  margin: 1.6em 0;
  padding: 14px 16px 14px 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  position: relative;
  font-size: 14px;
  line-height: 1.75;
  color: var(--fg);
}
.callout::before {
  content: "i";
  position: absolute;
  left: 14px;
  top: 14px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  background: var(--fg);
  color: var(--bg);
}
.callout > .callout__title {
  display: block;
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.callout > p {
  margin: 0;
}
.callout > * + * {
  margin-top: 6px;
}

.callout--info {
  background: var(--info-bg);
  border-color: var(--info-bd);
}
.callout--info::before {
  background: #2563eb;
  content: "i";
}
.callout--warn {
  background: var(--warn-bg);
  border-color: var(--warn-bd);
}
.callout--warn::before {
  background: #b45309;
  content: "!";
}
.callout--danger {
  background: var(--danger-bg);
  border-color: var(--danger-bd);
}
.callout--danger::before {
  background: #b91c1c;
  content: "×";
  font-size: 13px;
}
.callout--ok {
  background: var(--ok-bg);
  border-color: var(--ok-bd);
}
.callout--ok::before {
  background: #047857;
  content: "✓";
  font-size: 11px;
}

/* =========================================================
   Figure
   ========================================================= */

.figure {
  margin: 1.8em 0;
}
.figure__media {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: repeating-linear-gradient(
    135deg,
    var(--bg-subtle) 0 8px,
    var(--bg) 8px 16px
  );
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  color: var(--fg-faint);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-align: center;
  padding: 24px;
}
.figure__media-label {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 4px;
}
.figure__caption {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 12.5px;
  color: var(--fg-muted);
  line-height: 1.6;
}
.figure__caption-num {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--fg-faint);
  text-transform: uppercase;
  white-space: nowrap;
}

/* =========================================================
   Footnotes
   ========================================================= */

.prose .fn-ref {
  font-family: var(--font-mono);
  font-size: 0.7em;
  vertical-align: super;
  color: var(--accent);
  margin: 0 1px 0 2px;
  border: none;
}
.prose .fn-ref:hover {
  text-decoration: underline;
}

.footnotes {
  margin-top: 64px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--fg-muted);
}
.footnotes__title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin: 0 0 12px 0;
}
.footnotes ol {
  margin: 0;
  padding-left: 1.6em;
}
.footnotes li {
  margin-top: 6px;
  line-height: 1.7;
}
.footnotes li::marker {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-faint);
}

/* =========================================================
   In-page TOC (right rail)
   ========================================================= */

.toc {
  position: sticky;
  top: 56px;
  align-self: start;
  padding: 4px 0 0 16px;
  border-left: 1px solid var(--border);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}
.toc__title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin: 0 0 10px 0;
  font-weight: 600;
}
.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.toc a {
  display: block;
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1.55;
  padding: 2px 0;
  border: none;
}
.toc a:hover {
  color: var(--fg);
}
.toc .toc--h3 {
  padding-left: 12px;
  font-size: 12.5px;
}
.toc .toc--h4 {
  padding-left: 24px;
  font-size: 12.5px;
  color: var(--fg-faint);
}

/* =========================================================
   Design catalog — component showcase blocks
   ========================================================= */

.catalog-section {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.catalog-section:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.catalog-section__head {
  margin-bottom: 24px;
}
.catalog-section__eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin: 0 0 6px 0;
  font-weight: 600;
}
.catalog-section__title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.005em;
  margin: 0 0 6px 0;
  line-height: 1.4;
}
.catalog-section__desc {
  font-size: 13.5px;
  color: var(--fg-muted);
  margin: 0;
  line-height: 1.7;
}

.specimen {
  margin-top: 22px;
}
.specimen + .specimen {
  margin-top: 28px;
}

.specimen__label {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin: 0 0 10px 0;
  font-weight: 600;
}
.specimen__label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.specimen__note {
  font-size: 12.5px;
  color: var(--fg-muted);
  margin: 8px 0 0 0;
  line-height: 1.7;
}
.specimen__note code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
}

.specimen__frame {
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.specimen__frame > *:first-child {
  margin-top: 0;
}
.specimen__frame > *:last-child {
  margin-bottom: 0;
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.swatch {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
}
.swatch__chip {
  height: 56px;
  border-bottom: 1px solid var(--border);
}
.swatch__meta {
  padding: 8px 10px;
  background: var(--bg);
}
.swatch__name {
  color: var(--fg);
  font-weight: 600;
}
.swatch__val {
  color: var(--fg-faint);
}

.type-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 18px;
  align-items: baseline;
  padding: 14px 0;
  border-bottom: 1px dashed var(--border);
}
.type-row:last-child {
  border-bottom: none;
}
.type-row__tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-faint);
  letter-spacing: 0.04em;
}
.type-row__demo {
  color: var(--fg);
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1100px) {
  .main--with-toc .main__inner {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    max-width: var(--content-w);
  }
  .toc {
    display: none;
  }
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .main {
    padding: 32px 22px 80px;
  }
  .doc-title {
    font-size: 28px;
  }
}
