:root {
  --bg: #0d1117;
  --card: #161b22;
  --card2: #1c2230;
  --line: #2a3140;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #1f6feb;
  --green: #2ea043;
  --red: #f85149;
  --gold: #d29922;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; }
body { padding-bottom: calc(64px + var(--safe-bottom)); }

#topbar { position: sticky; top: 0; z-index: 10; background: var(--card);
  padding: calc(10px + var(--safe-top)) 16px 10px; border-bottom: 1px solid var(--line);
  display: flex; align-items: baseline; gap: 10px; }
#title { font-size: 18px; margin: 0; font-weight: 700; }
#subtitle { font-size: 12px; color: var(--muted); }

#view { padding: 14px 14px 24px; max-width: 640px; margin: 0 auto; }
.loading { color: var(--muted); text-align: center; padding: 40px 0; }

#tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom); }
#tabbar button { background: none; border: 0; color: var(--muted);
  font-size: 10px; padding: 8px 0 9px; display: flex; flex-direction: column;
  align-items: center; gap: 3px; cursor: pointer; }
#tabbar button span { font-size: 20px; }
#tabbar button.active { color: var(--accent); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; margin-bottom: 12px; }
.card h2 { margin: 0 0 10px; font-size: 14px; color: var(--muted); font-weight: 600; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.stat { background: var(--card2); border-radius: 12px; padding: 12px; text-align: center; }
.stat .label { font-size: 11px; color: var(--muted); }
.stat .value { font-size: 18px; font-weight: 700; margin-top: 4px; }
.pos { color: var(--green); } .neg { color: var(--red); }

.row { display: flex; justify-content: space-between; align-items: center;
  padding: 11px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .main { font-size: 14px; } .row .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.row .amt { font-weight: 700; font-size: 15px; }

.badge { display: inline-block; font-size: 10px; padding: 2px 7px; border-radius: 999px;
  background: var(--card2); color: var(--muted); margin-left: 6px; vertical-align: middle; }
.badge.current { background: rgba(46,160,67,.18); color: var(--green); }
.badge.upcoming { background: rgba(31,111,235,.18); color: var(--accent); }
.badge.unknown, .badge.expired { background: rgba(139,148,158,.15); color: var(--muted); }
.badge.high { background: rgba(46,160,67,.18); color: var(--green); }
.badge.low { background: rgba(210,153,34,.16); color: var(--gold); }
.badge.P { background: rgba(31,111,235,.18); color: #79c0ff; }
.badge.S { background: rgba(210,153,34,.18); color: var(--gold); }

input, select, textarea, button.btn { width: 100%; background: var(--card2);
  border: 1px solid var(--line); border-radius: 10px; color: var(--text);
  font-size: 16px; padding: 11px 12px; margin-top: 6px; }
label { font-size: 12px; color: var(--muted); display: block; margin-top: 12px; }
button.btn { background: var(--accent); border: 0; font-weight: 700; margin-top: 16px;
  cursor: pointer; }
button.btn.ghost { background: var(--card2); color: var(--text); }
.field2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.search { position: sticky; top: calc(40px + var(--safe-top)); z-index: 5;
  background: var(--bg); padding: 8px 0; }
.chips { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 6px 12px; border-radius: 999px; background: var(--card2);
  border: 1px solid var(--line); color: var(--muted); cursor: pointer; }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.score { font-weight: 700; font-size: 16px; min-width: 42px; text-align: right; }
.score.hi { color: var(--green); } .score.mid { color: var(--gold); } .score.lo { color: var(--muted); }

.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.disclaimer { font-size: 11px; color: var(--muted); line-height: 1.5; margin-top: 10px;
  background: var(--card2); padding: 10px; border-radius: 10px; }
.result { font-size: 22px; font-weight: 800; text-align: center; margin: 8px 0; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
a { color: #79c0ff; }
.backlink { color: var(--accent); font-size: 14px; padding: 4px 0; display: inline-block; cursor: pointer; }

/* 月ナビ */
.monthnav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.monthnav button { width: 44px; height: 40px; font-size: 20px; background: var(--card2);
  border: 1px solid var(--line); border-radius: 10px; color: var(--text); cursor: pointer; }
.monthnav .ym { font-size: 16px; font-weight: 700; text-align: center; }
.monthnav .ym .tot { display: block; font-size: 15px; margin-top: 2px; }

/* カレンダー */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { text-align: center; font-size: 11px; color: var(--muted); padding: 2px 0; }
.cal .dow.sat { color: #79c0ff; } .cal .dow.sun { color: #ff7b72; }
.cal-cell { aspect-ratio: 1 / 1; background: var(--card2); border-radius: 9px; padding: 4px 3px;
  display: flex; flex-direction: column; justify-content: space-between; min-height: 46px; cursor: pointer; }
.cal-cell.empty { background: transparent; cursor: default; }
.cal-cell .d { font-size: 11px; color: var(--muted); }
.cal-cell.today .d { color: var(--accent); font-weight: 700; }
.cal-cell .v { font-size: 11px; font-weight: 700; text-align: right; line-height: 1.1; }
.cal-cell.win { background: rgba(46,160,67,.16); }
.cal-cell.lose { background: rgba(248,81,73,.14); }

/* 収支表 */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { padding: 9px 6px; border-bottom: 1px solid var(--line); text-align: right; }
table.tbl th { color: var(--muted); font-weight: 600; font-size: 11px; }
table.tbl th:first-child, table.tbl td:first-child { text-align: left; }

/* グラフ */
.chart { width: 100%; height: 150px; }
.chart svg { width: 100%; height: 100%; display: block; }

/* 狙い目ヒーロー */
.card.hero { border-color: var(--accent); }
.verdict { text-align: center; font-size: 20px; font-weight: 800; padding: 12px; border-radius: 12px; margin: 6px 0 10px; }
.verdict .vsub { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 3px; }
.verdict-go { background: rgba(46,160,67,.18); color: var(--green); }
.verdict-mid { background: rgba(210,153,34,.16); color: var(--gold); }
.verdict-no { background: rgba(248,81,73,.14); color: var(--red); }

/* 天井ゲージ */
.gauge { position: relative; height: 14px; background: var(--card2); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.gauge-zone { position: absolute; top: 0; bottom: 0; background: rgba(46,160,67,.35); }
.gauge-marker { position: absolute; top: -3px; bottom: -3px; width: 3px; background: #fff; box-shadow: 0 0 4px rgba(255,255,255,.8); }
.gauge-lab { position: relative; display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-top: 4px; height: 14px; }
.gauge-lab .m { position: absolute; transform: translateX(-50%); color: var(--green); font-weight: 700; }
