/* style.css — field journal PWA, "Surveyor Light". Tokens mirror web/style.css
   + DESIGN.md: warm limestone paper, graphite ink, per-dimension hue × intensity. */
:root {
  /* chrome */
  --graphite:   #23282b;
  --graphite-2: #4d555b;
  --graphite-3: #79828a;
  --limestone:  #f3efe7;
  --limestone-2:#e9e4d8;
  --limestone-3:#fbf8f2;
  --hair:       #ddd6c8;
  --hair-soft:  #e8e2d6;

  /* dimension hues */
  --h-walk: 150; --h-transit: 235; --h-safety: 300; --h-fit: 85; --h-price: 40;
  --c-walk: oklch(0.89 0.070 150); --c-transit: oklch(0.89 0.070 235);
  --c-safety: oklch(0.89 0.070 300); --c-fit: oklch(0.88 0.085 85); --c-price: oklch(0.89 0.070 40);
  --c-walk-ink: oklch(0.55 0.09 150); --c-transit-ink: oklch(0.55 0.09 235);
  --c-safety-ink: oklch(0.55 0.09 300); --c-fit-ink: oklch(0.55 0.10 85); --c-price-ink: oklch(0.55 0.09 40);
  --t-low: oklch(0.90 0.004 250); --t-high: oklch(0.62 0.010 250); --t-ink: oklch(0.45 0.010 250);

  /* legacy aliases → light (flips existing rules wholesale) */
  --ink: var(--limestone); --ink-2: var(--limestone-3); --ink-3: #ece7db; --ink-4: #e2dccd;
  --line: var(--hair); --line-soft: var(--hair-soft);
  --fog: var(--graphite-3); --fog-dim: #9aa2a9;
  --paper: var(--graphite); --paper-dim: var(--graphite-2);
  --amber: oklch(0.60 0.108 80); --amber-bright: oklch(0.66 0.118 82);
  --rust: var(--c-price-ink); --sage: var(--c-walk-ink); --cyan: var(--c-transit-ink);
  --rose: oklch(0.52 0.13 18);

  --radius: 11px;
  --radius-sm: 7px;
  --shadow: 0 14px 40px -24px rgba(40, 36, 28, 0.45);
  --ease: cubic-bezier(0.4, 0.1, 0.1, 1);
  --font-display: "Fraunces", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --font-body: "Hanken Grotesk", system-ui, sans-serif;
  --tabbar-h: 64px;
}

/* Iconography (thin-monoline sprite) + hued micro-band signature — DESIGN.md §5-6 */
.ic {
  width: 1em; height: 1em; flex: none; display: inline-block; vertical-align: -0.14em;
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
  color: var(--graphite-2);
}
.ic.lg { width: 1.2em; height: 1.2em; }
.sig { display: inline-flex; gap: 3px; vertical-align: middle; }
.sig .band { width: 9px; height: 24px; border-radius: 2px; background: var(--swatch, var(--limestone-2)); box-shadow: inset 0 -2px 0 var(--tick, transparent); }
.score-badge { flex: 1; text-align: center; border-radius: var(--radius-sm); padding: 6px 4px; font-family: var(--font-mono); border: 1px solid var(--hair-soft); background: var(--swatch, var(--limestone-2)); position: relative; overflow: hidden; }
.score-badge::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--tick, transparent); }
.score-badge .n { font-size: 16px; font-weight: 600; color: var(--graphite); }
.score-badge .l { font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--graphite-2); }
.scores { display: flex; gap: 6px; margin: 10px 0; }
/* mood swatch: Fit hue behind a graphite face icon (co-label). The 5 swatches
   form the Fit intensity ramp; the selected one is ringed. */
.mood-swatch { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; background: var(--swatch, var(--limestone-2)); color: var(--graphite); border: 1px solid var(--hair); cursor: pointer; font-size: 19px; }
.mood-swatch.on { box-shadow: 0 0 0 2px var(--c-fit-ink); border-color: transparent; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: contain;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

/* topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px calc(12px); padding-top: calc(12px + env(safe-area-inset-top));
  background: linear-gradient(180deg, var(--limestone-3), rgba(243, 239, 231, 0.9));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px) saturate(1.05);
  box-shadow: 0 6px 18px -12px rgba(40, 36, 28, 0.40);
}
.brand { display: flex; align-items: baseline; gap: 6px; font-family: var(--font-display); }
.brand-mark { color: var(--amber); font-size: 18px; }
.brand b { letter-spacing: .12em; font-size: 15px; }
.brand small { color: var(--fog); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.snap-age { font-family: var(--font-mono); font-size: 11px; color: var(--fog); }

.view { padding: 16px; max-width: 720px; margin: 0 auto; }

/* generic bits */
.muted { color: var(--fog); }
.small { font-size: 12px; }
.display { font-family: var(--font-display); font-size: 22px; }
.section-title { font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--fog-dim); margin: 0 0 8px; }
.empty { text-align: center; padding: 48px 16px; color: var(--fog); }
.row { display: flex; gap: 8px; align-items: center; }
.spacer { flex: 1; }
.panel { background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--ink-3); color: var(--paper);
  font-family: var(--font-body); font-size: 15px; font-weight: 600;
  padding: 11px 16px; border-radius: var(--radius-sm); cursor: pointer; transition: .15s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--amber); color: var(--limestone-3); border-color: var(--amber); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.danger { color: var(--rust); border-color: var(--rust); }
.btn:disabled { opacity: .5; }

textarea, input[type=text], input[type=date], input[type=time] {
  width: 100%; background: var(--ink); color: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px; font-family: var(--font-body); font-size: 16px;
}
textarea { resize: vertical; min-height: 84px; }

/* chips */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 9px 13px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--ink-3); color: var(--paper-dim);
  font-size: 14px; cursor: pointer; user-select: none;
}
/* active chip wears its dimension's pastel when JS sets --cdim/--cdim-ink; else Fit */
.chip.on { background: var(--cdim, var(--c-fit)); color: var(--graphite); border-color: var(--cdim-ink, var(--c-fit-ink)); font-weight: 600; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 8px; }

/* capture: big primary action */
.capture-hero {
  display: flex; flex-direction: column; gap: 4px; align-items: center; justify-content: center;
  width: 100%; padding: 26px; border-radius: var(--radius);
  background: linear-gradient(160deg, var(--amber), var(--rust)); color: var(--limestone-3);
  border: none; font-family: var(--font-display); font-size: 24px; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow);
}
.capture-hero .sub { font-family: var(--font-mono); font-size: 12px; opacity: .8; font-weight: 500; }
.capture-hero:active { transform: translateY(1px); }

/* subject header (auto-attach) */
.subject-head { display: flex; align-items: center; gap: 10px; margin: 14px 0; }
.subject-head .at { color: var(--fog-dim); font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }
.subject-head .name { font-family: var(--font-display); font-size: 19px; }
.subject-head .dist { font-family: var(--font-mono); font-size: 11px; color: var(--sage); }
.linklike { color: var(--amber); cursor: pointer; font-size: 13px; }

/* axis / mood grid in sheets */
.field-label { font-size: 13px; color: var(--fog); margin: 14px 0 6px; }

/* photo strip */
.photo-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.photo-thumb { width: 72px; height: 72px; border-radius: var(--radius-sm); object-fit: cover; border: 1px solid var(--line); }
.photo-add { width: 72px; height: 72px; border-radius: var(--radius-sm); border: 1px dashed var(--line); background: var(--ink-3); color: var(--fog); font-size: 26px; display:flex; align-items:center; justify-content:center; cursor: pointer; }

/* observation list */
.obs-card { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.obs-card .thumb { width: 56px; height: 56px; border-radius: var(--radius-sm); object-fit: cover; border: 1px solid var(--line); flex: 0 0 auto; background: var(--ink-3); }
.obs-card .meta { flex: 1; min-width: 0; }
.obs-card .meta .h { display: flex; gap: 8px; align-items: baseline; }
.obs-card .meta .h b { font-family: var(--font-display); }
.obs-card .meta .when { font-family: var(--font-mono); font-size: 11px; color: var(--fog-dim); }
.obs-card .meta .note { color: var(--paper-dim); font-size: 14px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.obs-card .meta .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.minitag { font-family: var(--font-mono); font-size: 10px; color: var(--mt, var(--graphite-2)); border: 1px solid var(--hair); border-radius: 4px; padding: 1px 5px; }

/* bottom sheet */
.sheet-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; display: flex; align-items: flex-end; }
.sheet {
  width: 100%; max-width: 720px; margin: 0 auto; background: var(--ink-2);
  border-radius: 18px 18px 0 0; border-top: 1px solid var(--line);
  max-height: 92vh; overflow-y: auto; padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow); animation: slideup .22s var(--ease);
}
@keyframes slideup { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 8px auto 4px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 16px; }

/* tabbar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: linear-gradient(0deg, var(--limestone-3), rgba(243, 239, 231, 0.92));
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(8px) saturate(1.05);
  box-shadow: 0 -6px 18px -12px rgba(40, 36, 28, 0.40);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 0 9px; text-decoration: none; color: var(--paper-dim);
  font-size: 11px; font-family: var(--font-mono); letter-spacing: .04em;
}
.tabbar a .ico { font-size: 19px; line-height: 1; }
.tabbar a.active { color: var(--amber); }

/* floating action button */
.fab {
  position: fixed;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  right: 16px;
  z-index: 35;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(160deg, var(--amber), var(--rust));
  color: var(--graphite);
  font-size: 28px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 18px rgba(0,0,0,0.55);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
.fab:active { transform: scale(0.93); box-shadow: 0 2px 8px rgba(0,0,0,0.4); }

/* toasts */
.toasts { position: fixed; bottom: calc(var(--tabbar-h) + 12px); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; pointer-events: none; }
.toast { background: var(--ink-4); border: 1px solid var(--line); color: var(--paper); padding: 9px 15px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); }
.toast.err { border-color: var(--rust); color: #ffd9c9; }
.toast.ok { border-color: var(--sage); }

/* transfer / QR */
.qr-box { background: #fff; padding: 14px; border-radius: var(--radius); display: inline-block; }
.qr-box img, .qr-box canvas, .qr-box table { display: block; }
.paircode { font-family: var(--font-mono); font-size: 28px; letter-spacing: .3em; color: var(--amber); text-align: center; margin: 10px 0; }
#scanVideo { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); background: #000; }
.log { font-family: var(--font-mono); font-size: 12px; color: var(--fog); max-height: 180px; overflow-y: auto; margin-top: 12px; }
.log div { padding: 2px 0; border-bottom: 1px solid var(--line-soft); }

/* subject picker list */
.pick-list { max-height: 50vh; overflow-y: auto; margin-top: 8px; }
.pick-row { display: flex; align-items: center; gap: 10px; padding: 11px 4px; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.pick-row .k { font-family: var(--font-mono); font-size: 10px; color: var(--fog-dim); text-transform: uppercase; }
.pick-row.sel { color: var(--amber); }

.detail { max-width: 100%; }
