:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #15181e;
  --muted: #5b6270;
  --line: #dde1e8;
  --accent: #d8330b;
  --accent-ink: #ffffff;
  --link: #1f5fbf;
  --good: #11734b;
  --warn-bg: #fff6e0;
  --warn-line: #f0d28a;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 2px 8px rgb(16 24 40 / 6%);
  --radius: 12px;
  --gutter: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --surface: #1a1d24;
    --surface-2: #232733;
    --text: #e9ecf2;
    --muted: #a0a7b5;
    --line: #2f3442;
    --accent: #ff6a3d;
    --accent-ink: #1a0a04;
    --link: #8cb8ff;
    --good: #4fd19a;
    --warn-bg: #2b2414;
    --warn-line: #5c4a1c;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: var(--link); }
code { font: 0.92em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 var(--gutter); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }

/* header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
.header-nav { display: flex; gap: 16px; font-size: 15px; }
.header-nav a { color: var(--muted); text-decoration: none; white-space: nowrap; }
.header-nav a:hover { color: var(--text); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; text-align: center; line-height: 20px; }
@media (max-width: 520px) {
  .header-nav a[href="#guide"], .header-nav a[href="#faq"] { display: none; }
}

/* hero */
.hero { padding: 32px 0 8px; }
h1 { font-size: clamp(1.6rem, 4.2vw, 2.4rem); line-height: 1.15; margin: 0 0 10px; letter-spacing: -0.01em; }
.lede { color: var(--muted); margin: 0 0 20px; max-width: 62ch; }

.search { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.search-row { display: flex; gap: 8px; }
.search-row input {
  flex: 1; min-width: 0; font: inherit; font-size: 17px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text);
}
.search-row input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.search-meta { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; }
.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.chip { font: inherit; font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.source-pick { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.source-pick select { font: inherit; font-size: 13px; padding: 4px 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }

.btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px; padding: 10px 16px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.05); border-color: var(--accent); }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn.ghost { background: transparent; }

.scan-note { display: flex; align-items: center; gap: 10px; margin: 12px 0 0; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.scan-note .btn { padding: 6px 12px; font-size: 14px; }
.honesty { margin: 14px 0 0; padding: 10px 12px; border: 1px solid var(--warn-line); background: var(--warn-bg); border-radius: 10px; font-size: 14px; }

/* results */
.results-wrap { padding: 20px 0 8px; }
.status { margin-bottom: 14px; font-size: 15px; color: var(--muted); }
.status .parsed { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.status .tag { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text); }
.status.error { color: var(--text); background: var(--warn-bg); border: 1px solid var(--warn-line); padding: 10px 12px; border-radius: 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
@media (max-width: 480px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; min-width: 0;
}
.card-img { background: var(--surface-2); aspect-ratio: 245 / 342; display: flex; align-items: center; justify-content: center; padding: 8px; border: 0; cursor: zoom-in; width: 100%; }
.card-img img { width: 100%; height: 100%; object-fit: contain; }
.card-img .noimg { color: var(--muted); font-size: 13px; text-align: center; }
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.card-name { font-weight: 700; font-size: 15px; line-height: 1.25; margin: 0; overflow-wrap: anywhere; }
.card-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.price-line { margin-top: 6px; }
.price { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.price-meta { font-size: 12px; color: var(--muted); }
.noprice { font-size: 14px; color: var(--muted); font-style: italic; }
.vlist { list-style: none; margin: 6px 0 0; padding: 0; font-size: 12.5px; display: grid; gap: 2px; }
.vlist li { display: flex; justify-content: space-between; gap: 6px; }
.vlist li span:first-child { color: var(--muted); }
.card-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 10px; }
.card-actions .btn { flex: 1; padding: 7px 8px; font-size: 13px; }
@media (max-width: 480px) {
  .card-body { padding: 8px 9px 10px; }
  .price { font-size: 18px; }
  .card-actions { flex-direction: column; }
}
.skel { background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--radius); aspect-ratio: 245/400; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }
.more-row { display: flex; justify-content: center; margin-top: 16px; }

/* detail dialog */
dialog { border: 0; padding: 0; border-radius: 16px; background: var(--surface); color: var(--text); width: min(880px, calc(100vw - 2 * var(--gutter))); max-height: calc(100dvh - 32px); box-shadow: 0 20px 60px rgb(0 0 0 / 35%); }
dialog::backdrop { background: rgb(10 12 16 / 60%); }
.dlg { position: relative; padding: 20px; }
.dlg-close { position: absolute; right: 10px; top: 8px; font-size: 28px; line-height: 1; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 6px 10px; }
.detail { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 20px; }
.detail-img img { border-radius: 12px; width: 100%; }
.detail h2 { margin: 0 32px 4px 0; font-size: 1.4rem; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 14px; margin: 10px 0 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.ptable-wrap { overflow-x: auto; margin: 8px 0 4px; }
.ptable { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.ptable th, .ptable td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.ptable th:first-child, .ptable td:first-child { text-align: left; }
.ptable thead th { font-size: 12px; color: var(--muted); font-weight: 600; }
.src { font-size: 12.5px; color: var(--muted); margin: 0 0 14px; }
.add-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; padding: 12px; background: var(--surface-2); border-radius: 10px; margin-top: 6px; }
.add-form label { display: grid; gap: 2px; font-size: 12px; color: var(--muted); }
.add-form select, .add-form input { font: inherit; font-size: 15px; padding: 7px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.add-form input { width: 72px; }
.fine { font-size: 13px; color: var(--muted); }
@media (max-width: 640px) {
  .dlg { padding: 16px; }
  .ptable { font-size: 13px; }
  .ptable th, .ptable td { padding: 6px 4px; }
  .detail { grid-template-columns: 1fr; }
  .detail-img { max-width: 220px; margin: 0 auto; }
}

/* collection */
.collection { padding: 32px 0 8px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.col-actions { display: flex; gap: 6px; }
.col-summary { margin: 12px 0; display: flex; flex-wrap: wrap; gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; min-width: 120px; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.col-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.col-item { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.col-item img { width: 44px; border-radius: 4px; }
.col-item .ci-name { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.col-item .ci-sub { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.ci-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.ci-val { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.qty button { border: 0; background: var(--surface-2); color: var(--text); width: 28px; height: 28px; font-size: 16px; cursor: pointer; }
.qty span { min-width: 28px; text-align: center; font-size: 14px; }
.ci-rm { border: 0; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; text-decoration: underline; padding: 0; }

/* guide */
.guide { padding: 40px 0 24px; }
.prose > p, .prose > ul, .prose > ol, .prose > .faq { max-width: 820px; }
.prose h2 { font-size: 1.45rem; margin: 36px 0 12px; line-height: 1.25; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 1.05rem; margin: 0 0 6px; }
.prose li { margin: 6px 0; }
.steps { padding-left: 1.3em; }
.factor-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.factor-grid section { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.factor-grid p { margin: 0; font-size: 15px; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; margin: 8px 0; }
.faq summary { cursor: pointer; padding: 12px 14px; font-weight: 600; }
.faq details p { margin: 0; padding: 0 14px 14px; }

.site-footer { border-top: 1px solid var(--line); padding: 20px 0 32px; font-size: 13px; color: var(--muted); margin-top: 24px; }
.site-footer p { max-width: 820px; }
.linkbtn { font: inherit; font-size: 13px; border: 0; background: none; color: var(--link); text-decoration: underline; cursor: pointer; padding: 0; }
