/* 色・文字・余白はここの変数だけで決める（design-rules.md、A案 黒地に金） */
:root {
  --bg: #0d0d0d;
  --surface: #1c1c1c;
  --line: #2a2a2a;
  --text: #f2f2f2;
  --sub: #9a9a9a;
  --gold: #d1a94f;
  --on-gold: #141414;
  --danger: #f07167;
  --ok: #5bbf7a;
  --radius: 16px;
  --font: -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* スマホ向け。広い画面では中央に寄せる */
#app { min-height: 100dvh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; }

/* 上の帯 */
.bar { padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); display: flex; align-items: center; gap: 8px; }
.brand { display: flex; align-items: center; gap: 8px; flex: 1; font-weight: 600; letter-spacing: 0.16em; font-size: 15px; }
.brand img { width: 24px; height: 24px; object-fit: contain; }
.brand .date { font-weight: 400; letter-spacing: 0; color: var(--sub); font-size: 13px; margin-left: 8px; }
.badge { border: 1px solid var(--line); border-radius: 999px; padding: 0 16px; min-height: 40px; background: none; color: var(--sub); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge.warn { background: var(--gold); border-color: var(--gold); color: var(--on-gold); font-weight: 600; }
.icon-btn { background: none; border: 0; color: var(--sub); min-width: 48px; height: 48px; font-size: 13px; }
.alert { margin: 0 16px; background: var(--surface); color: var(--danger); padding: 8px 16px; border-radius: var(--radius); font-size: 13px; }
.alert.info { color: var(--sub); }
.alert .btn.text { color: var(--text); min-height: 40px; padding: 0; }

main { flex: 1; padding: 16px 16px 120px; display: flex; flex-direction: column; gap: 24px; }
h1 { font-size: 18px; font-weight: 600; line-height: 1.4; margin: 0; }
.sub { color: var(--sub); font-size: 13px; margin: 0; }

/* 入力欄（ラベルを左、入力を右に並べる1行の形） */
.field { display: flex; align-items: center; gap: 16px; background: var(--surface); border-radius: var(--radius); padding: 0 16px; min-height: 52px; }
.field label { color: var(--sub); font-size: 13px; white-space: nowrap; min-width: 56px; }
.field input, .field select { flex: 1; min-width: 0; height: 52px; border: 0; background: none; text-align: right; outline: none; }
.field input::-webkit-calendar-picker-indicator { filter: invert(1); opacity: 0.6; }
.field-group { display: flex; flex-direction: column; gap: 8px; }
.error { color: var(--danger); font-size: 13px; margin: 0 16px; }

/* 今日の数字（記録の画面） */
.today { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); text-align: center; }
.today div { font-size: 13px; color: var(--sub); }
.today b { display: block; font-size: 32px; font-weight: 600; line-height: 1.2; color: var(--text); font-variant-numeric: tabular-nums; }

/* ボタン */
.btn { min-height: 52px; border-radius: var(--radius); font-weight: 600; font-size: 16px; padding: 0 16px; border: 0; background: var(--surface); color: var(--text); letter-spacing: 0.08em; }
.btn.primary { background: var(--gold); color: var(--on-gold); }
.btn.big { min-height: 76px; font-size: 18px; width: 100%; letter-spacing: 0.16em; }
.btn.text { background: none; color: var(--sub); font-weight: 400; letter-spacing: 0; }
.btn.danger-text { background: none; color: var(--danger); font-weight: 400; letter-spacing: 0; padding: 0 8px; }
.btn:active { opacity: 0.8; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row-btns { display: flex; gap: 12px; }
.row-btns .btn { flex: 1; }

/* 選択の行 */
.pick { display: flex; align-items: center; gap: 16px; min-height: 60px; padding: 0 16px; border: 0; border-radius: var(--radius); background: var(--surface); width: 100%; text-align: left; font-size: 16px; }
.pick .check { width: 24px; height: 24px; border: 1.5px solid var(--sub); border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; line-height: 1; }
.pick[aria-pressed="true"] .check, .pick[aria-checked="true"] .check { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }

/* 期間の切り替え */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border-radius: var(--radius); padding: 4px; }
.seg button { min-height: 44px; border: 0; border-radius: 12px; background: none; color: var(--sub); }
.seg button[aria-pressed="true"] { background: var(--gold); color: var(--on-gold); font-weight: 600; }

/* 数字の行 */
.metrics { display: flex; flex-direction: column; gap: 16px; }
.metric { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: baseline; }
.metric .name { color: var(--text); }
.metric .num { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric .num small { font-size: 13px; color: var(--sub); font-weight: 400; }
.meter { grid-column: 1 / 3; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 2px; }
.meter i.green { background: var(--ok); }
.meter i.yellow { background: var(--gold); }
.meter i.red { background: var(--danger); }
.rates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.rates div { background: var(--surface); border-radius: var(--radius); padding: 8px 16px; }
.rates dt { font-size: 13px; color: var(--sub); }
.rates dd { margin: 0; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* 履歴 */
.day h2 { font-size: 13px; font-weight: 400; color: var(--sub); margin: 0 0 8px; }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.hist .time { color: var(--sub); font-variant-numeric: tabular-nums; }
.hist .what { overflow-wrap: anywhere; }
.hist .state { display: block; font-size: 13px; color: var(--sub); }
.hist li.canceled .what { color: var(--sub); text-decoration: line-through; }
.empty { display: flex; flex-direction: column; gap: 16px; align-items: flex-start; color: var(--sub); }

/* 下のタブ */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; background: var(--bg); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, 1fr); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { min-height: 60px; border: 0; background: none; color: var(--sub); font-size: 13px; }
.tabs button[aria-current="page"] { color: var(--gold); font-weight: 600; }

/* 知らせ */
.toast { position: fixed; left: 16px; right: 16px; max-width: 528px; margin: 0 auto; bottom: calc(76px + env(safe-area-inset-bottom)); background: var(--surface); color: var(--text); border-radius: var(--radius); padding: 8px 8px 8px 16px; display: flex; align-items: center; gap: 8px; min-height: 56px; border: 1px solid var(--line); }
.toast[hidden] { display: none; }
.toast span { flex: 1; }
.toast button { background: none; color: var(--gold); border: 0; min-height: 40px; padding: 0 16px; font-weight: 600; }
