:root{
  --navy:#0b132b; --gold:#c4a449; --ink:#1a1a1a; --muted:#6b7280; --line:#e5e7eb;
  --bg:#f4f5f7; --card:#fff;
  --grail:#b8860b; --rare:#c0392b; --scarce:#e67e22; --error:#8e44ad; --common:#6b8f71;
  --collector:#2e7d63; --bullion:#7a6b3a; --predecimal:#5b6b7a; --other:#888;
}
*{box-sizing:border-box} html,body{margin:0}
body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
  background:var(--bg); color:var(--ink); -webkit-text-size-adjust:100%; padding-bottom:54px}
#appbar{position:sticky; top:0; z-index:30; background:var(--navy); color:#fff;
  padding:calc(env(safe-area-inset-top) + 10px) 12px 10px; box-shadow:0 2px 8px rgba(0,0,0,.15)}
.bar-row{display:flex; align-items:center; gap:8px}
#title{font-size:18px; font-weight:600; margin:0; flex:1; text-align:center}
#logo{width:30px; height:30px; border-radius:7px; flex:0 0 auto}
#menu{position:absolute; right:12px; top:calc(env(safe-area-inset-top) + 52px); z-index:40; background:#fff;
  border:1px solid var(--line); border-radius:12px; box-shadow:0 8px 28px rgba(0,0,0,.22); padding:6px; min-width:200px}
#menu button{display:flex; align-items:center; gap:10px; width:100%; text-align:left; background:none; border:0;
  padding:11px 14px; font-size:15px; color:var(--ink); cursor:pointer; border-radius:8px}
#menu button:hover{background:var(--bg)}
#menu .sep{height:1px; background:var(--line); margin:5px 8px}
/* pricing plans */
.plans{display:grid; gap:14px; padding:4px 0}
.plan{background:#fff; border:1px solid var(--line); border-radius:16px; padding:18px}
.plan.pro{border:2px solid var(--gold)}
.plan .pname{font-size:16px; font-weight:700; display:flex; align-items:center; gap:8px}
.plan .price{font-size:30px; font-weight:700; margin:6px 0 2px}
.plan .price small{font-size:14px; font-weight:500; color:var(--muted)}
.plan ul{margin:12px 0; padding-left:20px; line-height:1.7; font-size:14px}
.plan .cta{display:block; width:100%; text-align:center; border:0; border-radius:12px; padding:13px;
  font-size:15px; font-weight:700; cursor:pointer; text-decoration:none}
.cta.buy{background:var(--gold); color:#23200f} .cta.free{background:#eef1f4; color:var(--navy)}
.tag{font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.05em; background:var(--gold);
  color:#23200f; padding:3px 8px; border-radius:8px}
/* dashboard */
.stats{display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:12px 0}
.stat{background:#fff; border:1px solid var(--line); border-radius:12px; padding:14px}
.stat .k{font-size:12px; color:var(--muted)} .stat .v{font-size:22px; font-weight:700; margin-top:3px}
.prose{font-size:14px; line-height:1.65; color:#333}
.prose h3{font-size:14px; color:var(--navy); text-transform:uppercase; letter-spacing:.04em; margin:16px 0 6px}
.prose a{color:var(--navy)} .prose ul{padding-left:20px}
.brandline{display:flex; align-items:center; gap:10px; margin:2px 0 10px}
.brandline img{width:40px; height:40px; border-radius:9px}
.iconbtn{background:rgba(255,255,255,.12); color:#fff; border:0; width:34px; height:34px;
  border-radius:50%; font-size:16px; line-height:1; cursor:pointer}
#searchWrap{margin-top:10px}
#search{width:100%; height:42px; border-radius:21px; border:0; padding:0 16px; font-size:16px;
  background:#fff; color:var(--ink)}
#search:focus{outline:2px solid var(--gold)}

#filters{padding:10px 12px 4px}
.chips{display:flex; gap:7px; overflow-x:auto; padding-bottom:8px; -webkit-overflow-scrolling:touch}
.chips::-webkit-scrollbar{display:none}
.chip{flex:0 0 auto; padding:6px 13px; border-radius:16px; border:1px solid var(--line);
  background:#fff; color:var(--muted); font-size:13px; cursor:pointer; white-space:nowrap}
.chip.on{background:var(--navy); color:#fff; border-color:var(--navy)}
.chip.r-on{background:var(--gold); color:#23200f; border-color:var(--gold)}
.rowline{display:flex; justify-content:space-between; align-items:center; font-size:12px;
  color:var(--muted); padding:2px 2px 8px}
.links a{color:var(--navy); text-decoration:none; cursor:pointer}

#list{padding:0 12px 16px; display:flex; flex-direction:column; gap:10px}
.card{display:flex; gap:12px; background:var(--card); border:1px solid var(--line);
  border-radius:14px; padding:10px; cursor:pointer; align-items:center}
.card .thumb{width:62px; height:62px; flex:0 0 62px; border-radius:8px; object-fit:contain;
  background:#fafafa; border:1px solid var(--line)}
.card .meta{flex:1; min-width:0}
.card .nm{font-size:15px; font-weight:600; line-height:1.25}
.card .sub{font-size:12px; color:var(--muted); margin-top:2px}
.prices{display:flex; gap:6px; margin-top:6px; flex-wrap:wrap}
.pill{font-size:11px; padding:2px 8px; border-radius:10px; background:#f1f3f5; color:#333; white-space:nowrap}
.pill b{font-weight:600}
.badge{display:inline-block; font-size:10px; font-weight:700; color:#fff; padding:2px 7px;
  border-radius:8px; text-transform:uppercase; letter-spacing:.04em; margin-top:6px}
.b-grail{background:var(--grail)} .b-rare{background:var(--rare)} .b-scarce{background:var(--scarce)}
.b-error{background:var(--error)} .b-common{background:var(--common)} .b-collector{background:var(--collector)}
.b-bullion{background:var(--bullion)} .b-predecimal{background:var(--predecimal)}
.b-key{background:var(--rare)} .b-other{background:var(--other)} .b-forth{background:#888}

.detail{padding:14px}
.detail h2{font-size:20px; margin:0 0 2px}
.detail .yr{color:var(--gold); font-weight:600}
.imgrow{display:flex; gap:10px; margin:12px 0; justify-content:center; flex-wrap:wrap}
.imgrow figure{margin:0; text-align:center; flex:1 1 140px; max-width:48%}
.imgrow img{width:100%; max-width:200px; border-radius:10px; background:#fff; border:1px solid var(--line)}
.imgrow figcaption{font-size:11px; color:var(--muted); margin-top:4px; text-transform:uppercase; letter-spacing:.05em}
.imgrow figure.err figcaption{color:var(--error)}
.pricecards{display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:14px 0}
.pcard{background:#fff; border:1px solid var(--line); border-radius:12px; padding:12px}
.pcard .lab{font-size:12px; color:var(--muted)}
.pcard .val{font-size:18px; font-weight:600; margin-top:3px}
.section{background:#fff; border:1px solid var(--line); border-radius:12px; padding:12px 14px; margin:10px 0}
.section h3{font-size:13px; margin:0 0 6px; color:var(--navy); text-transform:uppercase; letter-spacing:.04em}
.section p{margin:0; font-size:14px; line-height:1.55; color:#333}
.kv{display:flex; justify-content:space-between; font-size:13px; padding:4px 0; border-bottom:1px solid #f0f1f3}
.kv:last-child{border:0} .kv span:first-child{color:var(--muted)}
.src a{color:var(--navy); font-size:12px; word-break:break-all; display:block; margin:3px 0}
.note-myth{background:#fdeeee; border-color:#f3c7c7}
.note-myth h3{color:var(--rare)}

#installBanner{margin:10px 12px 0; background:#fff; border:1px solid var(--gold); border-radius:12px;
  padding:12px; display:flex; align-items:center; gap:10px; font-size:13px}
#installBanner button{margin-left:auto; background:var(--navy); color:#fff; border:0; border-radius:8px;
  padding:8px 14px; font-size:13px; cursor:pointer}
#installBanner .x{background:none; color:var(--muted); padding:4px 8px}

/* scan + identify */
.scanhero{display:flex; align-items:center; justify-content:center; gap:10px; width:calc(100% - 24px);
  margin:12px 12px 4px; padding:15px; border:0; border-radius:14px; background:var(--navy); color:#fff;
  font-size:16px; font-weight:600; cursor:pointer; box-shadow:0 2px 8px rgba(11,19,43,.2)}
.scanhero .camicon{color:var(--gold); font-size:22px; line-height:1}
.scan{padding:12px}
.camwrap{position:relative; width:100%; aspect-ratio:1/1; max-height:58vh; background:#0d0f14; border-radius:16px;
  overflow:hidden; display:flex; align-items:center; justify-content:center}
.camwrap video{width:100%; height:100%; object-fit:cover; display:block}
.camwrap:not(.live){outline:2px dashed rgba(255,255,255,.22); outline-offset:-12px}
.camhint{position:absolute; bottom:10px; left:10px; right:10px; color:#fff; background:rgba(0,0,0,.5);
  font-size:12px; padding:8px 10px; border-radius:10px; text-align:center; line-height:1.4}
.scanbtns{display:flex; gap:10px; margin:12px 0}
.primary{flex:1; background:var(--gold); color:#23200f; border:0; border-radius:12px; padding:14px;
  font-size:16px; font-weight:700; cursor:pointer}
.uploadbtn{flex:1; display:flex; align-items:center; justify-content:center; background:#fff;
  border:1px solid var(--line); border-radius:12px; padding:14px; font-size:15px; cursor:pointer; color:var(--navy)}
.hint{font-size:13px; color:var(--muted); line-height:1.5; padding:2px 2px}
.hint a{color:var(--navy); cursor:pointer; text-decoration:underline}
.identify{padding:12px}
.yourcoin{display:flex; gap:12px; align-items:center; background:#fff; border:1px solid var(--line);
  border-radius:14px; padding:10px; margin-bottom:6px}
.yourcoin img{width:78px; height:78px; object-fit:cover; border-radius:10px; border:1px solid var(--line)}
.yc-t{font-weight:600; font-size:14px}
.linkbtn{background:none; border:0; color:var(--navy); font-size:13px; padding:4px 0; cursor:pointer; text-decoration:underline}
.idstep{display:flex; align-items:center; gap:8px; font-size:15px; font-weight:600; margin:14px 2px 8px}
.stepn{display:inline-flex; align-items:center; justify-content:center; width:22px; height:22px; flex:0 0 22px;
  border-radius:50%; background:var(--navy); color:#fff; font-size:12px; font-weight:700}
.idfilter{width:100%; height:40px; border-radius:20px; border:1px solid var(--line); padding:0 14px;
  font-size:16px; margin-bottom:10px}
#idList{display:flex; flex-direction:column; gap:10px}
.yc-sub{font-size:13px; color:var(--gold); margin-top:2px}
.busy{text-align:center; padding:40px 16px; color:var(--muted)}
.busy p{margin-top:16px; font-size:14px}
.spinner{width:44px; height:44px; margin:0 auto; border:4px solid var(--line); border-top-color:var(--navy);
  border-radius:50%; animation:spin .9s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.imgrow figure.you img{border:2px solid var(--gold)}
.imgrow figure.you figcaption{color:var(--gold); font-weight:700}
.matchhint{font-size:13px; color:var(--muted); text-align:center; margin:2px 0 4px; line-height:1.5}
.note-err{background:#f6eefb; border-color:#e2cef2}
.note-err h3{color:var(--error)}

/* keep / spend / collect advice */
.apill{display:inline-block; font-size:10px; font-weight:700; padding:2px 7px; border-radius:8px;
  text-transform:uppercase; letter-spacing:.03em; margin:6px 0 0 6px}
.a-collect{background:#efe6fb; color:#6b21a8}
.a-keep{background:#e6f0fb; color:#1d4ed8}
.a-spend{background:#eef3ea; color:#3f6212}
.section.adv{border-left:4px solid var(--muted)}
.section.adv.a-collect{background:#f7f1fe; border-color:#6b21a8}
.section.adv.a-collect h3{color:#6b21a8}
.section.adv.a-keep{background:#eef4fd; border-color:#1d4ed8}
.section.adv.a-keep h3{color:#1d4ed8}
.section.adv.a-spend{background:#f2f7ee; border-color:#3f6212}
.section.adv.a-spend h3{color:#3f6212}
.tips ol{padding-left:20px; line-height:1.6; font-size:14px}
.tips li{margin-bottom:8px}
.tipstep{background:#fff; border:1px solid var(--line); border-radius:12px; padding:12px; margin:10px 0}
.tipstep b{display:block; margin-bottom:3px}
.empty{text-align:center; color:var(--muted); padding:40px 16px; font-size:14px}
#foot{position:fixed; bottom:0; left:0; right:0; background:#fff; border-top:1px solid var(--line);
  font-size:10.5px; color:var(--muted); text-align:center; padding:8px 12px calc(env(safe-area-inset-bottom) + 8px)}

/* action buttons (detail / forms) */
.actionrow{display:flex; gap:8px; flex-wrap:wrap; margin:12px 0}
.actionbtn{flex:1 1 auto; min-width:150px; display:inline-flex; align-items:center; justify-content:center; gap:8px;
  background:var(--navy); color:#fff; border:0; border-radius:11px; padding:12px 14px; font-size:14px; font-weight:600; cursor:pointer}
.actionbtn.ghost{background:#fff; color:var(--navy); border:1px solid var(--navy)}
.actionbtn.ai{background:var(--gold); color:#23200f}
.userflag{display:inline-block; font-size:10px; font-weight:700; color:#fff; background:var(--collector);
  padding:2px 7px; border-radius:8px; text-transform:uppercase; letter-spacing:.04em; margin-left:6px}
.imgrow figure.ownref img{border:2px solid var(--collector)}
.imgrow figure.ownref figcaption{color:var(--collector); font-weight:700}

/* add-a-coin + settings forms */
.addlink{display:block; width:100%; text-align:center; background:#fff; border:1px dashed var(--navy); color:var(--navy);
  border-radius:12px; padding:12px; font-size:14px; font-weight:600; cursor:pointer; margin:12px 0}
.form{padding:14px}
.field{margin:0 0 14px}
.field label{display:block; font-size:13px; color:var(--muted); margin:0 0 5px}
.field input, .field select, .field textarea{width:100%; border:1px solid var(--line); border-radius:10px;
  padding:11px 12px; font-size:16px; background:#fff; color:var(--ink); font-family:inherit}
.field textarea{min-height:76px; resize:vertical}
.field input:focus, .field select:focus, .field textarea:focus{outline:2px solid var(--gold)}
.photopick{display:flex; gap:12px; align-items:center}
.photopick .prev{width:88px; height:88px; border-radius:10px; object-fit:cover; border:1px solid var(--line); background:#fafafa}
.savebtn{width:100%; background:var(--navy); color:#fff; border:0; border-radius:12px; padding:14px; font-size:16px; font-weight:700; cursor:pointer}
.aistatus{font-size:13px; color:var(--muted); margin:8px 0; line-height:1.5}
.aistatus.err{color:var(--rare)}
.aistatus.ok{color:var(--collector)}
.smallnote{font-size:12px; color:var(--muted); line-height:1.5; margin:8px 2px}

/* responsive: tablet + desktop */
@media (min-width:720px){
  body{padding-bottom:44px}
  .bar-row, #searchWrap, #installBanner{max-width:960px; margin-left:auto; margin-right:auto}
  #app{max-width:960px; margin:0 auto}
  #list{display:grid; grid-template-columns:repeat(auto-fill,minmax(300px,1fr)); align-items:stretch}
  .card{align-items:flex-start}
  .detail, .identify, .scan, .form{max-width:780px; margin:0 auto}
  .camwrap{max-height:64vh}
  .imgrow figure{max-width:280px}
  #foot{font-size:11px}
}
@media (min-width:1040px){
  #list{grid-template-columns:repeat(3,1fr)}
  .detail, .form{max-width:820px}
}
@media (hover:hover){
  .card:hover{border-color:var(--navy)}
  .chip:hover{border-color:var(--navy)}
  .actionbtn:hover{opacity:.92}
}
