/* app.css — 給油・燃費ログ
 * 方向性: アイコン(インディゴ→ティール、針のアンバー)を基準色に、計器のように「読める」画面。
 * 記憶に残す要素はホームの機械式オドメーターだけ。それ以外は罫線と余白で静かに構成する。
 * 警告は黄色の三角(標識の形)+黄帯。色だけに頼らない。 */

:root {
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  --ink: #16212e; --ink-2: #445466; --ink-3: #66788a;
  --paper: #edf0f2; --panel: #ffffff; --line: #d3dae0; --line-2: #e4e9ed;
  --primary: #1e3a5f; --primary-hi: #2a4f7e; --on-primary: #ffffff;
  --teal: #0b7d72; --teal-soft: #d9f0ed;
  --amber: #f59e0b; --amber-soft: #fef3c7; --on-amber: #4a3200;
  --danger: #b42318; --danger-soft: #fee4e2;
  --info-soft: #e3ebf3;
  --odo-bg: linear-gradient(135deg, #1e3a5f 0%, #17506a 62%, #0f6b68 100%);
  --odo-cell: #0f1c2b; --odo-on: #f4efe0; --odo-off: #4f6274;
  --focus: #0d9488;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e7edf2; --ink-2: #b4c1cd; --ink-3: #8b9caa;
    --paper: #0e151d; --panel: #16202b; --line: #2a3745; --line-2: #212d39;
    --primary: #2d5c94; --primary-hi: #3a6fae; --on-primary: #ffffff;
    --teal: #3ad0c0; --teal-soft: #12302f;
    --amber-soft: #3a2c0a; --on-amber: #fde9b0;
    --danger: #ff8a80; --danger-soft: #3a1917;
    --info-soft: #1a2734;
    --odo-cell: #0a121a;
  }
}
:root[data-theme="dark"] {
  --ink: #e7edf2; --ink-2: #b4c1cd; --ink-3: #8b9caa;
  --paper: #0e151d; --panel: #16202b; --line: #2a3745; --line-2: #212d39;
  --primary: #2d5c94; --primary-hi: #3a6fae; --on-primary: #ffffff;
  --teal: #3ad0c0; --teal-soft: #12302f;
  --amber-soft: #3a2c0a; --on-amber: #fde9b0;
  --danger: #ff8a80; --danger-soft: #3a1917;
  --info-soft: #1a2734;
  --odo-cell: #0a121a;
}

*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
  font-size: 16px; line-height: 1.6; font-feature-settings: "palt" 0;
  font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }
h1, h2, p, dl, dd { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.ico { display: inline-flex; flex: none; }

/* ---------- 画面の枠 ---------- */
#app { max-width: 560px; margin: 0 auto; }
.screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--paper); }
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; min-height: 56px;
  background: var(--paper); border-bottom: 1px solid var(--line-2);
}
.topbar .title { font-size: 1.08rem; font-weight: 700; flex: 1; min-width: 0; letter-spacing: .01em; }
.topbar .chip { margin-left: auto; }
.topbar.chip-first .chip { margin-left: 0; }
.icon-btn { width: 44px; height: 44px; margin-left: -8px; display: inline-grid; place-items: center; border: 0; background: none; border-radius: 999px; cursor: pointer; }
.body { flex: 1; padding: 16px 16px 24px; display: flex; flex-direction: column; gap: 16px; }
.actionbar {
  position: sticky; bottom: 0; z-index: 5;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--paper); border-top: 1px solid var(--line-2);
}
.footer-stack { display: flex; flex-direction: column; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ---------- 車両チップ ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; max-width: 70%;
  padding: 0 12px 0 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); cursor: pointer;
}
.chip-icon { font-size: 1.25rem; line-height: 1; }
.chip-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--teal-soft); color: var(--teal); margin-left: auto; }
.vehicle-line { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 0 20px; border-radius: var(--radius); border: 1px solid transparent;
  font-weight: 700; cursor: pointer; width: 100%; text-align: center;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:not(:disabled):active { background: var(--primary-hi); }
.btn-secondary { background: var(--panel); border-color: var(--line); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-xl { min-height: 72px; font-size: 1.1rem; }
.btn-small { min-height: 44px; width: auto; padding: 0 14px; font-size: .9rem; }
.btn-inline { min-height: 48px; font-weight: 600; }
.btn-cta { font-size: 1.1rem; letter-spacing: .02em; }
.btn-text {
  min-height: 44px; border: 0; background: none; color: var(--ink-2); font-weight: 600; cursor: pointer; padding: 0 12px;
}
.btn-text-danger { color: var(--danger); }

/* ---------- ホーム: オドメーター ---------- */
.hero { background: var(--odo-bg); color: #fff; border-radius: 14px; padding: 16px 16px 12px; display: flex; flex-direction: column; gap: 10px; }
.hero-label { font-size: .85rem; opacity: .82; }
.hero-empty { font-size: 1.3rem; font-weight: 700; padding: 14px 0; }
.odo { display: flex; align-items: flex-end; gap: 4px; }
.odo-cell {
  display: inline-grid; place-items: center; width: clamp(30px, 10.4vw, 46px); height: clamp(46px, 15vw, 66px);
  background: var(--odo-cell); color: var(--odo-on); border-radius: 4px;
  font-size: clamp(1.7rem, 6.4vw, 2.6rem); font-weight: 700; line-height: 1;
  box-shadow: inset 0 -10px 12px -10px rgba(0,0,0,.6), inset 0 10px 12px -10px rgba(255,255,255,.08);
}
.odo-cell.is-off { color: var(--odo-off); }
.odo-unit { margin: 0 0 6px 6px; font-weight: 700; opacity: .85; }
.readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin-top: 4px; border-top: 1px solid rgba(255,255,255,.22); padding-top: 10px; }
.readout { display: flex; flex-direction: column; gap: 2px; padding-right: 12px; min-width: 0; }
.readout + .readout { padding: 0 0 0 14px; border-left: 1px solid rgba(255,255,255,.22); }
.readout-label { font-size: .8rem; opacity: .82; }
.readout-value { font-size: 1.7rem; font-weight: 700; line-height: 1.15; }
.readout-value small { font-size: .8rem; font-weight: 600; margin-left: 4px; opacity: .85; }
.readout-empty { font-size: .8rem; line-height: 1.4; opacity: .9; }

/* ---------- 区切りだけで構成する一覧 ---------- */
.block { display: flex; flex-direction: column; gap: 6px; }
.section-title { font-size: .95rem; font-weight: 700; color: var(--ink-2); padding: 0 2px; }
.maint-list, .rec-list, .rows, .veh-list { background: var(--panel); border-radius: var(--radius); border: 1px solid var(--line-2); overflow: hidden; }
.maint, .rec-row, .row-btn, .veh-row { border-top: 1px solid var(--line-2); }
.maint:first-child, .rec-row:first-child, .row-btn:first-child, .veh-row:first-child { border-top: 0; }

.maint { display: flex; flex-direction: column; }
.maint.is-overdue { box-shadow: inset 5px 0 0 var(--amber); }
.maint-btn {
  display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 14px; border: 0; background: none; cursor: pointer; text-align: left;
}
.maint-btn:disabled { opacity: .5; }
.maint-icon { font-size: 1.3rem; }
.maint-label { font-weight: 700; flex: 1; }
.maint-act { font-size: .85rem; font-weight: 700; color: var(--teal); border: 1.5px solid var(--teal); border-radius: 999px; padding: 4px 12px; }
.maint-info {
  display: grid; grid-template-columns: 1fr auto; column-gap: 8px; align-items: center;
  padding: 0 14px 10px 14px; min-height: 44px; color: var(--ink-2); font-size: .9rem;
}
.maint-info > span { grid-column: 1; }
.maint-info .ico { grid-column: 2; grid-row: 1 / span 3; color: var(--ink-3); }
.maint-due { font-weight: 700; color: var(--ink); }
.maint.is-overdue .maint-due { color: var(--on-amber); background: var(--amber-soft); border-radius: 4px; padding: 0 6px; justify-self: start; }

.stats { background: var(--panel); border-radius: var(--radius); border: 1px solid var(--line-2); }
.stat { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line-2); }
.stat:first-child { border-top: 0; }
.stat dt { color: var(--ink-2); display: flex; flex-direction: column; }
.stat dt small { color: var(--ink-3); font-size: .75rem; }
.stat dd { font-weight: 700; font-size: 1.1rem; }

.rec-row, .row-btn {
  display: grid; grid-template-columns: 1.1fr 1fr auto; gap: 8px; align-items: center; width: 100%;
  min-height: 60px; padding: 8px 14px; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; cursor: pointer;
}
.row-btn { grid-template-columns: 1fr auto; }
.rec-col { display: flex; flex-direction: column; min-width: 0; }
.rec-top { font-weight: 700; }
.rec-sub { font-size: .85rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-eff { text-align: right; min-width: 64px; }
.rec-eff strong { font-size: 1.1rem; }
.rec-eff small { display: block; font-size: .7rem; color: var(--ink-3); line-height: 1; }
.rec-eff.is-off strong { font-size: .85rem; color: var(--ink-3); }
.ago { color: var(--ink-3); font-size: .85rem; }

.links { display: flex; flex-direction: column; background: var(--panel); border-radius: var(--radius); border: 1px solid var(--line-2); }
.links a { display: flex; justify-content: space-between; align-items: center; min-height: 52px; padding: 0 14px; border-top: 1px solid var(--line-2); font-weight: 600; }
.links a:first-child { border-top: 0; }
.links .ico { color: var(--ink-3); }

.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); padding: 18px 16px; display: flex; flex-direction: column; gap: 6px; }
.empty-hero { border: 0; background: none; padding: 24px 0; gap: 12px; }
.empty-hero h2 { font-size: 1.25rem; }

/* ---------- フォーム ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; scroll-margin-bottom: 140px; }
.field > label, .field > .label { font-size: .88rem; font-weight: 700; color: var(--ink-2); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input {
  width: 100%; min-height: 52px; padding: 0 14px; font: inherit; font-size: 1.05rem; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; appearance: none; -webkit-appearance: none;
}
select.input { background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.input-wrap .input { padding-right: 58px; }
.unit { position: absolute; right: 14px; color: var(--ink-3); font-weight: 600; pointer-events: none; }
.input-xl { min-height: 72px; font-size: 2rem; font-weight: 700; letter-spacing: .02em; }
.field-xl .unit { font-size: 1.1rem; }
.hint { font-size: .82rem; color: var(--ink-3); min-height: 0; }
.hint:empty { display: none; }
.hint-est { color: var(--ink-3); font-style: normal; }
.odo-ref { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); }
.odo-ref > div { display: flex; flex-direction: column; }
.ref-label { font-size: .8rem; color: var(--ink-3); }
.odo-ref strong { font-size: 1.15rem; }
.stepper { display: flex; gap: 6px; }
.stepper span { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.stepper .is-done { background: var(--teal); opacity: .55; }
.stepper .is-on { background: var(--primary); }

.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); }
.seg-btn { min-height: 60px; border: 0; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 6px 8px; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn small { font-size: .75rem; color: var(--ink-3); }
.seg-btn.is-on { background: var(--primary); color: var(--on-primary); }
.seg-btn.is-on small { color: inherit; opacity: .85; }

.more { border-top: 1px solid var(--line-2); padding-top: 4px; }
.more > summary { min-height: 48px; display: flex; align-items: center; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.more[open] { display: flex; flex-direction: column; gap: 14px; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 6px 0; }
.check input { width: 24px; height: 24px; margin-top: 2px; accent-color: var(--primary); flex: none; }
.check span { display: flex; flex-direction: column; }
.check small { color: var(--ink-3); font-size: .8rem; }

/* ---------- 帯(警告・エラー・情報) ---------- */
.bands { display: flex; flex-direction: column; gap: 6px; }
.bands:empty { display: none; }
.band { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 6px; font-size: .88rem; line-height: 1.5; }
.band .ico { margin-top: 1px; }
.band-warn { background: var(--amber-soft); color: var(--on-amber); border-left: 4px solid var(--amber); }
.band-error { background: var(--danger-soft); color: var(--danger); border-left: 4px solid var(--danger); font-weight: 600; }
.band-info { background: var(--info-soft); color: var(--ink-2); border-left: 4px solid var(--ink-3); }

/* ---------- 詳細・一覧の補助 ---------- */
.kv { background: var(--panel); border-radius: var(--radius); border: 1px solid var(--line-2); }
.kv-row { display: flex; justify-content: space-between; gap: 16px; padding: 11px 14px; border-top: 1px solid var(--line-2); }
.kv-row:first-child { border-top: 0; }
.kv-row dt { color: var(--ink-2); flex: none; }
.kv-row dd { text-align: right; font-weight: 600; word-break: break-word; }

.group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.group-head h2 { font-size: 1.05rem; }
.maint-group { display: flex; flex-direction: column; gap: 8px; }
.maint-group.is-focus .group-head h2 { color: var(--teal); }
.due { font-weight: 700; }
.due.is-overdue { color: var(--on-amber); background: var(--amber-soft); padding: 2px 8px; border-radius: 4px; align-self: flex-start; }

.veh-row { display: flex; flex-direction: column; }
.veh-main { display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 8px 14px; border: 0; background: none; cursor: pointer; text-align: left; width: 100%; }
.veh-text { display: flex; flex-direction: column; }
.veh-text small { color: var(--ink-3); }
.veh-actions { display: flex; gap: 8px; padding: 0 14px 10px; justify-content: flex-end; }

/* ---------- シート・ダイアログ・スナックバー ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(9, 16, 24, .5); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; max-height: 88dvh; overflow: auto; background: var(--panel);
  border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
}
.sheet-title { font-size: 1.1rem; margin-bottom: 8px; }
.sheet-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px; padding: 0 8px; border: 0; border-top: 1px solid var(--line-2); background: none; cursor: pointer; text-align: left; }
.sheet-item.is-current { font-weight: 700; }
.sheet-item-name { flex: 1; }
.sheet-retired { margin-top: 6px; }
.sheet-retired summary { min-height: 44px; display: flex; align-items: center; color: var(--ink-2); font-weight: 600; cursor: pointer; }
.sheet-manage { margin-top: 12px; min-height: 48px; }
.dialog { display: flex; flex-direction: column; gap: 10px; }
.dialog h2 { font-size: 1.1rem; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.dialog-actions .btn { min-height: 52px; }

.snackbar {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(92px + env(safe-area-inset-bottom, 0px)); width: min(calc(100% - 24px), 536px);
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 16px;
  background: #16212e; color: #f2f5f7; border-radius: 10px; font-size: .92rem;
  box-shadow: 0 6px 18px rgba(0,0,0,.28);
}
.snack-text { flex: 1; }
.snack-action { min-height: 44px; padding: 0 12px; border: 0; background: none; color: #6fe3d5; font-weight: 700; cursor: pointer; }

/* ---------- 読み込み中 ---------- */
.skel { background: linear-gradient(90deg, var(--line-2), var(--line), var(--line-2)); background-size: 200% 100%; border-radius: 8px; animation: sk 1.2s linear infinite; margin: 12px 16px; }
.skel-bar { height: 44px; width: 55%; } .skel-hero { height: 170px; } .skel-line { height: 56px; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }
