:root{
  /* Glass UI tokens */
  --bg0:#050712;
  --bg1:#0a1230;
  --bg2:#121a3f;

  --text:rgba(255,255,255,.92);
  --muted:rgba(255,255,255,.74);
  --muted2:rgba(255,255,255,.58);

  --glass:rgba(255,255,255,.10);
  --glass2:rgba(255,255,255,.06);
  --stroke:rgba(255,255,255,.18);

  --accent:rgba(120,192,255,.95);
  --accent2:rgba(255,168,223,.88);
  --ok:rgba(112,255,182,.95);
  --warn:rgba(255,204,102,.95);
  --danger:rgba(255,107,107,.95);

  --shadow:0 18px 60px rgba(0,0,0,.45);
  --shadow2:0 10px 28px rgba(0,0,0,.35);

  --radius:18px;
  --radius2:24px;
  --pad:14px;
}

*{box-sizing:border-box}
html,body{height:100%}

body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  color:var(--text);
  background:
    radial-gradient(900px 600px at 15% 10%, rgba(120,192,255,.18), transparent 60%),
    radial-gradient(900px 700px at 95% 20%, rgba(255,168,223,.14), transparent 62%),
    radial-gradient(900px 700px at 50% 110%, rgba(112,255,182,.12), transparent 55%),
    linear-gradient(160deg, var(--bg0), var(--bg1) 45%, var(--bg2));
  overflow-x:hidden;
}

/* subtle noise/scanlines without images */
body::before{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  opacity:.10;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,.03) 0, rgba(255,255,255,.03) 1px, transparent 1px, transparent 3px);
  mix-blend-mode:overlay;
}

.topbar{
  position:sticky;
  top:0;
  z-index:10;
  background: linear-gradient(180deg, rgba(10,14,30,.78), rgba(10,14,30,.55));
  border-bottom:1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand{
  max-width:980px;
  margin:0 auto;
  padding:14px 16px;
  display:flex;
  align-items:center;
  gap:12px;
}

.logo{
  width:44px;
  height:44px;
  display:grid;
  place-items:center;
  border-radius:14px;
  background:
    radial-gradient(60px 60px at 30% 20%, rgba(255,255,255,.18), transparent 55%),
    linear-gradient(180deg, rgba(120,192,255,.22), rgba(255,168,223,.10));
  border:1px solid rgba(255,255,255,.18);
  box-shadow: var(--shadow2);
  font-size:22px;
}

h1{
  margin:0;
  font-size:18px;
  letter-spacing:.2px;
}
.tagline{
  margin:2px 0 0;
  font-size:12px;
  color:var(--muted2);
}

.wrap{
  max-width:980px;
  margin:0 auto;
  padding:16px;
  display:flex;
  flex-direction:column;
  gap:14px;
}

/* Panels: frosted glass */
.panel{
  background:
    radial-gradient(900px 250px at 20% 0%, rgba(255,255,255,.10), transparent 55%),
    linear-gradient(180deg, var(--glass), var(--glass2));
  border:1px solid var(--stroke);
  border-radius: var(--radius2);
  box-shadow: var(--shadow);
  overflow:hidden;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.card{padding:var(--pad)}

.panelHeader{
  display:flex;
  flex-direction:column;
  gap:4px;
  margin-bottom:10px;
}
.panelHeader h2{
  margin:0;
  font-size:16px;
}
.small{
  margin:0;
  color:var(--muted2);
  font-size:12px;
}

.label{
  display:block;
  font-size:12px;
  color:var(--muted);
  margin-bottom:6px;
}

.searchRow{
  display:flex;
  gap:10px;
  align-items:center;
}

/* Inputs: glassy, high-contrast */
.input, select{
  width:100%;
  padding:12px 12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.18);
  background: rgba(10,14,30,.40);
  color:var(--text);
  outline:none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.input::placeholder{ color: rgba(255,255,255,.45); }

.input:focus, select:focus{
  border-color: rgba(120,192,255,.55);
  box-shadow: 0 0 0 4px rgba(120,192,255,.16), inset 0 1px 0 rgba(255,255,255,.06);
}

/* Modern select chevron */
select{
  appearance:none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(255,255,255,.70) 50%),
    linear-gradient(135deg, rgba(255,255,255,.70) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat:no-repeat;
  padding-right:34px;
}

.btn{
  padding:12px 12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.06);
  color:var(--text);
  cursor:pointer;
  user-select:none;
  white-space:nowrap;
  transition: transform 120ms ease, border-color 120ms ease, filter 120ms ease, box-shadow 120ms ease;
  box-shadow: 0 10px 22px rgba(0,0,0,.28);
}
.btn:hover{
  filter: brightness(1.05);
  border-color: rgba(120,192,255,.35);
}
.btn:active{ transform: translateY(1px) scale(.99); }

.btn.primary{
  background:
    radial-gradient(100px 60px at 30% 10%, rgba(255,255,255,.18), transparent 55%),
    linear-gradient(180deg, rgba(120,192,255,.28), rgba(120,192,255,.12));
  border-color: rgba(120,192,255,.45);
}

.btn.ghost{
  background:transparent;
  border-style:dashed;
  color:var(--muted);
  box-shadow:none;
}

.advanced{
  margin-top:12px;
  border-top:1px solid rgba(255,255,255,.12);
  padding-top:10px;
}
summary{
  cursor:pointer;
  color:var(--muted);
  font-size:13px;
}
.grid2{
  display:grid;
  gap:12px;
  margin-top:12px;
}
@media (min-width:760px){
  .grid2{grid-template-columns: 1fr 1fr;}
}

.hint{
  margin:8px 0 0;
  color:var(--muted2);
  font-size:12px;
}

.status{
  margin-top:12px;
  padding:10px 12px;
  border-radius:14px;
  background: rgba(10,14,30,.32);
  border:1px solid rgba(255,255,255,.14);
  color:var(--muted);
  font-size:13px;
  min-height:40px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.status.good{border-color:rgba(112,255,182,.35); color:rgba(214,255,240,.95)}
.status.warn{border-color:rgba(255,204,102,.35); color:rgba(255,243,204,.95)}
.status.bad{border-color:rgba(255,107,107,.35); color:rgba(255,215,215,.95)}

.quickLinks{
  display:flex;
  gap:10px;
  margin-top:10px;
  flex-wrap:wrap;
}

.results{
  display:grid;
  grid-template-columns: 1fr;
  gap:10px;
}
@media (min-width:520px){
  .results{grid-template-columns: 1fr 1fr;}
}

.resultItem{
  display:flex;
  gap:10px;
  align-items:center;
  padding:10px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.14);
  background:
    radial-gradient(140px 90px at 20% 0%, rgba(255,255,255,.12), transparent 60%),
    rgba(10,14,30,.30);
  cursor:pointer;
  transition: transform 120ms ease, border-color 120ms ease, filter 120ms ease;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.resultItem:hover{
  transform: translateY(-1px);
  border-color: rgba(120,192,255,.30);
  filter: brightness(1.03);
}

.thumb{
  width:56px;
  height:78px;
  border-radius:12px;
  object-fit:cover;
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.12);
}

.resultText{min-width:0}
.resultName{
  margin:0;
  font-size:14px;
  font-weight:800;
}
.resultMeta{
  margin:3px 0 0;
  font-size:12px;
  color:var(--muted2);
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.06);
  color:var(--muted);
  font-size:12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.cardView{
  display:flex;
  flex-direction:column;
  gap:12px;
}
@media (min-width:760px){
  .cardView{flex-direction:row; align-items:flex-start}
}
.imgWrap{
  width:100%;
  max-width:340px;
  margin:0 auto;
}
#cardImg{
  width:100%;
  height:auto;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.16);
  background:rgba(255,255,255,.05);
  display:block;
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
}

.cardInfo{flex:1; min-width:0}
.titleRow{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
}
#cardName{
  margin:0;
  font-size:18px;
  line-height:1.2;
}

.dl{
  margin:10px 0 0;
  display:grid;
  gap:8px;
}
.dl div{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  border-radius:14px;
  background: rgba(10,14,30,.24);
  border:1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
dt{color:var(--muted); font-size:12px}
dd{margin:0; font-size:13px; color:var(--text); text-align:right}

.priceBox{
  margin-top:10px;
  padding:12px;
  border-radius:16px;
  background:
    radial-gradient(240px 120px at 20% 0%, rgba(112,255,182,.12), transparent 55%),
    linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.04));
  border:1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* --- Grading math box (PSA) --- */
.gradeFlipBox{
  margin-top:12px;
  padding:12px;
  border-radius:16px;
  background:
    radial-gradient(240px 120px at 20% 0%, rgba(255,168,223,.10), transparent 55%),
    linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.03));
  border:1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.gradeFlipGrid{
  display:grid;
  grid-template-columns: 1fr;
  gap:10px;
}

@media (min-width:520px){
  .gradeFlipGrid{
    grid-template-columns: 1fr 1fr;
    column-gap:12px;
  }
  .gradeFlipActions{
    grid-column: 1 / -1;
    display:flex;
    gap:10px;
    flex-wrap:wrap;
  }
}

.smallLabel{
  margin-bottom:0;
}

.moneyInput.compact{
  min-width: 0;
}

.pctInput.compact{
  display:flex;
  align-items:center;
  gap:8px;
}

.pct{
  font-weight:900;
  color: var(--accent);
  padding-right:8px;
}

.input.compactInput{
  padding:10px 12px;
  border-radius:14px;
}

.gradeFlipOutput{
  margin-top:10px;
  padding:10px 12px;
  border-radius:16px;
  background: rgba(10,14,30,.22);
  border:1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size:13px;
  color:var(--text);
  display:grid;
  gap:6px;
}

.gradeFlipRow{
  display:flex;
  justify-content:space-between;
  gap:10px;
}

.gradeFlipKey{ color:var(--muted2); }
.gradeFlipVal{ font-weight:900; }
.gradeFlipVal.ok{ color:var(--ok); }
.gradeFlipVal.warn{ color:var(--warn); }
.gradeFlipVal.bad{ color:var(--danger); }
.priceTitle{
  font-size:12px;
  color:var(--muted);
  margin-bottom:6px;
}
.priceText{ font-size:14px; }
.priceDetails{
  margin-top:8px;
  font-size:12px;
  color:var(--muted2);
  line-height:1.4;
  white-space:pre-wrap;
}

.decisionRow{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}
.moneyInput{
  display:flex;
  align-items:center;
  gap:8px;
  flex:1;
  min-width:240px;
}
.money{
  font-weight:900;
  color: var(--accent);
  padding-left:8px;
}

.decision{
  margin-top:12px;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(10,14,30,.28);
  padding:12px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.decisionLabel{
  font-size:22px;
  font-weight:950;
  letter-spacing:.2px;
}
.decisionLabel.buy{color:var(--ok)}
.decisionLabel.negotiate{color:var(--warn)}
.decisionLabel.walk{color:var(--danger)}
.decisionReason{
  margin-top:6px;
  color:var(--muted2);
  font-size:13px;
}

.decisionMath{
  margin-top:10px;
  padding:10px 12px;
  border-radius:16px;
  background: rgba(10,14,30,.22);
  border:1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size:13px;
  color:var(--text);
  display:grid;
  gap:6px;
}
.decisionMathRow{
  display:flex;
  justify-content:space-between;
  gap:10px;
}
.decisionMathKey{ color:var(--muted2); }
.decisionMathVal{ font-weight:800; }
.decisionMathVal.ok{ color:var(--ok); }
.decisionMathVal.warn{ color:var(--warn); }
.decisionMathVal.bad{ color:var(--danger); }

.sayBox{
  margin-top:12px;
  padding:10px 12px;
  border-radius:16px;
  background: rgba(10,14,30,.22);
  border:1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.sayTitle{
  font-size:12px;
  color:var(--muted);
  margin-bottom:6px;
}
.sayList{
  margin:0;
  padding-left:18px;
  color:var(--text);
  font-size:13px;
}

.footer{
  text-align:center;
  padding:6px 0 20px;
}

/* --- Chibi Dad advice (BUY / NEGOTIATE / WALK) --- */
.dadAdvice{
  display:flex;
  gap:12px;
  align-items:center;
  margin-top:10px;
  margin-bottom:10px;
}
.dadAdvice img{
  width:96px;
  height:auto;
  flex-shrink:0;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.16);
  background:rgba(255,255,255,.04);
  box-shadow: 0 12px 30px rgba(0,0,0,.35);
}
.dadBubble{
  flex:1;
  min-width:0;
  border-radius:16px;
  padding:10px 12px;
  background: rgba(10,14,30,.22);
  border:1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.dadTag{
  font-weight:900;
  font-size:13px;
  color:var(--muted);
  margin-bottom:4px;
}
.dadQuote{
  font-size:14px;
  line-height:1.25;
  color:var(--text);
}
@media (max-width:420px){
  .dadAdvice img{ width:84px; }
}

/* --- Grade Check Modal + Camera Overlay --- */
.gradeBox{
  margin-top:12px;
  padding:12px;
  border-radius:16px;
  background:
    radial-gradient(240px 120px at 20% 0%, rgba(120,192,255,.10), transparent 55%),
    linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.03));
  border:1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.gradeRow{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}
.gradeHint{
  color:var(--muted2);
  font-size:12px;
}

.modal{
  position:fixed;
  inset:0;
  z-index:50;
}
.modalBackdrop{
  position:absolute;
  inset:0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modalCard{
  position:relative;
  max-width:980px;
  margin:0 auto;
  height:100%;
  display:flex;
  flex-direction:column;
  padding:16px;
  gap:12px;
}
@media (min-width:760px){
  .modalCard{ padding:22px; }
}
.modalHeader{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px;
  padding:14px;
  border-radius: var(--radius2);
  border:1px solid var(--stroke);
  background:
    radial-gradient(900px 250px at 20% 0%, rgba(255,255,255,.10), transparent 55%),
    linear-gradient(180deg, var(--glass), var(--glass2));
  box-shadow: var(--shadow2);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.modalTitle{
  font-weight:950;
  font-size:16px;
}
.modalSub{
  margin-top:4px;
  font-size:12px;
  color:var(--muted2);
  line-height:1.25;
}

.cameraWrap{
  position:relative;
  width:100%;
  flex:1;
  min-height:280px;
  border-radius: var(--radius2);
  overflow:hidden;
  border:1px solid rgba(255,255,255,.14);
  background: rgba(10,14,30,.45);
  box-shadow: var(--shadow2);
}
#camVideo{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit:cover;
}
.camOverlay{
  position:absolute;
  inset:0;
  pointer-events:none;
  display:grid;
  place-items:center;
}
.cardFrame{
  width:74%;
  max-width:420px;
  aspect-ratio: 63 / 88;
  border:2px solid rgba(255,255,255,.70);
  border-radius:16px;
  position:relative;
  box-shadow: 0 0 0 200vmax rgba(0,0,0,.12);
}
.grid{
  position:absolute;
  background:rgba(255,255,255,.18);
}
.grid.v1{ top:0; bottom:0; left:33.33%; width:1px; }
.grid.v2{ top:0; bottom:0; left:66.66%; width:1px; }
.grid.h1{ left:0; right:0; top:33.33%; height:1px; }
.grid.h2{ left:0; right:0; top:66.66%; height:1px; }

.modalActions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}
.gradeResult{
  padding:12px;
  border-radius:16px;
  background: rgba(10,14,30,.32);
  border:1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size:13px;
  color:var(--text);
  line-height:1.35;
}
.gradeResult .row{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding:8px 10px;
  border-radius:14px;
  background: rgba(10,14,30,.22);
  border:1px solid rgba(255,255,255,.10);
  margin-top:8px;
}
.gradeResult .k{ color:var(--muted2); }
.gradeResult .v{ font-weight:900; }
.gradeResult .v.ok{ color:var(--ok); }
.gradeResult .v.warn{ color:var(--warn); }
.gradeResult .v.bad{ color:var(--danger); }

/* Motion safety */
@media (prefers-reduced-motion: reduce){
  *{ transition:none !important; }
}

/* --- Manual centering mode: show captured frame + draggable guide lines --- */
#camCanvas{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  display:block;
}

.manualOverlay{
  position:absolute;
  inset:0;
  pointer-events:auto;
  touch-action:none;
}

/* Make the guides easy to grab on mobile.
   The hit area is wide/tall, the visible line stays thin. */
.manualOverlay .guide{
  position:absolute;
  background: transparent;
}

.manualOverlay .guide.v{
  top:0;
  bottom:0;
  width:28px;                 /* hit target */
  transform: translateX(-14px);
}

.manualOverlay .guide.h{
  left:0;
  right:0;
  height:28px;                /* hit target */
  transform: translateY(-14px);
}

.manualOverlay .guide::after{
  content:"";
  position:absolute;
  inset:0;
  margin:auto;
  background: rgba(255,255,255,.80);
  box-shadow: 0 0 0 1px rgba(0,0,0,.25);
}

.manualOverlay .guide.v::after{
  width:2px;
  height:100%;
}

.manualOverlay .guide.h::after{
  height:2px;
  width:100%;
}

/* Handle knob in the middle */
.manualOverlay .guide::before{
  content:"";
  position:absolute;
  left:50%;
  top:50%;
  width:30px;
  height:30px;
  transform: translate(-50%,-50%);
  border-radius:16px;
  background: rgba(10,14,30,.55);
  border:1px solid rgba(255,255,255,.42);
  box-shadow: 0 10px 20px rgba(0,0,0,.35);
}

.manualHint{
  position:absolute;
  left:12px;
  right:12px;
  bottom:12px;
  padding:10px 12px;
  border-radius:14px;
  background: rgba(10,14,30,.40);
  border:1px solid rgba(255,255,255,.14);
  color:var(--muted);
  font-size:12px;
  line-height:1.25;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}


.footer .fineprint{
  max-width:980px;
  margin:10px auto 0;
  padding:0 8px;
  color:rgba(255,255,255,.45);
  font-size:11px;
  line-height:1.35;
}


/* --- Grading math toggle (Dad) --- */
.gradeFlipToggleRow{display:flex;gap:8px;align-items:center;margin-top:10px;}
.gradeFlipToggleRow .btn{width:100%;}
