:root {
  --ink: #101211;
  --paper: #f0eee8;
  --paper-2: #e8e5dd;
  --white: #fbfaf7;
  --muted: #6b6e69;
  --line: rgba(16, 18, 17, 0.16);
  --acid: #d9ff57;
  --cyan: #56d7ef;
  --coral: #ff6f59;
  --radius: 18px;
  --shadow: 0 22px 70px rgba(12, 14, 13, 0.12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, "Noto Sans TC", "Noto Sans JP", "PingFang TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.5;
  min-width: 320px;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
.is-hidden { display: none !important; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: .28;
  background-image: radial-gradient(rgba(16, 18, 17, .08) .55px, transparent .55px);
  background-size: 4px 4px;
}

.site-header {
  width: min(1240px, calc(100% - 48px));
  height: 92px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { display: grid; grid-template-columns: 1fr 1fr; width: 46px; height: 46px; border: 2px solid var(--ink); }
.brand-mark i { display: grid; place-items: center; font-weight: 900; font-style: normal; font-size: 15px; }
.brand-mark i:first-child { background: var(--ink); color: var(--white); }
.brand strong, .brand small { display: block; letter-spacing: .12em; }
.brand strong { font-size: 15px; line-height: 1.15; }
.brand small { color: var(--muted); font-size: 9px; margin-top: 3px; }
.header-status { display: flex; align-items: center; gap: 9px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #4bc66b; box-shadow: 0 0 0 4px rgba(75, 198, 107, .15); }

main { overflow: hidden; }
.hero {
  width: min(1240px, calc(100% - 48px));
  min-height: 630px;
  margin: 0 auto;
  padding: 76px 0 82px;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(330px, .65fr);
  align-items: center;
  gap: 9vw;
}
.eyebrow { margin: 0 0 24px; color: var(--muted); font-size: 11px; letter-spacing: .16em; font-weight: 800; }
.eyebrow span { color: var(--ink); background: var(--acid); padding: 7px 10px; margin-right: 10px; }
.hero h1 { margin: 0; max-width: 850px; font-size: clamp(50px, 6.5vw, 96px); line-height: .97; letter-spacing: -.065em; font-weight: 900; }
.hero h1 em { font-style: normal; color: transparent; -webkit-text-stroke: 2px var(--ink); }
.hero-lead { max-width: 660px; margin: 32px 0 36px; font-size: 17px; color: #4f524e; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 24px; font-size: 12px; font-weight: 700; }
.hero-meta span { padding-right: 24px; border-right: 1px solid var(--line); }
.hero-meta span:last-child { border: 0; }
.hero-meta b { color: var(--coral); margin-right: 6px; }

.hero-card {
  position: relative;
  justify-self: end;
  width: min(100%, 340px);
  aspect-ratio: 2.5 / 3.5;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background:
    radial-gradient(circle at 70% 25%, rgba(86,215,239,.85), transparent 24%),
    radial-gradient(circle at 22% 78%, rgba(217,255,87,.8), transparent 23%),
    linear-gradient(145deg, #242726, #111312 52%, #292c2a);
  box-shadow: 24px 24px 0 var(--ink), var(--shadow);
  color: white;
  overflow: hidden;
  transform: rotate(3deg);
}
.hero-card::before, .hero-card::after { content: ""; position: absolute; inset: 10%; border: 1px solid rgba(255,255,255,.3); border-radius: 50%; transform: rotate(35deg); }
.hero-card::after { inset: 20% -20%; transform: rotate(-35deg); }
.hero-card > strong { position: absolute; inset: 0; display: grid; place-items: center; font-size: 110px; letter-spacing: -.12em; color: rgba(255,255,255,.92); font-weight: 950; }
.hero-card > small { position: absolute; left: 22px; bottom: 20px; font-family: ui-monospace, monospace; font-size: 13px; letter-spacing: .08em; }
.card-kicker { position: absolute; left: 22px; top: 22px; z-index: 2; font-size: 9px; letter-spacing: .18em; }
.scan-line { position: absolute; z-index: 4; left: 10px; right: 10px; height: 2px; top: 26%; background: var(--acid); box-shadow: 0 0 20px var(--acid); animation: scan 3.2s ease-in-out infinite; }
@keyframes scan { 0%, 100% { top: 22%; opacity: .4; } 50% { top: 80%; opacity: 1; } }
.corner { position: absolute; z-index: 3; width: 28px; height: 28px; border-color: white; border-style: solid; }
.corner-a { top: 14px; left: 14px; border-width: 2px 0 0 2px; }
.corner-b { top: 14px; right: 14px; border-width: 2px 2px 0 0; }
.corner-c { bottom: 14px; left: 14px; border-width: 0 0 2px 2px; }
.corner-d { bottom: 14px; right: 14px; border-width: 0 2px 2px 0; }

.scanner-shell, .results-section, .how-it-works { width: min(1240px, calc(100% - 48px)); margin: 0 auto; padding: 84px 0; }
.scanner-shell { border-top: 1px solid var(--line); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 40px; margin-bottom: 34px; }
.section-heading h2 { font-size: clamp(34px, 5vw, 64px); line-height: 1; letter-spacing: -.055em; margin: 5px 0 0; }
.section-heading > p { max-width: 420px; margin: 0 0 4px; color: var(--muted); font-size: 14px; }
.section-number { margin: 0; font-size: 10px; font-weight: 900; letter-spacing: .18em; color: var(--coral); }

.scanner-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(350px, .8fr); background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.capture-panel { padding: 28px; border-right: 1px solid var(--line); min-width: 0; }
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 20px; padding: 5px; background: var(--paper-2); border-radius: 12px; }
.mode-tab { min-height: 45px; border: 0; background: transparent; border-radius: 9px; cursor: pointer; font-size: 13px; font-weight: 800; }
.mode-tab.is-active { background: var(--ink); color: white; box-shadow: 0 4px 12px rgba(16,18,17,.18); }

.drop-zone { min-height: 440px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; border: 1.5px dashed #a7aaa4; border-radius: 14px; background: #f7f6f2; text-align: center; cursor: pointer; transition: .2s ease; }
.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--ink); background: #f0f5dd; transform: translateY(-2px); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-icon { display: grid; place-items: center; width: 62px; height: 62px; margin-bottom: 24px; border-radius: 50%; background: var(--acid); font-size: 35px; font-weight: 300; }
.drop-zone strong { font-size: 22px; letter-spacing: -.02em; }
.drop-zone small { margin-top: 6px; color: var(--muted); }
.file-types { margin-top: 25px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 50px; font-family: ui-monospace, monospace; font-size: 10px; color: var(--muted); }

.camera-stage { position: relative; min-height: 390px; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 14px; background: #141615; }
.camera-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: white; }
.camera-empty span { font-size: 11px; letter-spacing: .2em; color: var(--acid); }
.camera-empty p { margin: 8px 0 0; font-size: 14px; color: #a5aaa6; }
.camera-guide { position: absolute; pointer-events: none; inset: 8%; border: 1px solid rgba(255,255,255,.75); border-radius: 10px; }
.camera-guide span { position: absolute; height: 1px; left: 8%; right: 8%; bottom: 15%; background: var(--acid); box-shadow: 0 0 10px var(--acid); }
.camera-actions { display: flex; justify-content: center; gap: 10px; margin-top: 15px; }
.camera-note { text-align: center; color: var(--muted); font-size: 11px; margin: 10px 0 0; }

.button { min-height: 47px; border-radius: 10px; padding: 0 18px; border: 1px solid var(--ink); font-weight: 850; font-size: 13px; cursor: pointer; transition: .18s ease; }
.button:hover { transform: translateY(-2px); }
.button:disabled { cursor: wait; opacity: .55; transform: none; }
.button-primary { background: var(--acid); color: var(--ink); box-shadow: 4px 4px 0 var(--ink); }
.button-secondary { background: white; }

.recognition-panel { display: flex; flex-direction: column; min-width: 0; }
.recognition-preview { position: relative; min-height: 250px; height: 300px; display: grid; place-items: center; background: #171918; overflow: hidden; }
.recognition-preview img { display: none; width: 100%; height: 100%; object-fit: contain; }
.recognition-preview.has-image img { display: block; }
.recognition-preview.has-image .preview-placeholder { display: none; }
.preview-placeholder { color: white; text-align: center; }
.preview-placeholder span { font-size: 10px; letter-spacing: .2em; color: var(--cyan); }
.preview-placeholder p { color: #8f9590; font-size: 13px; }
.preview-badge { position: absolute; right: 12px; top: 12px; padding: 6px 9px; border-radius: 5px; color: var(--acid); background: rgba(0,0,0,.72); font-size: 9px; letter-spacing: .16em; font-weight: 800; }
.recognition-state { padding: 25px 28px 20px; border-bottom: 1px solid var(--line); }
.state-label { display: block; margin-bottom: 6px; color: var(--muted); text-transform: uppercase; font-size: 9px; letter-spacing: .16em; font-weight: 800; }
.recognition-state strong { display: block; font-size: 21px; letter-spacing: -.02em; }
.recognition-state p { min-height: 21px; margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.progress-track { height: 4px; margin-top: 16px; background: var(--paper-2); border-radius: 10px; overflow: hidden; opacity: 0; transition: opacity .2s; }
.progress-track.is-visible { opacity: 1; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--coral); transition: width .2s; }
.card-number-form { margin-top: auto; padding: 23px 28px 28px; }
.card-number-form label { display: block; margin-bottom: 8px; font-size: 11px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.input-row { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.input-row input { min-width: 0; height: 47px; padding: 0 14px; border: 1.5px solid var(--ink); border-radius: 10px; background: white; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 15px; text-transform: uppercase; }
.input-row input:focus { outline: 3px solid rgba(86,215,239,.35); outline-offset: 1px; }
.card-number-form > p { margin: 10px 0 0; color: var(--muted); font-size: 11px; }
.text-button { border: 0; background: transparent; padding: 0; text-decoration: underline; cursor: pointer; font-weight: 700; }

.results-section { padding-top: 64px; }
.results-heading { border-bottom: 1px solid var(--line); padding-bottom: 25px; }
.result-summary { font-family: ui-monospace, monospace; color: var(--muted); font-size: 12px; text-align: right; }
.results-empty { display: grid; justify-items: center; max-width: 620px; padding: 70px 30px; margin: 0 auto; text-align: center; }
.results-empty > span { display: grid; place-items: center; width: 74px; height: 74px; border: 2px solid var(--ink); border-radius: 50%; font-size: 30px; box-shadow: 6px 6px 0 var(--acid); }
.results-empty h3 { margin: 24px 0 8px; font-size: 20px; }
.results-empty p { margin: 0; color: var(--muted); font-size: 13px; }
.store-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.store-card { border: 1px solid var(--line); border-radius: 15px; background: var(--white); overflow: hidden; }
.store-card.is-best { border-color: var(--ink); box-shadow: 8px 8px 0 var(--acid); }
.store-head { min-height: 83px; padding: 18px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); }
.store-head h3 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.store-head p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.store-badge { flex: 0 0 auto; padding: 6px 8px; border-radius: 6px; background: var(--paper-2); font-size: 9px; font-weight: 900; letter-spacing: .1em; }
.store-badge.best { background: var(--acid); }
.store-body { padding: 8px; }
.product-row { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 11px; padding: 11px; border-radius: 10px; text-decoration: none; transition: background .15s; }
.product-row:hover { background: var(--paper-2); }
.product-image { width: 58px; height: 81px; border-radius: 5px; object-fit: cover; background: #d8d8d2; border: 1px solid var(--line); }
.product-image-fallback { display: grid; place-items: center; width: 58px; height: 81px; border-radius: 5px; background: var(--ink); color: var(--acid); font-weight: 900; font-size: 11px; }
.product-info { min-width: 0; }
.product-info strong { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 12px; line-height: 1.45; }
.product-code { display: block; margin: 4px 0 8px; color: var(--muted); font-family: ui-monospace, monospace; font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-bottom { display: flex; align-items: end; justify-content: space-between; gap: 6px; }
.product-price { font-size: 18px; line-height: 1; font-weight: 950; letter-spacing: -.04em; }
.product-stock { font-size: 9px; color: #397e4a; font-weight: 750; }
.product-stock.out { color: #a1493e; }
.store-message { min-height: 190px; padding: 35px 22px; display: grid; place-content: center; text-align: center; }
.store-message span { font-size: 24px; }
.store-message p { color: var(--muted); font-size: 12px; }
.store-link { display: inline-flex; justify-content: center; margin-top: 5px; font-size: 11px; font-weight: 800; }
.more-link { display: flex; justify-content: center; padding: 13px; margin: 4px 8px 8px; border-radius: 9px; background: var(--ink); color: white; text-decoration: none; font-size: 11px; font-weight: 800; }
.results-loading { grid-column: 1 / -1; display: grid; place-items: center; padding: 70px; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--ink); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.how-it-works { border-top: 1px solid var(--line); }
.tip-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 15px; overflow: hidden; }
.tip-grid li { padding: 32px; background: var(--paper); }
.tip-grid li > span { display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 30px; border-radius: 50%; background: var(--ink); color: white; font-family: ui-monospace, monospace; font-size: 12px; }
.tip-grid strong { font-size: 18px; }
.tip-grid p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

footer { width: min(1240px, calc(100% - 48px)); margin: 0 auto; padding: 28px 0 40px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 30px; color: var(--muted); font-size: 10px; }
.toast { position: fixed; z-index: 200; left: 50%; bottom: 24px; transform: translate(-50%, 20px); padding: 12px 18px; border-radius: 10px; background: var(--ink); color: white; box-shadow: var(--shadow); font-size: 12px; opacity: 0; pointer-events: none; transition: .22s; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
noscript { display: block; margin: 20px; padding: 15px; background: #ffe4df; text-align: center; }

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr minmax(250px, .55fr); gap: 55px; min-height: 560px; }
  .hero-card { width: 270px; }
  .scanner-grid { grid-template-columns: 1fr; }
  .capture-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .recognition-panel { display: grid; grid-template-columns: 42% 58%; }
  .recognition-preview { height: auto; min-height: 300px; grid-row: span 2; }
  .card-number-form { margin: 0; }
  .store-grid { grid-template-columns: 1fr; }
  .store-card.is-best { box-shadow: 6px 6px 0 var(--acid); }
  .product-row { grid-template-columns: 50px minmax(0,1fr); }
  .product-image, .product-image-fallback { width: 50px; height: 70px; }
}

@media (max-width: 720px) {
  .site-header, .hero, .scanner-shell, .results-section, .how-it-works, footer { width: min(100% - 28px, 1240px); }
  .site-header { height: 74px; }
  .header-status { font-size: 0; }
  .hero { display: block; min-height: 0; padding: 58px 0 82px; }
  .hero h1 { font-size: clamp(48px, 15vw, 74px); }
  .hero h1 em { -webkit-text-stroke-width: 1.5px; }
  .hero-card { width: 230px; margin: 70px auto 20px; transform: rotate(3deg); box-shadow: 16px 16px 0 var(--ink); }
  .hero-meta { gap: 10px 18px; }
  .hero-meta span { border: 0; padding: 0; }
  .scanner-shell, .results-section, .how-it-works { padding: 60px 0; }
  .section-heading { display: block; }
  .section-heading > p { margin-top: 15px; }
  .section-heading h2 { font-size: 43px; }
  .scanner-grid { border-radius: 13px; }
  .capture-panel { padding: 15px; }
  .drop-zone { min-height: 330px; }
  .recognition-panel { display: block; }
  .recognition-preview { height: 290px; min-height: 0; }
  .recognition-state, .card-number-form { padding-left: 20px; padding-right: 20px; }
  .input-row { grid-template-columns: 1fr; }
  .input-row .button { width: 100%; }
  .results-heading .result-summary { margin-top: 15px; text-align: left; }
  .tip-grid { grid-template-columns: 1fr; }
  .tip-grid li { padding: 26px; }
  .tip-grid li > span { margin-bottom: 20px; }
  footer { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
