:root {
  --paper: oklch(0.972 0.006 85);
  --surface: oklch(0.993 0.003 85);
  --sunk: oklch(0.935 0.008 85);
  --line: oklch(0.87 0.009 85);
  --line-strong: oklch(0.74 0.012 85);
  --ink: oklch(0.22 0.012 85);
  --ink-soft: oklch(0.46 0.012 85);
  --on-ink: oklch(0.985 0.004 85);

  --ok: oklch(0.58 0.16 150);
  --ok-tint: oklch(0.94 0.06 150);
  --ok-ink: oklch(0.37 0.11 150);
  --bad: oklch(0.56 0.2 27);
  --bad-tint: oklch(0.94 0.04 27);
  --bad-ink: oklch(0.44 0.17 27);
  --same: oklch(0.78 0.14 82);
  --same-tint: oklch(0.95 0.06 90);
  --same-ink: oklch(0.43 0.09 70);

  --mode-move: var(--ink);
  --mode-send: oklch(0.5 0.12 52);
  --mode-recv: oklch(0.47 0.14 255);
  --mode-arch: oklch(0.42 0.1 330);
  --focus: oklch(0.55 0.17 255);

  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --r: 12px;
  --r-lg: 16px;
  --gutter: 16px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.45 var(--ui);
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
ol, ul { margin: 0; padding: 0; list-style: none; }
svg { flex: none; }
[hidden] { display: none !important; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.soft { color: var(--ink-soft); }
.eyebrow {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Top bar ---------- */

#bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: max(env(safe-area-inset-top), 0px) var(--gutter) 0;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
#bar:empty { display: none; }
.bar-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  margin-left: -10px;
  padding: 0 12px 0 6px;
  border: 0;
  border-radius: var(--r);
  background: none;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.bar-home:active { background: var(--sunk); }
.wordmark { font-weight: 800; letter-spacing: -0.01em; font-size: 1.1rem; }
.wordmark b { display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 2px; background: var(--ink); }
.bar-spacer { flex: 1; }
.bar-user { font-size: 0.9rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.bar-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--r);
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  text-decoration: none;
}
.bar-btn:hover, .bar-btn:active { background: var(--sunk); color: var(--ink); }
.bar-btn svg, .bar-home svg { width: 22px; height: 22px; }

/* ---------- Page ---------- */

#view {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px var(--gutter) 24px;
  display: flex;
  flex-direction: column;
}
.page { flex: 1; display: flex; flex-direction: column; gap: 20px; }
.page > form.stack { flex: 1; }
.page-title { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.015em; line-height: 1.15; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 20px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  font-size: 1.0625rem;
  font-weight: 750;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-decoration: none;
  text-align: center;
  line-height: 1.15;
  cursor: pointer;
  user-select: none;
  transition: transform 120ms var(--ease), background-color 150ms var(--ease);
}
.btn:hover { background: var(--sunk); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn.primary:hover { background: oklch(0.3 0.012 85); }
.btn.big { min-height: 72px; font-size: 1.2rem; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn.busy { cursor: progress; opacity: 0.7; }
.btn svg { width: 24px; height: 24px; }

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--ink);
  font-weight: 650;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 4px;
  cursor: pointer;
}
.text-btn:hover { text-decoration-color: var(--ink); }
.text-btn svg { width: 18px; height: 18px; }

/* ---------- Home ---------- */

.notice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--r);
  background: var(--ok-tint);
  color: var(--ok-ink);
  font-weight: 700;
  animation: rise 250ms var(--ease);
}
.notice svg { width: 22px; height: 22px; }

.tile-scan {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: clamp(180px, 30vh, 280px);
  border-radius: var(--r-lg);
  background: var(--ink);
  color: var(--on-ink);
  text-decoration: none;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: transform 120ms var(--ease);
}
.tile-scan svg { width: 64px; height: 64px; }
.tile-scan:active { transform: scale(0.985); }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile {
  --m: var(--mode-move);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  min-height: 128px;
  padding: 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.15;
  text-transform: uppercase;
  transition: transform 120ms var(--ease), border-color 150ms var(--ease);
}
.tile:hover { border-color: var(--line-strong); }
.tile:active { transform: scale(0.98); }
.tile .ic {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--m) 12%, var(--surface));
  color: var(--m);
}
.tile .ic svg { width: 28px; height: 28px; }
.tile.send { --m: var(--mode-send); }
.tile.recv { --m: var(--mode-recv); }
.tile.arch { --m: var(--mode-arch); }

.open-parcels { display: flex; flex-direction: column; gap: 8px; }
.open-parcel {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 14px;
  border-radius: var(--r);
  background: var(--sunk);
  text-decoration: none;
  font-weight: 650;
}
.open-parcel .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.open-parcel svg { width: 20px; height: 20px; color: var(--ink-soft); }

.ready-hint { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: 0.95rem; }
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 color-mix(in oklch, var(--ok) 50%, transparent);
  animation: pulse 2s var(--ease) infinite;
}
.dot.off { background: var(--line-strong); animation: none; }

/* ---------- Scan session ---------- */

.band {
  --m: var(--mode-move);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 4px 16px;
  padding: 16px 18px 18px;
  border-radius: var(--r-lg);
  background: var(--m);
  color: var(--on-ink);
}
.band.send { --m: var(--mode-send); }
.band.recv { --m: var(--mode-recv); }
.band.arch { --m: var(--mode-arch); }
.band .eyebrow { color: inherit; opacity: 0.82; grid-column: 1 / -1; }
.band-title {
  font-size: 2.1rem;
  font-weight: 850;
  line-height: 1.02;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}
.band-title.mono { font-size: 1.9rem; }
.band-detail { grid-column: 1; font-size: 0.95rem; opacity: 0.9; overflow-wrap: anywhere; }
.band-count { grid-row: 2 / span 2; grid-column: 2; text-align: right; line-height: 1; }
.band-count b { display: block; font-size: 2.75rem; font-weight: 850; font-variant-numeric: tabular-nums; }
.band-count span { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.82; }
.band-edit {
  grid-column: 1 / -1;
  justify-self: start;
  margin: 4px 0 -6px -4px;
  color: inherit;
  text-decoration-color: color-mix(in oklch, currentColor 45%, transparent);
}

.prompt { font-size: 1.25rem; font-weight: 800; letter-spacing: 0.02em; text-transform: uppercase; }

.scanner { display: flex; flex-direction: column; gap: 10px; }
.viewfinder {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  max-height: 42vh;
  width: 100%;
  border-radius: var(--r-lg);
  background: var(--ink);
}
.viewfinder.compact { aspect-ratio: 16 / 9; max-height: 30vh; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewfinder::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: min(62%, 240px);
  aspect-ratio: 1;
  translate: -50% -50%;
  --c: var(--on-ink);
  background:
    linear-gradient(var(--c) 0 0) 0 0 / 34px 4px no-repeat, linear-gradient(var(--c) 0 0) 0 0 / 4px 34px no-repeat,
    linear-gradient(var(--c) 0 0) 100% 0 / 34px 4px no-repeat, linear-gradient(var(--c) 0 0) 100% 0 / 4px 34px no-repeat,
    linear-gradient(var(--c) 0 0) 0 100% / 34px 4px no-repeat, linear-gradient(var(--c) 0 0) 0 100% / 4px 34px no-repeat,
    linear-gradient(var(--c) 0 0) 100% 100% / 34px 4px no-repeat, linear-gradient(var(--c) 0 0) 100% 100% / 4px 34px no-repeat;
  border-radius: 6px;
  filter: drop-shadow(0 1px 2px oklch(0 0 0 / 0.4));
  pointer-events: none;
}
.viewfinder.off { aspect-ratio: auto; min-height: 180px; }
.viewfinder.off::after { display: none; }
.viewfinder.hit::after { --c: var(--ok); }
.viewfinder.miss::after { --c: var(--bad); }
.vf-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--on-ink);
  font-weight: 650;
}
.vf-tools { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 8px; z-index: 1; }
.vf-tool {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: oklch(0.22 0.012 85 / 0.6);
  color: var(--on-ink);
  cursor: pointer;
}
.vf-tool[aria-pressed="true"] { background: var(--on-ink); color: var(--ink); }
.vf-tool svg { width: 22px; height: 22px; }

.ready {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  padding: 14px 20px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--r-lg);
  font-size: 1.15rem;
  font-weight: 700;
}
.ready .dot { width: 14px; height: 14px; }
.ready small { display: block; font-size: 0.9rem; font-weight: 500; color: var(--ink-soft); }

.manual { display: flex; gap: 8px; }
.manual input { flex: 1; min-width: 0; }
.manual .btn { padding: 0 16px; }
.cam-toggle { align-self: flex-start; }

.result {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 4px 14px;
  min-height: 88px;
  padding: 14px 16px;
  border-radius: var(--r-lg);
  background: var(--sunk);
  color: var(--ink-soft);
}
.result .r-ic {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--line);
  color: var(--surface);
}
.result .r-ic svg { width: 30px; height: 30px; stroke-width: 3; }
.result .r-main { font-size: 1.6rem; font-weight: 850; line-height: 1.1; overflow-wrap: anywhere; }
.result .r-sub { font-size: 0.98rem; font-weight: 600; }
.result.ok { background: var(--ok-tint); color: var(--ok-ink); }
.result.ok .r-ic { background: var(--ok); }
.result.bad { background: var(--bad-tint); color: var(--bad-ink); }
.result.bad .r-ic { background: var(--bad); }
.result.same { background: var(--same-tint); color: var(--same-ink); }
.result.same .r-ic { background: var(--same); color: var(--ink); }
.result.pop { animation: pop 220ms var(--ease); }

.lines-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.lines li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.lines li:first-child { border-top: 1px solid var(--line); }
.lines li.new { animation: rise 220ms var(--ease); }
.lines .l-ic { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: var(--surface); }
.lines .l-ic svg { width: 18px; height: 18px; stroke-width: 3; }
.lines .ok .l-ic { background: var(--ok); }
.lines .bad .l-ic { background: var(--bad); }
.lines .same .l-ic { background: var(--same); color: var(--ink); }
.lines .gone .l-ic { background: var(--line-strong); }
.lines .info .l-ic { background: var(--ink); }
.lines .l-main { min-width: 0; }
.lines .l-code { font-family: var(--mono); font-weight: 750; font-size: 1.05rem; }
.lines .l-sub { font-size: 0.9rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lines .bad .l-code { color: var(--bad-ink); font-family: var(--ui); }
.lines .gone .l-code { text-decoration: line-through; color: var(--ink-soft); }
.lines a.l-main { text-decoration: none; }
.lines .l-x {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: var(--r);
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
}
.lines .l-x:hover { background: var(--sunk); color: var(--bad-ink); }
.lines .l-x svg { width: 20px; height: 20px; }
.lines .l-tag { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); }

details.more { border-top: 1px solid var(--line); padding-top: 8px; }
details.more summary { min-height: 48px; display: flex; align-items: center; font-weight: 700; cursor: pointer; }

.dock {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  gap: 10px;
  margin: auto calc(var(--gutter) * -1) -24px;
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 1px solid var(--line);
}
.dock .btn { flex: 1; }
.dock .btn.secondary { flex: 0 1 auto; }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 8px; }
.field > label, .field > .eyebrow { font-size: 0.8rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.field .opt { font-weight: 500; letter-spacing: 0; text-transform: none; }
.input, .select {
  width: 100%;
  min-height: 56px;
  padding: 0 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  font-size: 1.15rem;
}
textarea.input { padding: 12px 14px; min-height: 96px; resize: vertical; }
.input:focus, .select:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in oklch, var(--focus) 35%, transparent); }
.input.mono { font-family: var(--mono); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; font-weight: 650; }
.error-text { color: var(--bad-ink); font-weight: 650; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 52px;
  padding: 0 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  font-weight: 750;
  font-size: 1rem;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.chip:hover { background: var(--sunk); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg .chip { min-height: 64px; font-size: 1.1rem; letter-spacing: 0.05em; text-transform: uppercase; }

.here-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.here-line .select { width: auto; min-width: 220px; flex: 1; }

/* ---------- Document ---------- */

.doc-head { display: flex; flex-direction: column; gap: 6px; }
.doc-head .mono { font-size: 1.05rem; font-weight: 700; color: var(--ink-soft); }
.doc-title { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: 2rem; font-weight: 850; line-height: 1.1; letter-spacing: -0.015em; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  vertical-align: middle;
}
.badge.orig { background: var(--ink); color: var(--on-ink); }
.doc-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--ink-soft); font-size: 1rem; }
.doc-meta b { color: var(--ink); font-weight: 650; }

.where { display: flex; flex-direction: column; gap: 6px; padding: 18px; border-radius: var(--r-lg); background: var(--surface); border: 1.5px solid var(--line); }
.where-name { font-size: 2.4rem; font-weight: 900; line-height: 1.02; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.where-detail { font-size: 1.1rem; font-weight: 650; }
.where-detail a { font-family: var(--mono); }
.where-when { font-size: 0.95rem; color: var(--ink-soft); }
.where.flash-ok { background: var(--ok-tint); border-color: var(--ok); animation: pop 220ms var(--ease); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.minor { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.notes { padding: 12px 14px; border-radius: var(--r); background: var(--sunk); white-space: pre-wrap; }

.picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.picker .btn { min-height: 76px; padding: 8px 12px; overflow-wrap: anywhere; }
.picker .btn.current { border-style: dashed; color: var(--ink-soft); }
.picker .btn small { display: block; font-size: 0.75rem; letter-spacing: 0.06em; opacity: 0.8; }

.history li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 4px 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.history li::before { content: ""; width: 10px; height: 10px; margin-top: 7px; border-radius: 50%; background: var(--line-strong); justify-self: center; }
.history li:first-child::before { background: var(--ink); }
.history .h-what { font-weight: 750; font-size: 1.1rem; overflow-wrap: anywhere; }
.history .h-what.corr { color: var(--same-ink); }
.history .h-when { grid-column: 2; font-size: 0.92rem; color: var(--ink-soft); }
.history a { font-family: var(--mono); }

/* ---------- Label preview (50 × 28 mm at 3×) ---------- */

.label-wrap { display: flex; justify-content: center; padding: 28px 16px; border-radius: var(--r-lg); background: var(--sunk); }
.label {
  width: min(150mm, 100%);
  aspect-ratio: 50 / 28;
  display: flex;
  align-items: center;
  gap: 6%;
  padding: 4%;
  background: oklch(1 0 0);
  color: oklch(0 0 0);
  border-radius: 6px;
  box-shadow: 0 1px 2px oklch(0 0 0 / 0.12), 0 6px 20px oklch(0 0 0 / 0.08);
  container-type: inline-size;
}
.label img { width: 47%; aspect-ratio: 1; flex: none; display: block; }
.label .l-txt { display: flex; flex-direction: column; gap: 3cqi; min-width: 0; }
.label .l-id { font: 800 7.4cqi/1 var(--mono); }
.label .l-type { font: 800 6.6cqi/1.05 Arial, sans-serif; }
.label .l-oc { align-self: flex-start; padding: 0.6cqi 1.6cqi; border: 0.6cqi solid oklch(0 0 0); font: 800 5cqi/1.2 Arial, sans-serif; letter-spacing: 0.04em; }
.label .l-oc.orig { background: oklch(0 0 0); color: oklch(1 0 0); }

.saved-head { display: flex; align-items: center; gap: 14px; }
.saved-head .r-ic { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--ok); color: var(--surface); }
.saved-head .r-ic svg { width: 30px; height: 30px; stroke-width: 3; }

/* ---------- Search ---------- */

.search-box { position: sticky; top: 56px; z-index: 5; margin: -16px calc(var(--gutter) * -1) 0; padding: 16px var(--gutter) 12px; background: var(--paper); }
.search-box .input { min-height: 64px; font-size: 1.25rem; padding-left: 52px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") 16px 50% / 24px no-repeat; }
.results { display: flex; flex-direction: column; }
.res {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}
.res:first-child { border-top: 1px solid var(--line); }
.res { position: relative; }
.res .stretch { text-decoration: none; display: block; }
.res .stretch::after { content: ""; position: absolute; inset: 0; }
.res .res-hist { position: relative; z-index: 1; }
.res-type { font-size: 1.15rem; font-weight: 800; }
.res-ref { font-family: var(--mono); font-size: 0.98rem; }
.res-sub { font-size: 0.9rem; color: var(--ink-soft); }
.res-where { grid-row: 1 / span 3; grid-column: 2; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.res-where .eyebrow { font-size: 0.7rem; }
.res-place { font-size: 1.05rem; font-weight: 850; max-width: 42vw; overflow-wrap: anywhere; }
.res-when { font-size: 0.85rem; color: var(--ink-soft); }
.res-hist { grid-column: 1 / -1; justify-self: start; }
.res.group { background: var(--sunk); border-radius: var(--r); border: 0; padding: 14px 16px; margin-bottom: 8px; }
.empty { padding: 32px 8px; text-align: center; color: var(--ink-soft); }
.empty b { display: block; color: var(--ink); font-size: 1.15rem; margin-bottom: 4px; }

/* ---------- Summary / definition lists ---------- */

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 20px; }
.facts dt { font-size: 0.8rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.facts dd { margin: 2px 0 0; font-size: 1.15rem; font-weight: 700; overflow-wrap: anywhere; }

/* ---------- Movements log ---------- */

.log-controls { display: flex; flex-direction: column; gap: 12px; }
.log-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.log-dates .select { font-size: 1rem; }
.log-day { display: flex; flex-direction: column; }
.log-date {
  position: sticky;
  top: 56px;
  z-index: 2;
  padding: 14px 0 8px;
  background: var(--paper);
  border-bottom: 1.5px solid var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
}
.log-list li { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.log-list time { font-weight: 700; padding-top: 2px; }
.log-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.log-main .h-what { font-weight: 750; font-size: 1.05rem; overflow-wrap: anywhere; }
.log-main .h-what.corr { color: var(--same-ink); }
.log-main .h-what a, .log-sub a { font-family: var(--mono); }
.log-sub { font-size: 0.92rem; color: var(--ink-soft); overflow-wrap: anywhere; }
.log-sub a { color: var(--ink); font-weight: 700; }
.log + .log-day, .log-day + .log-day { margin-top: 12px; }

/* ---------- Admin ---------- */

.admin-section { display: flex; flex-direction: column; gap: 12px; }
.admin-list li { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.admin-list .grow { flex: 1; min-width: 160px; }
.admin-list .grow b { display: block; }
.admin-form { display: grid; gap: 10px; padding: 16px; border-radius: var(--r-lg); background: var(--sunk); }
@media (min-width: 640px) { .admin-form.cols { grid-template-columns: 1fr 1fr; } .admin-form .full { grid-column: 1 / -1; } }
.pill { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; padding: 3px 8px; border-radius: 6px; background: var(--ink); color: var(--on-ink); }
.pill.muted { background: var(--line); color: var(--ink-soft); }

/* ---------- Login ---------- */

.login { margin: auto; width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 18px; padding: 32px 0; }
.login .wordmark { font-size: 1.6rem; }

/* ---------- Feedback layers ---------- */

#flash {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  box-shadow: inset 0 0 0 12px var(--fc, var(--ok));
  background: color-mix(in oklch, var(--fc, var(--ok)) 10%, transparent);
}
#flash.go { animation: flash 480ms var(--ease); }

#toast {
  position: fixed;
  left: 50%;
  top: calc(64px + env(safe-area-inset-top));
  z-index: 60;
  translate: -50% 0;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 14px 18px;
  border-radius: var(--r);
  background: var(--ink);
  color: var(--on-ink);
  font-weight: 700;
  box-shadow: 0 8px 30px oklch(0.22 0.012 85 / 0.25);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
  pointer-events: none;
}
#toast.show { opacity: 1; transform: none; }
#toast.bad { background: var(--bad); }
#toast.ok { background: var(--ok-ink); }

#focus-warn {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 40;
  translate: -50% 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border: 0;
  border-radius: var(--r);
  background: var(--same);
  color: var(--ink);
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 8px 30px oklch(0.22 0.012 85 / 0.2);
}

#printer { position: fixed; width: 0; height: 0; border: 0; visibility: hidden; }

/* ---------- Motion ---------- */

@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes pop { 0% { transform: scale(0.97); } 100% { transform: none; } }
@keyframes rise { 0% { opacity: 0; transform: translateY(6px); } 100% { opacity: 1; transform: none; } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--ok) 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 10px color-mix(in oklch, var(--ok) 0%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  #flash.go { animation: none; opacity: 1; }
}

/* ---------- Larger screens ---------- */

@media (min-width: 720px) {
  :root { --gutter: 24px; }
  #view { padding-top: 24px; }
  .page { gap: 24px; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tile { min-height: 140px; font-size: 1.1rem; }
  .band-title { font-size: 2.6rem; }
  .band-title.mono { font-size: 2.3rem; }
  .actions { grid-template-columns: repeat(4, 1fr); }
  .picker { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .doc-title { font-size: 2.4rem; }
  .where-name { font-size: 3rem; }
  .res-place { max-width: 260px; }
  .dock { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
}
