@font-face {
  font-family: "Atkinson Hyperlegible";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/AtkinsonHyperlegible-400.woff2") format("woff2");
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/AtkinsonHyperlegible-700.woff2") format("woff2");
}

:root {
  --paper: #e8ece9;
  --sheet: #f7f8f6;
  --ink: #1c2422;
  --muted: #3e4c48;
  --rule: #c5cdc8;
  --pine: #0a4a3e;
  --pine-hover: #083830;
  --pine-soft: #dce8e4;
  --mark: #f3e27a;
  --mark-ink: #2a2408;
  --alert: #8a2b16;
  --ok: #0a4a3e;
  --warn-bg: #f8f1c8;
  --alert-bg: #f8ebe6;
  --info-bg: #cfe0da;
  --sans: "Atkinson Hyperlegible", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --radius: 4px;
  --focus: 0 0 0 2px var(--paper), 0 0 0 4px var(--pine);
}

html { color-scheme: light; }
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  font-size: 1.0625rem;
}

::selection {
  background: var(--mark);
  color: var(--mark-ink);
}

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

a { color: var(--pine); text-underline-offset: 0.15em; }
a:hover { color: var(--pine-hover); }

mark {
  background: var(--mark);
  color: var(--mark-ink);
  padding: 0.05em 0.2em;
  border-radius: 2px;
}

header, main, footer {
  width: min(40rem, calc(100% - 2rem));
  margin-inline: auto;
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 0 1rem;
  margin-bottom: 1.75rem;
}

.letterhead { min-width: 0; }
.brand {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}
.brand:hover { color: var(--pine); }
.place {
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

nav {
  display: flex;
  gap: 0.65rem 1rem;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-end;
  font-size: 0.95rem;
}
nav a { color: var(--ink); text-decoration: none; }
nav a:hover { color: var(--pine); text-decoration: underline; }

.lang { display: inline-flex; gap: 0.55rem; }
.lang button {
  font: inherit;
  font-size: 0.9rem;
  border: 0;
  background: none;
  color: var(--muted);
  padding: 0.15rem 0;
  cursor: pointer;
}
.lang button[aria-pressed="true"] {
  color: var(--ink);
  font-weight: 700;
}

h1, h2, h3 {
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  text-wrap: balance;
}
h1 { font-size: 1.85rem; margin: 0 0 0.65rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.45rem; }
h3 { font-size: 1.05rem; margin: 1.4rem 0 0.4rem; }

.lede {
  margin: 0 0 1.5rem;
  max-width: 38rem;
  color: var(--ink);
}

.why { margin: 2rem 0 1.25rem; }
.why h2 { margin-top: 0; }
.why p { margin: 0 0 0.7rem; }

.example {
  font-size: 1rem;
  margin: 0;
  padding: 0.7rem 0 0;
  border-top: 1px solid var(--rule);
}

.money, .teaser-num, input[type="number"],
td:nth-child(2), td:nth-child(3), .example strong {
  font-variant-numeric: tabular-nums;
}

.sheet, .card {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  margin: 0 0 1.5rem;
  box-shadow: none;
}

.sheet-label {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.9rem;
}

label, .label {
  display: block;
  font-weight: 700;
  margin: 0.75rem 0 0.3rem;
  font-size: 0.95rem;
}

input, select, textarea {
  width: 100%;
  font: inherit;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius);
  border: 1px solid #9aa59f;
  background: var(--sheet);
  color: var(--ink);
  caret-color: var(--pine);
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--pine);
  outline-offset: 1px;
  border-color: var(--pine);
}

.grid { display: grid; gap: 0.55rem 1rem; grid-template-columns: 1fr 1fr; }
.row {
  display: grid;
  gap: 0.4rem 0.65rem;
  grid-template-columns: minmax(0, 1.3fr) minmax(7.5rem, 0.8fr) minmax(0, 1fr) auto;
  align-items: end;
  margin-bottom: 0.65rem;
}
@media (max-width: 640px) {
  .grid, .row { grid-template-columns: 1fr; }
}

.checks { display: flex; gap: 0.75rem 1.1rem; flex-wrap: wrap; margin: 0.9rem 0; }
.checks label { display: flex; gap: 0.4rem; align-items: center; font-weight: 400; margin: 0; }
.checks input { width: auto; }

.actions { display: flex; gap: 0.55rem; flex-wrap: wrap; margin-top: 1.1rem; }

button, .btn, .upload-btn {
  font: inherit;
  font-weight: 700;
  border: 1px solid var(--pine);
  border-radius: var(--radius);
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  background: var(--sheet);
  color: var(--pine);
  line-height: 1.3;
}
button:hover, .btn:hover, .upload-btn:hover, .upload-btn:focus-within {
  background: var(--pine-soft);
}
button:active, .btn:active, .upload-btn:active {
  transform: translateY(1px);
}
.primary {
  background: var(--pine);
  color: var(--sheet);
  border-color: var(--pine);
}
.primary:hover { background: var(--pine-hover); border-color: var(--pine-hover); color: var(--sheet); }
.secondary { background: var(--sheet); color: var(--pine); }
.ghost {
  background: none;
  border-color: transparent;
  color: var(--muted);
  font-weight: 400;
  padding-left: 0.2rem;
  padding-right: 0.2rem;
}
.ghost:hover { background: none; color: var(--alert); }
button:disabled, .btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.muted { color: var(--muted); }

.disclaimer, .note {
  font-size: 0.95rem;
  color: var(--muted);
}

.teaser-num {
  font-size: 1.7rem;
  font-weight: 700;
  margin: 0.15rem 0 0.2rem;
  letter-spacing: -0.02em;
}

.flag { padding: 0.55rem 0.7rem; margin: 0.5rem 0; border-radius: var(--radius); }
.flag.alert { background: var(--mark); color: var(--mark-ink); }
.flag.info { background: var(--info-bg); }

.status-high { font-weight: 700; color: var(--mark-ink); }
.status-match, .status-low { color: var(--ok); font-weight: 700; }

table { width: 100%; border-collapse: collapse; font-size: 0.98rem; margin: 0.6rem 0 0.9rem; }
th, td { text-align: left; padding: 0.45rem 0.5rem 0.45rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-weight: 700; border-bottom: 1px solid var(--ink); }
tr.is-high td { background: var(--mark); color: var(--mark-ink); box-decoration-break: clone; }

.paywall {
  background: var(--pine-soft);
  border: 0;
  border-radius: var(--radius);
  padding: 1rem 1.05rem 1.15rem;
}

pre, textarea.template {
  white-space: pre-wrap;
  font-family: var(--sans);
  font-size: 0.92rem;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.75rem;
  overflow-x: auto;
}

footer {
  padding: 1.5rem 0 2.6rem;
  color: var(--muted);
  font-size: 0.92rem;
  margin-top: 1.2rem;
}
footer a { color: var(--muted); }
footer a:hover { color: var(--pine); }

.legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  margin: 0.8rem 0 0;
  padding: 0;
  list-style: none;
}
.legal-links a { color: var(--muted); }

.hidden { display: none !important; }
.error { color: var(--alert); }
ol.steps { padding-left: 1.2rem; }
ol.steps li { margin: 0.45rem 0; }

.upload { margin-bottom: 1.1rem; }
.upload-btn input { display: none; }
.upload .muted { margin: 0.45rem 0 0; font-weight: 400; }

.banner {
  background: var(--warn-bg);
  color: var(--mark-ink);
  border: 0;
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
  margin: 0 0 1rem;
}

#scanStatus { margin: 0.45rem 0 0; }
#scanStatus.error { color: var(--alert); }

@media (prefers-reduced-motion: reduce) {
  button:active, .btn:active, .upload-btn:active { transform: none; }
}


@media (max-width: 640px) {
  header {
    flex-direction: row;
    align-items: baseline;
  }
}


#teaser, #report {
  margin-top: 2rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--rule);
}
#paywall { margin-top: 2rem; }

table { table-layout: auto; }
th, td { padding: 0.5rem 0.65rem 0.5rem 0.35rem; }
th:first-child, td:first-child { padding-left: 0.45rem; }
th:last-child, td:last-child { padding-right: 0.45rem; }
th:nth-child(2), td:nth-child(2),
th:nth-child(3), td:nth-child(3),
#report th:nth-child(4), #report td:nth-child(4) {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

ol.steps a { overflow-wrap: anywhere; }

#start {
  min-height: calc(100dvh - 7.5rem);
  padding-top: 1.25rem;
}
#start .lede { margin-bottom: 1.75rem; }
.hero-actions { margin: 0; }
#start .upload-btn.primary {
  padding: 0.7rem 1.15rem;
  font-size: 1.05rem;
}
#start .upload-btn.primary:hover,
#start .upload-btn.primary:focus-within {
  background: var(--pine-hover);
  border-color: var(--pine-hover);
  color: var(--sheet);
}
.type-in-wrap { margin: 0.85rem 0 0; }
button.link {
  background: none;
  border: 0;
  color: var(--pine);
  font: inherit;
  font-weight: 400;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}
button.link:hover { background: none; color: var(--pine-hover); }

.step-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin: 0 0 1rem;
  font-size: 0.95rem;
  color: var(--muted);
}
.step-meta .ghost:hover { color: var(--pine); }

#tool h2 { margin-top: 0; }

.more-details {
  margin: 1rem 0 0;
  padding-top: 0.2rem;
}
.more-details summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 400;
}
.more-details summary:hover { color: var(--pine); }
.more-details[open] summary { margin-bottom: 0.5rem; }

.more {
  margin-top: 0.5rem;
  padding-bottom: 0.5rem;
}
.more details {
  border-top: 1px solid var(--rule);
  padding: 0.75rem 0;
}
.more summary {
  cursor: pointer;
  font-weight: 700;
}
.more .example {
  border-top: 0;
  padding-top: 0.55rem;
}

.ghost:hover { color: var(--pine); }
.remove.ghost:hover { color: var(--alert); }

#teaser, #report, #paywall { margin-top: 0; padding-top: 0; border-top: 0; }
#teaser h2, #report h2, #paywall h2 { margin-top: 0; }

#step-ship .grid > label:nth-child(3) { grid-column: 1 / -1; }

/* Hero: copy + illustrated receipt */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16rem, 20rem);
  gap: 2.25rem 3rem;
  align-items: center;
  min-height: calc(100dvh - 8rem);
  padding-top: 0.5rem;
}
#start { min-height: 0; padding-top: 0.5rem; }
#start .lede { margin-bottom: 1.5rem; }

.bill {
  position: relative;
  background: var(--sheet);
  color: var(--ink);
  padding: 1.15rem 1.2rem 1.25rem;
  border-radius: 2px;
  box-shadow:
    0 1px 0 rgba(28, 36, 34, 0.05),
    0 12px 28px -14px rgba(28, 36, 34, 0.3),
    0 3px 8px -3px rgba(28, 36, 34, 0.12);
  overflow: hidden;
  transform: rotate(-0.6deg);
}
.bill::before {
  content: "";
  display: block;
  height: 6px;
  margin: -1.15rem -1.2rem 0.9rem;
  background: var(--pine);
}
.bill-tag {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.bill-title {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 1.15rem;
}
.bill-meta {
  margin: 0.15rem 0 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.bill-lines {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}
.bill-lines li {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0.35rem;
  border-bottom: 1px solid var(--rule);
}
.bill-lines li > *:not(.bill-mark) { position: relative; z-index: 1; }
.bill-lines li .bill-mark {
  position: absolute;
  inset: 0;
  background: var(--mark);
  z-index: 0;
  transform-origin: left center;
}
.bill-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 1rem;
  margin-top: 0.85rem;
  font-size: 0.9rem;
}
.bill-compare p { margin: 0; color: var(--muted); }
.bill-compare strong { display: block; color: var(--ink); font-size: 1.05rem; }
.bill-delta { grid-column: 1 / -1; margin-top: 0.25rem; }
.bill-delta mark {
  display: inline-block;
  transform-origin: left center;
}

.bill-scan {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  top: 0;
  background: var(--pine);
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  box-shadow: 0 0 12px rgba(10, 74, 62, 0.35);
}

.drop-hint {
  display: none;
  margin: 0.8rem 0 0;
  text-align: center;
  font-size: 0.9rem;
  color: var(--pine);
  font-weight: 700;
}

#dropZone.is-drag .bill {
  transform: rotate(0deg) translateY(-6px);
  box-shadow:
    0 1px 0 rgba(28, 36, 34, 0.05),
    0 18px 36px -14px rgba(28, 36, 34, 0.35);
  outline: 2px dashed var(--pine);
  outline-offset: 6px;
}
#dropZone.is-drag .drop-hint { display: block; }
#dropZone.is-drag .bill-scan {
  opacity: 0.85;
  animation: scan-loop 0.7s linear infinite;
}

#start.is-scanning .bill-scan {
  opacity: 0.9;
  animation: scan-loop 0.85s linear infinite;
}
#start.is-scanning .upload-btn.primary { pointer-events: none; opacity: 0.8; }
#start.is-scanning .type-in-wrap { visibility: hidden; }

#start .upload-btn.primary {
  padding: 0.7rem 1.15rem;
  font-size: 1.05rem;
  box-shadow: 0 1px 0 rgba(10, 74, 62, 0.18);
  transition: transform 0.16s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}
#start .upload-btn.primary:hover,
#start .upload-btn.primary:focus-within {
  background: var(--pine-hover);
  border-color: var(--pine-hover);
  color: var(--sheet);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px -2px rgba(10, 74, 62, 0.28);
}
#start .upload-btn.primary:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(10, 74, 62, 0.18);
}

#teaser.is-revealed .teaser-num { }
tr.is-high td {
  background: var(--mark);
  color: var(--mark-ink);
}

.step-in-right, .step-in-left, .panel-in { }

@media (prefers-reduced-motion: no-preference) {
  .hero-copy h1 { animation: rise 0.55s 0.08s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
  .hero-copy .lede { animation: rise 0.55s 0.16s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
  .hero-actions { animation: rise 0.55s 0.24s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
  .bill { animation: bill-settle 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
  .bill-mark { animation: wipe 0.55s 0.85s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
  .bill-delta mark { animation: rise 0.4s 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
  .bill-scan { animation: scan-once 1.05s 0.15s ease-in-out both; }

  .step-in-right { animation: step-in-right 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
  .step-in-left { animation: step-in-left 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
  .panel-in { animation: rise 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both; }

  #teaser.is-revealed tr.is-high td {
    background: transparent;
    animation: row-wipe 0.55s 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  }
  #report.is-revealed tr.is-high td {
    background: transparent;
    animation: row-wipe 0.55s 0.2s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes bill-settle {
  from { opacity: 0; transform: translateY(16px) rotate(-2.2deg); }
  to { opacity: 1; transform: rotate(-0.6deg); }
}
@keyframes wipe {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
@keyframes scan-once {
  0% { opacity: 0; top: 8%; }
  12% { opacity: 0.85; }
  88% { opacity: 0.85; }
  100% { opacity: 0; top: 92%; }
}
@keyframes scan-loop {
  0% { top: 4%; opacity: 0; }
  8% { opacity: 0.9; }
  92% { opacity: 0.9; }
  100% { top: 96%; opacity: 0; }
}
@keyframes step-in-right {
  from { opacity: 0; transform: translateX(1.1rem); }
  to { opacity: 1; transform: none; }
}
@keyframes step-in-left {
  from { opacity: 0; transform: translateX(-1.1rem); }
  to { opacity: 1; transform: none; }
}
@keyframes row-wipe {
  from { background-color: transparent; box-shadow: inset 0 0 0 0 var(--mark); }
  to { background-color: var(--mark); }
}

@media (max-width: 800px) {
  .hero {
    grid-template-columns: 1fr;
    min-height: 0;
    gap: 1.6rem;
    padding-bottom: 1rem;
  }
  .hero-visual, .bill { max-width: 22rem; }
}

@media (prefers-reduced-motion: reduce) {
  .bill { transform: none; animation: none; }
  .bill-mark { transform: none; }
  .bill-scan { display: none; }
  #start .upload-btn.primary,
  #start .upload-btn.primary:hover,
  #start .upload-btn.primary:active {
    transition: none;
    transform: none;
    box-shadow: none;
  }
  #dropZone.is-drag .bill { transform: none; }
}

