/* 公立高校入試DB — トークン。直値はこの :root にだけ書く */
:root {
  --c-bg: #f7f8fa;        /* ページ地（淡グレー） */
  --c-box: #ffffff;       /* 主要な情報の箱 */
  --c-alt: #f2f3f5;       /* 学校ページのブロック交互 */
  --c-line: #e5e7eb;      /* 1px線 */
  --c-text: #1f2328;      /* 本文 */
  --c-head: #1f3a5f;      /* 見出し（ネイビー） */
  --c-link: #2c5e9e;      /* リンク（白地 6.6 / 淡グレー地 5.9） */
  --c-muted: #5c5c5c;     /* 補助テキスト（#666 より濃く） */
  --c-primary: #c9302c;   /* 主操作。1画面に1つだけ */
  --c-on-primary: #ffffff;

  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  --fs-s: 13px;
  --fs-m: 15px;
  --fs-l: 20px;
  --fs-xl: 28px;
  --fs-input: 16px;       /* iOS のフォーカス時ズーム回避 */
  --lh-body: 1.7;
  --lh-head: 1.3;
  --lh-row: 1.4;

  --radius: 6px;
  --border: 1px solid var(--c-line);
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;
  --row-pad: 7px;         /* 15px × 1.4 + 7px × 2 + 1px ≒ 36px */
  --tap: 44px;
  --maxw: 960px;
  --focus: 2px solid var(--c-link);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }  /* スマホの一覧は tr を block にするので、絞り込みで隠した行が出ないように */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font);
  font-size: var(--fs-m);
  line-height: var(--lh-body);
  font-variant-numeric: tabular-nums;
}
a { color: var(--c-link); }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible {
  outline: var(--focus);
  outline-offset: 2px;
}
h1, h2, h3 { color: var(--c-head); line-height: var(--lh-head); margin: 0; }
h1 { font-size: var(--fs-xl); font-weight: 700; }
h2 { font-size: var(--fs-l); font-weight: 700; }
h3 { font-size: var(--fs-m); font-weight: 700; }
p { margin: 0; }
code { font-family: inherit; font-size: var(--fs-s); }
.num { font-variant-numeric: tabular-nums; }
.s { font-size: var(--fs-s); }
.muted { color: var(--c-muted); }
.raw { white-space: pre-line; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--sp-4); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ヘッダー */
.site-h { background: var(--c-box); border-bottom: var(--border); }
.site-h .wrap { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-1) var(--sp-4); padding-top: var(--sp-2); padding-bottom: var(--sp-2); }
.site-name { font-weight: 700; color: var(--c-head); text-decoration: none; }
.site-nav { display: flex; flex-wrap: wrap; gap: 0 var(--sp-3); font-size: var(--fs-s); }
.site-nav a { text-decoration: none; padding: var(--sp-1) 0; }
.site-nav a[aria-current="page"] { color: var(--c-text); font-weight: 700; }
.provenance { font-size: var(--fs-s); color: var(--c-muted); padding-top: var(--sp-3); }

main { padding-bottom: var(--sp-8); }
.page-h { padding: var(--sp-4) 0 0; margin-bottom: var(--sp-8); }
.page-h .sub { font-size: var(--fs-s); color: var(--c-muted); margin-top: var(--sp-1); }
.lead { margin-bottom: var(--sp-6); }

.box { background: var(--c-box); border: var(--border); border-radius: var(--radius); }
.box + .box, .box + h2, h2 + .box { margin-top: var(--sp-4); }
.box-pad { padding: var(--sp-4); }
section + section { margin-top: var(--sp-6); }
.sec-h { margin-bottom: var(--sp-3); }

/* 県を選ぶ・検索フォーム */
.sub-nav { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--sp-3); font-size: var(--fs-s); padding-top: var(--sp-3); }
.sub-nav-h { color: var(--c-head); font-weight: 700; }
.sub-nav a { text-decoration: none; padding: var(--sp-1) 0; }
.sub-nav a[aria-current="page"] { color: var(--c-text); font-weight: 700; }
.pref-list { list-style: none; margin: 0; padding: 0; }
.pref-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--sp-3); padding: var(--sp-2) 0; }
.pref-list li + li { border-top: var(--border); }
.pref-list a { font-size: var(--fs-l); font-weight: 700; text-decoration: none; }
.pref-list a:hover { text-decoration: underline; }
.filter { padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-4); }
.f-row { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); align-items: end; margin: 0 0 var(--sp-3); }
fieldset.f-row { border: 0; padding: 0; min-width: 0; align-items: center; }
fieldset.f-row legend { float: left; width: 100%; padding: 0; font-size: var(--fs-s); color: var(--c-muted); }
.filter label { display: flex; flex-direction: column; font-size: var(--fs-s); color: var(--c-muted); gap: 2px; }
.filter label.chk { flex-direction: row; align-items: center; gap: var(--sp-1); font-size: var(--fs-m); color: var(--c-text); min-height: 32px; cursor: pointer; }
.filter input[type=checkbox] { width: 18px; height: 18px; margin: 0; accent-color: var(--c-link); }
.filter select, .filter input[type=search] {
  font: inherit; font-size: var(--fs-input); color: var(--c-text);
  min-height: 36px; padding: 0 var(--sp-2);
  border: var(--border); border-radius: var(--radius); background: var(--c-box);
}
.filter input[type=search] { width: 12em; }
.btn-primary {
  font: inherit; font-size: var(--fs-m); font-weight: 700;
  min-height: 36px; padding: 0 var(--sp-4);
  border: 0; border-radius: var(--radius);
  background: var(--c-primary); color: var(--c-on-primary); cursor: pointer;
}
.result-count { font-size: var(--fs-s); color: var(--c-muted); margin: 0 0 var(--sp-2); }
.note { font-size: var(--fs-s); color: var(--c-text); border-left: 2px solid var(--c-line); padding-left: var(--sp-2); margin: 0 0 var(--sp-2); }
.list-links { font-size: var(--fs-s); margin-bottom: var(--sp-4); }
.list-links a { margin-right: var(--sp-3); }

/* 一覧（1行36px前後） */
.grp { margin-bottom: var(--sp-4); }
.grp > summary { cursor: pointer; padding: var(--sp-1) 0; color: var(--c-head); font-weight: 700; }
.grp > summary .muted { font-weight: 400; font-size: var(--fs-s); }
table.list { width: 100%; border-collapse: collapse; background: var(--c-box); border: var(--border); border-radius: var(--radius); table-layout: fixed; }
table.list th, table.list td { padding: var(--row-pad) var(--sp-2); line-height: var(--lh-row); text-align: left; vertical-align: top; border-top: var(--border); }
table.list thead th { font-size: var(--fs-s); font-weight: 400; color: var(--c-muted); border-top: 0; word-break: keep-all; }
table.list abbr { text-decoration: none; }
table.list tbody tr:nth-child(even) { background: var(--c-bg); }
/* 東京の一覧 */
table.tk thead .c-name { width: 24%; }
table.tk thead .c-dept { width: 19%; }
table.tk thead .c-quota { width: 8%; }
table.tk thead .c-tests { width: 14%; }
table.tk thead .c-subj { width: 7%; }
table.tk thead .c-self { width: 9%; }
table.tk thead .c-exc { width: 19%; }
/* 神奈川の一覧 */
table.kn thead .c-name { width: 22%; }
table.kn thead .c-dept { width: 20%; }
table.kn thead .c-subj { width: 8%; }
table.kn thead .c-toku { width: 12%; }
table.kn thead .c-r1, table.kn thead .c-r2 { width: 11%; }
table.kn thead .c-exc { width: 16%; }
/* 県をまたぐ検索 */
table.x thead .c-name { width: 26%; }
table.x thead .c-dept { width: 26%; }
table.x thead .c-subj { width: 8%; }
table.x thead .c-tests { width: 22%; }
table.x thead .c-exc { width: 18%; }
table.list td.c-name a { font-weight: 700; text-decoration: none; }
table.list td.c-name a:hover { text-decoration: underline; }
table.list .area { font-size: var(--fs-s); color: var(--c-muted); margin-left: var(--sp-1); white-space: nowrap; }
.tok { white-space: nowrap; }
.tok ~ .tok::before { content: "・"; }
.m { display: none; }

/* 学校ページ */
.prog-nav { font-size: var(--fs-s); margin-top: var(--sp-2); }
.prog-nav a { margin-right: var(--sp-3); white-space: nowrap; }
.prog > h2 { padding: var(--sp-4) var(--sp-4) var(--sp-3); }
.prog-note { padding: 0 var(--sp-4) var(--sp-3); font-size: var(--fs-s); color: var(--c-muted); }
.blk { padding: var(--sp-4); border-top: var(--border); }
.blk:nth-of-type(even) { background: var(--c-alt); }
.blk-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-1) var(--sp-3); margin-bottom: var(--sp-2); }
.st { font-size: var(--fs-s); color: var(--c-muted); border: var(--border); border-radius: var(--radius); padding: 0 var(--sp-1); background: var(--c-box); white-space: nowrap; }
.st-verified { color: var(--c-text); }
dl.kv { display: grid; grid-template-columns: 8em 1fr; gap: 2px var(--sp-3); margin: 0; }
dl.kv dt { font-size: var(--fs-s); color: var(--c-muted); padding-top: 2px; }
dl.kv dd { margin: 0; }
dl.kv-wide { grid-template-columns: 9em 1fr; gap: var(--sp-2) var(--sp-3); }
.ratio { font-weight: 700; margin-right: var(--sp-2); }
.part { margin-top: var(--sp-3); padding: var(--sp-3); background: var(--c-box); border: var(--border); border-radius: var(--radius); }
.part h4 { font-size: var(--fs-m); color: var(--c-head); margin: 0 0 var(--sp-2); line-height: var(--lh-head); }
ul.plain-ul { margin: 0; padding-left: 1.2em; }
ul.exc { margin: 0; padding-left: 1.2em; }
.std { margin: 0; }
.src { margin-top: var(--sp-3); font-size: var(--fs-s); color: var(--c-muted); }
.src .srcref { display: block; }
.blk-h .st, .src .st { margin-right: var(--sp-2); }
details.fold { margin-top: var(--sp-3); }
details.fold > summary { cursor: pointer; color: var(--c-link); font-size: var(--fs-s); min-height: 24px; }
details.fold .fold-body { margin-top: var(--sp-2); padding: var(--sp-3); background: var(--c-box); border: var(--border); border-radius: var(--radius); }
details.fold .fold-body + .fold-body { margin-top: var(--sp-2); }
.track + .track { border-top: var(--border); padding-top: var(--sp-2); margin-top: var(--sp-2); }
.track > summary { cursor: pointer; }
table.mini { border-collapse: collapse; font-size: var(--fs-s); margin-top: var(--sp-2); }
table.mini th, table.mini td { border: var(--border); padding: 2px var(--sp-2); text-align: center; }
table.mini th { font-weight: 400; color: var(--c-muted); }
.scroll-x { overflow-x: auto; max-width: 100%; }
.nw { white-space: nowrap; }
table.gm-stages th { white-space: nowrap; }
table.gm-stages th, table.gm-stages td { padding: 2px var(--sp-1); }
table.sa thead .c-name { width: 22%; }
table.sa thead .c-dept { width: 24%; }
table.sa thead .c-r1 { width: 10%; }
table.sa thead .c-pts { width: 22%; }
table.sa thead .c-exc { width: 22%; }
table.gm thead .c-name { width: 24%; }
table.gm thead .c-dept { width: 26%; }
table.gm thead .c-r1 { width: 14%; }
table.gm thead .c-r2 { width: 12%; }
table.gm thead .c-exc { width: 24%; }
table.tg thead .c-name { width: 22%; }
table.tg thead .c-dept { width: 24%; }
table.tg thead .c-r1 { width: 10%; }
table.tg thead .c-r2 { width: 20%; }
table.tg thead .c-exc { width: 24%; }
table.tg-w th, table.tg-w td { padding: 2px var(--sp-1); }
table.ai thead .c-name { width: 22%; }
table.ai thead .c-dept { width: 22%; }
table.ai thead .c-r1 { width: 10%; }
table.ai thead .c-r2 { width: 20%; }
table.ai thead .c-exc { width: 26%; }

/* 県ルール */
.toc { font-size: var(--fs-s); margin-bottom: var(--sp-6); }
.toc a { margin-right: var(--sp-3); white-space: nowrap; }
.rule { padding: var(--sp-3) var(--sp-4); border-top: var(--border); }
.rule:first-of-type { border-top: 0; }
.rule-h { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-3); align-items: baseline; font-size: var(--fs-s); color: var(--c-muted); }
.rule-h code { color: var(--c-text); overflow-wrap: anywhere; }
.rule-v { font-size: var(--fs-s); overflow-wrap: anywhere; margin-top: 2px; }
.rule-raw { margin-top: var(--sp-1); }

/* 変更履歴・ダウンロード・説明 */
table.plain { width: 100%; border-collapse: collapse; }
table.plain th, table.plain td { padding: var(--row-pad) var(--sp-2); border-top: var(--border); text-align: left; vertical-align: top; line-height: var(--lh-row); }
table.plain thead th { border-top: 0; font-size: var(--fs-s); font-weight: 400; color: var(--c-muted); }
table.plain td.r { text-align: right; white-space: nowrap; }
.prose p + p, .prose ul + p, .prose p + ul { margin-top: var(--sp-3); }
.prose ul { margin: 0; padding-left: 1.2em; }
.prose h2 { margin: var(--sp-8) 0 var(--sp-3); }
.prose h2:first-child { margin-top: 0; }

.site-f { border-top: var(--border); background: var(--c-box); font-size: var(--fs-s); color: var(--c-muted); }
.site-f .wrap { padding-top: var(--sp-4); padding-bottom: var(--sp-6); }

/* スマホ：一覧は2行の行に組み替える（行全体でタップ領域44px以上） */
@media (max-width: 640px) {
  .f-row { flex-direction: column; align-items: stretch; }
  fieldset.f-row { flex-direction: row; gap: 0 var(--sp-4); }
  .filter input[type=search] { width: 100%; }
  .filter select, .filter input[type=search], .btn-primary, .filter label.chk { min-height: var(--tap); }
  .btn-primary { width: 100%; }
  dl.kv.kv-wide, .part dl.kv { grid-template-columns: 1fr; gap: 0; }
  .part dl.kv dd { margin-bottom: var(--sp-2); }
  dl.kv.kv-wide dd { margin-bottom: var(--sp-2); }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: auto; }
  table.list thead { display: none; }
  table.list { table-layout: auto; }
  table.list tr { padding: var(--sp-2) var(--sp-3); border-top: var(--border); min-height: var(--tap); line-height: var(--lh-row); }
  table.list tbody tr:first-child { border-top: 0; }
  table.list td { border: 0; padding: 0; display: inline; font-size: var(--fs-s); color: var(--c-muted); }
  table.list td.c-name { display: inline; font-size: var(--fs-m); color: var(--c-text); }
  table.list td.c-dept { display: inline; }
  table.list .area { margin-left: 0; }
  table.list td.c-name a { margin-right: var(--sp-1); }
  table.list .area::after { content: "・"; }
  table.list td.c-dept { margin-left: 0; }
  table.list td.l2::before { content: "\A"; white-space: pre; }
  table.list td.l2 ~ td:not(.empty)::before { content: "　"; }
  table.list td.empty { display: none; }
  .m { display: inline; }
  dl.kv { grid-template-columns: 6.5em 1fr; }
}

/* 余白の補助 */
.mt2 { margin-top: var(--sp-2); }
.mt3 { margin-top: var(--sp-3); }
.mt4 { margin-top: var(--sp-4); }
.mt6 { margin-top: var(--sp-6); }

/* 県ルールが暫定の県（愛知）: 全ページの上部に1行 */
.prov-banner { font-size: var(--fs-s); color: var(--c-text); border-left: 3px solid var(--c-line); background: var(--c-box); padding: var(--sp-1) var(--sp-2); margin: var(--sp-2) 0 0; }
