:root {
  --bg: #ffffff;
  --ink: #17171a;
  --muted: #6d6d75;
  --faint: #a4a4ab;
  --line: #ececef;
  --soft: #f6f6f8;
  --sakura: #e58fab;        /* accent: primary action, active state, top コスパ */
  --sakura-ink: #b9506f;
  --sakura-soft: #fdf0f4;
  --good: #2f8f5b;
  --warn: #b7791f;
  --radius: 18px;
  --font: "Figtree", "Zen Kaku Gothic New", system-ui, -apple-system, "Hiragino Sans", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); }
body { overflow: hidden; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--sakura-ink); font-size: 14px; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* logo */
.logo { font-weight: 700; font-size: 30px; letter-spacing: .04em; }
.logo span { font-family: "Zen Kaku Gothic New", sans-serif; color: var(--sakura); margin-left: 4px; }
.logo.small { font-size: 18px; }

/* gate */
#gate { align-items: center; justify-content: center; padding: 24px 16px; background: linear-gradient(180deg, #fff 60%, var(--sakura-soft)); }
.gate-card { width: 100%; max-width: 360px; display: grid; gap: 14px; }
.gate-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.gate-card input { height: 48px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; font-size: 16px; background: #fff; }
.gate-card input:focus { outline: 2px solid var(--sakura); border-color: transparent; }

/* buttons */
.btn { height: 46px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: 15px; cursor: pointer; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.small { height: 38px; font-size: 14px; padding: 0 14px; }
.btn.wide { width: 100%; margin-top: 12px; }
.btn:active { transform: scale(.98); }
.pill { height: 32px; min-width: 44px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: 13px; }
.ghost { color: var(--muted); font-size: 14px; cursor: pointer; }

/* camera */
#camera { background: #0d0d0f; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: #fff; }
.seg { display: inline-flex; background: var(--soft); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; height: 30px; padding: 0 14px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.viewfinder { position: relative; flex: 1; overflow: hidden; }
#video, #still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.frame { position: absolute; left: 50%; top: 46%; width: min(72vw, 360px); aspect-ratio: 3 / 4; transform: translate(-50%, -50%); }
.frame .c { position: absolute; width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.85); transition: border-color .2s, transform .25s; }
.frame .tl { left: 0; top: 0; border-right: 0; border-bottom: 0; border-radius: 14px 0 0 0; }
.frame .tr { right: 0; top: 0; border-left: 0; border-bottom: 0; border-radius: 0 14px 0 0; }
.frame .bl { left: 0; bottom: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 14px; }
.frame .br { right: 0; bottom: 0; border-left: 0; border-top: 0; border-radius: 0 0 14px 0; }
.frame.steady .c { border-color: var(--sakura); }
.frame.locked .c { border-color: var(--sakura); transform: scale(.94); }
.frame .sweep { position: absolute; left: 4%; right: 4%; height: 22%; top: 0; opacity: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(229,143,171,.28) 70%, rgba(255,255,255,.9) 100%); border-bottom: 2px solid #fff; }
.frame.scanning .sweep { opacity: 1; animation: sweep 1.3s ease-in-out infinite alternate; }
@keyframes sweep { from { top: 0; } to { top: 78%; } }
.frame.scanning .c { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { border-color: #fff; } }
.ring { position: absolute; right: -8px; bottom: -8px; width: 38px; height: 38px; transform: rotate(-90deg); opacity: 0; transition: opacity .2s; }
.ring circle { fill: none; stroke-width: 4; stroke: rgba(255,255,255,.35); }
#ringFill { stroke: var(--sakura); stroke-linecap: round; stroke-dasharray: 119.4; stroke-dashoffset: 119.4; }
.frame.steady .ring { opacity: 1; }
.hint { position: absolute; left: 16px; right: 16px; bottom: 18px; text-align: center; color: #fff; font-size: 15px; font-weight: 600;
  text-shadow: 0 1px 8px rgba(0,0,0,.5); min-height: 22px; }
.nocam { position: absolute; inset: 0; display: grid; place-items: center; padding: 32px; color: #fff; text-align: center; }

.controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 14px 20px calc(env(safe-area-inset-bottom) + 16px); background: #fff; }
.controls .ghost { justify-self: start; }
.counter { justify-self: end; color: var(--faint); font-size: 13px; }
.shutter { width: 70px; height: 70px; border-radius: 50%; border: 4px solid var(--ink); background: #fff; display: grid; place-items: center; padding: 0; }
.shutter span { width: 54px; height: 54px; border-radius: 50%; background: var(--sakura); }
.shutter:active span { transform: scale(.92); }
.shutter.live { border-color: var(--line); }
.shutter.live span { background: var(--soft); }

/* result sheet */
.sheet { position: fixed; inset: 0; background: rgba(10,10,12,.35); display: flex; align-items: flex-end; z-index: 10; }
.sheet-inner { width: 100%; max-height: 92vh; overflow-y: auto; background: #fff; border-radius: 24px 24px 0 0;
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 20px); animation: up .28s ease-out; -webkit-overflow-scrolling: touch; }
@media (min-width: 700px) { .sheet { align-items: center; justify-content: center; } .sheet-inner { max-width: 520px; border-radius: 24px; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 14px; }

.hero { display: grid; grid-template-columns: 84px 1fr; gap: 14px; align-items: start; }
.hero img { width: 84px; height: 112px; object-fit: contain; background: var(--soft); border-radius: 12px; }
.hero h2 { margin: 2px 0 4px; font-size: 21px; line-height: 1.3; font-family: "Zen Kaku Gothic New", var(--font); font-weight: 700; }
.hero .sub { color: var(--muted); font-size: 14px; line-height: 1.45; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 999px; background: var(--soft); color: var(--muted); }
.chip.match { background: #eaf6ef; color: var(--good); }
.chip.maybe { background: #fdf5e6; color: var(--warn); }
.chip.pr { background: var(--soft); color: var(--faint); }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.kpi { border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.kpi .v small { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi.cospa.top { border-color: var(--sakura); background: var(--sakura-soft); }
.kpi.cospa.top .v { color: var(--sakura-ink); }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 14px; margin: 6px 0 16px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.section-t { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .04em; margin: 18px 0 8px; text-transform: uppercase; }
.taste { display: grid; gap: 10px; }
.taste .r { display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.taste .r span:last-child { text-align: right; }
.bar { position: relative; height: 6px; background: var(--soft); border-radius: 6px; }
.bar i { position: absolute; top: 50%; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--ink); transform: translateY(-50%); }
.est { font-size: 12px; color: var(--faint); margin-top: 6px; }

.offers { display: grid; gap: 8px; }
.offer { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; text-decoration: none; color: inherit; font-size: 14px; }
.offer b { font-size: 16px; }
.offer .shop { color: var(--muted); font-size: 12px; }

.feedback { margin-top: 20px; padding: 14px; border-radius: 16px; background: var(--soft); }
.feedback .q { margin: 0 0 10px; font-weight: 600; }
.feedback .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.feedback.done { background: #eaf6ef; color: var(--good); font-weight: 600; text-align: center; }

#fix h3 { font-size: 16px; margin: 18px 0 10px; }
.alts { display: grid; gap: 8px; }
.alt { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center; text-align: left; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.alt img { width: 44px; height: 58px; object-fit: contain; background: var(--soft); border-radius: 8px; }
.alt .n { font-weight: 600; font-size: 14px; }
.alt .s { color: var(--muted); font-size: 12px; }
.search, .notlisted { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 12px 0; }
.search input, .notlisted input { height: 40px; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; font-size: 16px; }

.none h2 { font-size: 20px; margin: 8px 0; }
.debug { margin-top: 16px; font-size: 12px; color: var(--muted); }
.debug summary { cursor: pointer; font-weight: 600; }
.debug pre { white-space: pre-wrap; word-break: break-word; background: var(--soft); padding: 10px; border-radius: 10px; font-size: 11px; }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 110px); transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 20; max-width: calc(100% - 32px); text-align: center; }
