:root{
  --parch:#e9dcbd; --parch2:#f4ead2; --card:#f7efdb; --card-edge:#c9b68c;
  --ink:#332516; --ink-soft:#6e5a41;
  /* --ink-faint はもと #9a8768（--card #f7efdb 上で3.03:1 / --parch #e9dcbd 上で2.56:1、
     WCAG AA 4.5:1 未達）。同じ色相・彩度(H≈37° S≈20%)を保ったまま明度だけを
     50.6%→35%まで下げ、両背景で4.5:1以上（card 5.52:1 / parch 4.65:1、実測値）を確保した。
     この明度は --ink-soft(#6e5a41 相当 L≈34.3%)とほぼ同じになり、色だけでは
     ink-soft と ink-faint を見分けられない（詳細は docs/design_tokens.md）。
     階層は --fs-sm 等の文字サイズ・使用箇所（th/補助テキスト）で保つ判断とした。 */
  --ink-faint:#6b5e48;
  --wood:#191008; --wood2:#26180d; --gold:#e6c979; --gold-deep:#c79a2a;
  --red:#a5231b; --red-deep:#7d150f;
  --profit:#1e7d3c; --loss:#c0392b; --blue:#2f6db5;
  --warn:#c07a12; --shadow:0 2px 6px rgba(51,37,22,.18), 0 1px 2px rgba(51,37,22,.12);

  /* ===== 文字サイズ（6段の型スケール） =====
     Phase 3 の実測で 8.5px〜16.5px の13種が場当たりに散っていた。
     階層が読み取れないので6段に集約し、モバイルはこの6つを差し替えるだけにする。
     font-size に生pxを書いてよいのは装飾（絵文字・アイコン・看板の意匠）だけ。 */
  --fs-h1:19px;     /* 画面見出し・統計カードの主値 */
  --fs-h2:15px;     /* 節見出し */
  --fs-h3:13px;     /* 小見出し・フォーム部品・ボタン */
  --fs-body:12.5px; /* 本文・表のセル */
  --fs-sm:11.5px;   /* 補助テキスト・表の見出し・バッジ */
  --fs-xs:10.5px;   /* 極小（キャレット等） */

  /* カレンダーのセルだけは別スケール。7列を375pxに収める密度が本文と両立しないため、
     意図的な例外として3つだけ独立させる（場当たりに散らさないための宣言）。 */
  --fs-cell:11.5px; --fs-cell-p:12.5px; --fs-cell-t:10.5px;

  /* ===== 行送り =====
     このアプリは DotGothic16（.pixel）と M PLUS 1p を混在させる。
     line-height:normal のままだと両フォントで行箱の高さが変わり、
     フレックス行で align-items:center したときに視覚的なベースラインがずれる。
     明示的に固定して行箱を揃える。 */
  --lh-tight:1.2;   /* 見出し・数値 */
  --lh-base:1.5;    /* 本文 */

  /* ===== 余白（4pxグリッド） ===== */
  --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px; --sp-5:24px;

  /* ===== 入力部品の高さ =====
     .filters は align-items:flex-end で並ぶ。高さが揃っていないと
     入力欄・月送り・同期バッジ・更新ボタンの下端が合わず段差になる。 */
  --ctl-h:34px; --ctl-h-sm:26px;

  /* ===== ドット絵スプライト（自作・DQのマップアイコン風） =====
     もとは絵文字（城・山・✦）だったが、絵文字はOS/フォントで見た目が変わり
     「やっつけ感」が出る（本人指摘）。墨シルエット＋金の2トーンで自作し、
     パレットを完全一致させた。設計図(ASCII)と生成はscratchpad/make_sprites.py。 */
  --sprite-castle: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2018%22%20shape-rendering%3D%22crispEdges%22%3E%3Crect%20x%3D%224%22%20y%3D%221%22%20width%3D%222%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%2210%22%20y%3D%221%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%2218%22%20y%3D%221%22%20width%3D%222%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%222%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%2210%22%20y%3D%222%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%2217%22%20y%3D%222%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%223%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%2210%22%20y%3D%223%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%223%22%20width%3D%222%22%20height%3D%221%22%20fill%3D%22%23e6c979%22%2F%3E%3Crect%20x%3D%2213%22%20y%3D%223%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%2217%22%20y%3D%223%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%224%22%20width%3D%2218%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%225%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%227%22%20y%3D%225%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%225%22%20width%3D%223%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%2214%22%20y%3D%225%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2218%22%20y%3D%225%22%20width%3D%223%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%226%22%20width%3D%2218%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%222%22%20y%3D%227%22%20width%3D%2220%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%222%22%20y%3D%228%22%20width%3D%227%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%229%22%20y%3D%228%22%20width%3D%227%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2216%22%20y%3D%228%22%20width%3D%226%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%222%22%20y%3D%229%22%20width%3D%227%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%229%22%20y%3D%229%22%20width%3D%222%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%229%22%20width%3D%223%22%20height%3D%221%22%20fill%3D%22%23e6c979%22%2F%3E%3Crect%20x%3D%2214%22%20y%3D%229%22%20width%3D%222%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2216%22%20y%3D%229%22%20width%3D%226%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%222%22%20y%3D%2210%22%20width%3D%2220%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%222%22%20y%3D%2211%22%20width%3D%2220%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%222%22%20y%3D%2212%22%20width%3D%225%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%227%22%20y%3D%2212%22%20width%3D%2211%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2218%22%20y%3D%2212%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%222%22%20y%3D%2213%22%20width%3D%225%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%227%22%20y%3D%2213%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%2213%22%20width%3D%223%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%2214%22%20y%3D%2213%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2218%22%20y%3D%2213%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%222%22%20y%3D%2214%22%20width%3D%225%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%227%22%20y%3D%2214%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%2214%22%20width%3D%223%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%2214%22%20y%3D%2214%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2218%22%20y%3D%2214%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%222%22%20y%3D%2215%22%20width%3D%225%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%227%22%20y%3D%2215%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%2215%22%20width%3D%223%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%2214%22%20y%3D%2215%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2218%22%20y%3D%2215%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%222%22%20y%3D%2216%22%20width%3D%225%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%227%22%20y%3D%2216%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%2216%22%20width%3D%223%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%2214%22%20y%3D%2216%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2218%22%20y%3D%2216%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3C%2Fsvg%3E");  /* チャッピー作 24x18（2026-07-29差し替え） */
  --sprite-mountain: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2012%22%20shape-rendering%3D%22crispEdges%22%3E%3Crect%20x%3D%2211%22%20y%3D%221%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%224%22%20y%3D%222%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%2210%22%20y%3D%222%22%20width%3D%223%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%2218%22%20y%3D%222%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%223%22%20width%3D%223%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%229%22%20y%3D%223%22%20width%3D%225%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%2217%22%20y%3D%223%22%20width%3D%223%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%222%22%20y%3D%224%22%20width%3D%225%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%228%22%20y%3D%224%22%20width%3D%227%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%2216%22%20y%3D%224%22%20width%3D%225%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%221%22%20y%3D%225%22%20width%3D%2210%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%2211%22%20y%3D%225%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2212%22%20y%3D%225%22%20width%3D%222%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%2214%22%20y%3D%225%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2215%22%20y%3D%225%22%20width%3D%227%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%220%22%20y%3D%226%22%20width%3D%228%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%228%22%20y%3D%226%22%20width%3D%227%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2215%22%20y%3D%226%22%20width%3D%228%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%220%22%20y%3D%227%22%20width%3D%227%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%227%22%20y%3D%227%22%20width%3D%223%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2210%22%20y%3D%227%22%20width%3D%223%22%20height%3D%221%22%20fill%3D%22%23e6c979%22%2F%3E%3Crect%20x%3D%2213%22%20y%3D%227%22%20width%3D%223%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2216%22%20y%3D%227%22%20width%3D%228%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%220%22%20y%3D%228%22%20width%3D%225%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%225%22%20y%3D%228%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%229%22%20y%3D%228%22%20width%3D%225%22%20height%3D%221%22%20fill%3D%22%23e6c979%22%2F%3E%3Crect%20x%3D%2214%22%20y%3D%228%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2218%22%20y%3D%228%22%20width%3D%226%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%220%22%20y%3D%229%22%20width%3D%223%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%229%22%20width%3D%225%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%228%22%20y%3D%229%22%20width%3D%228%22%20height%3D%221%22%20fill%3D%22%23e6c979%22%2F%3E%3Crect%20x%3D%2216%22%20y%3D%229%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%2220%22%20y%3D%229%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3Crect%20x%3D%220%22%20y%3D%2210%22%20width%3D%227%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%227%22%20y%3D%2210%22%20width%3D%2210%22%20height%3D%221%22%20fill%3D%22%23e6c979%22%2F%3E%3Crect%20x%3D%2217%22%20y%3D%2210%22%20width%3D%227%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%220%22%20y%3D%2211%22%20width%3D%2224%22%20height%3D%221%22%20fill%3D%22%23332516%22%2F%3E%3C%2Fsvg%3E");  /* チャッピー作 24x12（2026-07-29差し替え） */
  --sprite-shield: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2012%2014%22%20shape-rendering%3D%22crispEdges%22%3E%3Crect%20x%3D%224%22%20y%3D%220%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%221%22%20width%3D%226%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%222%22%20y%3D%222%22%20width%3D%228%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%222%22%20y%3D%223%22%20width%3D%228%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%221%22%20y%3D%224%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%225%22%20y%3D%224%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22%23e6c979%22%2F%3E%3Crect%20x%3D%226%22%20y%3D%224%22%20width%3D%225%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%221%22%20y%3D%225%22%20width%3D%223%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%224%22%20y%3D%225%22%20width%3D%223%22%20height%3D%221%22%20fill%3D%22%23e6c979%22%2F%3E%3Crect%20x%3D%227%22%20y%3D%225%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%221%22%20y%3D%226%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%225%22%20y%3D%226%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22%23e6c979%22%2F%3E%3Crect%20x%3D%226%22%20y%3D%226%22%20width%3D%225%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%221%22%20y%3D%227%22%20width%3D%2210%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%221%22%20y%3D%228%22%20width%3D%2210%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%222%22%20y%3D%229%22%20width%3D%228%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%222%22%20y%3D%2210%22%20width%3D%228%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%2211%22%20width%3D%226%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3Crect%20x%3D%224%22%20y%3D%2212%22%20width%3D%224%22%20height%3D%221%22%20fill%3D%22%23fdf3d8%22%2F%3E%3C%2Fsvg%3E");  /* チャッピー作 12x14（2026-07-29差し替え） */

  /* ナビ用ドット絵アイコン10種（チャッピー作・2026-07-29）。
     絵文字アイコンはOS依存で見た目が揃わないため置き換える。
     元データ: C:\Claude Code\pips_quest\pips-quest-icons.html */
  --icon-dash: url("/static/img/icons/dash.png");  /* チャッピー画像版 2026-07-29 */
  --icon-trades: url("/static/img/icons/trades.png");  /* チャッピー画像版 2026-07-29 */
  --icon-accounts: url("/static/img/icons/accounts.png");  /* チャッピー画像版 2026-07-29 */
  --icon-report: url("/static/img/icons/report.png");  /* チャッピー画像版 2026-07-29 */
  --icon-calendar: url("/static/img/icons/calendar.png");  /* チャッピー画像版 2026-07-29 */
  --icon-stats: url("/static/img/icons/stats.png");  /* チャッピー画像版 2026-07-29 */
  --icon-backtest: url("/static/img/icons/backtest.png");  /* チャッピー画像版 2026-07-29 */
  --icon-sim: url("/static/img/icons/sim.png");  /* 電卓（denntaku）2026-07-29 */
  --icon-goals: url("/static/img/icons/goals.png");  /* チャッピー画像版 2026-07-29 */
  --icon-memo: url("/static/img/icons/memo.png");  /* チャッピー画像版 2026-07-29 */
  --icon-settings: url("/static/img/icons/settings.png");  /* チャッピー画像版 2026-07-29 */
}
*{margin:0;padding:0;box-sizing:border-box}
/* hidden 属性を必ず効かせる。
   ブラウザ標準の [hidden]{display:none} は詳細度(0,1,0)で、
   .modal-bg{display:flex} のようなクラス指定と同点になり後勝ちで負ける。
   その結果 JS が hidden=true にしてもモーダルが消えず、透明な覆いが
   クリックを全部飲む不具合を実際に踏んだ。ここで一括して抑える。 */
[hidden]{display:none !important}
html{font-size:15px}
body{
  font-family:'M PLUS 1p','Meiryo',sans-serif; color:var(--ink);
  font-size:var(--fs-body); line-height:var(--lh-base);
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255,250,235,.55), transparent 55%),
    radial-gradient(ellipse at 85% 90%, rgba(120,90,45,.18), transparent 50%),
    repeating-linear-gradient(0deg, rgba(120,95,55,.035) 0 2px, transparent 2px 4px),
    var(--parch);
  min-height:100vh; font-feature-settings:"tnum";
}
/* DotGothic16 は400の1ウェイトしか読み込んでいない。
   font-weight:700 を当てると合成太字になり、ピクセルフォントの輪郭が濁る。
   .pixel の階層は「大きさと色」で作り、太字は使わない。 */
.pixel{font-family:'DotGothic16','MS Gothic',monospace; letter-spacing:.02em; font-weight:400}

/* ===== layout ===== */
.app{display:grid; grid-template-columns:212px minmax(0,1fr); min-height:100vh; max-width:100%}
.mbar{grid-column:1/-1; min-width:0}
@media(min-width:821px){.mbar{display:none}}
/* min-width:0 が無いと、グリッドの 1fr トラックが中身（同期状態のテーブル等）の
   最小内容幅に押し広げられ、狭い画面で横スクロールが出る */
main{
  padding:18px 22px 40px; max-width:1400px; min-width:0;
  /* 本文（メニュー以外）の背景に地図イラストの羊皮紙(haikei.png由来)を敷く。
     fixed でスクロールしても絵が流れないようにする。パネル類は不透明カード
     なので可読性には影響せず、隙間から絵が覗く。 */
  background:url("/static/img/bg_main.jpg") center / cover no-repeat fixed;
}

/* ===== sidebar ===== */
.side{
  background:linear-gradient(180deg,#221609 0%, #191008 30%, #14100b 100%);
  border-right:3px solid #0c0805; position:sticky; top:0; height:100vh;
  display:flex; flex-direction:column; overflow-y:auto;
}
/* 2026-07-29差し替え: 旗・紋章・ワードマークを全部持つ透過PNG
   (banner_side.png) 1枚に。旧実装のCSS旗(clip-path)・盾スプライト・
   h1文字は画像に内包されたため廃止。 */
.banner{margin:14px auto 10px;width:150px}
.banner img{display:block;width:100%;height:auto;filter:drop-shadow(0 3px 5px rgba(0,0,0,.35))}
nav{padding:6px 10px 0; flex:0 0 auto}
.nav-item{
  position:relative; /* ▶カーソル(::before)を絶対配置する基準にする */
  display:flex;align-items:center;gap:10px;padding:9px 12px 9px 24px;margin:2px 0;
  color:#cbb58a;font-size:var(--fs-h3);line-height:var(--lh-tight);
  border-radius:8px;cursor:pointer;
  border:1px solid transparent; user-select:none; text-decoration:none;
}
.nav-item .ico{width:20px;text-align:center;font-size:15px;filter:grayscale(.2);line-height:1}
.nav-item:hover{background:rgba(230,201,121,.1);color:#f0e0b4}
.nav-item.active{
  background:linear-gradient(180deg,#f7efdb,#e9dcbd); color:var(--ink);
  border:1px solid #b79c66; box-shadow:0 1px 0 rgba(0,0,0,.4);
}
/* DQのコマンド選択カーソル。▶は常に生成しておき、非アクティブ時は
   transparent にするだけで幅は変えない。position:absolute にしてあるのは、
   flexの子として数えると gap 分の間隔まで状態によって変わってしまうのを避けるため
   （常に同じ padding-left を確保しているので、hover/active の切り替えで
   他の項目が横に動くことはない）。 */
.nav-item::before{
  content:'\25B6';position:absolute;left:9px;top:50%;transform:translateY(-50%);
  font-size:var(--fs-xs);line-height:1;color:transparent;
}
.nav-item.active::before{
  color:var(--ink);
  animation:pq-cursor-blink 1.05s steps(1, end) infinite;
}
/* デザイン意図（スタディ .dq-nav 由来）: マウスがメニュー内のどこかにある間は
   「今どれを選ぼうとしているか」を hover 中の項目の▶で示し、
   紛らわしくならないよう active の▶はメニュー hover 中だけ隠す。
   マウスがメニュー外に出れば active の▶表示に戻る。 */
.nav-item:hover::before{color:var(--ink)}
.side nav:hover .nav-item.active::before{color:transparent}
@keyframes pq-cursor-blink{50%{opacity:.15}}

/* ===== 今日の名言（モック pips_quest/pips quest mock.html の .quote 準拠） =====
   nav の直後・margin-top:auto でサイドバー最下部に沈める固定の札。
   文言は app.js が日付シードで選ぶ（今日の名言 = 同じ日は同じ内容）。
   色はモックの生の色指定（#efe1bd/#dcc99a/#6d5836/#f6ecd2/#7a5c22/#41301a）を、
   このプロジェクトの既存トークンで最も近い色に置き換えている
   （#6d5836→--ink-soft、#41301a→--ink、背景の淡いベージュ→--parch/--parch2、
   ハイライトの縁→--parch2）。border-width・border-radius は他の羊皮紙カード群
   （.panel .modal 等）と同様この設計にトークンが無いため生pxのまま。 */
.quote{
  margin:auto var(--sp-3) var(--sp-4); padding:var(--sp-3) var(--sp-3) var(--sp-4);
  text-align:center; border-radius:6px;
  background:linear-gradient(180deg,var(--parch2),var(--parch));
  border:2px solid var(--ink-soft);
  box-shadow:inset 0 0 0 2px var(--parch2), var(--shadow);
}
.quote .qt{font-size:var(--fs-sm);line-height:var(--lh-tight);color:var(--ink-soft);margin-bottom:var(--sp-2)}
.quote p{font-size:var(--fs-body);line-height:var(--lh-base);color:var(--ink)}
/* 名言アイコン（チャッピー生成48種から app.js が名言に合わせて日替わりで選ぶ）。
   切り出しは縦横比バラバラなので枠を48px角に固定して contain で収める */
.quote .qicon{display:block;width:48px;height:48px;margin:var(--sp-2) auto 0;object-fit:contain}

/* ===== ナビの絵文字をドット絵アイコンに置き換える =====
   HTMLは変えず、.ico/.bi の絵文字を font-size:0 で隠して背景に描く
   （絵文字はcolor:transparentでは消えない）。設定ページのサイドバーは
   data-s を持たないリンクなので href で拾う。 */
.nav-item .ico{
  font-size:0;height:16px;
  background:no-repeat center / 16px 16px;
  /* チャッピー画像はAAつきの絵画調ドット絵。64→16px縮小は
     pixelated だと粒が潰れるので通常補間にする */
  filter:none;  /* 絵文字用の grayscale(.2) を引き継がない（金がくすむ） */
}
.nav-item[data-s="dash"] .ico, .nav-item[href="/"] .ico{background-image:var(--icon-dash)}
.nav-item[data-s="trades"] .ico{background-image:var(--icon-trades)}
.nav-item[data-s="accounts"] .ico{background-image:var(--icon-accounts)}
.nav-item[data-s="report"] .ico{background-image:var(--icon-report)}
.nav-item[data-s="calendar"] .ico{background-image:var(--icon-calendar)}
.nav-item[data-s="stats"] .ico{background-image:var(--icon-stats)}
.nav-item[data-s="backtest"] .ico{background-image:var(--icon-backtest)}
.nav-item[data-s="sim"] .ico{background-image:var(--icon-sim)}
.nav-item[data-s="goals"] .ico{background-image:var(--icon-goals)}
.nav-item[data-s="memo"] .ico{background-image:var(--icon-memo)}
.nav-item[href="/settings"] .ico{background-image:var(--icon-settings)}

/* ページタイトル内のアイコン。絵文字をやめてナビと同じチャッピー画像に
   そろえる（本人指示: 押した先の表題も変える）。 */
.pticon{
  display:inline-block;width:22px;height:22px;flex:0 0 auto;
  background:no-repeat center / contain;
}
.pticon[data-i="dash"]{background-image:var(--icon-dash)}
.pticon[data-i="trades"]{background-image:var(--icon-trades)}
.pticon[data-i="accounts"]{background-image:var(--icon-accounts)}
.pticon[data-i="report"]{background-image:var(--icon-report)}
.pticon[data-i="calendar"]{background-image:var(--icon-calendar)}
.pticon[data-i="stats"]{background-image:var(--icon-stats)}
.pticon[data-i="backtest"]{background-image:var(--icon-backtest)}
.pticon[data-i="sim"]{background-image:var(--icon-sim)}
.pticon[data-i="goals"]{background-image:var(--icon-goals)}
.pticon[data-i="memo"]{background-image:var(--icon-memo)}
.pticon[data-i="settings"]{background-image:var(--icon-settings)}

/* ===== panel / stat / grid ===== */
.grid4{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin-bottom:var(--sp-4)}
.stat{
  background:var(--card);border:1px solid var(--card-edge);border-radius:12px;box-shadow:var(--shadow);
  padding:14px var(--sp-4);display:flex;gap:var(--sp-3);align-items:center;
}
.stat .ic{font-size:26px;line-height:1;flex:0 0 auto}
/* ラベル・値・補足を縦に積む箱。min-width:0 で長い値がカードを押し広げないようにする */
.stat > div{min-width:0}
/* ダッシュボードの統計パネルは .cols の右側（380px）に入るので、
   4カラムだと1枚76px・内側50pxしか無く 171,541 のような値があふれる（実測）。
   この場所だけ2カラムにする。統計画面（全幅）は4カラムのままでよい。 */
#statsArea .grid4,#statsOverview .grid4{grid-template-columns:repeat(2,minmax(0,1fr))}
/* 全期間サマリー（今年の損益・総資金）と月次カードの境目 */
#statsOverview{margin-bottom:var(--sp-3);padding-bottom:var(--sp-3);border-bottom:1px dashed #ddcba0}
#statsOverview:empty{display:none}
.stat .lb{font-size:var(--fs-sm);color:var(--ink-soft);line-height:var(--lh-tight)}
.stat .vl{font-size:var(--fs-h1);font-weight:800;line-height:var(--lh-tight)}
.stat .sb{font-size:var(--fs-sm);color:var(--ink-faint);line-height:var(--lh-tight)}
.pos{color:var(--profit)} .neg{color:var(--loss)}
/* ===== ロゴ看板 =====
   2026-07-29差し替え: 額縁・城・山・ワードマークを全部持つ透過PNG
   (banner_header.png) 1枚に。旧実装のCSS額縁(border+box-shadowリング)・
   疑似要素の城山スプライト・mix-blend-mode:multiply は画像に内包されたため廃止。 */
/* 寸法はチャッピー推奨（2026-07-29）: 幅760px・高さ160px前後・上余白10px・下余白14px。
   現画像は約3:1なので max-height:160px が効くと表示幅は約485pxに縮む。
   チャッピー曰く枠いっぱい(760×160)にするには画像側を4.75:1(1520×320)で
   再構成するのが正解（届いたら banner_header.png を差し替えるだけ）。 */
.logo-wrap{display:flex;justify-content:center;align-items:center;padding:10px 20px 14px}
.logo-wrap img{
  display:block;width:min(760px,72vw);height:auto;max-height:160px;object-fit:contain;
  filter:drop-shadow(0 6px 12px rgba(25,16,8,.25));
}
@media(min-width:1500px){
  .logo-wrap img{width:760px}
}
@media(max-width:1200px){
  .logo-wrap img{width:660px}
}
@media(max-width:800px){
  .logo-wrap img{width:92%;max-height:130px}
}

/* 更新ボタンと最終更新時刻（生存確認用）。
   もとは別々のフレックス項目で、時刻に align-self:center が付いていた。
   そのため背の高いフィルタ行の中央に浮いて隣のボタンと行が合わず、
   さらに幅が足りないと時刻だけが次の行に取り残されていた。
   群にまとめてコントロールと同じ高さに揃える。 */
.refresh-group{display:flex;align-items:center;gap:var(--sp-2);height:var(--ctl-h)}
.updated-at{
  font-size:var(--fs-sm);line-height:var(--lh-tight);
  color:var(--ink-faint);white-space:nowrap;
}

/* 有効/無効バッジ（設定画面の口座一覧で使用・モック143-144行に準拠） */
.tag-run{color:var(--profit);font-weight:700;font-size:var(--fs-sm)}
.tag-stop{color:#c07a12;font-weight:700;font-size:var(--fs-sm)}

.panel{
  background:var(--card);border:1px solid var(--card-edge);border-radius:12px;box-shadow:var(--shadow);
  padding:14px var(--sp-4);margin-bottom:14px;
}
/* 節見出しをDQのメッセージウィンドウ同様の黒帯へ強化する。
   出典: pips_quest/pips-quest-dq-ui-study.html の .dq-h3。
   二重の縁取りは border(クリーム2px) + box-shadow(焦げ茶黒2px→クリーム系4px)を
   重ねて作る（.page-title と同じ手法）。◆装飾の色(--gold-deep)は現行のまま変えない。
   リングは外側4pxまで広がるが、.panel の padding(14px以上)の内側に収まる。 */
.panel h3{
  font-size:var(--fs-h2);line-height:var(--lh-tight);
  display:flex;align-items:center;justify-content:space-between;gap:var(--sp-2);
  margin-bottom:var(--sp-2);
  color:var(--parch2);
  background:var(--wood);
  border:2px solid var(--parch2);border-radius:8px;
  box-shadow:
    0 0 0 2px var(--wood),
    0 0 0 4px rgba(253,243,216,.82);
  /* DQ風の小さなドット装飾だけを足す。h3 は justify-content:space-between の
     flexコンテナで、report.js の <select> や ea.js の <a class="btn"> のように
     右側へ寄せる部品を子に持つ画面がある。::before を通常の flex子にすると
     2子構成になって space-between が「マーカーは左端・本文は右端」に割ってしまい
     右側部品の並びごと壊れる。position:absolute で flex から外し、
     padding で常に一定の余白を確保するだけにして安全に留める。 */
  position:relative;padding:7px 8px 7px 11px;
}
.panel h3 > *{line-height:var(--lh-tight)}
.panel h3::before{
  content:'\25C6';position:absolute;left:0;top:50%;transform:translateY(-50%);
  color:var(--gold-deep);font-size:var(--fs-sm);line-height:1;
}
/* h3が黒帯化したことで、内部に入る既存部品（月/週セグメント・年送り・
   通貨切替select・ボタンリンク）が羊皮紙前提の明るい配色のままだと
   黒地に沈んで読めなくなる。.panel h3 の中だけで配色を上書きし、
   グローバルな .seg / .btn / select の見た目は変えない。 */
.panel h3 .seg{background:var(--wood2);border-color:rgba(253,243,216,.5)}
.panel h3 .seg button{color:var(--parch2)}
.panel h3 .seg button.on{background:var(--gold);color:var(--wood)}
.panel h3 .btn,
.panel h3 .btn.ghost{background:var(--wood2);color:var(--parch2);border-color:rgba(253,243,216,.5)}
.panel h3 .monthnav-label{color:var(--parch2)}
.panel h3 select{background:var(--wood2);color:var(--parch2);border-color:rgba(253,243,216,.5)}
.cols{display:grid;grid-template-columns:minmax(0,1fr) 380px;gap:14px;align-items:start}

.seg{display:flex;gap:2px;background:#e0d0a8;border:1px solid #bda876;border-radius:7px;padding:2px}
.seg button{
  border:0;background:transparent;font-family:'DotGothic16','MS Gothic',monospace;
  font-size:var(--fs-body);line-height:var(--lh-tight);padding:var(--sp-1) 10px;
  border-radius:5px;cursor:pointer;color:var(--ink-soft)
}
.seg button.on{background:#3b2a1a;color:#f3e6c3}

/* tables */
table{width:100%;border-collapse:collapse;font-size:var(--fs-body)}
th{
  font-weight:500;color:var(--ink-faint);text-align:left;padding:5px var(--sp-2);
  border-bottom:1px solid #d8c69c;font-size:var(--fs-sm);line-height:var(--lh-tight);
  white-space:nowrap;
}
td{padding:7px var(--sp-2);border-bottom:1px dashed #ddcba0;line-height:var(--lh-base)}
tr:last-child td{border-bottom:0}
/* 数値列。tnum は body で有効なので桁は揃う。折り返すと桁が崩れるので nowrap。 */
td.num,th.num{text-align:right;white-space:nowrap;font-variant-numeric:tabular-nums}
.pill{display:inline-block;padding:1px var(--sp-2);border-radius:10px;font-size:var(--fs-sm);line-height:1.4;border:1px solid #c9b482;background:#efe2bf;color:var(--ink-soft)}
/* セルの補助テキスト（同期状態テーブルの口座ID・エラー行など）。
 * Phase 3-1 の型スケール統一で取りこぼしていた生pxのインラインstyleをここに集約する。
 * --fs-xs にすることでモバイルでも他の型スケールと同じ比率で自動的に縮む。 */
.cell-sub{font-size:var(--fs-xs);line-height:var(--lh-tight);color:var(--ink-faint)}
.cell-sub.err{color:var(--loss)}
.tscroll{overflow-x:auto;-webkit-overflow-scrolling:touch}

/* calendar */
.cal{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:5px}
.cal .ch{text-align:center;font-size:var(--fs-sm);line-height:var(--lh-tight);color:var(--ink-soft);padding:var(--sp-1) 0}
.cal .cd{
  min-height:66px;border:1px solid #d3c090;border-radius:7px;background:#f2e7cb;
  padding:5px 6px;font-size:var(--fs-cell);line-height:var(--lh-tight);position:relative;
  overflow:hidden;
}
.cal .cd .d{color:var(--ink-faint)}
.cal .cd.plus{background:#e2eed7;border-color:#a9c48e}
.cal .cd.minus{background:#f3ded6;border-color:#d3a08c}
/* 損益。widthに余裕のあるデスクトップは完全な値、狭い画面は丸めた表記。
   JS が両方を出しておき、どちらを見せるかはここで決める（app.js cellMoney）。
   ellipsis は 100万円超のような想定外の桁に対する最後の保険。 */
.cal .cd .p{
  font-weight:800;font-size:var(--fs-cell-p);line-height:var(--lh-tight);margin-top:var(--sp-1);
  font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.cal .cd .p .p-compact{display:none}
.cal .cd .t{color:var(--ink-faint);font-size:var(--fs-cell-t);line-height:var(--lh-tight);margin-top:var(--sp-1)}
.cal .cd.today{outline:2px solid var(--gold-deep)}
.cal .cd.dim{opacity:.35}
.cal .cd .mk{position:absolute;top:4px;right:5px;width:6px;height:6px;border-radius:50%;background:var(--blue)}
.cal-empty{grid-column:1/-1;text-align:center;color:var(--ink-faint);padding:20px 0;font-size:var(--fs-body)}

/* forms / buttons */
.form-row{display:grid;grid-template-columns:110px minmax(0,1fr);gap:var(--sp-3);align-items:center;padding:10px 0;border-bottom:1px dashed #ddcba0}
.form-row label{font-size:var(--fs-h3);line-height:var(--lh-tight);color:var(--ink-soft)}
/* もとは select と input[type=text] だけを整えていた。
   設定画面は password / time / number / date も使っており、
   それらがブラウザ既定のまま（別書体・別の高さ・別の枠線）で並んでいた。
   入力欄は種類で見た目が変わってよいものではないので一括で当てる。
   高さを揃えないと .filters の下端が段差になる。line-height:1 にして
   height で高さを決め、padding は左右だけに使う。 */
select,
input[type=text],input[type=password],input[type=number],
input[type=time],input[type=date],input[type=search],input[type=email]{
  font-family:'M PLUS 1p','Meiryo',sans-serif;font-size:var(--fs-h3);line-height:1;
  height:var(--ctl-h);padding:0 10px;border-radius:7px;
  border:1px solid #bda876;background:#fdf6e4;color:var(--ink);max-width:320px;width:100%;
}
/* number のスピナーと time のピッカーは羊皮紙の上で浮くので落ち着かせる */
input[type=number]{-moz-appearance:textfield}
input[type=number]::-webkit-inner-spin-button{opacity:.45}
input[type=time]::-webkit-calendar-picker-indicator{opacity:.55;cursor:pointer}
input:disabled{background:#efe6cf;color:var(--ink-soft);cursor:not-allowed}
input:focus-visible,select:focus-visible,.btn:focus-visible{
  outline:2px solid var(--gold-deep);outline-offset:1px
}
.btn{
  font-family:'DotGothic16','MS Gothic',monospace;font-size:var(--fs-h3);line-height:1;
  height:var(--ctl-h);padding:0 18px;border-radius:8px;cursor:pointer;
  border:1px solid #1d3a63;background:linear-gradient(180deg,#3f7cc0,#2d5d97);color:#fff;box-shadow:var(--shadow);
  /* <a class="btn"> でも <button> と同じ見た目になるように。
     アンカーは既定で下線＋ベースライン配置なので、ここで打ち消す */
  display:inline-flex;align-items:center;justify-content:center;text-decoration:none;
}
.btn.ghost{background:#efe3c4;color:var(--ink);border-color:#c3ab77}
.btn.small{font-size:var(--fs-sm);height:var(--ctl-h-sm);padding:0 10px}
.checklabel{display:flex;align-items:center;gap:6px;font-size:var(--fs-h3);line-height:var(--lh-tight);color:var(--ink)}

/* screens */
.screen{display:none}
.screen.active{display:block}
/* DQ風メッセージウィンドウ化。焦げ茶黒地(--wood系)+クリームの二重枠+ドット文字。
   inline-flex でテキスト幅に沿わせ、羊皮紙のフィールドの上にDQのウィンドウが
   乗っているような見た目にする（全幅バーにはしない）。
   二重枠は border(クリーム3px) + box-shadow の inset(焦げ茶2px) を重ねて作る。 */
/* DQ風メッセージウィンドウ化（A案＝古典DQ）。
   出典: pips_quest/pips-quest-dq-ui-study.html の .dq-title / .dq-title--classic。
   inline-flex でテキスト幅に沿わせ、羊皮紙のフィールドの上にDQのウィンドウが
   乗っているような見た目にする（全幅バーにはしない）。
   多重リングは border+inset ではなく box-shadow の重ね掛けで作る
   （border:0 にして、リングは要素の外側7pxまで視覚的に広がる）。 */
.page-title{
  font-size:var(--fs-h1);line-height:var(--lh-tight);margin-bottom:14px;
  display:inline-flex;align-items:center;gap:10px;max-width:100%;
  position:relative;isolation:isolate;
  color:var(--parch2);text-shadow:1px 1px 0 rgba(25,16,8,.9);
  background:#0f0a06;
  border:0;border-radius:9px;
  box-shadow:
    0 0 0 2px var(--parch2),
    0 0 0 5px var(--wood),
    0 0 0 7px rgba(253,243,216,.82),
    0 7px 14px rgba(25,16,8,.18);
  padding:8px 18px;
}
.page-title::before,
.page-title::after{content:"";position:absolute;z-index:-1;pointer-events:none}
.page-title::before{inset:4px;border:1px solid rgba(253,243,216,.2);border-radius:6px}
.page-title::after{
  inset:0;border-radius:inherit;
  background:
    radial-gradient(circle at 16% 20%, rgba(253,243,216,.08) 0 1px, transparent 1px),
    linear-gradient(180deg, rgba(255,255,255,.035), transparent 55%);
  background-size:8px 8px, auto;
  mix-blend-mode:screen;
}
/* 1280px で中身の合計が 982px、使える幅が 975px と 7px 足りずに
   「更新」の群が折り返していた。隙間と各部品の最小幅を実寸に合わせて詰める。 */
.filters{display:flex;gap:var(--sp-3);flex-wrap:wrap;margin-bottom:var(--sp-2);align-items:flex-end}
canvas{max-width:100%}
.footnote{font-size:var(--fs-sm);color:var(--ink-faint);margin-top:20px;text-align:center}
@media(max-width:1100px){.cols{grid-template-columns:minmax(0,1fr)}.grid4{grid-template-columns:repeat(2,minmax(0,1fr))}}

/* ===== placeholder screens ===== */
.placeholder-panel{text-align:center;padding:34px var(--sp-4)}
.placeholder-title{font-size:var(--fs-h2);font-weight:700;color:var(--ink-soft);margin-bottom:var(--sp-2)}
.placeholder-desc{font-size:var(--fs-body);color:var(--ink-faint)}

/* ===== 口座コンボ ===== */
.combo,.combo-plain{position:relative;display:flex;flex-direction:column;gap:var(--sp-1)}
.combo-label{font-size:var(--fs-sm);line-height:var(--lh-tight);color:var(--ink-soft)}
/* 「すべて（通貨別合計）」が収まればよく、220pxは過大だった */
.combo-input{min-width:200px}
.combo-list{
  position:absolute;top:100%;left:0;margin-top:2px;width:280px;max-height:260px;overflow-y:auto;
  background:#fdf6e4;border:1px solid #bda876;border-radius:7px;box-shadow:var(--shadow);z-index:30;
}
.combo-item{padding:7px 10px;font-size:var(--fs-body);line-height:var(--lh-base);cursor:pointer;border-bottom:1px dashed #ddcba0}
.combo-item:last-child{border-bottom:0}
.combo-item:hover,.combo-item.hi{background:#e9dcbd}
.combo-item .cur{color:var(--ink-faint);font-size:var(--fs-sm);margin-left:6px}
.combo-empty{padding:10px;font-size:var(--fs-body);color:var(--ink-faint);text-align:center}

/* ===== 月送り ===== */
.monthnav{display:flex;align-items:center;gap:var(--sp-2);height:var(--ctl-h)}
/* 「2026年07月」が収まる幅。110pxだと月送りの塊が215pxになり、
   フィルタ行の1行に収まらなくなっていた */
.monthnav-label{font-size:var(--fs-h3);line-height:var(--ctl-h);min-width:96px;text-align:center}
/* 口座プルダウン＋順送り矢印（本人指示 2026-07-30: 検索をやめてプルダウンに）。
   月送りと同じ .monthnav の骨格を使う。口座名＋通貨が収まる最低幅を持たせつつ、
   フィルタ行が折り返さないよう上限も決める（実測: 最長で約230px） */
.accountnav select{min-width:190px;max-width:240px}
@media(max-width:820px){
  .accountnav{width:100%}
  .accountnav select{flex:1 1 0;min-width:0;max-width:none}
}

/* ===== 同期状態 ===== */
.sync-badge{
  margin-left:auto;display:flex;align-items:center;gap:var(--sp-2);font-family:'M PLUS 1p','Meiryo',sans-serif;
  font-size:var(--fs-body);line-height:1;height:var(--ctl-h);padding:0 14px;
  border-radius:8px;border:1px solid #c3ab77;background:#efe3c4;
  color:var(--ink);cursor:pointer;
}
.sync-badge.state-ok{border-color:#8fbb7a;background:#e2eed7;color:var(--profit)}
.sync-badge.state-delayed{border-color:#e0b96a;background:#f5e7c9;color:var(--warn)}
.sync-badge.state-error{border-color:#d9a49a;background:#f3ded6;color:var(--loss)}
.sync-caret{font-size:var(--fs-xs);line-height:1}
.sync-detail{margin-top:10px;border-top:1px dashed #ddcba0;padding-top:10px}
.state-dot{display:inline-block;width:9px;height:9px;border-radius:50%;margin-right:6px}
.state-dot.ok{background:var(--profit)}
.state-dot.delayed{background:var(--warn)}
.state-dot.error{background:var(--loss)}
.state-dot.never{background:#9a8768}
/* レポート手動取込の口座。巡回しないのが正常なので警告色にしない */
.state-dot.import{background:var(--blue)}
.state-text{font-size:var(--fs-sm)}
.state-text.ok{color:var(--profit)}
.state-text.delayed{color:var(--warn)}
.state-text.error{color:var(--loss)}
.state-text.never{color:var(--ink-faint)}
.state-text.import{color:var(--blue)}

.banner-error{
  background:linear-gradient(180deg,#c34a3c,#9c2c20);color:#fff;border-radius:10px;
  padding:10px var(--sp-4);margin-bottom:14px;font-size:var(--fs-h3);box-shadow:var(--shadow);
}
/* 成功メッセージ（.bt-import-ok 等）と同じ画面に交互に出るので寸法をそろえる */
.inline-error{
  background:#f3ded6;border:1px solid #d3a08c;color:var(--loss);border-radius:8px;
  padding:var(--sp-3) var(--sp-4);font-size:var(--fs-body);line-height:var(--lh-base);
  margin-bottom:var(--sp-3);
}
.empty-msg{color:var(--ink-faint);font-size:var(--fs-body);text-align:center;padding:18px 0}

/* ===== 統計（通貨別） ===== */
.currency-block{margin-bottom:14px}
.currency-block:last-child{margin-bottom:0}
.currency-block h4{font-size:var(--fs-h3);line-height:var(--lh-tight);color:var(--ink-soft);margin-bottom:var(--sp-2);display:flex;align-items:center;gap:6px}
.currency-block h4 .cur-badge{
  font-family:'DotGothic16','MS Gothic',monospace;background:#3b2a1a;color:#f3e6c3;border-radius:5px;
  padding:2px var(--sp-2);font-size:var(--fs-sm);line-height:1.4;
}
.stat.mini{
  padding:10px var(--sp-3);
  /* 補足行（勝239/負114 等）の有無で枠の高さが52px/65pxに割れて
     バラバラに見えていた（本人指示 2026-07-30: 全部同じ枠サイズに）。
     2行構成のカードの実測高65pxを全カードの最低枠にする。
     .stat の align-items:center で1行カードの中身は上下中央に座る */
  min-height:65px;
}
.stat.mini .vl{font-size:var(--fs-h2)}

/* ===== 口座編集モーダル ===== */
.modal-bg{
  position:fixed;inset:0;background:rgba(20,12,5,.55);z-index:80;
  display:flex;align-items:center;justify-content:center;padding:var(--sp-4);
}
.modal-bg[hidden]{display:none}
.modal{
  background:var(--parch2);border:1px solid var(--card-edge);border-radius:12px;
  box-shadow:var(--shadow);padding:18px 20px;width:100%;max-width:420px;
}
.modal h3{font-size:var(--fs-h2);line-height:var(--lh-tight);margin-bottom:var(--sp-2)}
.modal-error{color:var(--loss);font-size:var(--fs-sm);margin-top:var(--sp-2)}
.modal-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:14px}

/* ===== mobile ===== */
.mbar,.bottomnav,.drawer-bg{display:none}
@media(max-width:820px){
  /* 型スケール・余白・部品高をここで一括して差し替える。
     画面別CSSがそれぞれモバイル用の font-size を持たなくて済むようにするのが狙い。 */
  :root{
    --fs-h1:16.5px; --fs-h2:14px; --fs-h3:12.5px;
    --fs-body:12px; --fs-sm:11px; --fs-xs:10px;
    --fs-cell:9.5px; --fs-cell-p:10px; --fs-cell-t:8.5px;
    --ctl-h:32px; --ctl-h-sm:24px;
  }
  html{font-size:14px}
  .app{grid-template-columns:minmax(0,1fr)}
  main{padding:12px 12px 92px; min-width:0}

  .side{
    position:fixed;left:0;top:0;bottom:0;width:240px;z-index:60;height:100dvh;
    transform:translateX(-105%);transition:transform .25s ease;
    box-shadow:4px 0 18px rgba(0,0,0,.5);
  }
  body.drawer-open .side{transform:translateX(0)}
  .drawer-bg{display:block;position:fixed;inset:0;background:rgba(20,12,5,.55);z-index:55;
    opacity:0;pointer-events:none;transition:opacity .25s}
  body.drawer-open .drawer-bg{opacity:1;pointer-events:auto}

  .mbar{
    display:flex;align-items:center;gap:var(--sp-3);position:sticky;top:0;z-index:50;
    background:linear-gradient(180deg,#221609,#171009);border-bottom:2px solid #0c0805;
    padding:10px 14px;color:#f0e0b4;
  }
  .mbar .burger{font-size:20px;line-height:1;background:none;border:1px solid #5a4327;color:var(--gold);
    border-radius:7px;padding:4px 10px;cursor:pointer}
  /* DQ風の小さなウィンドウ札。表示内容は常に固定文字列「PIPS QUEST」なので
     （page-titleと違い画面ごとに文字数が変わらない）、375pxでもあふれない。 */
  .mbar .mtitle{
    font-size:var(--fs-h2);line-height:var(--lh-tight);color:#fdf3d8;text-shadow:0 2px 0 #4a0b06;
    padding:3px 10px;border:2px solid var(--parch2);border-radius:6px;
    box-shadow:inset 0 0 0 1px var(--wood);
  }

  .grid4{grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}
  .stat{padding:11px var(--sp-3);gap:9px}
  .stat .ic{font-size:22px}
  .cols{grid-template-columns:minmax(0,1fr);gap:10px}
  .panel{padding:var(--sp-3) var(--sp-3);margin-bottom:10px}
  .panel h3{flex-wrap:wrap;gap:6px}

  .tscroll table{min-width:560px}

  .cal{gap:3px}
  /* 左右のpaddingは2pxまで削る。375pxでは1セルの内容幅が34pxしかなく、
     4pxだと数字1文字ぶん足りずに損益があふれていた（実測15/23セル）。 */
  .cal .cd{min-height:52px;padding:3px 2px;border-radius:5px}
  /* 狭い画面は丸めた表記に切り替える */
  .cal .cd .p .p-full{display:none}
  .cal .cd .p .p-compact{display:inline}

  .form-row{grid-template-columns:minmax(0,1fr);gap:5px}
  /* スタディの520px調整（padding圧縮）を参考にした軽い詰め。
     文字サイズは --fs-h1 がモバイル値へ既存トークンで自動的に縮むため、
     ここでは触らない（min-heightは元々未設定なので対象外）。 */
  .page-title{flex-wrap:wrap;padding:7px 14px}
  .filters{gap:10px}
  .combo-input{min-width:0;width:100%}
  .sync-badge{margin-left:0;width:100%;justify-content:space-between}

  .bottomnav{
    display:grid;grid-template-columns:repeat(5,1fr);position:fixed;left:0;right:0;bottom:0;z-index:50;
    background:linear-gradient(180deg,#26180d,#171009);border-top:3px solid #0c0805;
    padding:6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottomnav button{
    background:none;border:0;color:#a68e63;font-family:'DotGothic16','MS Gothic',monospace;
    font-size:var(--fs-xs);line-height:var(--lh-tight);
    display:flex;flex-direction:column;align-items:center;gap:3px;padding:5px 0;cursor:pointer;border-radius:8px;
  }
  .bottomnav button .bi{font-size:19px;line-height:1}
  /* ボトムナビも同じドット絵に */
  .bottomnav button .bi{
    font-size:0;width:20px;height:20px;
    background:no-repeat center / 19px 19px;
  }
  .bottomnav button[data-s="dash"] .bi{background-image:var(--icon-dash)}
  .bottomnav button[data-s="trades"] .bi{background-image:var(--icon-trades)}
  .bottomnav button[data-s="calendar"] .bi{background-image:var(--icon-calendar)}
  .bottomnav button[data-s="stats"] .bi{background-image:var(--icon-stats)}
  .bottomnav button[data-s="goals"] .bi{background-image:var(--icon-goals)}

  .bottomnav button.on{color:var(--gold);background:rgba(230,201,121,.12)}
}
@media(max-width:400px){
  .grid4{gap:7px}.stat{flex-direction:column;align-items:flex-start;gap:var(--sp-1)}
}
@media(prefers-reduced-motion:reduce){
  .side,.drawer-bg{transition:none}
  .nav-item.active::before{animation:none} /* ▶カーソルの点滅を止める */
}
