/* Forge design system — shared by the tracker and every add-on.
   Dark, warm, phone-first. No dependencies. */

:root {
  --bg: #121410;
  --surface: #1b1e19;
  --surface-2: #242822;
  --line: #2f342d;
  --fg: #ece7dc;
  --muted: #9a9b90;
  --brass: #c9973c;
  --brass-ink: #1a1408;
  --sage: #8fb27a;
  --warn: #d9a441;
  --danger: #c75a4a;
  --info: #7aa7c7;
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Newsreader", Georgia, "Times New Roman", serif;
  --nav-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark; /* native controls (date picker icon, pickers) drawn for a dark page */
}

@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --bg: #f4f1ea;
    --surface: #ffffff;
    --surface-2: #ebe6da;
    --line: #d9d3c4;
    --fg: #1b1b17;
    --muted: #6a6a60;
    --brass: #9c6f1f;
    --brass-ink: #fff8e8;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* the hidden attribute wins over component display rules */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.1; }
h1.display, h2.display, .display { font-family: var(--display); font-weight: 520; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--brass); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--fg); }
ul { list-style: none; margin: 0; padding: 0; }

/* Layout */
.app { max-width: 520px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(var(--nav-h) + var(--safe-b) + 24px); }
.app.no-nav { padding-bottom: 32px; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: 14px 16px 12px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { font-family: var(--display); font-size: 26px; line-height: 1; color: var(--brass); }
.topbar .sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
main { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grid-7 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 10px; } .mt-3 { margin-top: 14px; } .mt-4 { margin-top: 20px; }
.hide { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.flat { background: var(--surface-2); border-color: transparent; }
.card.accent { border-color: var(--brass); }
.card h2 { font-family: var(--display); font-size: 24px; font-weight: 520; }
.card h3 { font-size: 16px; }
.eyebrow { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.eyebrow.brass { color: var(--brass); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.brass { color: var(--brass); }
.sage { color: var(--sage); }
.warn { color: var(--warn); }
.danger { color: var(--danger); }
.bold { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 16px; width: 100%;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; font-size: 15px; -webkit-tap-highlight-color: transparent;
}
.btn.primary { background: var(--brass); color: var(--brass-ink); border-color: var(--brass); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.sm { min-height: 40px; font-size: 14px; padding: 0 12px; width: auto; }
.btn.xs { min-height: 34px; font-size: 13px; padding: 0 10px; width: auto; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:active { transform: translateY(1px); }
.icon-btn { background: none; border: 0; padding: 8px; color: var(--muted); min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }

/* Chips / toggles */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 42px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; -webkit-tap-highlight-color: transparent;
}
.chip.on { background: var(--brass); color: var(--brass-ink); border-color: var(--brass); }
.chip.sm { min-height: 36px; font-size: 13px; padding: 0 10px; }

/* Forms */
label.field { display: block; font-size: 12px; color: var(--muted); }
label.field > span { display: block; margin-bottom: 4px; }
.input, textarea.input, select.input {
  width: 100%; min-height: 48px; padding: 10px 12px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font-size: 16px;
}
textarea.input { min-height: 96px; resize: vertical; line-height: 1.4; }
.input:focus { outline: 2px solid var(--brass); outline-offset: 0; border-color: var(--brass); }
.input::placeholder { color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--brass); }
.switch { display: inline-flex; align-items: center; gap: 10px; }

/* Lists */
.list > li { padding: 10px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; padding-top: 0; }
.list.tight > li { padding: 6px 0; }
.kv { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }

/* Bars and badges */
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brass); border-radius: 999px; transition: width 0.25s; }
.bar.sage > span { background: var(--sage); }
.bar.info > span { background: var(--info); }
.bar.danger > span { background: var(--danger); }
.bar.tall { height: 12px; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.badge.brass { background: var(--brass); color: var(--brass-ink); }
.badge.sage { background: color-mix(in srgb, var(--sage) 25%, transparent); color: var(--sage); }
.badge.warn { background: color-mix(in srgb, var(--warn) 25%, transparent); color: var(--warn); }
.badge.danger { background: color-mix(in srgb, var(--danger) 25%, transparent); color: var(--danger); }
.badge.info { background: color-mix(in srgb, var(--info) 25%, transparent); color: var(--info); }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 8px; text-align: center; }
.stat .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 11px; color: var(--muted); }

/* Banners */
.banner { border-radius: var(--radius); padding: 12px 16px; font-size: 14px; border: 1px solid var(--line); background: var(--surface); }
.banner.warn { background: var(--warn); color: var(--brass-ink); border-color: var(--warn); }
.banner.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.banner.sage { background: color-mix(in srgb, var(--sage) 22%, var(--surface)); border-color: var(--sage); }
.banner.info { background: color-mix(in srgb, var(--info) 18%, var(--surface)); border-color: var(--info); }

/* Tabs (in-page) */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
/* wide screens (desktop/tablet): no hidden tabs — wrap instead of scroll */
@media (min-width: 640px) { .tabs:not(.nowrap) { flex-wrap: wrap; overflow-x: visible; } }
.tab { flex: 0 0 auto; min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 500; white-space: nowrap; }
.tab.on { background: var(--brass); color: var(--brass-ink); border-color: var(--brass); }
.tabs.fill .tab { flex: 1 1 0; text-align: center; }

/* Bottom nav */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.bottom-nav .inner { max-width: 520px; margin: 0 auto; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.bottom-nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: var(--nav-h); border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 500;
}
.bottom-nav button.on { color: var(--brass); }
.bottom-nav svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bottom-nav button.on svg { stroke-width: 2.4; }

/* Calendar cells */
.cal-cell { border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); padding: 6px 2px; text-align: center; font-size: 11px; line-height: 1.2; min-height: 64px; }
.cal-cell.today { border-color: var(--brass); background: var(--surface); box-shadow: inset 0 0 0 1px var(--brass); }
.cal-cell.bike { border-color: var(--sage); }
.cal-cell.past { opacity: 0.55; }
.cal-cell .d { font-weight: 600; font-size: 12px; }

/* Photos */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-grid figure { margin: 0; position: relative; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; display: block; }
.photo-grid figcaption { font-size: 11px; color: var(--muted); margin-top: 4px; }
.photo-grid .del { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,0.6); color: #fff; border: 0; border-radius: 8px; min-width: 30px; min-height: 30px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 50; opacity: 0; transition: opacity 0.2s; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; }

/* Timer */
.timer { font-variant-numeric: tabular-nums; font-size: 15px; display: inline-flex; align-items: center; gap: 6px; }
.timer.active { color: var(--brass); font-weight: 600; }

/* Misc */
.divider { height: 1px; background: var(--line); margin: 6px 0; }
.swipe-hint { display: flex; justify-content: space-between; align-items: center; }
.pill-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.strike { text-decoration: line-through; color: var(--muted); }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th, table.t td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
table.t td.r, table.t th.r { text-align: right; font-variant-numeric: tabular-nums; }
.sub-link { font-size: 13px; color: var(--brass); }
.notice { font-size: 12px; color: var(--muted); }
dialog { background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; max-width: 480px; width: calc(100vw - 32px); }
dialog::backdrop { background: rgba(0,0,0,0.6); }
