:root {
  --ink: #0a100e;
  --ink-elevated: #121c18;
  --mist: #d7ebe3;
  --paper: #f6fbf8;
  --signal: #c6f000;
  --signal-dim: #8fb000;
  --warn: #e8a020;
  --fail: #e84a3a;
  --pass: #2f9e6b;
  --muted: #6a7f76;
  --stroke: rgba(255, 255, 255, 0.08);
  --card: rgba(255, 255, 255, 0.04);
  --radius: 16px;
  --radius-sm: 10px;
  --font-brand: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--signal); text-decoration: none; }
a:hover, a:focus { text-decoration: underline; }

.atmosphere {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(120vw 80vh at 85% -5%, rgba(198, 240, 0, 0.12), transparent 55%),
    radial-gradient(90vw 70vh at -5% 105%, rgba(47, 158, 107, 0.14), transparent 50%),
    linear-gradient(165deg, #0a100e 0%, #121f1a 50%, #0a100e 100%);
}

.shell {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 32px 20px 56px;
}

.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 36px;
}

.app-nav a.back-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
}

.wordmark {
  font-family: var(--font-brand);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.03em;
  color: var(--paper);
}

.wordmark em {
  font-style: normal;
  color: var(--signal);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--signal-dim);
  margin: 0 0 10px;
}

.brand {
  font-family: var(--font-brand);
  font-weight: 800;
  font-size: clamp(2.5rem, 8vw, 3.75rem);
  letter-spacing: -0.04em;
  line-height: 1;
  margin: 0 0 16px;
}

.brand span { color: var(--signal); }

.lede {
  font-size: clamp(1.05rem, 2.4vw, 1.2rem);
  line-height: 1.55;
  color: var(--mist);
  margin: 0 0 28px;
  max-width: 36rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.feature-list { list-style: none; margin: 0; padding: 0; }

.feature-item {
  display: flex;
  gap: 14px;
  padding: 14px 0;
}

.feature-item + .feature-item {
  border-top: 1px solid var(--stroke);
}

.feature-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(198, 240, 0, 0.12);
  color: var(--signal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.feature-copy h3 {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 600;
}

.feature-copy p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--muted);
}

.cta-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 24px 0;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 1rem;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 16px 22px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, opacity 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--signal);
  color: var(--ink);
}

.btn-secondary {
  background: transparent;
  color: var(--paper);
  box-shadow: inset 0 0 0 1.5px rgba(215, 235, 227, 0.28);
}

.note {
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--muted);
  max-width: 36rem;
}

/* Live display */
.display-root {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 50% 0%, rgba(198, 240, 0, 0.08), transparent 42%),
    var(--ink);
}

.display-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 10px;
}

.display-top .back-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--stroke);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 1rem;
}

.status-pill {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--signal);
  padding: 7px 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-pill .live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink);
  animation: livePulse 1.2s ease-in-out infinite;
}

.status-pill.is-warn {
  background: rgba(232, 160, 32, 0.85);
  color: var(--paper);
}

.status-pill.is-warn .live-dot { display: none; }

.status-pill.is-err {
  background: rgba(232, 74, 58, 0.9);
  color: var(--paper);
}

.status-pill.is-err .live-dot { display: none; }

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.35); }
}

.qr-stage {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px 16px;
}

.qr-binder {
  width: min(92vw, 420px);
  aspect-ratio: 1 / 1;
  position: relative;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 2px solid rgba(198, 240, 0, 0.35);
  padding: 28px;
}

.qr-frame {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-frame svg { width: 100%; height: 100%; display: block; }

.meta-card {
  margin: 0 20px 12px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
}

.meta-card .label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.meta-card .value {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--mist);
  white-space: pre-line;
}

.display-actions {
  display: flex;
  gap: 12px;
  padding: 16px 20px 24px;
  background: rgba(10, 16, 14, 0.82);
  border-top: 1px solid var(--stroke);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.display-actions .btn { flex: 1; margin: 0; }

/* Verify */
.verify-panel label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.verify-panel textarea {
  width: 100%;
  min-height: 148px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--paper);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 14px;
  resize: vertical;
  line-height: 1.5;
}

.verify-actions {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}

.verify-actions .btn { flex: 1; margin: 0; }

.report {
  margin-top: 8px;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  border-left: 4px solid var(--muted);
}

.report.grade-pass { border-left-color: var(--pass); }
.report.grade-weak { border-left-color: var(--warn); }
.report.grade-fail { border-left-color: var(--fail); }

.report-header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.report-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.report.grade-pass .report-icon { background: rgba(47, 158, 107, 0.15); color: var(--pass); }
.report.grade-weak .report-icon { background: rgba(232, 160, 32, 0.15); color: var(--warn); }
.report.grade-fail .report-icon { background: rgba(232, 74, 58, 0.15); color: var(--fail); }

.report h2 {
  font-family: var(--font-brand);
  margin: 0 0 4px;
  font-size: 1.15rem;
  line-height: 1.3;
}

.report-sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
}

.grades {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.grade-chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
}

.grade-chip strong {
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.grade-chip[data-v="pass"],
.grade-chip[data-v="high"],
.grade-chip[data-v="claim"] { color: var(--pass); background: rgba(47, 158, 107, 0.12); }

.grade-chip[data-v="weak"],
.grade-chip[data-v="medium"],
.grade-chip[data-v="low"] { color: var(--warn); background: rgba(232, 160, 32, 0.12); }

.grade-chip[data-v="fail"],
.grade-chip[data-v="untrusted"] { color: var(--fail); background: rgba(232, 74, 58, 0.12); }

.details {
  margin: 0;
  padding: 0;
  list-style: none;
}

.details li {
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--mist);
  padding: 6px 0 6px 14px;
  position: relative;
}

.details li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
}

.payload-block {
  margin-top: 14px;
  padding: 12px;
  overflow-x: auto;
  background: rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-all;
}

.hidden { display: none !important; }

@media (max-height: 280px), (max-width: 280px) {
  .display-top { padding: 6px 10px; }
  .status-pill { font-size: 0.58rem; padding: 4px 8px; }
  .qr-binder { width: min(96vw, 96dvh); padding: 12px; border-radius: 12px; }
  .meta-card { display: none; }
  .display-actions { padding: 8px 10px 12px; }
  .display-actions .btn { padding: 10px; font-size: 0.85rem; }
}

@supports not (aspect-ratio: 1 / 1) {
  .qr-binder { height: min(92vw, 420px); }
}

/* Camera scanner */
.scanner-box {
  position: relative;
  margin: 0 0 16px;
  border-radius: var(--radius-sm, 10px);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--stroke, rgba(255,255,255,0.08));
}
.scanner-box video {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  background: #000;
}
.hidden { display: none !important; }
.note { color: var(--muted, #6a7f76); font-size: 0.85rem; line-height: 1.4; }

/* Prefer snappy UI: tone down continuous pulse */
.live-dot { animation: none; opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .live-dot {
    animation: livePulse 2.4s ease-in-out infinite;
  }
}
