/* オッズポケット — トークンは DESIGN.md と同じ名前。実測コントラストは DESIGN.md に。 */
:root {
  --paper: #f6f5f1;
  --paper-2: #efede6;
  --chip: #e9e7e0;
  --ink: #1c1b19;
  --mute: #4b544f;
  --line: #c9c5bb;
  --edge: #867f74;
  --accent: #0b6e4f;
  --on-accent: #ffffff;
  --warn: #7a4f00;
  --danger: #a8321f;
  --zoom: 1;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15181a;
    --paper-2: #1b1f22;
    --chip: #22282b;
    --ink: #ecebe6;
    --mute: #b3bcb5;
    --line: #3a4246;
    --edge: #6f7a80;
    --accent: #4fc08d;
    --on-accent: #15181a;
    --warn: #e0a53a;
    --danger: #ff8a76;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic Medium", "Meiryo", "Noto Sans JP", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.35; text-wrap: balance; }
p { margin: 0; }
.num, .odds, .combo, .time, .yen { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

.app { zoom: var(--zoom); min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; }

/* ---- ヘッダー */
.top { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 12px 16px 4px; }
.brand { font-size: 18px; font-weight: 700; letter-spacing: 0.02em; }
.status { font-size: 14px; color: var(--mute); text-align: right; }

/* ---- 条件 */
.cond { position: sticky; top: 0; z-index: 5; background: var(--paper); border-bottom: 1.5px solid var(--line); padding: 8px 16px 8px; }
.cond-main { display: flex; flex-direction: column; gap: 8px; }
.target { display: flex; align-items: center; gap: 8px; }
.step { width: 48px; height: 48px; border-radius: var(--radius); border: 1.5px solid var(--edge); background: var(--chip); font-size: 22px; line-height: 1; }
.target-field { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 6px; border: 1.5px solid var(--edge); border-radius: var(--radius); background: var(--paper-2); padding: 0 12px; height: 48px; }
.target-field input { flex: 1; width: 100%; min-width: 0; border: 0; background: transparent; font-size: 24px; font-weight: 700; height: 46px; padding: 0; text-align: right; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.target-field input::-webkit-outer-spin-button, .target-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.target-field .unit { font-size: 16px; color: var(--mute); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1.5px solid var(--edge); background: var(--chip); font-size: 15px; line-height: 1; display: inline-flex; align-items: center; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }
.cond-sum { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.count { font-size: 17px; font-weight: 700; }
.count .num { font-size: 20px; }
.note { font-size: 14px; color: var(--mute); line-height: 1.5; }
.more { margin-top: 8px; width: 100%; min-height: 44px; border: 1.5px solid var(--edge); border-radius: var(--radius); background: transparent; font-size: 15px; color: var(--ink); display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px; text-align: left; }
.more-sum { flex: 1; min-width: 0; font-size: 14px; color: var(--mute); line-height: 1.4; }
.more-act { font-weight: 700; white-space: nowrap; }
a.btn { color: inherit; text-decoration: none; display: inline-flex; align-items: center; }
.cond-more { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; }
.cond-row { display: grid; grid-template-columns: 64px 1fr; gap: 8px; align-items: start; }
.cond-label { font-size: 14px; color: var(--mute); padding-top: 10px; }

/* ---- 一覧 */
.view { flex: 1; padding: 8px 16px 96px; display: flex; flex-direction: column; gap: 8px; }
.empty { padding: 32px 0; color: var(--mute); text-align: left; line-height: 1.8; }
.row { border: 1.5px solid var(--edge); border-radius: var(--radius); background: var(--paper-2); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.row.finished { opacity: 1; border-style: dashed; }
.row-head { display: grid; grid-template-columns: auto 1fr auto; gap: 8px 10px; align-items: baseline; }
.row-head .time { font-size: 17px; font-weight: 700; }
.row-head .race { font-size: 16px; }
.row-head .race .bet { color: var(--mute); font-size: 14px; margin-left: 6px; }
.row-head .odds { font-size: 22px; font-weight: 700; justify-self: end; }
.row-head .odds small { font-size: 14px; font-weight: 400; color: var(--mute); margin-left: 2px; }
.combos { display: flex; flex-wrap: wrap; gap: 8px; }
.combo { min-height: 44px; padding: 0 14px; border-radius: var(--radius); border: 1.5px solid var(--edge); background: var(--paper); font-size: 18px; font-weight: 700; display: inline-flex; align-items: center; letter-spacing: 0.04em; }
.combo.checked { border-color: var(--accent); }
.combo .mark { font-size: 13px; font-weight: 400; color: var(--accent); margin-left: 6px; }
.more-combos { min-height: 44px; padding: 0 12px; border-radius: var(--radius); border: 1.5px dashed var(--edge); background: transparent; font-size: 15px; color: var(--ink); }
.row-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; color: var(--mute); line-height: 1.5; }
.row-meta .warn { color: var(--warn); font-weight: 700; }
.row-meta .result { color: var(--ink); font-weight: 700; }
.section-title { font-size: 15px; color: var(--mute); margin-top: 8px; }

/* ---- チェック(台帳) */
.card { border: 1.5px solid var(--edge); border-radius: var(--radius); background: var(--paper-2); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.card h2 { font-size: 17px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 15px; line-height: 1.6; }
.kv dt { color: var(--mute); }
.kv dd { margin: 0; min-width: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kv dd.strong { font-weight: 700; font-size: 17px; }
.ledger-row { border: 1.5px solid var(--edge); border-radius: var(--radius); background: var(--paper-2); padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.ledger-row .l1 { font-size: 16px; font-weight: 700; }
.ledger-row .l2 { font-size: 14px; color: var(--mute); line-height: 1.5; }
.ledger-row .st { font-size: 15px; font-weight: 700; text-align: right; }
.ledger-row .st.hit { color: var(--accent); }
.ledger-row .st.miss { color: var(--mute); font-weight: 400; }
.ledger-row .acts { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.btn { min-height: 44px; padding: 0 16px; border-radius: var(--radius); border: 1.5px solid var(--edge); background: var(--chip); font-size: 16px; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 40px; font-size: 15px; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
select.sel { min-height: 44px; border: 1.5px solid var(--edge); border-radius: var(--radius); background: var(--chip); color: var(--ink); font: inherit; padding: 0 10px; }

/* ---- 設定 */
.zoom-chips .chip { font-size: calc(15px * var(--z, 1)); min-height: calc(40px * var(--z, 1)); }
.log { font-size: 14px; color: var(--mute); line-height: 1.6; word-break: break-all; }
.log .ng { color: var(--danger); }

/* ---- タブ */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--paper); border-top: 1.5px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tab { min-height: 56px; border: 0; background: transparent; font-size: 15px; color: var(--mute); }
.tab[aria-current="page"] { color: var(--accent); font-weight: 700; box-shadow: inset 0 3px 0 var(--accent); }

/* ---- シート */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-back { position: absolute; inset: 0; background: rgba(0,0,0,0.45); }
.sheet-body { zoom: var(--zoom); position: absolute; left: 0; right: 0; bottom: 0; background: var(--paper); border-top-left-radius: 16px; border-top-right-radius: 16px; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 84vh; max-height: calc(84svh / var(--zoom, 1)); overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-title { font-size: 17px; }
.sheet-close { min-height: 40px; padding: 0 12px; border-radius: var(--radius); border: 1.5px solid var(--edge); background: var(--chip); font-size: 15px; white-space: nowrap; }
/* 文字 130% 以上と狭い端末では、操作ボタンを 1 列に(2 列だと「気になる、で記録」が 3 行に折れる) */
:root[data-zoom="130"] .sheet-actions, :root[data-zoom="150"] .sheet-actions { grid-template-columns: 1fr; }
@media (max-width: 360px) { .sheet-actions { grid-template-columns: 1fr; } }
.sheet-line { font-size: 16px; line-height: 1.7; }
.sheet-line .big { font-size: 24px; font-weight: 700; }
.amounts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.amounts input { width: 120px; min-height: 44px; border: 1.5px solid var(--edge); border-radius: var(--radius); background: var(--paper-2); padding: 0 10px; font-size: 18px; text-align: right; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet-actions .wide { grid-column: 1 / -1; }

/* ---- 合言葉 */
.login { position: fixed; inset: 0; z-index: 30; background: var(--paper); display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.login-box h2 { font-size: 20px; }
.login-box input { min-height: 48px; border: 1.5px solid var(--edge); border-radius: var(--radius); background: var(--paper-2); padding: 0 12px; font-size: 18px; }
.login-msg { font-size: 15px; color: var(--danger); min-height: 1.5em; }

/* ---- トースト */
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 25; background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: var(--radius); font-size: 15px; }

/* ---- 状態 */
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.chip:active, .combo:active, .btn:active, .step:active { filter: brightness(0.92); }
@media (hover: hover) {
  .chip:hover, .combo:hover, .btn:hover, .step:hover, .more:hover, .more-combos:hover { border-color: var(--mute); }
}
@media (prefers-reduced-motion: no-preference) {
  .sheet-body { animation: up 160ms ease-out; }
  @keyframes up { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
}
@media (min-width: 720px) {
  .app { max-width: 720px; margin: 0 auto; }
  .tabs { max-width: 720px; margin: 0 auto; }
  .sheet-body { max-width: 720px; margin: 0 auto; }
}
