/* 潮目（Shiome）静的サイト — デザイントークンとコンポーネント。
   旧 app/ui.py のダーク＋ティールの識別性を継承しつつ、コントラストを引き上げた改訂版:
   - muted 文字を 5.0:1 → 7.2:1 に強化。旧 faint 色は負荷情報から全廃（装飾のみ soft）。
   - 行ボーダー #1c2531 → #2a3445（行の区切りを視認可能に）。
   - モバイルでスパークライン・ミニバーを消さない（grid-template-areas で再配置）。
   - :focus-visible を必ず可視化（キーボード操作対応）。 */

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #1b222c;
  --ink: #e6edf3;
  --muted: #a9b6c5;        /* 第二情報。7.2:1 on surface */
  --soft: #8b98a9;         /* 装飾・補助のみ（負荷情報には使わない） */
  --line: #2a3445;
  --accent: #2dd4bf;
  --accent-dk: #5eead4;
  --accent-us: #34d399;
  --up: #34d399;
  --down: #f87171;
  --maxw: 1140px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: 'Inter', 'Noto Sans JP', system-ui, -apple-system, sans-serif;
  font-size: 16px; line-height: 1.65;
  overflow-x: hidden;
}
a { color: var(--accent-dk); }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--accent); color: #06231f;
  padding: 8px 14px; border-radius: 0 0 8px 0; font-weight: 700; z-index: 100; }
.skip-link:focus { left: 0; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
main.wrap { padding-top: 18px; padding-bottom: 60px; }

/* ---- ヘッダー / ナビ ---- */
.site-head {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11, 16, 24, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-head .bar { display: flex; align-items: center; gap: 22px; padding: 14px 22px;
  max-width: var(--maxw); margin: 0 auto; }
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; white-space: nowrap; }
.brand .ja { font-size: 1.62rem; font-weight: 800; color: var(--ink); letter-spacing: .08em; }
.brand .en { font-size: .68rem; font-weight: 700; color: var(--accent); letter-spacing: .32em; }
nav.main-nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1;
  padding-left: 20px; margin-left: 2px; border-left: 1px solid var(--line); }
nav.main-nav::-webkit-scrollbar { display: none; }
nav.main-nav a {
  text-decoration: none; color: var(--muted); font-size: .96rem; font-weight: 700;
  padding: 9px 15px; border-radius: 10px; white-space: nowrap;
}
nav.main-nav a:hover { background: rgba(255,255,255,.05); color: var(--ink); }
nav.main-nav a[aria-current="page"] { background: rgba(45,212,191,.16); color: var(--accent);
  font-weight: 800; box-shadow: inset 0 -2px 0 var(--accent); }

/* ---- 鮮度バー ---- */
.fresh-bar { font-size: .76rem; color: var(--muted); padding: 7px 20px;
  max-width: var(--maxw); margin: 0 auto; display: flex; gap: 14px; flex-wrap: wrap; }
.fresh-bar b { color: var(--ink); font-weight: 600; }
.fresh-warn { display: none; background: rgba(248,113,113,.14); border: 1px solid rgba(248,113,113,.4);
  color: #fda4af; border-radius: 10px; padding: 9px 14px; margin: 10px 0 0;
  font-size: .84rem; font-weight: 600; }
.fresh-warn.show { display: block; }

/* ---- ヒーロー ---- */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(900px 300px at 88% -40%, rgba(45,212,191,.20), transparent 60%),
    linear-gradient(135deg, #0b1622 0%, #102433 52%, #0c3330 100%);
  border: 1px solid #223344; border-radius: 20px; padding: 26px 28px; margin: 14px 0 20px;
}
.hero h1 { font-size: 1.85rem; font-weight: 800; margin: 0 0 6px; letter-spacing: .3px;
  display: flex; align-items: baseline; gap: 13px; flex-wrap: wrap; }
.hero h1 .en { font-size: .85rem; font-weight: 700; color: #7fe9df; letter-spacing: .32em; }
.hero p { margin: 0; color: #bfcddc; font-size: .94rem; max-width: 64ch; }
.hero p b { color: #e3eef5; }
.hero .asof { margin-top: 12px; font-size: .8rem; color: #9db4c6; }
.hero .asof b { color: #dcebf3; font-weight: 600; }

/* ---- 地合いウェザーレポート ---- */
.regime { background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px 20px; margin: 0 0 20px; }
.regime .top { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.regime .ttl { font-size: .8rem; font-weight: 700; color: var(--muted); letter-spacing: .05em; }
.regime .label { font-size: 1.5rem; font-weight: 800; color: var(--ink); }
.regime .score { font-size: .95rem; font-weight: 700; color: var(--muted); }
.regime .score b { color: var(--accent); font-size: 1.15rem; }
.gauge { position: relative; height: 10px; border-radius: 6px; margin: 12px 0 6px;
  background: linear-gradient(90deg, #f87171 0%, #fbbf24 35%, #94a3b8 50%, #5eead4 65%, #34d399 100%);
  opacity: .9; }
.gauge .pin { position: absolute; top: -4px; width: 4px; height: 18px; border-radius: 2px;
  background: #fff; box-shadow: 0 0 0 2px rgba(13,17,23,.8); }
.gauge-ends { display: flex; justify-content: space-between; font-size: .7rem; color: var(--soft); }
.regime .chips { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.chip { background: var(--surface2); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 13px; font-size: .8rem; color: var(--muted); }
.chip b { color: var(--ink); font-weight: 700; }
.regime .more { font-size: .8rem; font-weight: 700; }

/* ---- 相場サマリ ---- */
.mkt-grp { margin: 0 0 12px; }
.mkt-hd { font-size: .85rem; font-weight: 800; color: var(--ink); margin: 0 0 8px;
  display: flex; align-items: center; gap: 7px; }
.mkt-hd .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.mkt-hd.us .dot { background: var(--accent-us); }
.mkt-hd .asof { font-size: .72rem; font-weight: 600; color: var(--muted); }
.mkt { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 10px; }
.mkt .it { background: var(--surface); border: 1px solid var(--line); border-radius: 13px;
  padding: 11px 14px; min-width: 0; }
.mkt .nm { font-size: .75rem; color: var(--muted); font-weight: 700; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.mkt .row2 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 4px; }
.mkt .lv { font-size: 1.16rem; font-weight: 800; color: var(--ink); line-height: 1.1; }
.mkt .pc { font-size: .92rem; font-weight: 800; white-space: nowrap; }
.mkt .pc.up { color: var(--up); }
.mkt .pc.dn { color: var(--down); }

/* ---- KPI ---- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 13px; margin: 4px 0 24px; }
.kpi { background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.012)), var(--surface);
  border: 1px solid var(--line); border-top: 2px solid rgba(45,212,191,.4);
  border-radius: 15px; padding: 14px 16px; min-width: 0; }
.kpi .lab { font-size: .72rem; color: var(--muted); font-weight: 600; letter-spacing: .04em; }
.kpi .val { font-size: 1.1rem; font-weight: 800; color: var(--accent-dk); line-height: 1.3;
  margin-top: 4px; overflow-wrap: anywhere; }
.kpi .sub { font-size: .73rem; color: var(--muted); margin-top: 3px; }

/* ---- セクション見出し・注記 ---- */
.sec { font-size: 1.1rem; font-weight: 800; color: var(--ink); margin: 28px 0 6px;
  padding-left: 11px; border-left: 4px solid var(--accent); }
.sec.us { border-left-color: var(--accent-us); }
.sec-sub { font-size: .84rem; color: var(--muted); margin: 0 0 14px; max-width: 86ch; }
.note { font-size: .8rem; color: var(--muted); line-height: 1.75; margin: 0 0 18px;
  padding: 11px 15px; background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: 10px; }
.note b { color: var(--ink); }
.note.warn { border-left-color: #f59e0b; }
.src { font-size: .74rem; color: var(--soft); margin: 6px 0 18px; }
.src a { color: var(--soft); }

/* ---- ランキング行 ---- */
.legend { display: flex; flex-wrap: wrap; gap: 13px; margin: 2px 0 14px; }
.legend .it { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; color: var(--muted); }
.legend .it small { color: var(--soft); }
a.row-link { text-decoration: none; display: block; color: inherit; }
.row {
  position: relative; display: grid;
  grid-template-columns: 42px minmax(0,1.8fr) minmax(0,2.6fr) 124px 116px;
  grid-template-areas: "rank name flows mini spark";
  align-items: center; gap: 12px 14px;
  background: var(--surface); border: 1px solid #243043; border-radius: 14px;
  padding: 13px 18px 13px 20px; margin-bottom: 9px; overflow: hidden;
}
.row::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--accent); opacity: calc(0.22 + 0.78 * var(--w, 0)); }
a.row-link:hover .row, a.row-link:focus-visible .row {
  background: var(--surface2); border-color: rgba(45,212,191,.4); }
.row.top { border-color: rgba(45,212,191,.4);
  background: linear-gradient(135deg, rgba(45,212,191,.08), rgba(45,212,191,.02) 44%), var(--surface); }
.row.top::before { width: 5px; }
.us-block { --accent: var(--accent-us); }
.us-block .row.top { border-color: rgba(52,211,153,.42); }
.rank { grid-area: rank; font-size: 1.3rem; font-weight: 800; color: var(--soft);
  text-align: center; font-variant-numeric: tabular-nums; }
.row.top .rank { color: var(--accent); }
.name-cell { grid-area: name; min-width: 0; }
.name { font-size: 1.04rem; font-weight: 700; color: var(--ink); }
.name .go { font-size: .72rem; color: var(--accent); font-weight: 700; margin-left: 7px; }
.desc { display: block; font-size: .72rem; color: var(--muted); font-weight: 400; margin-top: 3px; line-height: 1.5; }
.meta { font-size: .73rem; color: var(--muted); font-weight: 500; margin-top: 6px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meta .code { color: var(--soft); }
.corr { font-size: .72rem; color: #8fdcc0; font-weight: 600; }
.flows { grid-area: flows; display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; }
.flow { text-align: center; }
.flow .p { font-size: .66rem; color: var(--muted); font-weight: 600; }
.flow .v { font-size: 1rem; font-weight: 800; color: var(--ink); line-height: 1.15;
  font-variant-numeric: tabular-nums; }
.flow .v .u { font-size: .68em; opacity: .65; font-weight: 600; margin-left: 1px; }
.flow .r { font-size: .64rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.flow .r b { color: var(--accent); }
.flow.lead .v { color: var(--accent); }
.mini-wrap { grid-area: mini; }
.mini { font-size: .7rem; color: var(--muted); }
.mini + .mini { margin-top: 5px; }
.bar { height: 5px; border-radius: 4px; background: rgba(255,255,255,.08); overflow: hidden; margin-top: 3px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.spark { grid-area: spark; }
.spark svg { display: block; margin-left: auto; }

/* 段階バッジ */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .73rem; font-weight: 700;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.badge.lg { font-size: .94rem; font-weight: 800; padding: 6px 16px;
  border: 1px solid rgba(255,255,255,.14); }
.badge.lg .dot { width: 9px; height: 9px; }

/* ---- 導線カード ---- */
.navcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 12px;
  margin: 6px 0 8px; }
.navcard { display: block; text-decoration: none; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.navcard:hover { border-color: rgba(45,212,191,.45); background: var(--surface2); }
.navcard .t { font-size: .98rem; font-weight: 800; color: var(--ink); display: flex;
  align-items: center; gap: 8px; }
.navcard .d { font-size: .8rem; color: var(--muted); margin-top: 6px; line-height: 1.6; }
.navcard .a { font-size: .78rem; color: var(--accent); font-weight: 700; margin-top: 8px; }

/* ---- テーブル ---- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 13px;
  background: var(--surface); margin: 0 0 8px; }
table.tbl { border-collapse: collapse; width: 100%; font-size: .86rem; min-width: 560px; }
.tbl th, .tbl td { padding: 9px 12px; text-align: right; white-space: nowrap;
  border-bottom: 1px solid #232e3d; }
.tbl th:first-child, .tbl td:first-child,
.tbl th.l, .tbl td.l { text-align: left; }
.tbl thead th { position: sticky; top: 0; background: var(--surface2); color: var(--muted);
  font-size: .76rem; font-weight: 700; z-index: 1; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: rgba(255,255,255,.025); }
.tbl td { color: var(--ink); font-variant-numeric: tabular-nums; }
.tbl td.dim { color: var(--muted); }
.tbl .pos { color: var(--up); font-weight: 700; }
.tbl .neg { color: var(--down); font-weight: 700; }
.tbl a { font-weight: 700; }
table.sortable thead th { cursor: pointer; user-select: none; }
table.sortable thead th:hover { color: var(--ink); }
table.sortable thead th .arr { opacity: .55; font-size: .85em; margin-left: 3px; }
.tbl .spark-cell svg { display: block; }

/* ---- タブ ---- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.tabs button { background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  font: inherit; font-size: .84rem; font-weight: 700; padding: 7px 16px; border-radius: 999px;
  cursor: pointer; }
.tabs button[aria-selected="true"] { background: rgba(45,212,191,.15); color: var(--accent);
  border-color: rgba(45,212,191,.45); }
.tab-panel[hidden] { display: none; }

/* ---- チャート ---- */
.chart { width: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; margin: 0 0 16px; }
.chart-fallback { padding: 18px; color: var(--muted); font-size: .85rem; }

/* ---- 統計カード（シグナル） ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 11px;
  margin: 0 0 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 13px;
  padding: 12px 15px; }
.stat .l { font-size: .71rem; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 1.18rem; font-weight: 800; color: var(--ink); margin-top: 3px;
  font-variant-numeric: tabular-nums; }
.stat .v small { font-size: .68em; color: var(--muted); font-weight: 600; }
.stat .v.accent { color: var(--accent-dk); }
.hbar { display: inline-block; height: 8px; border-radius: 4px; background: var(--accent);
  vertical-align: middle; min-width: 2px; }
.hbar.neg { background: var(--down); }

/* ---- ドキュメント（about/用語/免責） ---- */
.doc { background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 22px 26px; line-height: 1.9; font-size: .92rem; margin-bottom: 18px; }
.doc h3 { margin: 20px 0 8px; font-size: 1.02rem; color: var(--ink); }
.doc h3:first-child { margin-top: 0; }
.doc p, .doc li { color: #c9d3df; }
.doc b { color: var(--ink); }
.doc table { border-collapse: collapse; margin: 10px 0; font-size: .86rem; width: 100%; }
.doc table th, .doc table td { border: 1px solid var(--line); padding: 7px 11px; text-align: left; }
.doc table th { background: var(--surface2); color: var(--muted); }
.doc code { background: var(--surface2); border-radius: 5px; padding: 1px 6px; font-size: .85em; }
.term { padding: 14px 0; border-bottom: 1px solid var(--line); }
.term:last-child { border-bottom: none; }
.term .t { font-size: .97rem; font-weight: 700; color: var(--ink); display: flex;
  align-items: center; gap: 8px; }
.term .d { font-size: .87rem; color: #b9c5d3; line-height: 1.85; margin-top: 5px; }
.term .d b { color: var(--ink); }
.formula { background: var(--surface2); border-radius: 9px; padding: 10px 14px; margin: 8px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .84rem;
  color: var(--accent-dk); overflow-x: auto; white-space: nowrap; }
.rel { padding: 16px 0; border-bottom: 1px solid var(--line); }
.rel:first-child { padding-top: 0; }
.rel:last-child { border-bottom: none; padding-bottom: 0; }
.rel-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rel-head .ver { font-size: 1rem; font-weight: 800; color: #06231f; background: var(--accent);
  border-radius: 7px; padding: 2px 12px; }
.rel-head .date { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.rel-head .ttl { font-size: .92rem; font-weight: 700; color: var(--ink); }
.rel ul { margin: 11px 0 0; padding-left: 1.2em; }
.rel li { font-size: .87rem; color: #b9c5d3; line-height: 1.8; margin-bottom: 3px; }

/* ---- スポンサー（広告・PR明示） ---- */
.ad-wrap { margin: 26px 0 8px; }
.ad-label { display: inline-flex; align-items: center; gap: 6px; font-size: .7rem; font-weight: 700;
  color: var(--soft); letter-spacing: .06em; margin-bottom: 8px; }
.ad-label .pr { background: rgba(148,163,184,.16); color: #aebdcb; border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 6px; font-size: .66rem; letter-spacing: .08em; }
.ad-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 12px; }
.ad-card { background: var(--surface); border: 1px solid var(--line); border-radius: 13px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.ad-card .nm { font-size: .96rem; font-weight: 800; color: var(--ink); }
.ad-card .bl { font-size: .8rem; color: var(--muted); line-height: 1.6; flex: 1; }
.ad-card .nt { font-size: .72rem; color: var(--accent-dk); }
.ad-card .cta { display: inline-block; align-self: flex-start; text-decoration: none;
  font-size: .8rem; font-weight: 700; color: #06241f; background: var(--accent);
  border-radius: 8px; padding: 7px 14px; }
.ad-card .cta:hover { background: var(--accent-dk); color: #06241f; }
.ad-foot { font-size: .72rem; color: var(--soft); margin-top: 9px; line-height: 1.65; }

/* ---- フッター ---- */
.site-foot { border-top: 1px solid var(--line); margin-top: 30px; }
.site-foot .inner { max-width: var(--maxw); margin: 0 auto; padding: 22px 20px 34px;
  font-size: .78rem; color: var(--muted); }
.site-foot nav { display: flex; gap: 4px 16px; flex-wrap: wrap; margin-bottom: 10px; }
.site-foot a { color: var(--muted); text-decoration: none; font-weight: 600; }
.site-foot a:hover { color: var(--accent); }
.site-foot .copy { color: var(--soft); }

/* ---- 戻るリンク ---- */
.backlink { display: inline-block; margin: 4px 0 12px; font-size: .85rem; font-weight: 700;
  color: var(--accent-dk); text-decoration: none; }
.backlink:hover { color: var(--accent); }

/* ============ レスポンシブ ============ */
@media (max-width: 880px) {
  .row { grid-template-columns: 36px minmax(0,1.6fr) minmax(0,2.4fr) 110px;
    grid-template-areas: "rank name flows spark" "mini mini mini mini"; }
  .mini-wrap { display: flex; gap: 16px; }
  .mini-wrap .mini { flex: 1; }
}
@media (max-width: 760px) {
  body { font-size: 15px; }
  .wrap { padding: 0 14px; }
  .site-head .bar { padding: 10px 15px; gap: 13px; }
  .brand .ja { font-size: 1.42rem; }
  nav.main-nav { padding-left: 13px; }
  nav.main-nav a { font-size: .92rem; padding: 8px 12px; }
  .hero { padding: 20px 17px; border-radius: 17px; }
  .hero h1 { font-size: 1.5rem; }
  .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
  /* 行: スパークライン・ミニバーは消さず再配置（旧UIの情報消失を解消） */
  .row { grid-template-columns: 30px minmax(0,1fr) 96px;
    grid-template-areas: "rank name spark" "flows flows flows" "mini mini mini";
    padding: 12px 13px 12px 16px; gap: 10px 10px; }
  .rank { font-size: 1.05rem; }
  .name { font-size: .98rem; }
  .flow .v { font-size: .92rem; }
  .doc { padding: 18px 16px; }
  .regime .label { font-size: 1.3rem; }
}
@media (max-width: 480px) {
  body { font-size: 14px; }
  .hero h1 { font-size: 1.32rem; }
  .flow .p { font-size: .62rem; }
  .mini-wrap { flex-direction: column; gap: 5px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
