:root {
  --bg: #000000;
  --surface: #2a2a2a;
  --surface-2: #3d3d3d;
  --input: #3a3a3a;
  --text: #f5f5f5;
  --muted: #b0b0b0;
  --border: #404040;
  --ok: #00C853;
  --watch: #FFEB3B;
  --due: #F44336;
  --accent: #90caf9;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
  min-height: 100dvh;
}

.wrap {
  box-sizing: border-box;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  min-height: 100%;
  min-height: 100dvh;
  padding-bottom: max(48px, env(safe-area-inset-bottom));
}

@media (max-width: 800px) {
  .wrap {
    max-width: none;
    padding: 12px 12px max(24px, env(safe-area-inset-bottom));
    min-height: 100vh;
    min-height: 100dvh;
  }
  .grid {
    grid-template-columns: 1fr;
    min-height: calc(100dvh - 80px);
  }
  .card {
    min-height: auto;
  }
  .garage-card {
    min-height: auto;
  }
  .items {
    padding-bottom: 32px;
  }
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.subtitle { color: var(--muted); font-size: 0.9rem; }

.guest-banner {
  display: block;
  margin: 0;
  padding: 8px 12px;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 8px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 800px) {
  .grid {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

.card {
  background: var(--surface);
  border-radius: 12px;
  padding: 16px;
  border: none;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 600;
}

.detail-heading {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.detail-heading h2 {
  margin: 0;
  line-height: 1.25;
  font-size: 1.05rem;
  font-weight: 600;
}

/* Whole-car collapse (matches section chevrons) */
.car-block {
  border: none;
  background: transparent;
  margin: 0;
  padding: 0;
}

.car-block > summary.detail-heading {
  list-style: none;
  cursor: pointer;
  user-select: none;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 12px;
  padding-inline-start: 0;
  gap: 8px;
}

/* Kill native disclosure marker (looks like a dash/triangle beside title on some browsers) */
.car-block > summary.detail-heading::-webkit-details-marker {
  display: none;
}
.car-block > summary.detail-heading::marker {
  content: "";
  display: none;
}

.car-block > summary .car-heading-left {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  min-width: 0;
  line-height: 1.25;
}

/* ▶ flush left of title, vertically centered with title text (not above) */
.car-block > summary .chev {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1;
  transition: transform 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.85em;
  height: 1.05rem;
  flex: 0 0 auto;
  position: static;
  transform: none;
  margin: 0;
  padding: 0;
}

.car-block[open] > summary .chev {
  transform: rotate(90deg);
}

.car-block-body {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Multi-car accordion in main detail card (replaces top garage cards) */
.cars-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cars-list > .car-block {
  position: relative;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
}

.cars-list > .car-block.is-open,
.cars-list > .car-block[open] {
  border-color: var(--accent);
  background: #2a3540;
}

.cars-list > .car-block > summary.car-summary {
  position: relative;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 12px 42px 12px 14px; /* room for overlaid × */
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.cars-list > .car-block > summary.car-summary::-webkit-details-marker {
  display: none;
}
.cars-list > .car-block > summary.car-summary::marker {
  content: "";
  display: none;
}

.car-summary-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.cars-list > .car-block > summary .car-heading-left {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  min-width: 0;
  line-height: 1.25;
}

.cars-list > .car-block > summary .car-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.25;
}

.car-summary-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  padding-left: calc(0.85em + 6px); /* align under title, past chevron */
  margin-top: 0;
}

.car-summary-meta .garage-health-dot {
  width: 8px;
  height: 8px;
  margin-left: 2px;
}

.cars-list > .car-block > summary .car-delete {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
}

.cars-list > .car-block > .car-block-body {
  padding: 0 12px 12px;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
  box-sizing: border-box;
}

.cars-list > .car-block:not([open]) > .car-block-body {
  display: none;
}

.garage-card,
.cars-list,
.cars-list > .car-block {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.garage-card {
  overflow-x: hidden;
}

/* Car-name health bubble removed (Hunter) — keep hidden if markup remains */
.health-bubble { display: none !important; }

.garage-row {
  position: relative;
  display: block;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 10px;
  transition: border-color 0.15s, background 0.15s;
}

.garage-row:hover {
  border-color: var(--accent);
}

.garage-row:has(.car-btn.active) {
  border-color: var(--accent);
  background: #2a3540;
}

/* One shared border on .garage-row; car-btn fills it, × overlays end inside */
.garage-row .car-btn {
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 10px;
  padding-right: 42px; /* room for overlaid × */
}

.garage-row .car-btn:hover,
.garage-row .car-btn.active {
  border-color: transparent;
  background: transparent;
}

.car-delete {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1;
  transition: color 0.15s;
}

.car-delete:hover {
  color: #ef9a9a;
  background: transparent;
  border: none;
}

.garage-list {
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.car-btn {
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.car-btn:hover { border-color: var(--accent); }
.car-btn.active {
  border-color: var(--accent);
  background: #2a3540;
}

.car-btn .name { font-weight: 600; font-size: 0.95rem; }
.car-btn .meta {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.car-btn .meta .meta-text { color: var(--muted); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 16px;
}

.miles-bar {
  display: flex;
  flex-wrap: nowrap;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
  box-sizing: border-box;
  margin-bottom: 10px;
}

.miles-bar label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
}

.miles-bar label .odo-label {
  flex: 0 0 auto;
  white-space: nowrap;
}

.miles-bar label .miles-input {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 9rem;
  width: auto;
  background: #000000;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 4px 8px;
  height: 28px;
  box-sizing: border-box;
}

.add-form select.ymm-select {
  background: #000000;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 8px 10px;
  min-width: 0;
  width: 100%;
  font-family: inherit;
  appearance: auto;
  cursor: pointer;
}

.add-form select.ymm-select:focus {
  outline: none;
  border-color: var(--accent);
}

.add-form select.ymm-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.miles-bar .save-miles-btn {
  flex: 0 0 auto;
  margin-left: auto;
  white-space: nowrap;
  font-weight: 600;
  font-size: 0.75rem;
  padding: 4px 10px;
  line-height: 1.2;
  height: 28px;
  border-radius: 6px;
}

/* Secondary outline charcoal — smaller than Update */
.miles-bar .customize-btn {
  flex: 0 0 auto;
  white-space: nowrap;
  font-weight: 600;
  font-size: 0.7rem;
  padding: 4px 8px;
  line-height: 1.2;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid #5a5a5a;
  color: var(--muted);
  cursor: pointer;
}
.miles-bar .customize-btn:hover {
  color: var(--text);
  border-color: #808080;
  background: rgba(255, 255, 255, 0.04);
}
.miles-bar .customize-btn.is-active {
  color: var(--text);
  border-color: #808080;
  background: rgba(255, 255, 255, 0.08);
}

/* Customize mode: name + compact everyMiles / everyMonths inputs */
.item.item--customize {
  gap: 6px;
}
.item.item--customize .item-name-col {
  flex: 1 1 auto;
  min-width: 0;
}
.item.item--customize .item-name {
  flex: 1 1 auto;
}
.interval-fields {
  display: inline-flex;
  flex: 0 0 auto;
  flex-shrink: 0;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.interval-field {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 3px;
  margin: 0;
  padding: 0;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  min-width: 0;
}
.item.item--customize .interval-input,
.item.item--add-part .interval-input,
.interval-input {
  width: 4.25rem;
  max-width: 4.25rem;
  min-width: 0;
  height: 26px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid #5a5a5a;
  background: #2a2a2a;
  /* Match tire “e.g. …” / input::placeholder muted grey */
  color: #6a6a6a;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: right;
  box-sizing: border-box;
  -moz-appearance: textfield;
}
.interval-input::-webkit-outer-spin-button,
.interval-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.interval-input:focus {
  outline: none;
  border-color: var(--accent);
  background: #333;
  color: var(--text);
}
.interval-input::placeholder {
  color: #6a6a6a;
  opacity: 1;
}
.interval-unit {
  flex: 0 0 auto;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1;
}

/* Customize: Add a part row */
.item.item--add-part {
  justify-content: flex-start;
  align-items: center;
}
.item.item--add-part:not(.is-editing) {
  padding-top: 6px;
  padding-bottom: 6px;
}
.item.item--add-part .add-part-btn {
  flex: 0 0 auto;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: 6px;
  height: 26px;
}
.item.item--add-part .add-part-name {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 26px;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid #5a5a5a;
  background: #2a2a2a;
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  box-sizing: border-box;
}
.item.item--add-part .add-part-name:focus {
  outline: none;
  border-color: var(--accent);
  background: #333;
}
.item.item--add-part .add-part-name::placeholder {
  color: #6a6a6a;
  font-weight: 500;
}
.item.item--add-part .item-name-col {
  flex: 1 1 auto;
  min-width: 0;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input, select, button.primary, button.ghost, button.type-btn {
  font: inherit;
  color: var(--text);
}

input {
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  min-width: 0;
}

input:focus {
  outline: none;
  border-color: var(--accent);
}

input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.primary {
  background: #1565c0;
  border: 1px solid #42a5f5;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  color: #fff;
}

button.primary:hover { background: #1976d2; }
button.primary:disabled { opacity: 0.5; cursor: wait; }

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
}

button.ghost:hover {
  color: var(--text);
  border-color: var(--accent);
}

.type-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

button.type-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
}

button.type-btn:hover { border-color: var(--accent); }
button.type-btn.selected {
  border-color: var(--accent);
  background: #2a3540;
  color: var(--accent);
}

.type-hint {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  margin-top: -2px;
}

.items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.section {
  background: #0d0d0d;
  border: none;
  border-radius: 12px;
  overflow: hidden;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.section > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 10px 8px;
  background: transparent;
  border-bottom: none;
  user-select: none;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: hidden;
}

.section > summary::-webkit-details-marker { display: none; }

.section > summary .sec-left {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
}

.section > summary .chev {
  color: var(--muted);
  font-size: 0.75rem;
  transition: transform 0.15s;
  display: inline-block;
  width: 1em;
}

.section[open] > summary .chev {
  transform: rotate(90deg);
}

.section > summary .sec-count {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin-left: 2px;
}

.section-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
  box-sizing: border-box;
}

.section-body:empty {
  display: none;
}

.section-note {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.35;
  padding: 2px 4px 6px;
}

/* Compact single-line maintenance rows: dot | name | date | Update | Undo */
.item {
  display: flex !important;
  flex-wrap: nowrap !important;
  flex-direction: row !important;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border-radius: 6px;
  padding: 4px 8px;
  border: none;
  min-height: 0 !important;
  height: auto;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.item > .health-dot,
.item > .f-mark,
.item > .f-undo {
  flex-shrink: 0;
}

.item > .item-name,
.item > .item-name-col,
.item > .f-last-wrap {
  min-width: 0;
}

.item.has-seg {
  overflow: visible;
}

.item-name-col {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.item-name-col .item-name {
  flex: 1 1 auto;
  min-width: 0;
}

.item-name-col .seg-btns {
  flex: 0 0 auto;
  margin-left: auto;
}

.item .f-last-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  margin-right: 4px;
  flex-shrink: 0;
}

.item-name {
  flex: 1 1 auto !important;
  flex-shrink: 1 !important;
  min-width: 0 !important;
  font-weight: 600;
  font-size: 0.85rem;
  line-height: 1.2;
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item .f-last-wrap {
  cursor: pointer;
  position: relative;
  flex: 0 0 auto;
  flex-shrink: 0 !important;
  display: inline-flex;
  align-items: center;
  gap: 0;
  min-width: 0;
  max-width: 46%;
}

.item .f-last {
  flex: 0 0 auto;
  min-width: 1.25rem;
  padding: 0;
  margin: 0;
  font: inherit;
  /* Match .f-last-label: muted + same size/weight */
  font-weight: 500;
  font-size: 0.75rem;
  line-height: 1.2;
  color: var(--muted);
  text-align: center;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  white-space: nowrap;
}

.item .f-last.is-empty {
  color: var(--muted);
}

.item .f-last:focus {
  outline: none;
}

.item .f-last:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Hidden date value holder (scroll-wheel picker writes here) */
.item .f-last-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.item .f-mark {
  flex: 0 0 auto;
  flex-shrink: 0 !important;
  padding: 3px 8px;
  font-weight: 600;
  font-size: 0.75rem;
  line-height: 1.2;
  white-space: nowrap;
  border-radius: 6px;
}

.item .f-undo {
  flex: 0 0 auto;
  flex-shrink: 0 !important;
  width: 24px;
  height: 24px;
  min-width: 24px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  font-weight: 600;
}

.item .f-undo:hover {
  color: var(--text);
  border-color: var(--accent);
}

.item .f-undo:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Mobile: even skinnier controls so date+Update+Undo stay on the same row as name */
@media (max-width: 560px) {
  .item {
    display: flex !important;
    flex-wrap: nowrap !important;
    flex-direction: row !important;
    gap: 4px;
    padding: 3px 6px;
    min-height: 0 !important;
  }
  .item-name {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    font-size: 0.8rem;
  }
  .item .f-last-wrap {
    flex: 0 0 auto;
    flex-shrink: 0 !important;
    min-width: 0;
  }
  .item .f-last {
    min-width: 1rem;
    font-size: 0.65rem;
    font-weight: 500;
  }
  .item .f-mark {
    padding: 2px 6px;
    font-size: 0.7rem;
  }
  .item .f-undo {
    width: 22px;
    height: 22px;
    min-width: 22px;
    font-size: 0.8rem;
  }
}

.health-dot {
  flex: 0 0 auto;
  flex-shrink: 0 !important;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #555;
  display: inline-block;
}

/* Hunter thirds on charcoal: green >2/3 / yellow >1/3 / red ≤1/3 (no orange) */
.health-dot.ok { background: #00C853; }
.health-dot.watch { background: #FFEB3B; }
.health-dot.due { background: #F44336; }

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 100;
  max-width: 280px;
}

.toast.show { opacity: 1; }
.toast.err { border-color: var(--due); }

.empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 8px 0;
}

.add-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: none;
  display: none;
  flex-direction: column;
  gap: 8px;
}

.add-form.open { display: flex; }

.add-form > .ymm-select {
  width: 100%;
}

.status-bar {
  min-height: 1.2em;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.site-footer {
  margin-top: 28px;
  padding-top: 12px;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
}


/* ── Auth / login screen ────────────────────────────────────────── */

.guest-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}

.guest-banner.signed-in {
  color: var(--text);
  border: 1px solid #2a4050;
}

.banner-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.banner-btn {
  padding: 4px 10px !important;
  font-size: 0.75rem !important;
  white-space: nowrap;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  background: #000;
  overflow-y: auto;
}

.login-screen.is-hidden {
  display: none;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px 22px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.login-brand {
  text-align: center;
  margin-bottom: 22px;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.85rem;
  letter-spacing: 0.02em;
}

.login-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-guest {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  text-align: left;
  background: #1565c0;
  border: 1px solid #42a5f5;
  border-radius: 10px;
  padding: 14px 16px;
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}

.login-guest:hover {
  background: #1976d2;
}

.login-guest-hint {
  font-weight: 400;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.75);
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: var(--muted);
  font-size: 0.75rem;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
}

.login-tab {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.login-tab:hover {
  border-color: var(--accent);
  color: var(--text);
}

.login-tab.active {
  border-color: var(--accent);
  background: #2a3540;
  color: var(--accent);
}

.login-pane[hidden] {
  display: none !important;
}

.login-label {
  display: block;
  margin: 0 0 6px;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.login-pane input {
  width: 100%;
  margin-bottom: 12px;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}

.login-pane input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.login-full {
  width: 100%;
}

.login-hint {
  margin: 10px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}

.login-google {
  width: 100%;
  margin-top: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

.login-google:hover {
  border-color: var(--accent);
}

.google-g {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: #fff;
  color: #4285f4;
  font-weight: 700;
  font-size: 0.85rem;
  font-family: Arial, sans-serif;
}

.login-error {
  margin: 12px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--due);
  color: #ffcdd2;
  font-size: 0.8rem;
  line-height: 1.35;
}

.login-error[hidden] {
  display: none !important;
}

.login-foot {
  margin: 16px 0 0;
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.35;
}

body.login-open {
  overflow: hidden;
}

body.login-open .wrap {
  visibility: hidden;
  pointer-events: none;
}


/* ── Guest-first: secondary dismiss + close ─────────────────────── */

.login-card {
  position: relative;
}

.login-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.login-close:hover {
  color: var(--text);
  background: var(--surface-2);
}

/* Secondary text link at bottom (was big blue Continue as guest) */
.login-guest-link {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 10px 8px;
  background: transparent;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  text-align: center;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.login-guest-link:hover {
  color: var(--accent);
}

.login-guest-link:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* Keep legacy .login-guest if referenced elsewhere */
.login-guest {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  text-align: left;
  background: #1565c0;
  border: 1px solid #42a5f5;
  border-radius: 10px;
  padding: 14px 16px;
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}

.guest-banner.has-unsaved {
  color: var(--text);
  border: 1px solid #5a4a20;
  background: #1a1608;
}

.guest-banner.has-unsaved #bannerText {
  color: #ffe082;
}

/* ── Leave / save nudge modal ───────────────────────────────────── */

.leave-save-modal {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  background: rgba(0, 0, 0, 0.72);
  overflow-y: auto;
}

.leave-save-modal.is-hidden,
.leave-save-modal[hidden] {
  display: none !important;
}

.leave-save-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 22px 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.leave-save-card h2 {
  margin: 0 0 10px;
  font-size: 1.25rem;
  font-weight: 600;
}

.leave-save-body {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.leave-save-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leave-save-actions .primary,
.leave-save-actions .ghost {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.9rem;
}

.leave-save-actions .leave-danger {
  color: #ef9a9a;
  border-color: #5c3030;
}

.leave-save-actions .leave-danger:hover {
  color: #ffcdd2;
  border-color: var(--due);
}

body.leave-modal-open {
  overflow: hidden;
}

/* Banner Sign in / Save matches Add car primary blue (#1565c0), not accent sky */
.banner-btn.primary {
  background: #1565c0;
  border: 1px solid #42a5f5;
  color: #fff;
  padding: 8px 14px !important;
  font-size: 0.85rem !important;
  border-radius: 8px;
}
.banner-btn.primary:hover { background: #1976d2; }
.garage-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-top: 12px;
}
.garage-toolbar #toggleAdd.primary {
  flex: none;
  width: 100%;
  min-width: 0;
}
button.danger.garage-remove-btn[hidden],
.garage-remove-btn[hidden] {
  display: none !important;
}
button.danger.garage-remove-btn,
.garage-remove-btn {
  flex: 0 0 auto;
  align-self: flex-start;
  width: auto;
  max-width: 50%;
  background: #c62828;
  border: 1px solid #ef5350;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.7rem;
  line-height: 1.2;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}
button.danger.garage-remove-btn:hover,
.garage-remove-btn:hover {
  background: #d32f2f;
}
.garage-remove-btn[aria-pressed="true"] {
  background: #6d1b1b;
  border-color: #ef9a9a;
}

.garage-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
}
button.ghost.garage-export-btn[hidden],
.garage-export-btn[hidden] {
  display: none !important;
}
button.ghost.garage-export-btn,
.garage-export-btn {
  flex: 0 0 auto;
  width: auto;
  max-width: 50%;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.7rem;
  line-height: 1.2;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* Hide car × until Remove mode is active */
.cars-list:not(.remove-mode) .car-delete {
  display: none !important;
}
.cars-list:not(.remove-mode) > .car-block > summary.car-summary {
  padding-right: 14px;
}

/* Home width handled by .grid / body.has-detail .grid above */
/* detailCard removed — cars live inside .garage-card */


/* Garage list overall health (after mileage) */
.car-btn .meta .garage-health-dot {
  width: 8px;
  height: 8px;
  margin-left: 2px;
}

.section > summary .sec-health-dot {
  width: 9px;
  height: 9px;
  margin-left: 2px;
}

.tire-size-row {
  padding: 2px 4px 8px;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: hidden;
}

.tire-size-row--compact .tire-size-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tire-size-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.tire-size-header {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.tire-size-row--pair {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tire-pair-inputs {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: flex-end;
}

.tire-pair-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 0 1 auto;
  margin: 0;
  min-width: 0;
}

.tire-pair-mini {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.2;
}

.tire-size-input {
  width: 100%;
  max-width: 160px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  box-sizing: border-box;
}

.tire-size-input--short {
  width: 9.5rem;
  max-width: 9.5rem;
  flex: 0 0 auto;
}

.tire-size-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

@media (max-width: 420px) {
  .tire-size-input--short {
    width: 7.75rem;
    max-width: 7.75rem;
  }
  .tire-pair-inputs {
    gap: 6px;
  }
}

.seg-btns,
.tire-fitment {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: stretch;
  margin-left: auto;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  overflow: hidden;
  background: #1a1a1a;
  box-shadow: inset 0 0 0 1px #111;
  box-sizing: border-box;
}

.seg-btn,
.tire-fitment-btn {
  appearance: none;
  border: none;
  margin: 0;
  padding: 5px 9px;
  min-height: 28px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.1;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.seg-btn + .seg-btn,
.tire-fitment-btn + .tire-fitment-btn {
  border-left: 1px solid #3a3a3a;
}

.seg-btn.is-active,
.tire-fitment-btn.is-active {
  color: var(--text);
  background: #2f2f2f;
}

.seg-btn:focus-visible,
.tire-fitment-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 1;
}

.item-seg.seg-btns {
  border-radius: 6px;
}

.item-seg .seg-btn {
  padding: 2px 7px;
  min-height: 22px;
  font-size: 0.65rem;
}

.tire-rot-na {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
  flex-shrink: 0;
}

.tire-rot-na-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

@media (max-width: 560px) {
  .seg-btn,
  .tire-fitment-btn {
    padding: 5px 7px;
    font-size: 0.68rem;
  }
  .item-seg .seg-btn {
    padding: 2px 6px;
    min-height: 20px;
    font-size: 0.62rem;
  }
  .tire-rot-na-label {
    font-size: 0.65rem;
  }
}

@media (max-width: 560px) {
  .item .f-last-label {
    font-size: 0.65rem;
    margin-right: 3px;
  }
  .item .f-last-wrap {
    max-width: 52%;
  }
}


@media (max-width: 560px) {
  .cars-list > .car-block > .car-block-body,
  .section,
  .section-body,
  .items,
  .item,
  .miles-bar {
    max-width: 100%;
    overflow-x: hidden;
  }
  .miles-bar {
    flex-wrap: nowrap !important;
    gap: 4px;
  }
  .miles-bar label {
    gap: 4px;
    font-size: 0.7rem;
  }
  .miles-bar label .miles-input {
    max-width: none;
    flex: 1 1 auto;
    min-width: 0;
    padding: 3px 6px;
    font-size: 0.75rem;
    height: 26px;
  }
  .miles-bar .save-miles-btn {
    padding: 3px 8px;
    font-size: 0.7rem;
    height: 26px;
  }
  .miles-bar .customize-btn {
    padding: 3px 6px;
    font-size: 0.65rem;
    height: 26px;
  }
  .item.item--customize {
    gap: 4px;
  }
  .item.item--add-part .add-part-btn {
    padding: 3px 8px;
    font-size: 0.7rem;
    height: 24px;
  }
  .item.item--add-part .add-part-name {
    height: 24px;
    font-size: 0.75rem;
    padding: 2px 6px;
  }
  .interval-fields {
    gap: 4px;
  }
  .interval-input {
    width: 3.5rem;
    max-width: 3.5rem;
    height: 24px;
    padding: 2px 4px;
    font-size: 0.7rem;
  }
  .interval-unit {
    font-size: 0.6rem;
  }
  .section > summary .seg-btns,
  .section > summary .tire-fitment {
    margin-left: 0;
    width: 100%;
    justify-content: stretch;
  }
  .section > summary .seg-btn,
  .section > summary .tire-fitment-btn {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
  }
  .tire-size-input,
  .tire-size-input--short {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
  }
}

/* ── Scroll-wheel date picker (charcoal AutoLog) ─────────────────── */
.date-wheel-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  padding: 0;
}
.date-wheel-modal.is-hidden,
.date-wheel-modal[hidden] {
  display: none !important;
}
.date-wheel-sheet {
  width: 100%;
  max-width: 420px;
  background: #1e1e1e;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
  padding: 12px 14px max(16px, env(safe-area-inset-bottom));
  color: var(--text);
}
.date-wheel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.date-wheel-title {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.date-wheel-header .ghost,
.date-wheel-header .primary {
  padding: 8px 12px;
  font-size: 0.85rem;
  border-radius: 8px;
  min-width: 72px;
}
.date-wheel-hint {
  margin: 0 0 10px;
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
}
.date-wheel-cols {
  position: relative;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1fr;
  gap: 4px;
  height: 180px;
  overflow: hidden;
  background: #2a2a2a;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.date-wheel-cols::before,
.date-wheel-cols::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
  height: 60px;
  pointer-events: none;
}
.date-wheel-cols::before {
  top: 0;
  background: linear-gradient(to bottom, rgba(30,30,30,0.95), rgba(30,30,30,0));
}
.date-wheel-cols::after {
  bottom: 0;
  background: linear-gradient(to top, rgba(30,30,30,0.95), rgba(30,30,30,0));
}
.date-wheel-selection {
  position: absolute;
  left: 6px;
  right: 6px;
  top: 50%;
  height: 36px;
  margin-top: -18px;
  border-radius: 8px;
  background: rgba(144, 202, 249, 0.12);
  border: 1px solid rgba(144, 202, 249, 0.28);
  z-index: 1;
  pointer-events: none;
}
.date-wheel-col {
  position: relative;
  z-index: 3;
  height: 100%;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.date-wheel-col::-webkit-scrollbar { display: none; }
.date-wheel-spacer {
  height: 72px;
  flex-shrink: 0;
  pointer-events: none;
}
.date-wheel-option {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: center;
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted);
  user-select: none;
}
.date-wheel-option.is-selected {
  color: var(--text);
  font-weight: 600;
}
body.date-wheel-open {
  overflow: hidden;
}

@media (min-width: 561px) {
  .date-wheel-modal {
    align-items: center;
    padding: 24px;
  }
  .date-wheel-sheet {
    border-radius: 16px;
    border-bottom: 1px solid var(--border);
  }
}

/* ── Unified My Garage + cars (continuous block) ───────────────── */
.garage-card {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.garage-card > h2 {
  margin-bottom: 8px;
}
.garage-card .garage-toolbar {
  margin-top: 0;
  margin-bottom: 0;
}
.garage-card .add-form {
  margin-top: 10px;
  padding-top: 10px;
}
.garage-card .cars-list {
  margin-top: 12px;
  gap: 8px;
}
.garage-card .cars-list:empty {
  margin-top: 0;
}

/* Muted wear explainer under last car (above signed-in strip) */
.garage-wear-note {
  margin: 12px 0 0;
  padding: 0 2px;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--muted);
  opacity: 0.85;
}
.cars-list:empty + .garage-wear-note {
  display: none;
}
/* Auth / signed-in strip sits under the last car */
.garage-card > .guest-banner {
  margin: 16px 0 0;
  order: 99;
}
/* Single-column garage (no separate detail card) */
.grid {
  grid-template-columns: 1fr;
  max-width: 420px;
}
body.has-detail .grid {
  max-width: 560px;
}
@media (min-width: 800px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

/* Hide Standard|Staggered / Chain|Belt when section is collapsed */
details.section:not([open]) > summary .tire-fitment,
details.section:not([open]) > summary .seg-btns {
  display: none !important;
}

/* Customize: grey × to delete custom parts */
.item-custom-delete {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #8a8a8a;
  cursor: pointer;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.item-custom-delete:hover {
  color: #c0c0c0;
  background: rgba(255, 255, 255, 0.06);
}
.item.item--customize .item-custom-delete {
  order: -1;
  margin-right: 2px;
}
