/* Visual contract — docs/specs/pwa-lite-v1.md §1 (OKLCH tokens, Ledger
   components, dark default). Fonts: self-hosted woff2 deferred (Phase 1 uses
   the spec's fallback stacks). */

:root {
  --radius-base: 6px;
  --hairline: 1px;
  --shadow-offset: 3px;
  --tile-pad: 12px;
  --card-pad: 24px;
  --page-pad: 16px;
  --content-max: 672px;
  --section-gap: 24px;

  --font-head: Fraunces, "Playfair Display", Georgia, serif;
  --font-body: Inter, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", monospace;
}

[data-theme="light"] {
  --c-paper: oklch(0.96 0.018 85);
  --c-paper-deep: oklch(0.92 0.025 85);
  --c-card: oklch(0.98 0.012 85);
  --c-ink: oklch(0.18 0.01 60);
  --c-rule: oklch(0.35 0.015 60);
  --c-muted: oklch(0.42 0.015 60);
  --c-accent: oklch(0.65 0.18 40);
  --c-good: oklch(0.55 0.13 145);
  --c-warn: oklch(0.7 0.16 75);
  --c-bad: oklch(0.5 0.21 27);
}

[data-theme="dark"] {
  --c-paper: oklch(0.16 0.01 60);
  --c-paper-deep: oklch(0.22 0.012 60);
  --c-card: oklch(0.2 0.012 60);
  --c-ink: oklch(0.94 0.015 85);
  --c-rule: oklch(0.55 0.015 60);
  --c-muted: oklch(0.7 0.015 60);
  --c-accent: oklch(0.7 0.18 40);
  --c-good: oklch(0.55 0.13 145);
  --c-warn: oklch(0.7 0.16 75);
  --c-bad: oklch(0.6 0.21 27);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--c-paper);
  color: var(--c-ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---- Ledger primitives ---- */
.ledger-card {
  background: var(--c-card);
  border: var(--hairline) solid var(--c-ink);
  border-radius: var(--radius-base);
  box-shadow: var(--shadow-offset) var(--shadow-offset) 0 0 var(--c-ink);
  padding: var(--card-pad);
}
.ledger-tile {
  background: var(--c-paper-deep);
  border: var(--hairline) solid var(--c-ink);
  border-radius: var(--radius-base);
  padding: var(--tile-pad);
}
.hairline {
  height: var(--hairline);
  background: var(--c-rule);
}
.label-mono {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c-muted);
}
.mono {
  font-family: var(--font-mono);
}

/* ---- Buttons ---- */
.btn-primary {
  width: 100%;
  min-height: 48px;
  background: var(--c-ink);
  color: var(--c-paper);
  border: var(--hairline) solid var(--c-ink);
  border-radius: var(--radius-base);
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}
.btn-ghost-icon {
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  font-size: 18px;
  color: var(--c-ink);
  cursor: pointer;
}

/* ---- Inputs ---- */
.input,
.select,
.textarea {
  width: 100%;
  background: var(--c-paper);
  color: var(--c-ink);
  border: var(--hairline) solid var(--c-ink);
  border-radius: var(--radius-base);
  font-family: var(--font-mono);
  font-size: 15px;
  padding: 10px 12px;
}
.textarea {
  font-family: var(--font-body);
  resize: vertical;
}
.input::placeholder {
  color: color-mix(in oklch, var(--c-muted) 60%, transparent);
}

/* ---- Header ---- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--c-paper);
  border-bottom: var(--hairline) solid var(--c-rule);
  padding: calc(var(--page-pad) + env(safe-area-inset-top)) var(--page-pad)
    var(--page-pad);
}
.header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  max-width: var(--content-max);
  margin: 0 auto;
}
.brand-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 22px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sync-label {
  border: var(--hairline) solid var(--c-rule);
  border-radius: var(--radius-base);
  padding: 4px 8px;
}
.vehicle-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: var(--content-max);
  margin: 12px auto 0;
}

/* ---- Content ---- */
.content {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--section-gap) var(--page-pad) 96px;
}

/* ---- Form ---- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--section-gap);
}
.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: var(--section-gap);
}
.advanced {
  margin-bottom: var(--section-gap);
}
.advanced summary {
  cursor: pointer;
  margin-bottom: 12px;
}
.helper {
  display: block;
  font-style: normal;
  font-size: 12px;
  color: var(--c-muted);
}
.form-error {
  color: var(--c-bad);
  min-height: 1.2em;
  margin: 0 0 8px;
}
.form-success {
  color: var(--c-good);
  min-height: 1.2em;
  margin: 0 0 8px;
}

/* ---- History ---- */
.history-row {
  margin-bottom: 12px;
}
.history-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.history-body {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 14px;
}
.pill {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  border: var(--hairline) solid currentColor;
}
.pill-warn {
  color: var(--c-warn);
}
.pill-good {
  color: var(--c-good);
}
.pill-bad {
  color: var(--c-bad);
}
.empty-state p {
  margin: 0 0 8px;
}

/* ---- Tab bar ---- */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--c-paper);
  border-top: var(--hairline) solid var(--c-ink);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  min-height: 56px;
  background: transparent;
  border: none;
  color: var(--c-muted);
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 13px;
  cursor: pointer;
}
.tab.active {
  color: var(--c-ink);
  border-top: 2px solid var(--c-accent);
}
