/* Motocreate — mobile-first styles. Primary target: iPhone Safari, ~390px. */

:root {
  --bg: #0e0f12;
  --surface: #17191e;
  --surface-2: #1f2228;
  --border: #2a2e36;
  --text: #f2f3f5;
  --muted: #9aa1ad;
  --accent: #ff5a36;
  --accent-press: #e84a28;
  --accent-text: #ffffff;
  --btn-primary: #c2370f;       /* white text 5.5:1 */
  --btn-primary-press: #a83010;
  --btn-danger: #c22a38;        /* white text 5.7:1 */
  --ok: #34c77b;
  --soon: #f5b52e;
  --danger: #ff4d5e;
  --info: #5aa9ff;
  --warn-bg: rgba(245, 181, 46, 0.12);
  --danger-bg: rgba(255, 77, 94, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --gutter: 16px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --border: #dde0e6;
  --text: #121418;
  --muted: #5d6573;
  --accent: #c2370f;            /* links/active tab on white 5.5:1 */
  --accent-press: #a83010;
  --ok: #167d47;                /* 5.2:1 on white */
  --soon: #8f5d05;              /* 5.6:1 on white */
  --danger: #d42b3c;
  --info: #1f6fd1;
  --warn-bg: rgba(183, 121, 10, 0.1);
  --danger-bg: rgba(212, 43, 60, 0.08);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }

.icon { flex: none; display: block; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.strong { font-weight: 700; }
.mono, input.mono { font-family: var(--mono); letter-spacing: 0.04em; }
.pre { white-space: pre-wrap; }
.strike { text-decoration: line-through; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------ Layout */

.main {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 12px) max(var(--gutter), env(safe-area-inset-right, 0px)) calc(var(--tabbar-h) + var(--safe-b) + 24px) max(var(--gutter), env(safe-area-inset-left, 0px));
  outline: none;
  min-height: 100vh;
}
.loading { padding: 48px 0; text-align: center; color: var(--muted); }

.stack { display: flex; flex-direction: column; gap: 14px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-2 > * { min-width: 0; }

.page-head {
  display: flex; align-items: center; gap: 8px;
  min-height: 48px; margin-bottom: 12px;
}
.page-head h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.page-head .back { margin-left: -10px; }

.setup-head { flex-direction: column; align-items: flex-start; gap: 8px; margin: 12px 0 18px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text);
}

/* ------------------------------------------------------------ Cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 12px; }
.eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.placeholder { border-style: dashed; color: var(--muted); display: flex; flex-direction: column; gap: 8px; }
.placeholder p { color: var(--muted); }
.empty { text-align: center; color: var(--muted); }

.hero { display: flex; align-items: center; gap: 14px; padding: 12px; }
.hero-photo {
  width: 96px; height: 72px; border-radius: var(--radius-sm); overflow: hidden; flex: none;
  background: var(--surface-2); display: grid; place-items: center; color: var(--muted);
}
.hero-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-photo .bike-art { width: 72px; }
.hero-text { min-width: 0; }
.hero-text h2 { font-size: 20px; font-weight: 750; overflow-wrap: anywhere; }

.odo { display: flex; flex-direction: column; gap: 6px; }
.odo-value {
  font-size: 48px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.05;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.odo-value .unit { font-size: 20px; font-weight: 600; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.odo .actions { margin-top: 8px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; min-width: 0; }
.stat-value { font-size: 24px; font-weight: 750; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--muted); }

.notice {
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px;
  background: var(--warn-bg); border: 1px solid color-mix(in srgb, var(--soon) 40%, transparent);
}
.notice-danger { background: var(--danger-bg); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); }

/* ------------------------------------------------------------ Buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 650; text-decoration: none;
  cursor: pointer; touch-action: manipulation; user-select: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--btn-primary); border-color: var(--btn-primary); color: var(--accent-text); }
.btn-primary:active { background: var(--btn-primary-press); }
.btn-danger { background: var(--btn-danger); border-color: var(--btn-danger); color: #fff; }
.btn-danger-ghost { color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-small { min-height: 44px; padding: 0 14px; font-size: 15px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions > .btn { flex: 1 1 0; min-width: 0; }

.icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center;
  border: 0; background: transparent; color: var(--text); border-radius: 50%;
  cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }

:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px; }

/* ------------------------------------------------------------ Forms */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field label { font-size: 14px; font-weight: 600; }
.opt { font-weight: 400; color: var(--muted); font-size: 13px; }
input, select, textarea {
  width: 100%; min-width: 0; min-height: 48px;
  padding: 12px 14px;
  font: inherit; font-size: 16px; /* ≥16px prevents iOS zoom on focus */
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  appearance: none; -webkit-appearance: none;
}
input[type="date"] { display: block; min-height: 48px; line-height: 22px; }
input::-webkit-date-and-time-value { text-align: left; }
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
[aria-invalid="true"] { border-color: var(--danger); }
.input-lg { font-size: 28px !important; font-weight: 750; font-variant-numeric: tabular-nums; min-height: 60px; }
.hint { font-size: 13px; color: var(--muted); }
.error { font-size: 13px; color: var(--danger); min-height: 0; }
.error:empty { display: none; }
.form-error { font-size: 14px; }

.warn-box {
  background: var(--warn-bg); border: 1px solid color-mix(in srgb, var(--soon) 45%, transparent);
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px;
}
.warn-box ul { margin: 6px 0; padding-left: 20px; }
.warn-title { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--soon); }
.warn-hint { color: var(--muted); font-size: 13px; }

.readonly-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 4px 0 6px; }
.readonly-row strong { font-variant-numeric: tabular-nums; }

.toggle-row { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; }
.toggle-row input { width: 22px; height: 22px; min-height: 0; padding: 0; appearance: auto; -webkit-appearance: checkbox; accent-color: var(--accent); }

.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; min-height: 0; }
.segmented span { display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 9px; font-weight: 650; color: var(--muted); }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.segmented input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 70%, transparent); }

.photo-pick { display: flex; align-items: center; gap: 14px; }
.photo-frame {
  width: 120px; height: 90px; border-radius: var(--radius-sm); overflow: hidden; flex: none;
  background: var(--surface-2); display: grid; place-items: center; color: var(--muted);
}
.photo-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-frame .bike-art { width: 84px; }
.photo-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.photo-actions label.btn { cursor: pointer; }

/* ------------------------------------------------------------ Lists */

.list { list-style: none; margin: 0; padding: 0; overflow: hidden; }
.list.card { padding: 0; }
.list li + li { border-top: 1px solid var(--border); }
.list-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 60px; padding: 12px 16px;
  background: transparent; border: 0; color: inherit; font: inherit; text-align: left;
  text-decoration: none; cursor: pointer;
}
.card > .list-item { padding: 4px 0; min-height: 52px; }
a.card.list-item {
  padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
a.card.list-item > .icon { color: var(--muted); }
.list-item:active { background: var(--surface-2); }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 650; display: flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.li-sub { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.li-tags { display: flex; align-items: center; gap: 6px; color: var(--muted); flex: none; }
.is-muted .li-title, .is-muted .li-sub { color: var(--muted); }
.delta { font-size: 13px; color: var(--ok); font-weight: 600; }
.tag { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.tag-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.tag-info { color: var(--info); border-color: color-mix(in srgb, var(--info) 40%, transparent); }

.dl { margin: 12px 0 0; display: flex; flex-direction: column; }
.dl > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--border); }
.dl > div:first-child { border-top: 0; }
.dl dt { color: var(--muted); flex: none; max-width: 45%; }
.dl + .actions { margin-top: 16px; }
.dl dd { margin: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ Tab bar */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 0 env(safe-area-inset-right, 0px) var(--safe-b) env(safe-area-inset-left, 0px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar[hidden] { display: none; }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--tabbar-h); color: var(--muted); text-decoration: none;
  font-size: 11px; font-weight: 600;
}
.tabbar a[aria-current="page"] { color: var(--accent); }

/* ------------------------------------------------------------ Sheets */

dialog.sheet {
  width: 100%; max-width: 640px; max-height: 92vh; max-height: 92dvh;
  margin: auto auto 0; padding: 0;
  border: 1px solid var(--border); border-bottom: 0;
  border-radius: 20px 20px 0 0;
  background: var(--surface); color: var(--text);
  overflow: auto; overscroll-behavior: contain;
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, 0.55); }
.sheet-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 8px 6px 16px; background: var(--surface);
}
.sheet-head h2 { font-size: 20px; font-weight: 750; }
.sheet-body { padding: 4px 16px calc(20px + var(--safe-b)); }
@media (min-width: 700px) {
  dialog.sheet { margin: auto; border-radius: 20px; border-bottom: 1px solid var(--border); }
}

/* ------------------------------------------------------------ Toast */

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); width: max-content;
  padding: 12px 16px; border-radius: 12px; font-size: 15px; font-weight: 600;
  background: var(--text); color: var(--bg);
  transition: opacity .18s, transform .18s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast[data-kind="error"] { background: var(--danger); color: #fff; }

.fatal { margin-top: 40px; display: flex; flex-direction: column; gap: 12px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .btn:active { transform: none; }
}

/* ------------------------------------------------------------ Maintenance (Stage 2) */

/* Status colors are always paired with a glyph and a text label, never color alone. */
.status-overdue { --st: var(--danger); }
.status-due-soon { --st: var(--soon); }
.status-ok { --st: var(--ok); }
.status-unknown { --st: var(--info); }
.status-as-needed, .status-not-configured, .status-disabled { --st: var(--muted); }

.badge {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  font-size: 12px; font-weight: 750; letter-spacing: 0.02em; white-space: nowrap;
  padding: 4px 9px 4px 6px; border-radius: 999px;
  color: var(--st); background: color-mix(in srgb, var(--st) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--st) 45%, transparent);
}
.badge.status-unknown, .badge.status-not-configured { border-style: dashed; }
.badge-glyph {
  display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%;
  font-size: 11px; line-height: 1; background: var(--st); color: var(--surface);
}

.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chip {
  display: flex; flex-direction: column; align-items: flex-start; min-width: 0;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--surface-2); border-left: 4px solid var(--st);
  font-size: 12px; color: var(--muted);
}
.chip-n { font-size: 22px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.1; }

.maint-card { display: flex; flex-direction: column; gap: 12px; }
.maint-card .list { margin: 0 -16px; border-top: 1px solid var(--border); }
.maint-card .list li:last-child { border-bottom: 1px solid var(--border); }
.setup-link { font-size: 14px; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.link-btn { font-weight: 650; font-size: 15px; min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: flex-end; text-decoration: none; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.h1-wrap { font-size: 24px !important; overflow-wrap: anywhere; }
.warn-text { color: var(--soon); }
.no-margin { margin: 0; }

.schedule-card { display: flex; flex-direction: column; gap: 4px; }
.schedule-title { font-size: 18px; font-weight: 750; }
.schedule-card .actions { margin-top: 12px; }

fieldset.schedule-edit { margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
fieldset.schedule-edit .row-between { margin-bottom: 8px; }

.disclosure summary { cursor: pointer; font-weight: 650; min-height: 44px; display: flex; align-items: center; }
.disclosure .list { margin: 8px -16px -16px; border-top: 1px solid var(--border); }
.due-soon-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

/* ------------------------------------------------------------ Service records (Stage 3) */

.stack-sm { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.row-3 { display: grid; grid-template-columns: 1.2fr 0.7fr 1fr; gap: 8px; }
.row-3 > * { min-width: 0; }
.card-inset { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.card-inset input { background: var(--surface); }
.section-gap { margin-top: 18px; }
.plain-fieldset { border: 0; padding: 0; margin: 0 0 12px; min-width: 0; }
.label-like { font-size: 14px; font-weight: 600; padding: 0; margin-bottom: 6px; }

.check-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chip { position: relative; }
.check-chip input { position: absolute; opacity: 0; inset: 0; min-height: 0; margin: 0; }
.check-chip span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2);
  font-weight: 650; font-size: 15px; color: var(--muted);
}
.check-chip input:checked + span { background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: var(--accent); color: var(--text); }
.check-chip input:checked + span::before { content: '✓'; margin-right: 6px; color: var(--accent); }
.check-chip input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px; }

.effect-list { list-style: none; margin: 4px 0 0; padding: 0; font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.eff-yes { color: var(--ok); font-weight: 600; }
.eff-no { color: var(--muted); }

.segmented + #shop-row { margin-top: 12px; }
#odo-row + .segmented { margin-top: 4px; }
.card > .segmented { margin-top: 4px; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; margin-bottom: 10px; }
.thumb {
  position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border); padding: 0; cursor: pointer;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-x {
  position: absolute; top: 2px; right: 2px; width: 44px; height: 44px; border: 0; border-radius: 50%;
  display: grid; place-items: center; background: transparent; color: #fff; cursor: pointer;
}
.thumb-x .icon { width: 28px; height: 28px; padding: 5px; border-radius: 50%; background: rgba(0, 0, 0, 0.6); }
.file-btn { cursor: pointer; }

.file-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.file-kind { flex: none; font-size: 11px; font-weight: 800; padding: 4px 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.parts-list { list-style: none; margin: 0; padding: 0; }
.parts-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.parts-list li:first-child { border-top: 0; }
.money { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; color: var(--text); }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.list.flush { margin: 0 -16px -16px; border-top: 1px solid var(--border); }
.viewer-img { width: 100%; height: auto; border-radius: var(--radius-sm); margin-bottom: 12px; background: var(--surface-2); }

/* ------------------------------------------------------------ Ownership (Stage 4) */

.list.flush-top { margin: 0 -16px -16px; }
.list.flush-top li:first-child { border-top: 0; }
.total-row { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 12px; }

a.card.tire-card { display: flex; flex-direction: column; gap: 6px; color: inherit; text-decoration: none; }
a.card.tire-card .icon { color: var(--muted); }
.tire-card .stats, .tire-summary .stats, .maint-card .stats { margin: 6px 0; }
.tire-summary { display: flex; flex-direction: column; gap: 8px; }

.explain { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--muted); }
.explain strong { color: var(--text); }

.quick-links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: -4px 0 12px; }
.quick-links a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  font-size: 14px; font-weight: 650; color: var(--text); text-decoration: none;
}

.check-items, .check-results { list-style: none; margin: 0; padding: 0; }
.check-item, .check-results li { padding: 12px 0; border-top: 1px solid var(--border); }
.check-item:first-child, .check-results li:first-child { border-top: 0; padding-top: 0; }
.check-results li { display: flex; flex-direction: column; gap: 6px; }
.check-label { font-weight: 650; margin-bottom: 8px; }

.result-chips { display: grid; grid-template-columns: 1fr 1fr 1fr 0.6fr; gap: 6px; }
.result-chip { position: relative; }
.result-chip input { position: absolute; opacity: 0; inset: 0; min-height: 0; margin: 0; }
.result-chip span {
  display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 6px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2);
  font-size: 14px; font-weight: 650; color: var(--muted);
}
.rc-pass input:checked + span { --st: var(--ok); }
.rc-attention input:checked + span { --st: var(--soon); }
.rc-fail input:checked + span { --st: var(--danger); }
.rc-pass input:checked + span, .rc-attention input:checked + span, .rc-fail input:checked + span {
  color: var(--st); border-color: var(--st); background: color-mix(in srgb, var(--st) 15%, transparent);
}
.rc-none input:checked + span { color: var(--text); border-style: dashed; }
.result-chip input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px; }

.item-details { margin-top: 8px; }
.item-details summary { cursor: pointer; font-size: 14px; color: var(--muted); min-height: 44px; display: flex; align-items: center; }
.item-details[open] summary { color: var(--text); }
.item-files .card-title { font-size: 12px; margin-bottom: 6px; }
.general-files { margin-top: 12px; }

.list.flush-all { margin: -16px; }
.list.flush-all li:first-child { border-top: 0; }

/* ------------------------------------------------------------ History, report, backup (Stage 5) */

.filters summary { cursor: pointer; font-weight: 650; min-height: 44px; display: flex; align-items: center; }
.filter-form { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.filter-form .check-chip span { min-height: 40px; padding: 0 12px; font-size: 14px; }
.filter-form .check-chips { margin-bottom: 4px; }

.timeline .month-head {
  padding: 14px 16px 6px; font-size: 12px; font-weight: 750; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); background: var(--surface);
}
.kind-tag {
  flex: none; font-size: 11px; font-weight: 750; padding: 2px 7px; border-radius: 6px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.kind-service { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.kind-repair { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.kind-inspection { color: var(--info); border-color: color-mix(in srgb, var(--info) 40%, transparent); }
.kind-tire, .kind-modification { color: var(--soon); border-color: color-mix(in srgb, var(--soon) 40%, transparent); }
.timeline .li-title { flex-wrap: wrap; }

a.notice.backup-reminder { display: block; color: var(--text); text-decoration: none; min-height: 44px; }
a.notice.backup-reminder strong { color: var(--accent); }

.restore-errors ul, .restore-ok ul { margin: 8px 0 0; padding-left: 18px; }
.restore-ok { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
#restore-result:not(:empty) { margin-top: 12px; }
table.compare { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.compare th, table.compare td { padding: 8px 4px; border-top: 1px solid var(--border); text-align: right; }
table.compare th[scope="row"], table.compare thead th:first-child { text-align: left; font-weight: 500; color: var(--muted); }
table.compare thead th { border-top: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

/* Report: rendered as a white "paper" preview on screen and as the only content when printing. */
.report-preview { background: #fff; color: #111; border-radius: var(--radius); padding: 20px 16px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); overflow-wrap: anywhere; }
.report { font-family: var(--font); font-size: 13px; line-height: 1.45; color: #111; }
.report .r-title { font-size: 20px; margin: 0 0 4px; }
.report h3 { font-size: 15px; margin: 18px 0 8px; padding-bottom: 4px; border-bottom: 2px solid #111; }
.report .r-bike { font-size: 15px; font-weight: 650; margin: 0 0 10px; }
.report .r-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin: 0; }
.report .r-facts dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: #555; }
.report .r-facts dd { margin: 0; font-weight: 600; }
.report .r-entry { padding: 8px 0; border-bottom: 1px solid #ddd; break-inside: avoid; page-break-inside: avoid; }
.report .r-line { display: flex; justify-content: space-between; gap: 12px; }
.report .r-cost { font-variant-numeric: tabular-nums; white-space: nowrap; }
.report .r-muted { color: #555; }
.report .r-note { margin: 4px 0 0; color: #333; white-space: pre-wrap; }
.report .r-parts { margin: 4px 0 0; padding-left: 18px; }
.report .r-images { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.report .r-images img { width: 110px; height: 110px; object-fit: cover; border: 1px solid #ccc; border-radius: 4px; }
.report .r-foot { margin-top: 18px; font-size: 11px; color: #555; border-top: 1px solid #ddd; padding-top: 8px; }

#print-root { display: none; }
@media print {
  @page { margin: 14mm; }
  html, body { background: #fff !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  #print-root .report { font-size: 11pt; }
  #print-root .r-images img { width: 38mm; height: 38mm; }
}

/* ------------------------------------------------------------ PWA (Stage 6) */

#update-banner {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
  width: min(608px, calc(100% - 32px));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 10px 10px 16px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35); font-size: 15px; font-weight: 600;
}
#offline-banner {
  position: sticky; top: 0; z-index: 40;
  padding: calc(var(--safe-t) + 8px) 16px 8px; text-align: center;
  background: var(--warn-bg); color: var(--text); border-bottom: 1px solid color-mix(in srgb, var(--soon) 45%, transparent);
  font-size: 14px; font-weight: 600; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
#offline-banner ~ .main { padding-top: 12px; }
h1:focus { outline: none; }
h1:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 4px; border-radius: 4px; }
@media print { #update-banner, #offline-banner { display: none !important; } }
body.has-update-banner #toast { bottom: calc(var(--tabbar-h) + var(--safe-b) + 92px); }
