:root {
  --paper: #f2ece0; --slip: #fbf8f1; --ink: #1d1a16; --ink2: #5b544a; --rule: #cfc5b3;
  --red: #c41e2a; --red-ink: #a3141f; --blue: #1f4e79; --void: #9a9184;
  --serif: 'Fraunces', Georgia, serif; --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace; --sans: 'Instrument Sans', -apple-system, system-ui, sans-serif;
  --st: env(safe-area-inset-top); --sb: env(safe-area-inset-bottom); --sl: env(safe-area-inset-left); --sr: env(safe-area-inset-right);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--paper); }
body {
  margin: 0; color: var(--ink); font: 16px/1.45 var(--sans); min-height: 100dvh;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .28 0 0 0 0 .18 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  padding: calc(var(--st) + 14px) calc(var(--sr) + 16px) calc(var(--sb) + 96px) calc(var(--sl) + 16px);
  -webkit-font-smoothing: antialiased;
}
main { max-width: 560px; margin: 0 auto; }
a { color: inherit; }
h1, h2 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; }
.muted { color: var(--ink2); } .pad { padding: 4px 2px 12px; }
.fine { font: 12.5px/1.45 var(--mono); color: var(--ink2); margin: 8px 0 0; }
.fine a, .src a, .warn a { color: var(--red-ink); }

/* Masthead */
.mast { padding: 8px 2px 18px; border-bottom: 3px double var(--ink); margin-bottom: 18px; }
.mast-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.wordmark { font: 800 42px/1 var(--serif); font-variation-settings: 'opsz' 144; letter-spacing: -.035em; }
.wordmark::after { content: ''; display: inline-block; width: .2em; height: .2em; background: var(--red); border-radius: 50%; margin-left: .06em; }
.wordmark.sm { font-size: 24px; }
.serial { font: 500 12px var(--mono); color: var(--red-ink); letter-spacing: .08em; border: 1.5px solid currentColor; padding: 2px 6px; border-radius: 2px; }
.tagline { margin: 10px 0 0; font: 17px/1.35 var(--serif); font-style: italic; color: var(--ink2); }
.hint { font: 13px/1.45 var(--mono); border: 1.5px dashed var(--ink2); padding: 10px 12px; margin: 0 0 18px; color: var(--ink2); }

.rule { display: flex; align-items: center; gap: 10px; font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: .14em; margin: 22px 0 12px; }
.rule::after { content: ''; flex: 1; border-top: 1px dashed var(--ink2); }
.rule small { order: 3; font: inherit; color: var(--red-ink); }

/* Docket paper with a torn zigzag bottom */
.docket {
  position: relative; background: var(--slip); padding: 18px 18px 26px; margin: 0 0 22px;
  box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 6px 18px -10px rgba(60,40,10,.35);
  --z: 7px;
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / calc(2 * var(--z)) 100%;
          mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / calc(2 * var(--z)) 100%;
}
.docket h2 { font-size: 22px; margin-bottom: 10px; }
.docket p { margin: 0 0 12px; }
.empty { text-align: left; } .empty h2 { font-size: 28px; } .empty p { color: var(--ink2); }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.tl { display: flex; gap: 14px; align-items: center; text-decoration: none; padding: 10px 0; border-bottom: 1px dotted var(--rule); }
.tl-body { display: grid; gap: 1px; min-width: 0; }
.tl-body b { font: 600 17px/1.25 var(--serif); }
.tl-body span { font: 13px var(--mono); color: var(--ink2); }
.tl-body em { font: italic 13px var(--serif); color: var(--blue); }
.tl.soon .tl-body span { color: var(--red-ink); font-weight: 600; }

/* Postmark stamps */
.stamp {
  --c: var(--ink); flex: none; width: 74px; height: 74px; border-radius: 50%; color: var(--c);
  border: 2px solid var(--c); box-shadow: inset 0 0 0 3px var(--slip), inset 0 0 0 4.5px var(--c);
  display: grid; place-content: center; text-align: center; transform: rotate(-7deg); line-height: 1; background: transparent;
  font-family: var(--mono); opacity: .92;
}
.stamp.red { --c: var(--red); } .stamp.blue { --c: var(--blue); } .stamp.void { --c: var(--void); transform: rotate(4deg); }
.stamp.acl { --c: var(--ink); border-style: dashed; box-shadow: none; transform: rotate(3deg); }
.stamp .st-top { font-size: 8px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.stamp .st-day { font: 800 26px/1 var(--serif); margin: 2px 0 1px; }
.stamp .st-mon { font-size: 9px; font-weight: 600; letter-spacing: .1em; }
.stamp.small { width: 64px; height: 64px; }

/* Docket list */
.dockets { list-style: none; margin: 0; padding: 0; }
.docket.mini { display: block; text-decoration: none; padding: 14px 16px 22px; margin-bottom: 14px; }
.dk-top { display: flex; justify-content: space-between; font: 500 12px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink2); }
.dk-name { font: 600 20px/1.2 var(--serif); margin: 6px 0 10px; }
.dk-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dk-total { margin-left: auto; font: 600 16px var(--mono); }
.chip { font: 500 11px var(--mono); padding: 3px 7px; border: 1px solid var(--rule); border-radius: 2px; color: var(--ink2); white-space: nowrap; }
.chip.return { color: var(--red-ink); border-color: currentColor; } .chip.warranty { color: var(--blue); border-color: currentColor; }

/* Buttons */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 16px;
  font: 600 15px var(--sans); color: var(--ink); background: transparent; border: 1.5px solid var(--ink); border-radius: 3px; text-decoration: none; cursor: pointer;
  transition: transform .08s ease, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn.red { background: var(--red); border-color: var(--red); color: #fff8ef; box-shadow: 0 2px 0 var(--red-ink); }
.btn.ink { background: var(--ink); color: var(--slip); }
.btn.big { width: 100%; min-height: 54px; font-size: 16.5px; }
.btn.ghost { background: var(--slip); }
.btn.text { border: 0; background: none; color: var(--ink2); text-decoration: underline; width: 100%; margin: 6px 0 20px; }
.btn.danger { color: var(--red-ink); }
.btn[disabled] { opacity: .4; pointer-events: none; }
.empty .btn + .btn { margin-top: 10px; width: 100%; }

/* Page heads */
.page-head { display: flex; align-items: center; gap: 10px; padding: 4px 0 14px; border-bottom: 3px double var(--ink); margin-bottom: 16px; }
.page-head h1 { font-size: 26px; line-height: 1.15; overflow-wrap: anywhere; }
.back { text-decoration: none; font: 500 22px var(--mono); width: 40px; height: 40px; display: grid; place-items: center; border: 1.5px solid var(--ink); border-radius: 50%; flex: none; }
.sub { font: 13px var(--mono); color: var(--ink2); margin: -6px 0 16px; }

/* Forms */
.snap { display: grid; grid-template-columns: 112px 1fr; gap: 14px; align-items: start; margin-bottom: 14px; }
.snap-preview { width: 112px; aspect-ratio: 3 / 4; border: 1.5px dashed var(--ink2); display: grid; place-items: center; overflow: hidden; background: var(--paper); }
.snap-preview img { width: 100%; height: 100%; object-fit: cover; }
.snap-empty span { font: 11px var(--mono); color: var(--ink2); text-transform: uppercase; letter-spacing: .1em; text-align: center; display: block; padding: 6px; }
.snap-actions { display: grid; gap: 8px; } .snap-actions .btn { width: 100%; }
.ocr { margin: 4px 0 12px; font: 13px var(--mono); }
.ocr-bar { height: 10px; border: 1.5px solid var(--ink); margin-bottom: 6px; background: repeating-linear-gradient(90deg, transparent 0 6px, rgba(0,0,0,.05) 6px 7px); }
.ocr-bar i { display: block; height: 100%; width: 0; background: var(--ink); transition: width .3s; }
.note { font: 13px/1.45 var(--mono); background: #fff3c9; border-left: 3px solid #c99a00; padding: 9px 11px; margin: 0 0 14px; }
.fld { display: block; margin: 0 0 14px; border: 0; padding: 0; min-width: 0; }
.fld > span, .fld legend { display: block; font: 600 11.5px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--ink2); margin-bottom: 5px; padding: 0; }
.fld i { text-transform: none; font-style: normal; letter-spacing: 0; font-weight: 400; }
input, select, textarea {
  width: 100%; font: 16px var(--sans); color: var(--ink); background: transparent; border: 0; border-bottom: 1.5px solid var(--ink);
  padding: 8px 2px; border-radius: 0; outline: none; -webkit-appearance: none; appearance: none;
}
select { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%231d1a16' stroke-width='1.6'/%3E%3C/svg%3E") right 4px center no-repeat; }
textarea { border: 1.5px solid var(--ink); padding: 8px 10px; resize: vertical; font-size: 15px; background: rgba(255,255,255,.4); }
input:focus, select:focus, textarea:focus { border-color: var(--red); }
input[type=date] { min-height: 40px; }
input.ocrd { background: #fff3c9; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chips button { font: 500 13px var(--mono); padding: 7px 10px; border: 1.5px solid var(--ink); background: var(--slip); color: var(--ink); border-radius: 2px; }
.chips button.on { background: var(--ink); color: var(--slip); }
.inline { display: flex; align-items: center; gap: 10px; } .inline input { width: 90px; } .inline span { font: 13px var(--mono); color: var(--ink2); }
.raw summary { font: 13px var(--mono); cursor: pointer; margin-bottom: 12px; }
.raw pre { font: 12px/1.4 var(--mono); white-space: pre-wrap; background: var(--paper); padding: 10px; max-height: 240px; overflow: auto; }

/* Item */
.receipt-img { display: block; width: 100%; padding: 0; border: 0; background: var(--paper); margin-bottom: 14px; max-height: 260px; overflow: hidden; }
.receipt-img img { width: 100%; display: block; object-fit: cover; object-position: top; max-height: 260px; filter: contrast(1.05) sepia(.08); }
.ledger { margin: 0; font-family: var(--mono); font-size: 14px; }
.ledger div { display: flex; align-items: baseline; gap: 6px; padding: 4px 0; }
.ledger dt { color: var(--ink2); white-space: nowrap; }
.ledger div::after { content: ''; order: 2; flex: 1; border-bottom: 1.5px dotted var(--rule); transform: translateY(-4px); }
.ledger dd { order: 3; margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.lines { font: 13px/1.5 var(--mono); margin: 12px 0 0; padding: 0; list-style: none; color: var(--ink2); }
.notes { font: 13px/1.5 var(--mono); color: var(--ink2); margin-top: 10px !important; }
.tear { border-top: 2px dashed var(--rule); margin: 16px -18px 16px; position: relative; }
.clocks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.clock { display: grid; justify-items: center; gap: 10px; }
.clock p { margin: 0; font: 12px/1.35 var(--mono); color: var(--ink2); }
.actions { display: grid; gap: 10px; margin: 0 0 24px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; } .row3 .btn { padding: 0 6px; font-size: 14px; }
.guide .lead { font: 17px/1.45 var(--serif); margin: 0 0 12px; }
.examples { margin: 0 0 12px; padding: 0; list-style: none; }
.examples li { border-left: 3px solid var(--blue); padding: 6px 0 6px 12px; margin-bottom: 10px; font-size: 15px; }
details summary { font: 600 13px var(--mono); cursor: pointer; padding: 8px 0; }
.factors { margin: 4px 0 10px; padding-left: 20px; font-size: 14.5px; }
.src { font: 12px/1.45 var(--mono); color: var(--ink2); }
.claimlog { font: 13px/1.5 var(--mono); padding-left: 18px; }
dialog { border: 0; padding: 12px; background: var(--slip); max-width: 94vw; max-height: 90vh; }
dialog img { max-width: 100%; max-height: 76vh; display: block; margin-bottom: 10px; }
dialog::backdrop { background: rgba(29,26,22,.7); }

/* Claim */
.step h2 { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.step h2 i { font: 700 13px var(--mono); font-style: normal; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--slip); }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px dotted var(--rule); font-size: 15px; }
.check input { width: 20px; height: 20px; flex: none; margin: 1px 0 0; border: 1.5px solid var(--ink); background: var(--slip); border-radius: 2px; display: grid; place-items: center; }
.check.radio input { border-radius: 50%; }
.check input:checked { background: var(--ink); box-shadow: inset 0 0 0 3px var(--slip); }
.warn { font: 13px/1.45 var(--mono); background: #fde6e2; border-left: 3px solid var(--red); padding: 9px 11px; margin: 10px 0 0 !important; }
.verdict { margin-top: 14px; padding: 12px 14px; border: 2px solid var(--ink); font-size: 15px; background: var(--paper); transform: rotate(-.4deg); }
.verdict b { display: block; font: 600 18px var(--serif); margin-bottom: 4px; }
.letter { background: #fffdf8; padding: 16px; margin-bottom: 16px; border: 1px solid var(--rule); box-shadow: 0 8px 20px -14px rgba(60,40,10,.5); border-left: 3px double var(--red); }
.letter-head { display: flex; align-items: baseline; gap: 10px; border-bottom: 1px solid var(--rule); }
.letter-head span { font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--ink2); width: 58px; flex: none; }
.letter-head input { border: 0; font-size: 15px; }
.letter textarea { border: 0; font: 15px/28px var(--sans); padding: 0; margin-top: 12px; min-height: 476px; background: repeating-linear-gradient(transparent 0 27px, rgba(31,78,121,.14) 27px 28px); background-attachment: local; }
.escalate ol { padding-left: 20px; margin: 0; } .escalate li { margin-bottom: 10px; } .escalate a { color: var(--red-ink); }

/* Rights */
.facts { padding-left: 20px; margin: 0 0 10px; } .facts li { margin-bottom: 9px; }
.stack { display: grid; gap: 8px; } .stack .btn { width: 100%; }
.srcs { padding-left: 18px; font: 13px/1.6 var(--mono); } .srcs a { color: var(--red-ink); }

/* Proof pack */
.proof { background: #fff; padding: 22px; margin: 16px 0 24px; box-shadow: 0 8px 22px -14px rgba(0,0,0,.4); }
.proof header { display: flex; justify-content: space-between; align-items: center; border-bottom: 3px double var(--ink); padding-bottom: 12px; margin-bottom: 14px; }
.proof h1 { font-size: 26px; margin-bottom: 12px; } .proof h2 { font-size: 17px; margin: 18px 0 6px; }
.proof table { width: 100%; border-collapse: collapse; font: 13.5px var(--mono); }
.proof th { text-align: left; font-weight: 500; color: var(--ink2); padding: 6px 10px 6px 0; vertical-align: top; width: 42%; border-bottom: 1px dotted var(--rule); }
.proof td { padding: 6px 0; border-bottom: 1px dotted var(--rule); font-weight: 600; }
.proof p, .proof li { font-size: 14px; }
.proof-img { max-width: 100%; border: 1px solid var(--rule); }
@media print {
  body { background: #fff; padding: 0; } .noprint, .tabs, #toast { display: none !important; }
  .proof { box-shadow: none; margin: 0; padding: 0; } .proof-img { max-height: 60vh; } .stamp { box-shadow: none; }
}

/* Tab bar: a tear-off strip */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: end;
  padding: 8px calc(var(--sr) + 12px) calc(var(--sb) + 8px) calc(var(--sl) + 12px);
  background: var(--slip); border-top: 2px dashed var(--rule); box-shadow: 0 -6px 18px -12px rgba(60,40,10,.35);
}
.tab { display: grid; justify-items: center; gap: 3px; text-decoration: none; font: 600 10.5px var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--ink2); padding: 4px 0; }
.tab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.tab.on { color: var(--ink); } .tab.on svg { stroke-width: 2; }
.tab.add .plus { width: 54px; height: 54px; margin-top: -26px; border-radius: 50%; background: var(--red); position: relative; box-shadow: 0 3px 0 var(--red-ink), 0 0 0 5px var(--slip); }
.tab.add .plus::before, .tab.add .plus::after { content: ''; position: absolute; left: 50%; top: 50%; width: 22px; height: 2.5px; background: #fff8ef; transform: translate(-50%, -50%); border-radius: 2px; }
.tab.add .plus::after { transform: translate(-50%, -50%) rotate(90deg); }
body[data-route=proof] .tabs, body[data-route=claim] .tabs { display: none; }
body[data-route=proof], body[data-route=claim] { padding-bottom: calc(var(--sb) + 24px); }

#toast { position: fixed; left: 50%; bottom: calc(var(--sb) + 92px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--slip); font: 500 13px var(--mono); padding: 10px 14px; border-radius: 2px; transition: .2s; z-index: 20; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
