:root {
  --blue: #1e8fff;
  --blue-dark: #0d6de0;
  --ink: #1c2430;
  --gray: #6b7684;
  --line: #e4e8ee;
  --bg: #0b0f14;
  --card: #ffffff;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 800; color: var(--ink); }
.logo .dots { display: grid; grid-template-columns: repeat(2, 12px); grid-gap: 3px; }
.logo .dots span { width: 12px; height: 12px; border-radius: 3px; background: var(--blue); }
.logo .dots span:nth-child(2) { background: var(--ink); }
.logo small { color: var(--gray); font-weight: 700; }
.nav-link { color: var(--gray); text-decoration: none; font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; }

/* --- Scanner view --- */
.scanner-wrap { max-width: 480px; margin: 0 auto; padding: 0; position: relative; }
.camera-box {
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  background: #000;
  overflow: hidden;
}
.camera-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame {
  position: absolute; inset: 12% 14%;
  border: 3px solid rgba(255,255,255,.85);
  border-radius: 20px;
  box-shadow: 0 0 0 2000px rgba(0,0,0,.35);
  pointer-events: none;
}
.scan-frame::before, .scan-frame::after {
  content: '';
  position: absolute; width: 32px; height: 32px;
  border: 4px solid var(--blue);
}
.scan-line {
  position: absolute; left: 14%; right: 14%; top: 12%;
  height: 3px; background: var(--blue); border-radius: 2px;
  box-shadow: 0 0 10px var(--blue);
  animation: scanmove 2.2s ease-in-out infinite;
}
@keyframes scanmove {
  0% { top: 12%; } 50% { top: 88%; } 100% { top: 12%; }
}
.camera-controls {
  position: absolute; bottom: 16px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 14px;
}
.round-btn {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,.15); backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.3); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; cursor: pointer;
}
.round-btn.active { background: var(--blue); border-color: var(--blue); }
.camera-status { position:absolute; top:14px; left:0; right:0; text-align:center; color:#fff; font-weight:700; font-size:14px; text-shadow: 0 1px 4px rgba(0,0,0,.6); }

.upload-row { padding: 16px; text-align: center; background: #fff; }
.upload-row label {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 20px; border: 2px dashed var(--line); border-radius: 12px;
  color: var(--blue); font-weight: 700; cursor: pointer; font-size: 14px;
}
.upload-row input[type=file] { display: none; }

/* --- Result modal --- */
.result-backdrop {
  position: fixed; inset: 0; background: rgba(20,26,34,.55);
  display: flex; align-items: flex-end; justify-content: center; z-index: 60;
}
.result-sheet {
  background: #fff; width: 100%; max-width: 480px;
  border-radius: 22px 22px 0 0; padding: 26px 22px 30px;
  animation: slideup .2s ease;
}
@keyframes slideup { from { transform: translateY(40px); opacity:0 } to { transform: translateY(0); opacity:1 } }
.result-type-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 800;
  background: #eef6ff; color: var(--blue); margin-bottom: 14px; text-transform: uppercase; letter-spacing: .03em;
}
.result-content {
  background: #f8fafc; border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; font-size: 15px; word-break: break-word; margin-bottom: 18px; line-height: 1.5;
}
.result-content .kv { display:flex; justify-content:space-between; gap:10px; padding:6px 0; border-bottom:1px solid #eef1f5; font-size:14px; }
.result-content .kv:last-child { border-bottom: none; }
.result-content .kv b { color: var(--gray); font-weight:700; }
.result-actions { display: flex; flex-direction: column; gap: 10px; }
.result-actions .btn { padding: 15px; border-radius: 12px; border: none; font-weight: 800; font-size: 15px; cursor: pointer; width: 100%; text-align:center; text-decoration:none; display:block; }
.result-actions .btn.primary { background: var(--blue); color: #fff; }
.result-actions .btn.ghost { background: #eef1f5; color: var(--ink); }
.result-actions .row { display:flex; gap:10px; }
.result-actions .row .btn { flex: 1; }
.close-x { position:absolute; top:16px; right:18px; background:none; border:none; font-size:22px; color:var(--gray); cursor:pointer; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1c2430; color: #fff; padding: 12px 20px; border-radius: 30px;
  font-size: 14px; font-weight: 700; z-index: 70; opacity: 0; transition: opacity .2s;
}
.toast.show { opacity: 1; }

.hidden { display: none !important; }

/* --- Profile capture modal --- */
.profile-backdrop {
  position: fixed; inset: 0; background: rgba(20,26,34,.6);
  display: flex; align-items: center; justify-content: center; z-index: 80; padding: 20px;
}
.profile-card { background:#fff; border-radius:18px; padding:26px; max-width:360px; width:100%; }
.profile-card h3 { margin:0 0 4px; }
.profile-card p.sub { color:var(--gray); font-size:13px; margin:0 0 18px; }
.profile-card label { display:block; font-weight:700; font-size:13px; margin-bottom:5px; }
.profile-card input { width:100%; padding:12px; border:1px solid var(--line); border-radius:10px; font-size:14px; margin-bottom:14px; box-sizing:border-box; }
.profile-card button { width:100%; padding:13px; border:none; border-radius:10px; background:var(--blue); color:#fff; font-weight:800; cursor:pointer; }
.profile-card .err { color:#dc2626; font-size:13px; font-weight:700; margin:-6px 0 12px; }
.profile-badge { position:fixed; top:16px; right:16px; background:#fff; border:1px solid var(--line); border-radius:20px; padding:6px 14px; font-size:12px; font-weight:700; color:var(--gray); z-index:40; cursor:pointer; }

/* --- History page --- */
.history-wrap { max-width: 560px; margin: 0 auto; padding: 20px 16px 60px; background:var(--bg); min-height:100vh; }
.history-item {
  background:#fff; border-radius:14px; padding:14px 16px; margin-bottom:10px;
  display:flex; align-items:center; gap:12px;
}
.history-item .type-icon { width:38px; height:38px; border-radius:10px; background:#eef6ff; color:var(--blue); display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.history-item .info { flex:1; min-width:0; }
.history-item .info .label { font-weight:700; font-size:14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.history-item .info .meta { color:var(--gray); font-size:12px; }
.history-item .fav-btn, .history-item .del-btn { background:none; border:none; font-size:18px; cursor:pointer; color:var(--gray); padding:6px; }
.history-item .fav-btn.active { color:#f59e0b; }
.history-empty { text-align:center; color:#aab2bd; padding:80px 20px; }
.history-empty i { font-size:40px; margin-bottom:14px; display:block; }
.filter-row { display:flex; gap:8px; margin-bottom:16px; overflow-x:auto; padding-bottom:4px; }
.filter-chip { padding:8px 16px; border-radius:20px; background:#fff; color:var(--gray); font-weight:700; font-size:13px; white-space:nowrap; cursor:pointer; border:1px solid transparent; }
.filter-chip.active { background:var(--blue); color:#fff; }
