:root {
  --bg: #000;
  --panel: #1c1c1e;
  --cell: #1f1f21;
  --line: #2c2c2e;
  --text: #f2f2f7;
  --sub: #8e8e93;
  --accent: #1fa89b;
  --up: #22c58b;
  --down: #e5787a;
  --danger: #ff453a;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Helvetica Neue", sans-serif;
  font-size: 16px; min-height: 100vh; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
main { padding-top: var(--safe-t); padding-bottom: calc(96px + var(--safe-b)); }

/* タブバー */
.tabbar {
  position: fixed; left: 16px; right: 16px; bottom: calc(10px + var(--safe-b)); z-index: 10;
  display: flex; gap: 4px; padding: 6px; border-radius: 32px;
  background: rgba(40, 40, 42, .92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid #3a3a3c;
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 0; background: none; padding: 6px 0; border-radius: 26px; font-size: 11px; color: var(--text);
}
.tabbar button .ico { font-size: 22px; filter: grayscale(1) brightness(1.6); }
.tabbar button.active { background: #111; color: var(--accent); }
.tabbar button.active .ico { filter: none; }

/* 給油記録: 車両カルーセル */
.vh-wrap { background: var(--panel); position: sticky; top: 0; z-index: 5; padding-top: var(--safe-t); margin-top: calc(-1 * var(--safe-t)); }
.dots { display: flex; gap: 8px; padding: 10px 16px 0; }
.dots span { flex: 1; height: 4px; border-radius: 2px; background: transparent; }
.dots span.on { background: var(--accent); }
.carousel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.carousel::-webkit-scrollbar { display: none; }
.vh {
  flex: 0 0 100%; scroll-snap-align: start; display: flex; align-items: center; gap: 14px; padding: 14px 16px 16px;
}
.vh .photo { width: 96px; height: 96px; border-radius: 8px; object-fit: cover; background: #333; flex: none; }
.vh .name { color: var(--accent); font-weight: 700; font-size: 18px; }
.vh .avg { font-size: 44px; font-weight: 600; line-height: 1.1; }
.vh .avg small { font-size: 16px; color: var(--sub); margin-left: 4px; }
.vh .meta { color: var(--sub); font-size: 12px; }

/* 記録リスト */
.rec { display: flex; gap: 8px; padding: 10px 12px 14px; border-bottom: 1px solid var(--line); }
.rec .eff { width: 104px; flex: none; display: flex; align-items: center; justify-content: center; gap: 6px; }
.rec .eff .v { font-size: 32px; font-weight: 600; text-align: center; line-height: 1; }
.rec .eff .u { font-size: 12px; color: var(--sub); text-align: center; }
.rec .arrow { width: 20px; height: 20px; border-radius: 4px; display: grid; place-items: center; font-size: 13px; color: #000; font-weight: 700; }
.rec .arrow.up { background: var(--up); }
.rec .arrow.down { background: var(--down); }
.rec .arrow.none { visibility: hidden; }
.rec .body { flex: 1; min-width: 0; }
.rec .date { text-align: right; color: var(--sub); font-size: 13px; margin-bottom: 4px; }
.grid { display: grid; gap: 4px; }
.g3 { grid-template-columns: 1fr 1fr 1fr; }
.g2 { grid-template-columns: 1fr 1.3fr; }
.cell { background: var(--cell); padding: 6px 6px; text-align: center; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell small { color: var(--sub); font-size: 12px; }
.memo { background: var(--cell); padding: 6px; text-align: center; font-size: 14px; margin-top: 4px; word-break: break-all; }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 8px; background: #3a3a3c; color: var(--sub); margin-left: 4px; }

.fab {
  position: fixed; right: 18px; bottom: calc(96px + var(--safe-b)); z-index: 9; width: 64px; height: 64px; border-radius: 50%;
  border: 0; background: var(--accent); color: #fff; font-size: 34px; line-height: 1; box-shadow: 0 4px 14px rgba(0,0,0,.5);
}

/* 汎用 */
.page-title { text-align: center; font-weight: 700; font-size: 20px; padding: 18px 56px 14px; position: relative; }
.icon-btn {
  position: absolute; top: 10px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid #3a3a3c;
  background: #1c1c1e; font-size: 24px; line-height: 1;
}
.icon-btn.right { right: 12px; }
.icon-btn.left { left: 12px; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.list-item img, .list-item .noimg { width: 64px; height: 64px; border-radius: 6px; object-fit: cover; background: #333; flex: none; }
.list-item .t { flex: 1; font-size: 20px; }
.empty { color: var(--sub); text-align: center; padding: 40px 20px; line-height: 1.7; }

.section-h { color: var(--sub); font-size: 13px; padding: 22px 16px 6px; }
.group { background: var(--panel); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); min-height: 50px; }
.row:last-child { border-bottom: 0; }
.row .label { flex: 1; }
.row .note { color: var(--sub); font-size: 12px; display: block; margin-top: 2px; }
.row select, .row input[type=text] {
  background: transparent; border: 0; color: var(--sub); text-align: right; max-width: 55%;
}
.row input[type=text] { border-bottom: 1px solid var(--line); }
.row button.link { background: none; border: 0; color: var(--accent); padding: 0; text-align: left; }
.row.danger button.link { color: var(--danger); }

.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #48484a; border-radius: 16px; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 28px; height: 28px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(20px); }

.seg { display: flex; background: #1c1c1e; border-radius: 22px; padding: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 9px 10px; border-radius: 19px; font-size: 14px; color: var(--text); }
.seg button.on { background: #636366; }

/* シート（入力画面） */
.sheet { position: fixed; inset: 0; z-index: 20; background: var(--panel); overflow-y: auto; padding: calc(var(--safe-t) + 4px) 0 calc(40px + var(--safe-b)); }
.sheet .form { padding: 8px 14px; display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--sub); }
.field input, .field textarea, .field select {
  background: transparent; border: 1px solid #48484a; border-radius: 6px; padding: 12px 10px; font-size: 20px; width: 100%;
}
.field textarea { min-height: 90px; font-size: 17px; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.fields3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; }
.fields2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vsel { display: flex; align-items: center; gap: 10px; background: #2c2c2e; border-radius: 6px; padding: 6px; }
.vsel img { width: 52px; height: 52px; border-radius: 4px; object-fit: cover; }
.vsel select { flex: 1; background: transparent; border: 0; color: var(--accent); font-size: 20px; font-weight: 600; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px; font-size: 18px; }
.calc-hint { color: var(--sub); font-size: 13px; text-align: right; min-height: 1em; }
.btn { border: 0; border-radius: 10px; padding: 14px; font-size: 17px; font-weight: 600; background: var(--accent); color: #fff; }
.btn.secondary { background: #2c2c2e; color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid #48484a; }
.photo-pick { display: block; margin: 0 auto; width: 100%; max-width: 360px; aspect-ratio: 1; object-fit: cover; background: #2c2c2e; border-radius: 6px; }
.photo-ph { display: grid; place-items: center; color: var(--sub); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(110px + var(--safe-b)); z-index: 30;
  background: #3a3a3c; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw; text-align: center;
}
