/* GAP (GX AI Protocol) — gxai.dev
   単一スタイルシート。外部フォント・外部CSSは読まない（配布サイトの寿命を依存で縮めない）。 */

:root {
  color-scheme: dark light;

  --bg: #0a0e13;
  --bg-panel: #111820;
  --bg-inset: #0d131a;
  --border: #1f2a35;
  --border-strong: #2d3b48;

  --text: #e6edf3;
  --text-dim: #9aa8b6;
  --text-faint: #6b7a89;

  --accent: #5eead4;
  --accent-dim: #2b6f66;
  --ok: #56d987;
  --bad: #fb7185;
  --warn: #fbbf24;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;

  --measure: 1080px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fbfcfd;
    --bg-panel: #ffffff;
    --bg-inset: #f3f6f8;
    --border: #dde5ec;
    --border-strong: #c3d0db;
    --text: #10181f;
    --text-dim: #4d5f70;
    --text-faint: #75879a;
    --accent: #0d7d70;
    --accent-dim: #9fded5;
    --ok: #1a8544;
    --bad: #c2334d;
    --warn: #9a6700;
  }
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
  background: var(--bg);
  overflow-wrap: break-word;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

code, pre, .mono { font-family: var(--mono); font-size: .875em; }

code {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .1em .38em;
}

pre {
  margin: 0;
  padding: 1rem 1.15rem;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.65;
}

pre code { background: none; border: 0; padding: 0; font-size: inherit; }

/* ---------- レイアウト ---------- */

.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 1.5rem; }

.section { padding: 4.5rem 0; border-top: 1px solid var(--border); }
.section:first-of-type { border-top: 0; }

.section > .wrap > h2 {
  margin: 0 0 .5rem;
  font-size: clamp(1.35rem, 1rem + 1.4vw, 1.9rem);
  line-height: 1.35;
  letter-spacing: -.01em;
}

.section-kicker {
  margin: 0 0 1.75rem;
  font-family: var(--mono);
  font-size: .75rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}

.lede { margin: 0 0 2rem; font-size: 1.05rem; color: var(--text-dim); max-width: 68ch; }

/* ---------- ヘッダ ---------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.masthead .wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 56px;
  flex-wrap: wrap;
}

.masthead-brand {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--text);
  text-decoration: none;
}

.masthead-brand span { color: var(--text-faint); font-weight: 400; }

.masthead nav {
  margin-left: auto;
  display: flex;
  gap: 1.25rem;
  font-size: .875rem;
  flex-wrap: wrap;
}

.masthead nav a { color: var(--text-dim); text-decoration: none; }
.masthead nav a:hover { color: var(--text); }
.masthead nav a[aria-current="page"] { color: var(--accent); }

/* ---------- ヒーロー ---------- */

.hero { padding: 5rem 0 4rem; }

.hero h1 {
  margin: 0 0 1.25rem;
  font-size: clamp(2.1rem, 1.2rem + 3.6vw, 3.6rem);
  line-height: 1.15;
  letter-spacing: -.025em;
  font-weight: 700;
}

.hero h1 .sub {
  display: block;
  margin-top: .5rem;
  font-size: clamp(.95rem, .8rem + .5vw, 1.15rem);
  font-weight: 400;
  letter-spacing: 0;
  color: var(--text-dim);
  font-family: var(--mono);
}

.principle {
  margin: 2rem 0;
  padding: 1.4rem 1.6rem;
  border-left: 3px solid var(--accent);
  background: var(--bg-panel);
  border-radius: 0 8px 8px 0;
  font-size: clamp(1.05rem, .95rem + .5vw, 1.3rem);
  line-height: 1.7;
  font-weight: 600;
}

.badges { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.75rem 0 0; padding: 0; list-style: none; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .7rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--text-dim);
  background: var(--bg-panel);
}

.badge b { color: var(--text); font-weight: 600; }
.badge.is-draft { border-color: var(--accent-dim); color: var(--accent); }

.cta { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2.25rem; }

.button {
  display: inline-block;
  padding: .7rem 1.3rem;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  color: var(--text);
  background: var(--bg-panel);
  text-decoration: none;
  font-size: .925rem;
  font-weight: 600;
}

.button:hover { border-color: var(--accent); color: var(--accent); }
.button.is-primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.button.is-primary:hover { filter: brightness(1.12); color: var(--bg); }

/* ---------- パイプライン図 ---------- */

.pipeline { margin: 0 0 2rem; }
.pipeline:last-child { margin-bottom: 0; }

.pipeline-label {
  margin: 0 0 .75rem;
  font-family: var(--mono);
  font-size: .78rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.pipeline-flow {
  display: flex;
  align-items: stretch;
  gap: .4rem;
  overflow-x: auto;
  padding-bottom: .5rem;
}

.pipeline-step {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: .6rem .9rem;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--bg-panel);
  font-size: .82rem;
  line-height: 1.45;
  white-space: nowrap;
}

.pipeline-step.is-bad { border-color: var(--bad); color: var(--bad); }
.pipeline-step.is-good { border-color: var(--accent); color: var(--accent); }
.pipeline-step.is-terminal { font-weight: 600; }

.pipeline-arrow {
  flex: 0 0 auto;
  align-self: center;
  color: var(--text-faint);
  font-family: var(--mono);
}

/* ---------- 汎用グリッド・カード ---------- */

.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.card {
  padding: 1.4rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-panel);
}

.card h3 {
  margin: 0 0 .6rem;
  font-size: 1.02rem;
  letter-spacing: -.005em;
}

.card h3 .tag {
  display: block;
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .35rem;
  font-weight: 400;
}

.card p { margin: 0; color: var(--text-dim); font-size: .925rem; line-height: 1.75; }
.card p + p { margin-top: .75rem; }

/* ---------- accept / reject 対比 ---------- */

.verdict { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg-panel); }

.verdict-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: .8rem;
  font-weight: 600;
}

.verdict.is-ok .verdict-head { color: var(--ok); }
.verdict.is-bad .verdict-head { color: var(--bad); }

.verdict pre { border: 0; border-radius: 0; background: var(--bg-inset); }

.verdict-note {
  margin: 0;
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
  font-size: .85rem;
  color: var(--text-dim);
}

/* ---------- 表 ---------- */

.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--bg-panel); }

th, td { padding: .7rem 1rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }

thead th {
  font-family: var(--mono);
  font-size: .75rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 600;
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: 0; }
td code, th code { white-space: nowrap; }

/* ---------- 証拠表 ---------- */

.evidence td { font-size: .875rem; line-height: 1.7; }
.evidence td:first-child { white-space: nowrap; }
.evidence th:last-child, .evidence td:last-child { min-width: 12rem; }

.metric {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--text);
  font-size: .95em;
  white-space: nowrap;
}

.cite {
  font-family: var(--mono);
  font-size: .8em;
  color: var(--accent);
  white-space: nowrap;
}

.verdict-tag {
  display: inline-block;
  margin-right: .5rem;
  padding: .1rem .55rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  font-family: var(--mono);
  font-size: .72rem;
  white-space: nowrap;
}

.verdict-tag.is-limited { border-color: var(--accent-dim); color: var(--accent); }
.verdict-tag.is-partial { border-color: var(--warn); color: var(--warn); }
.verdict-tag.is-out { color: var(--text-faint); }

@media (max-width: 640px) {
  .evidence td:first-child { white-space: normal; }
}

/* ---------- リスト ---------- */

.plain-list { margin: 0; padding-left: 1.15rem; color: var(--text-dim); }
.plain-list li { margin-bottom: .6rem; }
.plain-list li:last-child { margin-bottom: 0; }
.plain-list b, .plain-list strong { color: var(--text); }

/* ---------- 注意ブロック ---------- */

.note {
  padding: 1.15rem 1.35rem;
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--warn);
  border-radius: 0 8px 8px 0;
  background: var(--bg-panel);
  font-size: .92rem;
  color: var(--text-dim);
}

.note.is-neutral { border-left-color: var(--border-strong); }
.note b { color: var(--text); }
.note > :first-child { margin-top: 0; }
.note > :last-child { margin-bottom: 0; }

/* ---------- フッタ ---------- */

.footer { padding: 3rem 0 4rem; border-top: 1px solid var(--border); color: var(--text-faint); font-size: .85rem; }
.footer a { color: var(--text-dim); }
.footer-cols { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 2rem; }
.footer h4 { margin: 0 0 .6rem; font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-dim); font-family: var(--mono); }
.footer ul { margin: 0; padding: 0; list-style: none; }
.footer li { margin-bottom: .4rem; }

/* ---------- 仕様書ページ ---------- */

.doc-layout { display: grid; gap: 3rem; grid-template-columns: minmax(0, 1fr); padding: 3rem 0 5rem; }

@media (min-width: 1000px) {
  .doc-layout { grid-template-columns: 232px minmax(0, 1fr); gap: 3.5rem; }
  .toc { position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 96px); overflow-y: auto; }
}

.toc { font-size: .85rem; }
.toc h2 { margin: 0 0 .8rem; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint); font-family: var(--mono); }
.toc ol { margin: 0; padding: 0; list-style: none; }
.toc li { margin-bottom: .5rem; }
.toc a { color: var(--text-dim); text-decoration: none; display: block; }
.toc a:hover { color: var(--accent); }

.doc h1 { margin: 0 0 .6rem; font-size: clamp(1.7rem, 1.2rem + 2vw, 2.4rem); line-height: 1.25; letter-spacing: -.02em; }
.doc h2 { margin: 3.25rem 0 1rem; padding-top: 1.5rem; border-top: 1px solid var(--border); font-size: 1.35rem; line-height: 1.4; letter-spacing: -.01em; scroll-margin-top: 72px; }
.doc h3 { margin: 2.25rem 0 .75rem; font-size: 1.05rem; scroll-margin-top: 72px; }
.doc h4 { margin: 1.75rem 0 .5rem; font-size: .95rem; color: var(--text-dim); }
.doc p { margin: 0 0 1.15rem; }
.doc ul, .doc ol { margin: 0 0 1.25rem; padding-left: 1.3rem; }
.doc li { margin-bottom: .55rem; }
.doc li > ul, .doc li > ol { margin-top: .55rem; }
.doc pre { margin: 0 0 1.35rem; }
.doc .table-scroll { margin: 0 0 1.35rem; }
.doc blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.35rem;
  border-left: 3px solid var(--accent);
  background: var(--bg-panel);
  border-radius: 0 8px 8px 0;
  font-weight: 600;
}
.doc blockquote p:last-child { margin-bottom: 0; }

.doc-meta {
  margin: 0 0 2.5rem;
  padding: 1.1rem 1.35rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-panel);
  font-size: .875rem;
  color: var(--text-dim);
}

.doc-meta dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .4rem 1.25rem; margin: 0; }
.doc-meta dt { font-family: var(--mono); font-size: .78rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; }
.doc-meta dd { margin: 0; }

.anchor { color: var(--text-faint); text-decoration: none; font-weight: 400; opacity: 0; padding-left: .4rem; }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }

/* ---------- 404 ---------- */

.stub { min-height: 70vh; display: flex; align-items: center; }
.stub h1 { font-size: clamp(1.6rem, 1.2rem + 2vw, 2.2rem); margin: 0 0 1rem; }

/* ---------- ユーティリティ ---------- */

.stack > * + * { margin-top: 1.25rem; }
.muted { color: var(--text-dim); }
.nowrap { white-space: nowrap; }
.hash { font-family: var(--mono); font-size: .78rem; color: var(--accent); word-break: break-all; }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 1rem; top: .5rem; padding: .5rem .9rem; background: var(--accent); color: var(--bg); border-radius: 6px; z-index: 20; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
