:root {
  --bg: #090d16;
  --surface: #111827;
  --surface-2: #182235;
  --border: rgba(148, 163, 184, 0.16);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #2dd4bf;
  --accent-2: #38bdf8;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 18px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  line-height: 1.45;
  min-height: 100dvh;
}

.hidden {
  display: none !important;
}

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 12px 14px 28px;
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 2px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 14px rgba(45, 212, 191, 0.65);
}

.brand-title {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.icon-pill-accent {
  border-color: rgba(45, 212, 191, 0.4);
  background: rgba(45, 212, 191, 0.12);
  color: var(--accent);
}

/* Scanner Card */
.scanner-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.viewport-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: 54dvh;
  background: #04070e;
  overflow: hidden;
}

.reader-box {
  width: 100%;
  height: 100%;
}

.reader-box video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

/* Hide html5-qrcode built-in cluttered boxes */
#reader__dashboard,
#reader__scan_region img {
  display: none !important;
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 35%, #13223b 0%, #070b13 75%);
  z-index: 3;
}

.placeholder-icon {
  font-size: 40px;
  margin-bottom: 10px;
}

.placeholder-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
}

.placeholder-sub {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--muted);
  max-width: 260px;
}

.scan-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  z-index: 2;
}

.reticle {
  position: relative;
  width: 78%;
  height: 56%;
  margin: auto;
}

.corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--accent);
  border-style: solid;
  border-width: 0;
}
.corner.tl { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; border-top-left-radius: 10px; }
.corner.tr { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; border-top-right-radius: 10px; }
.corner.bl { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; border-bottom-left-radius: 10px; }
.corner.br { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; border-bottom-right-radius: 10px; }

.scan-line {
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 12px var(--accent);
  animation: sweep 2.2s ease-in-out infinite;
}

@keyframes sweep {
  0%, 100% { top: 10%; opacity: 0.5; }
  50% { top: 88%; opacity: 1; }
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(9, 13, 22, 0.78);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(45, 212, 191, 0.35);
  color: #e2e8f0;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12px;
  font-weight: 600;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.4s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.45; }
}

.analyzing-overlay {
  position: absolute;
  inset: 0;
  background: rgba(9, 13, 22, 0.86);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  z-index: 5;
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(56, 189, 248, 0.25);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.analyzing-title {
  margin: 0 0 4px;
  font-weight: 700;
  font-size: 16px;
}

.analyzing-sub {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

/* Controls */
.controls-stack {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 16px;
  border-radius: 13px;
  border: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #04131c;
}

.btn-capture {
  min-height: 54px;
  width: 100%;
  background: linear-gradient(135deg, #2dd4bf, #38bdf8);
  color: #04131c;
  font-size: 16px;
  box-shadow: 0 8px 24px rgba(45, 212, 191, 0.28);
}

.capture-ring {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid #04131c;
  position: relative;
}
.capture-ring::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: #04131c;
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 13px;
}

.btn-sm {
  min-height: 38px;
  padding: 7px 12px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.btn-save {
  width: 100%;
  background: rgba(45, 212, 191, 0.14);
  color: var(--accent);
  border: 1px solid rgba(45, 212, 191, 0.45);
}

.btn-save.saved {
  background: var(--accent);
  color: #04131c;
}

.hint-text {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.secondary-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.file-btn {
  margin: 0;
}

.manual-form {
  display: flex;
  gap: 8px;
}

.manual-form input {
  flex: 1;
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 14px;
}

.banner {
  padding: 10px 12px;
  border-radius: 11px;
  font-size: 12.5px;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fde68a;
}

.banner.error {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

/* Pilot Strip */
.pilot-strip {
  margin-top: 16px;
}

.strip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}

.strip-title {
  font-size: 13px;
  font-weight: 700;
  color: #e2e8f0;
}

.strip-badge {
  font-size: 11px;
  color: var(--accent);
  background: rgba(45, 212, 191, 0.1);
  border: 1px solid rgba(45, 212, 191, 0.25);
  padding: 3px 8px;
  border-radius: 999px;
}

.pilot-grid {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.pilot-grid::-webkit-scrollbar {
  display: none;
}

.pilot-chip {
  flex: 0 0 auto;
  width: 148px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}

.pilot-chip-brand {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-2);
}

.pilot-chip-name {
  font-size: 12.5px;
  font-weight: 700;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Result View */
.result-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.telemetry-pill {
  font-size: 11.5px;
  font-weight: 600;
  color: #cbd5e1;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 999px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.media-card {
  padding: 0;
  overflow: hidden;
}

.media-frame {
  width: 100%;
  background: #050811;
}

.yt-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 14;
  max-height: 62dvh;
  background: #000;
}

.yt-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Interactive 25s 4-Beat Story Player (Pre-YouTube Preview) */
.story-player {
  position: relative;
  min-height: 320px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  user-select: none;
  cursor: pointer;
}

.story-bars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-bottom: 14px;
}

.story-bar-track {
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}

.story-bar-fill {
  height: 100%;
  width: 0%;
  background: #fff;
  transition: width 0.2s linear;
}

.story-bar-fill.done {
  width: 100%;
}

.story-bar-fill.active {
  width: 100%;
  transition: width 6s linear;
}

.story-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
}

.story-headline {
  margin: 6px 0 8px;
  font-size: 24px;
  line-height: 1.18;
  font-weight: 800;
}

.story-sub {
  margin: 0 0 12px;
  font-size: 14px;
  color: rgba(248, 250, 252, 0.88);
}

.story-bullets {
  margin: 0;
  padding-left: 18px;
  font-size: 13.5px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.story-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: rgba(248, 250, 252, 0.72);
  margin-top: 18px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.product-header {
  padding: 16px;
}

.product-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.brand-chip {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cat-chip {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 999px;
}

.product-title {
  margin: 6px 0 2px;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.25;
}

.product-ko {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}

.product-oneliner {
  margin: 0 0 12px;
  font-size: 14px;
  color: #e2e8f0;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.skin-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
}

.badge-warn {
  background: rgba(251, 191, 36, 0.16);
  color: var(--warn);
  border: 1px solid rgba(251, 191, 36, 0.35);
}

.badge-ai {
  background: rgba(45, 212, 191, 0.16);
  color: var(--accent);
  border: 1px solid rgba(45, 212, 191, 0.35);
}

/* Facts */
.fact-block {
  margin-bottom: 14px;
}
.fact-block:last-of-type {
  margin-bottom: 8px;
}

.fact-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 5px;
}

.fact-value {
  font-size: 14px;
  color: #e2e8f0;
}
.fact-value.strong {
  font-weight: 700;
  color: var(--accent-2);
}

.fact-note {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: #cbd5e1;
}

.inci-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inci-list li {
  background: var(--surface-2);
  border-radius: 11px;
  padding: 9px 11px;
  font-size: 13px;
}

.inci-name {
  display: block;
  font-weight: 700;
  color: #f8fafc;
}

.inci-role {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
}

.tip-block {
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: 12px;
  padding: 10px 12px;
}

.legal-note {
  margin: 10px 0 0;
  font-size: 11px;
  color: #64748b;
}

/* Affiliate Card */
.aff-section-title {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 3px;
}

.aff-sub {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--muted);
}

.aff-actions-primary {
  margin-bottom: 10px;
}

.aff-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.aff-link {
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  padding: 10px 6px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
}

.aff-name {
  font-size: 12px;
  font-weight: 800;
}

.aff-tag {
  font-size: 10.5px;
  color: var(--accent);
  margin-top: 2px;
}

.aff-divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

.aff-korea-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.14), rgba(45, 212, 191, 0.12));
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: var(--text);
  text-decoration: none;
  margin-top: 8px;
}

.aff-korea-title {
  font-size: 13px;
  font-weight: 800;
}

.aff-korea-sub {
  font-size: 11.5px;
  color: var(--muted);
}

.aff-arrow {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
}

/* Medium Confirm Candidates */
.panel-title {
  margin: 8px 0 4px;
  font-size: 19px;
}

.panel-sub {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted);
}

.candidate-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.candidate-btn {
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 14px;
  padding: 13px 14px;
  color: var(--text);
  cursor: pointer;
}

.candidate-brand {
  font-size: 11px;
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
}

.candidate-name {
  font-size: 15px;
  font-weight: 800;
  margin: 2px 0 4px;
}

.candidate-tip {
  font-size: 12px;
  color: var(--muted);
}

.bottom-spacer {
  margin-top: 6px;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.modal-sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 82dvh;
  overflow-y: auto;
  background: var(--surface);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  border: 1px solid var(--border);
  padding: 18px 16px 24px;
  z-index: 2;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-head h2 {
  margin: 0;
  font-size: 17px;
}

.icon-close {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
}

.wishlist-list, .lab-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lab-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.wl-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 10px 12px;
}

.wl-title {
  font-size: 13.5px;
  font-weight: 700;
}

.wl-sub {
  font-size: 11.5px;
  color: var(--muted);
}

.wl-actions {
  display: flex;
  gap: 6px;
}

.modal-foot {
  margin-top: 14px;
}
