:root {
  color-scheme: light;
  --ink: #1d2733;
  --muted: #6d7885;
  --faint: #a5aeb7;
  --line: #dfe4e9;
  --surface: #ffffff;
  --canvas: #f6f7f9;
  --accent: #176b63;
  --accent-dark: #105149;
  --accent-soft: #e6f2ef;
  --warning: #a76a28;
  --danger: #b54d4d;
  --shadow: 0 8px 24px rgba(29, 39, 51, .06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--canvas); }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button, label { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .46; }

.app-shell {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 18px calc(30px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 2px 25px;
}

.eyebrow, .section-kicker {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .16em;
}

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-size: clamp(25px, 7vw, 32px);
  line-height: 1.1;
  letter-spacing: 0;
}

.topbar-mark {
  margin-top: 3px;
  padding: 8px 9px;
  border: 1px solid #c5d3d1;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
}

.scanner-section, .results-section {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.results-section { margin-top: 38px; }

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: 17px;
  line-height: 1.2;
  font-weight: 750;
}

.results-heading h2 span {
  display: inline-block;
  min-width: 22px;
  margin-left: 3px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.heading-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.copy-all-button {
  min-height: 38px;
  padding: 0 7px;
  white-space: nowrap;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.status-dot::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #bbc3ca;
  content: "";
}
.status-scanning { color: var(--accent); }
.status-scanning::before { background: #2a9a85; box-shadow: 0 0 0 4px rgba(42, 154, 133, .13); }
.status-error { color: var(--warning); }
.status-error::before { background: #d28b43; }

.scanner-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 1.54;
  min-height: 220px;
  border: 1px solid #ccd4da;
  background: #dfe5e9;
  box-shadow: var(--shadow);
}

#camera-video {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #e5eaed;
}

.camera-placeholder {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  background: #e8edf0;
}

.camera-placeholder p { margin: 10px 0 0; font-size: 13px; }
.placeholder-icon { color: #73808a; }
.placeholder-icon svg { width: 36px; height: 36px; }

.camera-placeholder.is-hidden { display: none; }

.scan-guide {
  position: absolute;
  z-index: 3;
  inset: 17% 9%;
  pointer-events: none;
}

.corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border-color: rgba(255, 255, 255, .94);
  border-style: solid;
}
.corner-tl { top: 0; left: 0; border-width: 2px 0 0 2px; }
.corner-tr { top: 0; right: 0; border-width: 2px 2px 0 0; }
.corner-bl { bottom: 0; left: 0; border-width: 0 0 2px 2px; }
.corner-br { right: 0; bottom: 0; border-width: 0 2px 2px 0; }

.scan-line {
  position: absolute;
  top: 50%;
  left: 4%;
  width: 92%;
  height: 2px;
  background: var(--accent);
  opacity: .9;
  box-shadow: 0 0 9px rgba(23, 107, 99, .7);
  transform: translateY(-50%);
}
.scanning .scan-line { animation: scan 2.2s ease-in-out infinite; }
@keyframes scan {
  0%, 100% { transform: translateY(-44px); opacity: .45; }
  50% { transform: translateY(44px); opacity: 1; }
}

.helper-text, .secure-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.secure-note { color: var(--warning); }

.action-row {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1.15fr;
  gap: 8px;
  margin-top: 16px;
}

.button {
  display: inline-flex;
  min-height: 45px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}
.button:active { transform: translateY(1px); }
.button svg { width: 16px; height: 16px; fill: currentColor; }
.button-secondary svg { fill: none; stroke: currentColor; stroke-width: 1.7; }
.button-primary { color: #fff; background: var(--accent); }
.button-primary:hover { background: var(--accent-dark); }
.button-secondary { border-color: #cfd6dc; color: var(--ink); background: var(--surface); }
.button-secondary:hover { border-color: #a9b5be; background: #fafbfc; }
.file-button { user-select: none; }
#photo-input { display: none; }

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
}
.icon-button:hover { border-color: var(--line); color: var(--ink); background: var(--surface); }
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }

.empty-state {
  display: grid;
  min-height: 150px;
  place-content: center;
  justify-items: center;
  border: 1px dashed #cfd6dc;
  color: var(--faint);
  text-align: center;
}
.empty-state p { margin: 9px 0 0; font-size: 13px; }
.empty-icon { color: #aeb8c0; }
.empty-icon svg { width: 30px; height: 30px; }

.category-panel[hidden] { display: none; }
.result-list { display: grid; gap: 10px; }
.result-item {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: var(--surface);
  box-shadow: 0 3px 12px rgba(29, 39, 51, .035);
}
.result-main {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 8px 8px 12px;
}
.result-index {
  display: inline-grid;
  width: 23px;
  height: 23px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 11px;
  font-weight: 800;
}
.page-category-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  border-bottom: 1px solid #edf0f2;
  padding: 0 0 12px;
}
.category-label {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.category-toggle {
  display: inline-flex;
  border: 1px solid #cfd6dc;
  border-radius: 5px;
  padding: 2px;
  background: #f7f9fa;
}
.category-choice {
  min-width: 52px;
  border: 0;
  border-radius: 3px;
  padding: 5px 8px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  line-height: 1.1;
}
.category-choice.is-selected {
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-weight: 750;
}
.category-choice:focus-visible {
  outline: 2px solid #8bbeb7;
  outline-offset: 1px;
}

.tracking-input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .025em;
}
.tracking-input:focus { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 4px; }
.result-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
  border-top: 1px solid #edf0f2;
  padding: 2px 8px 2px 44px;
}
.text-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  padding: 5px 0;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
}
.text-button:hover { color: var(--accent); }
.text-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.result-actions { display: flex; gap: 1px; }
.result-actions .icon-button { width: 34px; height: 34px; }
.note-wrap { padding: 0 12px 10px 44px; }
.note-input {
  display: block;
  width: 100%;
  resize: vertical;
  min-height: 54px;
  border: 1px solid #d9e0e5;
  border-radius: 4px;
  outline: 0;
  padding: 8px 9px;
  color: var(--ink);
  background: #fbfcfc;
  font-size: 13px;
  line-height: 1.45;
}
.note-input:focus { border-color: #8bbeb7; box-shadow: 0 0 0 3px rgba(23, 107, 99, .09); }
.item-feedback { min-height: 0; margin: 0 12px 0 44px; color: var(--accent); font-size: 11px; }
.item-feedback:not(:empty) { padding-bottom: 8px; }

.privacy-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 22px 2px 0;
  color: var(--faint);
  font-size: 11px;
}
.privacy-note svg { width: 15px; height: 15px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5; }

.toast {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 18px;
  z-index: 10;
  width: fit-content;
  max-width: calc(100% - 36px);
  margin: auto;
  border-radius: 4px;
  padding: 10px 13px;
  color: #fff;
  background: rgba(29, 39, 51, .92);
  box-shadow: 0 6px 22px rgba(29, 39, 51, .18);
  font-size: 13px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 420px) {
  .app-shell { padding-right: 14px; padding-left: 14px; }
  .action-row { grid-template-columns: 1fr 1fr; }
  .file-button { grid-column: span 2; }
  .scanner-frame { min-height: 205px; }
}

@media (min-width: 700px) {
  .app-shell { padding-top: 38px; }
  .scanner-frame { aspect-ratio: 1.8; }
}
