:root {
  /* Workshop Steel — cool neutral paper, confident cobalt accent, warm brass for contrast/achievement */
  --bg: #f3f5f8;
  --panel: #ffffff;
  --panel-2: #e9eef4;
  --ink: #161a21;
  --ink-soft: #5b6472;
  --border: #dce3ea;
  --accent: #2b5fa5;
  --accent-ink: #ffffff;
  --accent-2: #c99a46;
  --blue: #64748b;
  --green: #2f8f5b;
  --shadow: 0 1px 2px rgba(20, 30, 45, 0.06), 0 6px 20px rgba(20, 30, 45, 0.06);
  --radius: 14px;
  --font-serif: "Cardo", Georgia, "Iowan Old Style", ui-serif, serif;
  --font-sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-synthesis: none;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10151c;
    --panel: #171d26;
    --panel-2: #1c232e;
    --ink: #e9edf3;
    --ink-soft: #8a94a3;
    --border: #29323f;
    --accent: #6fa8e0;
    --accent-ink: #0b1420;
    --accent-2: #d9b563;
    --blue: #8493a6;
    --green: #5fbf95;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme="dark"] {
  --bg: #10151c; --panel: #171d26; --panel-2: #1c232e; --ink: #e9edf3; --ink-soft: #8a94a3;
  --border: #29323f; --accent: #6fa8e0; --accent-ink: #0b1420; --accent-2: #d9b563;
  --blue: #8493a6; --green: #5fbf95; --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 24px rgba(0,0,0,.4);
}
:root[data-theme="light"] {
  --bg: #f3f5f8; --panel: #ffffff; --panel-2: #e9eef4; --ink: #161a21; --ink-soft: #5b6472;
  --border: #dce3ea; --accent: #2b5fa5; --accent-ink: #ffffff; --accent-2: #c99a46;
  --blue: #64748b; --green: #2f8f5b; --shadow: 0 1px 2px rgba(20,30,45,.06), 0 6px 20px rgba(20,30,45,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; }
h1 { font-family: var(--font-serif); letter-spacing: -0.01em; font-weight: 700; }

.app-shell { max-width: 880px; margin: 0 auto; padding: 0 18px 80px; }

/* ---------- Header / nav ---------- */
header.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.top-inner {
  max-width: 880px; margin: 0 auto; padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17.5px; letter-spacing: -0.01em; font-family: var(--font-serif); }
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-ink); font-size: 16px; overflow: hidden;
}
.brand .mark img { width: 68%; height: 68%; object-fit: contain; }
nav.tabs { display: flex; gap: 4px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
nav.tabs button {
  border: none; background: transparent; padding: 7px 14px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer;
}
nav.tabs button.active { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- Bottom tab bar (mobile only) ---------- */
.bottom-tabs {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
}
.bottom-tabs .nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: none; background: transparent; color: var(--ink-soft); padding: 6px 4px; border-radius: 10px;
  font-size: 10.5px; font-weight: 700; cursor: pointer;
}
.bottom-tabs .nav-btn .bt-icon { font-size: 19px; line-height: 1; filter: grayscale(1); opacity: .55; }
.bottom-tabs .nav-btn.active { color: var(--accent); }
.bottom-tabs .nav-btn.active .bt-icon { filter: none; opacity: 1; }

/* ---------- Cards / layout ---------- */
.section { margin-top: 26px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.section-head h2 { font-size: 15px; margin: 0; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Home hero ---------- */
.hero { display: grid; grid-template-columns: 1fr 210px; gap: 18px; align-items: stretch; }
@media (max-width: 640px) { .hero { grid-template-columns: 1fr; } }
.hero .visual { display: flex; align-items: center; justify-content: center; padding: 6px; }
.topic-badge {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  color: var(--accent); border-radius: 24%;
}
.stat-row { display: flex; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.stat {
  flex: 1; min-width: 110px; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px;
}
.stat .num { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.stat .lbl { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

.progress-bar { height: 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border); overflow: hidden; }
.progress-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; transition: width .3s ease; }

.continue-card {
  display: flex; align-items: center; gap: 14px; margin-top: 16px; padding: 14px 16px;
  border-radius: 12px; background: var(--panel-2); border: 1px dashed var(--border); cursor: pointer;
}
.continue-card:hover { border-color: var(--accent); }
.continue-card .icon {
  width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
}
.continue-card .txt small { display: block; color: var(--ink-soft); font-size: 12px; margin-top: 2px; }
.continue-card .continue-title { font-family: var(--font-serif); font-weight: 700; font-size: 15.5px; }

/* ---------- Car shelf ---------- */
.shelf { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
@media (max-width: 640px) { .shelf { grid-template-columns: repeat(5, 1fr); } }
.shelf .slot {
  aspect-ratio: 1; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; padding: 10px; cursor: pointer; position: relative;
  color: var(--ink-soft);
}
.shelf .slot:hover { border-color: var(--accent); }
.shelf .slot.complete { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel-2)); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.shelf .slot svg { width: 100%; height: 100%; }
.shelf .slot .n { position: absolute; bottom: 2px; right: 5px; font-size: 9px; color: var(--ink-soft); font-weight: 700; }

/* ---------- Phase / garage list ---------- */
.phase-block { margin-bottom: 22px; }
.phase-title { font-size: 13px; font-weight: 700; color: var(--blue); text-transform: uppercase; letter-spacing: .05em; margin: 0 0 8px 2px; }
.garage-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--border); cursor: pointer; margin-bottom: 8px;
}
.garage-row:hover { border-color: var(--accent); }
.garage-row .badge-num {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; background: var(--panel-2); border: 1px solid var(--border); color: var(--ink-soft);
}
.garage-row.complete .badge-num { background: var(--green); color: #fff; border-color: transparent; }
.garage-row .info { flex: 1; min-width: 0; }
.garage-row .info .title-line { display: flex; align-items: center; gap: 8px; font-size: 15.5px; }
.garage-row .info .row-title { font-family: var(--font-serif); font-weight: 700; }
.garage-row .info .sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 1px; }
.garage-row .pbar { width: 90px; flex-shrink: 0; }
.pill {
  display: inline-flex; align-items: center; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; padding: 2px 7px; border-radius: 999px; background: var(--panel-2); color: var(--ink-soft);
  border: 1px solid var(--border);
}

/* ---------- Garage detail ---------- */
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-soft); cursor: pointer; margin-bottom: 10px; }
.back-link:hover { color: var(--ink); }
.detail-head { display: flex; gap: 18px; align-items: center; }
.detail-head .visual { width: 130px; height: 130px; flex-shrink: 0; }
.detail-head h1 { font-size: 22px; margin: 0 0 2px; letter-spacing: -0.01em; }
.detail-head .sub { color: var(--ink-soft); font-size: 14px; }

.swatch-picker { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.swatch-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); margin-bottom: 8px; }
.swatch-row { display: flex; flex-wrap: wrap; gap: 9px; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--panel);
  box-shadow: 0 0 0 1px var(--border); cursor: pointer; padding: 0; position: relative; flex-shrink: 0;
}
.swatch:hover { box-shadow: 0 0 0 1px var(--ink-soft); }
.swatch.selected { box-shadow: 0 0 0 2px var(--accent); }
.swatch-default { background: var(--panel-2); color: var(--ink-soft); font-size: 13px; display: flex; align-items: center; justify-content: center; }


.item-list { margin-top: 8px; }
.item-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border);
}
.item-row:last-child { border-bottom: none; }
.item-row .chk {
  width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--border); flex-shrink: 0; margin-top: 1px;
  display: flex; align-items: center; justify-content: center; cursor: pointer; background: var(--panel);
}
.item-row .chk.done { background: var(--green); border-color: var(--green); color: #fff; }
.item-row .body { flex: 1; min-width: 0; }
.item-row .ref { font-size: 14.5px; font-weight: 600; }
.item-row .label { font-size: 11.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.item-row .add-journal { font-size: 12px; color: var(--blue); font-weight: 700; cursor: pointer; }
.item-row.done .ref { color: var(--ink-soft); text-decoration: line-through; text-decoration-color: var(--border); }
.row-links { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 5px; align-items: center; }
.note-badge { font-size: 12px; font-weight: 700; color: var(--accent-2); cursor: pointer; }
.admin-link { font-size: 12px; font-weight: 700; color: var(--ink-soft); cursor: pointer; border: 1px dashed var(--border); border-radius: 999px; padding: 1px 8px; }
.admin-link:hover { color: var(--ink); border-color: var(--ink-soft); }

/* ---------- OM's Notes directory ---------- */
.note-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.note-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; cursor: pointer; display: flex; flex-direction: column; gap: 8px;
}
.note-card:hover { border-color: var(--accent); }
.note-card-top { display: flex; flex-wrap: wrap; gap: 6px; }
.note-card-title { font-family: var(--font-serif); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.note-card-excerpt { font-size: 13.5px; color: var(--ink-soft); line-height: 1.5; flex: 1; }
.note-card-meta { font-size: 11.5px; color: var(--ink-soft); border-top: 1px solid var(--border); padding-top: 8px; margin-top: 2px; }

/* ---------- OM's Notes feed ---------- */
.feed-author { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; flex-shrink: 0;
}
.feed-author-name { font-weight: 700; font-size: 13.5px; }
.feed-date { font-size: 12px; color: var(--ink-soft); }
.feed-body { font-size: 15px; line-height: 1.65; margin-top: 4px; }
.feed-body p { margin: 0 0 12px; }
.feed-body p:last-child { margin-bottom: 0; }

.comment-list { display: flex; flex-direction: column; gap: 16px; }
.comment { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: none; padding-bottom: 0; }
.comment-head { display: flex; align-items: baseline; gap: 8px; }
.comment-head .nick { font-weight: 700; font-size: 13.5px; }
.comment-head .when { font-size: 11.5px; color: var(--ink-soft); }
.comment-body { font-size: 14px; line-height: 1.55; margin-top: 3px; }
.comment-body p { margin: 0 0 6px; }
.comment-delete { font-size: 11.5px; font-weight: 700; color: var(--ink-soft); cursor: pointer; display: inline-block; margin-top: 4px; }
.comment-delete:hover { color: #c0392b; }

details.method { margin-top: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel-2); }
details.method summary { padding: 12px 16px; cursor: pointer; font-weight: 700; font-size: 13.5px; list-style: none; display: flex; align-items: center; gap: 8px; }
details.method summary::-webkit-details-marker { display: none; }
details.method .method-body { padding: 4px 16px 16px; }
.qcard { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-top: 8px; }
.qcard .qtitle { font-weight: 700; font-size: 13.5px; }
.qcard .qsub { font-size: 11px; color: var(--accent); text-transform: uppercase; font-weight: 700; letter-spacing: .04em; }
.qcard ul { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--ink-soft); }
.qcard .ex { font-size: 12px; margin-top: 6px; font-style: italic; color: var(--ink-soft); }
.tips { font-size: 12.5px; color: var(--ink-soft); margin-top: 10px; padding-left: 18px; }

/* ---------- Journal ---------- */
.entry-card { padding: 14px 16px; }
.entry-card + .entry-card { margin-top: 10px; }
.entry-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.entry-head .date { font-weight: 700; font-size: 13.5px; }
.entry-head .ref { font-size: 12.5px; color: var(--ink-soft); }
.entry-q { margin-top: 8px; }
.entry-q .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); font-weight: 700; }
.entry-q .v { font-size: 13.5px; margin-top: 1px; white-space: pre-wrap; }
.entry-actions { display: flex; gap: 10px; margin-top: 10px; }
.entry-actions span { font-size: 12px; font-weight: 700; color: var(--ink-soft); cursor: pointer; }
.entry-actions span:hover { color: var(--accent); }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.empty .big { font-size: 34px; margin-bottom: 8px; }

/* ---------- Form ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 5px; color: var(--ink-soft); }
.field .hint { font-size: 11.5px; color: var(--ink-soft); margin-top: 4px; }
input[type="text"], input[type="date"], select, textarea {
  width: 100%; padding: 10px 11px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--ink); font-size: 14px; font-family: inherit;
}
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: 10px;
  border: none; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 13.5px; cursor: pointer;
}
.btn.secondary { background: var(--panel-2); color: var(--ink); border: 1px solid var(--border); }
.btn-row { display: flex; gap: 10px; margin-top: 18px; }

.fab {
  position: fixed; right: 20px; bottom: 20px; width: 54px; height: 54px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); border: none; font-size: 26px; cursor: pointer;
  box-shadow: 0 8px 20px rgba(0,0,0,0.25); z-index: 30; display: flex; align-items: center; justify-content: center;
}

.muted-note { font-size: 12.5px; color: var(--ink-soft); background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-top: 14px; }

.theme-toggle {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--panel-2);
  color: var(--ink); font-size: 15px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent); }

/* ---------- Account / auth ---------- */
.account { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-soft); }
.account .email { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account button { border: 1px solid var(--border); background: var(--panel-2); color: var(--ink); border-radius: 999px; padding: 5px 11px; font-size: 12px; font-weight: 700; cursor: pointer; }
.account button:hover { border-color: var(--accent); }

.auth-wrap { max-width: 420px; margin: 60px auto; }
.auth-wrap .mark-lg { width: 68px; height: 68px; border-radius: 18px; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 26px; margin: 0 auto 14px; overflow: hidden; }
.auth-wrap .mark-lg img { width: 68%; height: 68%; object-fit: contain; }
.auth-wrap h1 { text-align: center; font-size: 20px; margin: 0 0 4px; }
.auth-wrap p.sub { text-align: center; color: var(--ink-soft); font-size: 13.5px; margin: 0 0 20px; }
.auth-msg { font-size: 13px; border-radius: 10px; padding: 10px 12px; margin-top: 12px; }
.auth-msg.ok { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); border: 1px solid color-mix(in srgb, var(--green) 40%, transparent); }
.auth-msg.err { background: color-mix(in srgb, #c0392b 16%, transparent); color: #e26a56; border: 1px solid color-mix(in srgb, #c0392b 40%, transparent); }

/* ===========================================================
   Mobile (≤640px): bottom tab bar replaces the header nav,
   layouts stack instead of sitting side by side, touch targets grow.
   (720, not 640, so there's no cramped middle ground between this and
   the ~768px tablet width where the full desktop header fits fine.)
   =========================================================== */
@media (max-width: 720px) {
  .app-shell { padding: 0 14px calc(84px + env(safe-area-inset-bottom, 0px)); }

  /* Header: icon-only brand, no inline nav (moved to bottom bar), compact account area */
  .top-inner { padding: 12px 14px; gap: 8px; }
  .brand-text { display: none; }
  nav.top-tabs { display: none; }
  .theme-toggle { width: 32px; height: 32px; font-size: 14px; }
  .account { gap: 6px; }
  .account .email { display: none; }
  .account button { padding: 5px 9px; font-size: 11.5px; }

  .bottom-tabs { display: flex; }
  .fab { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); right: 16px; width: 50px; height: 50px; font-size: 24px; }

  /* Home hero */
  .hero { gap: 14px; }
  .hero .visual svg { max-width: 150px; }
  .stat-row { gap: 8px; }
  .stat { min-width: 0; padding: 10px; }
  .stat .num { font-size: 18px; }

  /* Garage bay: 5 across × 7 rows on phones (7 × 5 on desktop) — 35 either way */
  .shelf { grid-template-columns: repeat(5, 1fr); gap: 7px; }

  /* Garage list rows: progress bar drops under the title instead of squeezing it */
  .garage-row { flex-wrap: wrap; padding: 11px 12px; }
  .garage-row .info { min-width: 0; flex-basis: 100%; order: 2; }
  .garage-row .pbar { order: 3; width: 100%; margin-left: 44px; width: calc(100% - 44px); }
  .garage-row .badge-num { order: 1; }
  .garage-row .info .title-line { flex-wrap: wrap; }

  /* Garage detail header: visual on top, text below, instead of cramped side-by-side */
  .detail-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .detail-head .visual { width: 110px; height: 110px; }
  .detail-head h1 { font-size: 19px; }

  /* Color picker: generous tap targets, tighter gaps so more fit per row */
  .swatch-row { gap: 11px 10px; }
  .swatch, .swatch-default { width: 32px; height: 32px; }

  /* Journal / note forms */
  .btn-row { flex-wrap: wrap; }
  .btn-row .btn, .btn-row .secondary { flex: 1 1 auto; }

  /* Feed */
  .feed-author { flex-wrap: wrap; }
  .avatar { width: 32px; height: 32px; font-size: 12px; }

  h1 { font-size: 20px; }
}
