/* Dude Log — mobile-first (primary use: ~390px phone) */
:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --bg-elevated: #ffffff;
  --bg-subtle: #e8edf7;
  --fg: #0f172a;
  --fg-muted: #475569;
  --fg-subtle: #64748b;
  --border: #dbe3f0;
  --border-strong: #cbd5e1;
  --primary: #1d4ed8;
  --primary-fg: #f8fafc;
  --danger: #b91c1c;
  --warn: #a16207;
  --shadow: 0 1px 0 rgba(15, 23, 42, 0.04), 0 10px 28px -18px rgba(15, 23, 42, 0.35);
  --radius: 14px;
  --font: "Figtree", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --tap: 44px;
  --pad: 1rem;
  --bottom-nav: calc(3.75rem + env(safe-area-inset-bottom, 0px));
  --topbar: 3.5rem;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--fg);
}
body {
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.45;
  background: var(--bg);
  color: var(--fg);
}

a { color: var(--primary); text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 45%, white);
  outline-offset: 2px;
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--bottom-nav);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  min-height: var(--topbar);
  padding: .65rem var(--pad);
  padding-top: max(.65rem, env(safe-area-inset-top, 0px));
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  color: inherit;
  min-height: var(--tap);
}
.brand .mark, .mark {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 10px;
  background: var(--primary);
  color: var(--primary-fg);
  font-weight: 700;
  font-size: .85rem;
}
.brand strong { display: block; font-size: 1rem; line-height: 1.1; }
.kicker, .sidebar-kicker {
  display: block;
  font-size: .75rem;
  color: var(--fg-muted);
  font-weight: 500;
}
.topbar-out { margin: 0; }

.content {
  flex: 1;
  width: 100%;
  max-width: 42rem;
  margin: 0 auto;
  padding: 1rem var(--pad) 1.5rem;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .25rem;
  min-height: var(--bottom-nav);
  padding: .35rem .5rem max(.35rem, env(safe-area-inset-bottom, 0px));
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px -18px rgba(15, 23, 42, 0.35);
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .15rem;
  min-height: var(--tap);
  border-radius: 12px;
  color: var(--fg-muted);
  font-size: .75rem;
  font-weight: 600;
}
.bottom-nav a.is-active {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}
.nav-ico { font-size: 1.05rem; line-height: 1; }

.stack { display: flex; flex-direction: column; gap: 1rem; }
.page-head h1, h1 { margin: 0 0 .25rem; font-size: 1.55rem; line-height: 1.15; }
h2 { margin: 0; font-size: 1.1rem; }
.lede { margin: 0; color: var(--fg-muted); }
.tiny { font-size: .875rem; }
.muted { color: var(--fg-subtle); }
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .65rem;
}
.stat-card {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding: .9rem .75rem;
  min-height: 4.5rem;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: inherit;
}
.stat-label { font-size: .75rem; color: var(--fg-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.stat-value { font-size: 1.45rem; font-weight: 700; }

.card, .empty {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .65rem;
}
.tap-card { padding: 0; overflow: hidden; }
.card-link {
  display: block;
  padding: 1rem;
  color: inherit;
  min-height: var(--tap);
}
.card-title { font-weight: 650; }
.card-meta { margin-top: .25rem; color: var(--fg-muted); font-size: .9rem; }

.pill {
  display: inline-block;
  padding: .15rem .45rem;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--fg-muted);
  font-size: .75rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .02em;
  margin-right: .35rem;
}

.notice {
  padding: .85rem 1rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--primary) 12%, white);
  border: 1px solid color-mix(in srgb, var(--primary) 28%, white);
  color: var(--fg);
}
.error {
  padding: .85rem 1rem;
  border-radius: var(--radius);
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
}

label {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  font-weight: 600;
  font-size: .92rem;
}
input, select, textarea, button {
  font: inherit;
}
input, select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: .7rem .85rem;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--bg-elevated);
  color: var(--fg);
}
/* No hover-only affordances — tap states via :active */
.btn, button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: var(--tap);
  padding: .7rem 1rem;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 650;
  cursor: pointer;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.btn.primary, button.btn.primary {
  background: var(--primary);
  color: var(--primary-fg);
}
.btn.ghost, button.btn.ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--border-strong);
}
.btn.block { width: 100%; }
.btn:active, .tap:active, .tap-card:active, .stat-card.tap:active {
  transform: scale(0.98);
  opacity: .92;
}

.sticky-action, .sticky-bar {
  position: sticky;
  bottom: calc(var(--bottom-nav) + .5rem);
  z-index: 15;
}
.sticky-bar {
  padding-top: .25rem;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .35rem;
  padding: .3rem;
  background: var(--bg-subtle);
  border-radius: 14px;
}
.tabs a {
  min-height: var(--tap);
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--fg-muted);
  font-weight: 650;
}
.tabs a.is-active {
  background: var(--bg-elevated);
  color: var(--fg);
  box-shadow: var(--shadow);
}

/* Auth — single column on phone */
.auth-body { min-height: 100dvh; background: var(--bg); }
.auth { min-height: 100dvh; display: flex; }
.auth-single { align-items: stretch; }
.auth-form {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.25rem var(--pad) 2rem;
  padding-top: max(1.25rem, env(safe-area-inset-top, 0px));
}
.auth-form-inner {
  width: 100%;
  max-width: 24rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.auth-form h1 { font-size: 1.65rem; }

/* Wider tablets: still single column content, slightly roomier */
@media (min-width: 640px) {
  :root { --pad: 1.25rem; }
  .content { padding-top: 1.35rem; }
  .stat-grid { gap: .85rem; }
}

/* Desktop: keep phone layout as default; widen content a bit */
@media (min-width: 900px) {
  .content { max-width: 48rem; }
  .bottom-nav { max-width: 48rem; left: 50%; transform: translateX(-50%); border-radius: 16px 16px 0 0; }
}

/* Stacked “tables” pattern helper if any table sneaks in */
table.data {
  width: 100%;
  border-collapse: collapse;
}
@media (max-width: 639px) {
  table.data, table.data thead, table.data tbody, table.data th, table.data td, table.data tr {
    display: block;
  }
  table.data thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.data tr {
    margin-bottom: .65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    padding: .75rem 1rem;
  }
  table.data td {
    padding: .25rem 0;
  }
  table.data td::before {
    content: attr(data-label);
    display: block;
    font-size: .75rem;
    font-weight: 650;
    color: var(--fg-muted);
    text-transform: uppercase;
  }
}

/* Phase 2 — 5-tab nav, due rows, hub */
.bottom-nav.nav-5 { grid-template-columns: repeat(5, 1fr); }
.bottom-nav.nav-5 a { font-size: .68rem; padding: .2rem .1rem; }
.stat-card.is-active {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 20%, transparent);
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.pill-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  padding: .35rem .7rem;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--fg-muted);
  font-size: .8rem;
  font-weight: 650;
}
.pill-link.is-active {
  background: var(--primary);
  color: var(--primary-fg);
}
.due-card { padding: 0; }
.due-card .card-link { padding-bottom: .5rem; }
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  padding: 0 1rem 1rem;
}
.inline-form { display: inline; margin: 0; }
.hub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .65rem;
}
.hub-grid .card { margin: 0; }
.check-row {
  flex-direction: row;
  align-items: center;
  gap: .65rem;
  font-weight: 600;
}
.check-row input { width: auto; min-height: var(--tap); min-width: var(--tap); }
.card.is-focus {
  border-color: var(--primary);
}
.filter-card { gap: .75rem; }
.btn:disabled, button:disabled {
  opacity: .55;
  cursor: not-allowed;
}


/* Phase 3 photos */
.photo-thumb {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 10px;
  background: #0f172a12;
}
.row.gap { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.inline { display: inline; }

/* Polish 0.5.0 */
.mark { display: inline-flex; color: var(--primary); }
.mark svg { display: block; border-radius: 8px; }
.nav-ico { display: inline-flex; align-items: center; justify-content: center; height: 1.35rem; }
.nav-ico svg { display: block; }
.empty-guide { text-align: center; padding: 1.25rem 1rem 1.35rem; gap: .75rem; display: flex; flex-direction: column; align-items: stretch; }
.empty-guide h2, .empty-title { margin: 0; font-size: 1.15rem; }
.empty-ico { color: var(--primary); opacity: .85; display: flex; justify-content: center; }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .55rem; text-align: left; }
.empty-caught-up { text-align: center; }
.empty-ctas { justify-content: center; }
.hub-hero { padding: 0; overflow: hidden; }
.hub-hero-img { width: 100%; max-height: 200px; object-fit: cover; display: block; background: #0f172a12; }
.hub-hero-meta { padding: .85rem 1rem 1rem; display: flex; flex-direction: column; gap: .25rem; }
.hub-meta { display: flex; flex-direction: column; gap: .25rem; }
.hub-grid .card-title { font-size: .95rem; }
.hub-grid .card-meta { font-size: .8rem; }
.field-group {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .75rem .9rem 1rem;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.field-group legend {
  padding: 0 .35rem;
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--fg-muted);
}
.pill-overdue { background: color-mix(in srgb, #dc2626 18%, transparent); color: #b91c1c; }
.pill-soon { background: color-mix(in srgb, #d97706 18%, transparent); color: #b45309; }
.pill-doc, .pill-warranty { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
