/* CompatRigs — データ重視 + 少しポップ + 少し未来的(設計書 15章) */

:root {
  --bg: #f6f8fb;
  --bg-grid: rgba(40, 90, 160, 0.06);
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --text: #16202e;
  --muted: #5c6b80;
  --line: #d9e1ec;
  --accent: #0a8fb0;      /* シアン: 未来的な線や数字 */
  --accent-2: #7b5cff;    /* バイオレット: ポップな差し色 */
  --accent-ink: #ffffff;
  --works: #1f9d55;
  --tweak: #2f6fdb;
  --unstable: #c98a00;
  --fails: #d23c3c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 50, 0.06), 0 4px 16px rgba(20, 30, 50, 0.05);
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", "Consolas", "Menlo", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1220;
    --bg-grid: rgba(80, 200, 255, 0.05);
    --surface: #131b2c;
    --surface-2: #1a2438;
    --text: #e6edf7;
    --muted: #93a2ba;
    --line: #26324a;
    --accent: #3cc8ea;
    --accent-2: #9d86ff;
    --accent-ink: #061018;
    --works: #3fcf7f;
    --tweak: #6a9cff;
    --unstable: #f2b632;
    --fails: #ff6b6b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background-color: var(--bg);
  /* 基板の方眼のような薄いグリッド */
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 28px 28px;
  line-height: 1.65;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); }
code { font-size: 0.88em; background: var(--surface-2); padding: 0.05em 0.4em; border-radius: 6px; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); line-height: 1.25; margin: 1.2rem 0 0.8rem; }
h2 { font-size: 1.2rem; margin: 2rem 0 0.8rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 0.5rem; }
h4 { font-size: 0.9rem; margin: 1rem 0 0.3rem; color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-bottom: 3rem; min-height: 60vh; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.num { text-align: right; white-space: nowrap; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.lead { font-size: 1.05rem; color: var(--muted); max-width: 46em; }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.scroll { overflow-x: auto; }

/* ---------- ヘッダー・フッター ---------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: 58px; }
.logo { font-weight: 800; font-size: 1.2rem; color: var(--text); letter-spacing: 0.01em; display: flex; align-items: center; gap: 0.45rem; }
.logo:hover { text-decoration: none; }
.logo span, h1 span { color: var(--accent-2); }
.logo-mark {
  width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.nav { display: flex; align-items: center; gap: 1rem; font-size: 0.92rem; }
.nav a:not(.btn) { color: var(--text); white-space: nowrap; }
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 1.2rem 0; }
.langs { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.9rem; }

@media (max-width: 640px) {
  .nav a:not(.btn) { display: none; }
  .nav a[href$="/combo"] { display: inline; }
}

/* ---------- ボタン・入力 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; flex: none;
  border: 0; cursor: pointer; font: inherit; font-weight: 700;
  color: var(--accent-ink); background: linear-gradient(135deg, var(--accent), var(--accent-2));
  padding: 0.55rem 1.1rem; border-radius: 999px;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent-2) 30%, transparent);
}
.btn:hover { text-decoration: none; filter: brightness(1.06); }
.btn:disabled { opacity: 0.5; cursor: wait; }
.btn-small { padding: 0.35rem 0.9rem; font-size: 0.88rem; }
.btn-big { padding: 0.8rem 1.8rem; font-size: 1.05rem; }
.btn-ghost { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.btn-danger { background: var(--fails); box-shadow: none; color: #fff; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 0.5rem 0.7rem; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
label { display: block; font-size: 0.9rem; font-weight: 600; margin: 0.6rem 0; }
label > input, label > select, label > textarea { margin-top: 0.25rem; font-weight: 400; }
label.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
label.check input { width: auto; }
.form-error { color: var(--fails); font-weight: 700; }
.form-msg { font-weight: 700; color: var(--accent); }

/* ---------- カード・バッジ ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.2rem; box-shadow: var(--shadow); position: relative;
}
section.card { margin: 1rem 0; }
.cols { display: grid; grid-template-columns: 3fr 2fr; gap: 1rem; }
.cols > .card { margin: 0; }
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } }

.ico { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem; white-space: nowrap;
  font-size: 0.82rem; font-weight: 700; padding: 0.12rem 0.6rem; border-radius: 999px;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
}
.r-works { --c: var(--works); }
.r-works_with_tweak { --c: var(--tweak); }
.r-unstable { --c: var(--unstable); }
.r-fails { --c: var(--fails); }
.chip { font-size: 0.78rem; padding: 0.1rem 0.55rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.maker { color: var(--muted); font-weight: 500; }
.rid { font-family: var(--mono); font-size: 0.85em; }
.log-label { font-size: 0.82rem; font-weight: 700; color: var(--muted); }

/* ---------- トップ ---------- */
.hero { padding: 2rem 0 0.5rem; }
.hero h1 { font-size: clamp(2.2rem, 7vw, 3.4rem); margin: 0.2rem 0 0.5rem; letter-spacing: -0.01em; }
.eyebrow { color: var(--accent); font-size: 0.85rem; margin: 0; }
.search-big { display: flex; gap: 0.5rem; max-width: 640px; margin: 1.2rem 0; }
.search-big input { border-radius: 999px; padding: 0.7rem 1.1rem; }
.stats { display: flex; gap: 1.5rem; flex-wrap: wrap; color: var(--muted); font-size: 0.9rem; }
.stats b { color: var(--accent); font-size: 1.3rem; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.7rem; }
.cat { display: flex; justify-content: space-between; align-items: center; color: var(--text); font-weight: 600; }
.cat:hover { text-decoration: none; border-color: var(--accent); }

/* ---------- 報告 ---------- */
.report-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0.8rem; margin: 0.8rem 0; }
.report-card header { display: flex; justify-content: space-between; align-items: baseline; }
.meta { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0.4rem 0; }
.items { list-style: none; padding: 0; margin: 0.5rem 0; display: grid; gap: 0.3rem; }
.items li { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: baseline; padding: 0.25rem 0.5rem; border-left: 3px solid var(--line); }
.items li.hl { border-left-color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 7%, transparent); border-radius: 0 8px 8px 0; }
.role { font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase; color: var(--accent); min-width: 6.5em; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); }
.sources { border-top: 1px dashed var(--line); margin-top: 1rem; }
.sources ul { margin: 0.2rem 0; padding-left: 1.2rem; font-size: 0.9rem; }
.sources li { overflow-wrap: anywhere; }

/* ---------- 集計 ---------- */
.bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface-2); margin: 0.6rem 0; gap: 2px; }
.seg { background: var(--c); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.summary-table td { vertical-align: middle; }
.src-links { font-size: 0.85rem; line-height: 1.9; }
.list { background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.kv th { width: 34%; }
.filters { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 1rem 0; }
.filters input { flex: 2 1 220px; width: auto; }
.filters select { flex: 1 1 160px; width: auto; }

.matrix th, .matrix td { text-align: center; border: 1px solid var(--line); min-width: 90px; }
.matrix td.void { background: var(--surface-2); }
.matrix .cell { display: inline-flex; gap: 0.35rem; flex-wrap: wrap; justify-content: center; }
.mini { display: inline-flex; align-items: center; gap: 0.15rem; color: var(--c); font-family: var(--mono); font-weight: 700; }

/* ---------- 組み合わせの選択 ---------- */
.combo-picker { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pchip {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.25rem 0.35rem 0.25rem 0.8rem;
  border-radius: 999px; background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); font-size: 0.9rem;
}
.x { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0.1rem 0.4rem; border-radius: 999px; }
.x:hover { color: var(--fails); background: var(--surface-2); }
.combo-picker .ac { flex: 1 1 260px; }

/* ---------- 入力補完 ---------- */
.ac { position: relative; }
.ac-list {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 20; margin-top: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
}
.ac-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; color: var(--text); font: inherit; padding: 0.5rem 0.8rem; cursor: pointer; }
.ac-item:hover, .ac-item.on { background: var(--surface-2); }

/* ---------- 報告フォーム ---------- */
.report-form { max-width: 860px; }
.item-row { margin: 0.7rem 0; padding-right: 2.6rem; border: 1px solid var(--line); }
.item-row.linked { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.item-row > .x { position: absolute; top: 0.5rem; right: 0.5rem; }
.grid-item { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 0.8rem; }
.grid-item label { margin: 0.3rem 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.8rem; }
@media (max-width: 760px) { .grid-item, .grid-2 { grid-template-columns: 1fr; } }
.result-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.5rem; }
.rp {
  display: flex; align-items: center; gap: 0.45rem; margin: 0; cursor: pointer;
  padding: 0.7rem 0.9rem; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--c);
}
.rp input { width: auto; margin: 0; accent-color: var(--c); }
.rp:has(input:checked) { border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, var(--surface)); }
.copy-row { display: flex; gap: 0.5rem; margin-top: 0.3rem; }
.cf-turnstile { margin: 1rem 0; }

/* ---------- 症状・対処の選択肢、お知らせ、「同じ結果だった」 ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.4rem 0; }
.tag { font-size: 0.78rem; padding: 0.1rem 0.55rem; border-radius: 6px; border: 1px solid var(--line); }
.tag-sym { color: var(--fails); border-color: color-mix(in srgb, var(--fails) 35%, transparent); }
.tag-tw { color: var(--tweak); border-color: color-mix(in srgb, var(--tweak) 35%, transparent); }
.chip-accent { color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 12%, transparent); }
.tag-pick { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.3rem 0 0.6rem; }
.tp {
  display: inline-flex; align-items: center; gap: 0.35rem; margin: 0; font-weight: 500; cursor: pointer;
  padding: 0.35rem 0.75rem; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface);
}
.tp input { width: auto; margin: 0; }
.tp:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.notice { padding: 0.7rem 1rem; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.notice-warn { border-color: color-mix(in srgb, var(--unstable) 50%, transparent); background: color-mix(in srgb, var(--unstable) 10%, var(--surface)); }
.quick { margin-bottom: 0.3rem; }
.confirm-box .row { align-items: center; }
.confirm-count { color: var(--accent-2); font-weight: 700; }
