/*
 * ライト / ダーク両対応。色は :root にまとめてあるので、ここだけ直せば全体が変わる。
 * スマホで見るのが前提なので、幅の狭いほうから書いている。
 */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #e2e5ea;
  --text: #1b1e23;
  --dim: #6b7280;
  --accent: #c8102e;      /* スト6の赤 */
  --on-accent: #ffffff;   /* 赤の上に置く文字の色 */
  --accent-soft: #fdecef;
  --chip: #eef0f4;

  --lv-beginner: #1f8a4c;
  --lv-basic: #2563c9;
  --lv-hard: #a3341f;
  --lv-beginner-bg: #e6f4ec;
  --lv-basic-bg: #e7eefb;
  --lv-hard-bg: #fae9e4;

  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1c1f25;
    --line: #2c313a;
    --text: #e8eaee;
    --dim: #9aa2af;
    /* 暗い画面では赤を明るくするので、上に載せる文字は**黒のほうが読める**
       （白だと明暗の差が 3.2 倍しかない。黒なら 5.6 倍） */
    --accent: #ff4d63;
    --on-accent: #14161a;
    --accent-soft: #33191e;
    --chip: #262b33;

    --lv-beginner: #5fd18f;
    --lv-basic: #79aaff;
    --lv-hard: #ff8f70;
    --lv-beginner-bg: #16301f;
    --lv-basic-bg: #172439;
    --lv-hard-bg: #33201a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 0 48px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 820px; margin: 0 auto; padding: 0 16px; }

/* ------------------------------------------------------------- ヘッダ */

header {
  position: sticky; top: 0; z-index: 10;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

header .wrap { display: flex; align-items: center; gap: 12px; min-height: 56px; }

header h1 {
  font-size: 17px; margin: 0; font-weight: 700;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
header h1 a { color: inherit; text-decoration: none; }

.back {
  color: var(--dim); text-decoration: none; font-size: 14px;
  padding: 6px 0; white-space: nowrap;
}
.back:hover { color: var(--text); }

.note { color: var(--dim); font-size: 13px; margin: 14px 0; }

/* --------------------------------------------------------- キャラ一覧 */

#search {
  width: 100%; margin: 16px 0 8px; padding: 11px 13px;
  font-size: 16px; /* 16px 未満だと iPhone が勝手に拡大する */
  color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
}
#search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.chars {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 8px; margin: 12px 0; list-style: none; padding: 0;
}

/* li を flex にして中の a を伸ばす。こうすると、
   「エドモンド・本田」のように名前が2行になるキャラがいても、
   **その行のタイルが全部そろって**背が高くなる（1枚だけ大きくならない）。
   名前が1行で収まる行は、今までどおりの高さのまま */
.chars li { display: flex; }
/* スマホは2列、それより広ければ4列。
   スマホで4列にすると「エドモンド本田」のような長い名前が入らない */
@media (min-width: 560px) { .chars { grid-template-columns: repeat(4, 1fr); } }

.chars a {
  display: flex; align-items: center; gap: 10px;
  flex: 1;                       /* li いっぱいに広がる＝行の高さにそろう */
  min-height: 62px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--text); text-decoration: none;
}
.chars a:hover { border-color: var(--accent); }

/* Notion のページアイコンから取った顔写真。無いキャラは文字だけになる */
.chars .face {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  object-fit: cover; border-radius: 6px;
  background: var(--chip);
}

/* flex: 1 1 auto と min-width: 0 がないと、長い名前のときに
   この箱が縮まず、タイルからはみ出す（折り返しも効かない） */
.chars .text { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.chars .name { font-weight: 600; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }

/* 「エドモンド・本田」のような長い名前だけ、少し小さくして1行に収める。
   「エドモンド・本 / 田」と割れるほうが、字の大きさが違うより読みにくい */
.chars .name.long { font-size: 13px; letter-spacing: -.01em; }
.chars .cnt { color: var(--dim); font-size: 12px; }
.chars .empty a, a.is-empty { opacity: .45; }

.section-label {
  margin: 22px 0 6px; font-size: 12px; font-weight: 600;
  color: var(--dim); letter-spacing: .04em;
}

/* ------------------------------------------------------- レベル切り替え */

/* flex ではなく grid にしている。
   flex だとボタンの文字の幅が画面幅を押し広げてしまい、
   ページ全体が横にずれる（4つ目の「ぜんぶ」が画面の外に出ていた）。
   grid の 1fr なら、文字が長くてもボタンのほうが縮む。 */
.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 14px 0 6px; }

.levels button {
  min-width: 0; overflow: hidden;
  padding: 9px 4px; font-size: 14px; font-family: inherit; font-weight: 600;
  white-space: nowrap;
  color: var(--dim); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer;
}
.levels button[aria-pressed="true"] {
  color: var(--on-accent); background: var(--accent); border-color: var(--accent);
}
.levels button .n { font-weight: 400; opacity: .75; font-size: 12px; }

.level-hint { font-size: 12px; color: var(--dim); margin: 6px 0 0; }
.level-hint b { color: var(--text); font-weight: 600; }

.bar { display: flex; justify-content: flex-end; margin: 12px 0 4px; }
.bar button {
  padding: 6px 12px; font-size: 13px; font-family: inherit;
  color: var(--dim); background: var(--panel);
  border: 1px solid var(--line); border-radius: 99px; cursor: pointer;
}
.bar button:hover { color: var(--text); border-color: var(--accent); }

/* ------------------------------------------------- 開閉するトグル（状況） */

/*
 * Notion のトグルと同じ形。深さに制限は設けない（JP には5段ある）。
 * 深くなっても字は小さくしない。読めなくなるため。
 * 代わりに、左の線と少しの余白で深さを示す。
 */

.node { margin: 6px 0; }

.node > summary {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 4px; cursor: pointer;
  font-size: 15px; font-weight: 600;
  list-style: none; /* 既定の三角を消して、自前のものに差し替える */
  min-height: 24px; /* スマホで指が届く高さ */
}
.node > summary::-webkit-details-marker { display: none; }

.node > summary::before {
  content: "▶";
  flex: 0 0 auto;
  font-size: 10px; color: var(--accent);
  transition: transform .12s;
}
.node[open] > summary::before { transform: rotate(90deg); }

.node > summary:hover .node-name { color: var(--accent); }

.node-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }

.node-count {
  flex: 0 0 auto;
  font-size: 11px; font-weight: 600;
  color: var(--dim); background: var(--chip);
  padding: 1px 8px; border-radius: 99px;
}

/* 中身。左の線で、どこまでが同じ枝かを示す */
.node-body {
  margin-left: 5px;
  padding-left: 11px;
  border-left: 1px solid var(--line);
}

/* 一番外側の見出しだけ、区切りとして目立たせる */
.node[data-depth="0"] { border-top: 1px solid var(--line); padding-top: 2px; }
.node[data-depth="0"]:first-child { border-top: 0; }
.node[data-depth="0"] > summary { font-size: 16px; }

/* コンボではないと判定した行 */
.note-line {
  font-size: 13px; color: var(--dim);
  padding: 5px 2px; margin-bottom: 4px;
}

/*
 * Notion の 💡 で書いた「この見出しの前提」。
 *
 * 帯にするとコンボの白いカードと張り合って浮くので、**注釈の形**にする。
 * 上に細い線を引いて「ここから下は注釈」と示し、行頭に小さく「メモ」と付ける。
 * 文字そのものは Notion の中身だけ（印は CSS で付けるので、本文は足さない）。
 */
.tip-line {
  font-size: 13px; line-height: 1.8;
  padding: 9px 2px 2px; margin: 4px 0 2px;
  border-top: 1px solid var(--line);
  color: var(--text);
}
.tip-line::before {
  content: "メモ";
  display: inline-block; margin-right: 8px;
  font-size: 11px; font-weight: 700; color: var(--dim);
  vertical-align: 1px;
}

.combo {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 11px 13px; margin-bottom: 8px;
}

/* レシピ。手ごとに区切るので、折り返しても読める。
   min-width: 0 と overflow-wrap が無いと、長い技名で画面からはみ出す */
.recipe { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; min-width: 0; }
.step {
  font-size: 15px; font-weight: 600;
  min-width: 0; overflow-wrap: anywhere;
}
.arrow { color: var(--dim); padding: 0 5px; font-size: 13px; flex: 0 0 auto; }

.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 7px; }

.lv { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.lv-初心者 { color: var(--lv-beginner); background: var(--lv-beginner-bg); }
.lv-とりこれ { color: var(--lv-basic); background: var(--lv-basic-bg); }
.lv-上級者 { color: var(--lv-hard); background: var(--lv-hard-bg); }

.cond {
  font-size: 11px; padding: 2px 8px; border-radius: 99px;
  color: var(--accent); background: var(--accent-soft);
}

.memo { font-size: 12px; color: var(--dim); margin-top: 5px; }

/* 用語。点線の下線を引き、押すと意味が出る */
.term {
  border-bottom: 1px dotted var(--dim);
  cursor: pointer;
}
.term:hover { border-bottom-color: var(--accent); }

/* 用語の説明。画面の下から出す（スマホで指が届く位置） */
#tip {
  position: fixed; left: 8px; right: 8px; bottom: 8px; z-index: 20;
  max-width: 560px; margin: 0 auto; padding: 13px 15px;
  background: var(--panel); border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 6px 26px rgba(0,0,0,.22);
}
#tip[hidden] { display: none; }
#tip .word { font-weight: 700; color: var(--accent); }
#tip .desc { font-size: 14px; margin-top: 2px; }
#tip .close { position: absolute; top: 6px; right: 10px; color: var(--dim); cursor: pointer; font-size: 18px; }

.empty-state { color: var(--dim); text-align: center; padding: 40px 16px; }


/* ----------------------------------------------------------- 用語ページ */

/*
 * 邪魔にならない置き方にする。
 * 一覧は下の小さいリンク、キャラページはヘッダの右端。
 * どちらも、コンボを見ているときは目に入らない場所。
 */

.foot {
  margin-top: 40px; padding: 18px 0 28px;
  border-top: 1px solid var(--line);
}
.foot .wrap {
  color: var(--dim); font-size: 13px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}

/*
 * 用語とフレーム知識への入口。
 * 薄い字のままだと気づかれないので、**枠のある小さなボタン**にする。
 * 色までは付けない（コンボより目立ってはいけない）。
 */
.foot .link {
  color: var(--text); text-decoration: none; font-size: 14px; font-weight: 600;
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 99px;
  background: var(--panel);
}
.foot .link:hover { border-color: var(--accent); color: var(--accent); }

.terms-link {
  margin-left: auto;           /* ヘッダの右端へ寄せる */
  color: var(--dim); text-decoration: none;
  font-size: 13px; white-space: nowrap;
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 99px;
}
.terms-link:hover { color: var(--text); border-color: var(--accent); }
/* ボタンとリンクを並べるので、右へ寄せるのは先頭だけ。2つ目は隣に置く */
.terms-link ~ .terms-link { margin-left: 6px; }
button.terms-link {
  font-family: inherit; background: var(--panel); cursor: pointer;
  /* 名前の長いキャラでも、ヘッダを押し広げない */
  max-width: 50vw; overflow: hidden; text-overflow: ellipsis;
}
button.terms-link[aria-expanded="true"] { color: var(--text); border-color: var(--accent); }

/* ヘッダの「キャラ用語」で開け閉めする箱。閉じているのがふつう */
#own-terms {
  margin: 14px 0 0; padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
}
#own-terms[hidden] { display: none; }
.own-terms-head { margin: 0 0 4px; font-size: 12px; color: var(--dim); font-weight: 700; }
#own-terms .terms { background: transparent; border: 0; border-radius: 0; }
#own-terms .term-row { padding: 6px 2px; }

#term-search {
  width: 100%; margin: 4px 0 14px; padding: 11px 13px;
  font-size: 16px; /* 16px 未満だと iPhone が勝手に拡大する */
  color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
}
#term-search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/*
 * 用語は「語｜説明」の2列にする。
 * 1件ずつ枠で囲むと、22件が縦に長く伸びて探しにくかった。
 * まとめて1枚の白い板にして、間は細い線で区切る。
 */
.terms {
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.term-row { padding: 11px 14px; }
.term-row + .term-row { border-top: 1px solid var(--line); }

/* 画面が広いときだけ2列。語の幅をそろえると、目が縦に走る */
@media (min-width: 560px) {
  .term-row { display: grid; grid-template-columns: 140px 1fr; gap: 14px; align-items: baseline; }
  .term-row dd { margin: 0; }
}

.term-row dt { font-weight: 700; font-size: 15px; }
.term-row dd { margin: 3px 0 0; color: var(--dim); font-size: 14px; line-height: 1.7; }

.tip-links { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.tip-more {
  display: inline-block;
  color: var(--dim); font-size: 12px;
}
.tip-more:hover { color: var(--text); }
#tip-switch[hidden] { display: none; }

.term-head {
  font-size: 13px; margin: 24px 0 8px;
  color: var(--dim); font-weight: 700; letter-spacing: .04em;
}
.term-head:first-child { margin-top: 4px; }
.term-sub { font-size: 12px; color: var(--dim); margin: -4px 0 8px; }

/* キャラ限定は閉じておく。共通の用語を探しに来た人の邪魔をしない */
.term-char {
  background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 8px;
}
.term-char > summary {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 14px; cursor: pointer; list-style: none;
  font-weight: 700; font-size: 15px;
}
.term-char > summary::-webkit-details-marker { display: none; }
.term-char > summary::before { content: "▶"; color: var(--accent); font-size: 10px; }
.term-char[open] > summary::before { content: "▼"; }
.term-char > summary .node-count { margin-left: auto; color: var(--dim); font-size: 12px; font-weight: 400; }
.term-char .node-body { padding: 0 10px 8px; }
.term-char .terms { background: transparent; border: 0; border-radius: 0; }
.term-char .term-row { padding: 7px 4px; }

/* 見出しと説明に分けられない行は、見出しの列に丸ごと入れる（太字でそろう） */
.term-row dt.wide { grid-column: 1 / -1; font-weight: 700; }

/* フレーム知識の板は、トグルの中でも外でも同じ見た目にする */
#frames .terms { margin-bottom: 10px; }
#frames .node-body > .terms:last-child { margin-bottom: 0; }

/* 「教えてください」の欄。コンボを見終わったところに置く */
.ask {
  margin: 20px 0 32px;
  font-size: 13px; color: var(--dim); line-height: 2.2;
}
/* キャラのページでは、コンボの続きに見えないよう上に線を引く */
main .ask { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }

/* 「名前やメールが残るのでは」と思われると、書いてもらえない */
.ask-note { display: block; margin-top: -6px; font-size: 12px; }

/*
 * スマホでは、ボタンを文の途中に挟まない。
 * 「…教えてくださ / [ボタン] / い！」と割れて読みにくくなるため、行を分ける。
 */
@media (max-width: 559px) {
  .ask { line-height: 1.9; }
  .ask .link { display: block; width: fit-content; margin: 10px 0 8px; }
  .ask-note { margin-top: 0; }
}
.ask .link {
  margin-left: 8px;
  color: var(--text); text-decoration: none; font-size: 14px; font-weight: 600;
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 99px;
  background: var(--panel); white-space: nowrap;
}
.ask .link:hover { border-color: var(--accent); color: var(--accent); }

/* 「教える」は押してほしいボタンなので、色を付けて他と区別する */
.ask .link.primary {
  color: var(--on-accent); background: var(--accent); border-color: var(--accent);
}
.ask .link.primary:hover { color: var(--on-accent); filter: brightness(1.08); }
.ask .link[hidden] { display: none; }

/* ------------------------------------------------- キャラの切り替え（ヘッダ） */

/*
 * キャラ名を押すと、一覧が下りてくる。
 * 一覧ページに戻らずにキャラを変えられるようにするためのもの。
 */
#char-switch {
  display: flex; align-items: center; gap: 6px;
  font-family: inherit; font-size: 17px; font-weight: 700;
  color: var(--text); background: none; border: 0; padding: 4px 6px;
  border-radius: 8px; cursor: pointer;
  min-width: 0; overflow: hidden; white-space: nowrap;
}
#char-switch:hover { background: var(--chip); }
#char-switch .caret { color: var(--dim); font-size: 12px; }
#char-switch[aria-expanded="true"] .caret { color: var(--accent); }

#char-menu {
  position: sticky; top: 56px; z-index: 9;
  background: var(--panel); border-bottom: 1px solid var(--line);
  max-height: 60vh; overflow-y: auto;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .08);
}
#char-menu[hidden] { display: none; }
#char-menu ul {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px;
  list-style: none; padding: 10px 0 14px; margin: 0;
}
@media (min-width: 560px) { #char-menu ul { grid-template-columns: repeat(4, 1fr); } }
#char-menu a {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-size: 14px; font-weight: 600;
}
#char-menu a:hover { background: var(--chip); }
#char-menu a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
#char-menu img { width: 28px; height: 28px; border-radius: 5px; object-fit: cover; background: var(--chip); }
#char-menu span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* コンボを探す欄。ぜんぶ開くボタンと同じ行に置く */
.bar { gap: 8px; }
#combo-search {
  flex: 1; min-width: 0; padding: 8px 12px;
  font-size: 16px; /* 16px 未満だと iPhone が勝手に拡大する */
  color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 99px;
}
#combo-search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
