:root {
  --bg: #0b0d10;
  --panel: #14181d;
  --panel-2: #1a1f26;
  --fg: #e8eaed;
  --fg-dim: #99a2ad;
  --accent: #7c5cff;
  --accent-2: #5b8def;
  --ok: #2ecc71;
  --warn: #f5a623;
  --err: #ef5350;
  --border: #232932;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a {
  color: var(--accent-2);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ----- Landing ----- */
.page-landing {
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  width: min(520px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.title {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0 0 20px;
  color: var(--fg-dim);
}

.block {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 14px;
}

.block h2 {
  margin: 0 0 6px;
  font-size: 16px;
}

.hint {
  margin: 0 0 12px;
  color: var(--fg-dim);
  font-size: 13px;
}

.row {
  display: flex;
  gap: 8px;
}

.input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f1318;
  color: var(--fg);
  font-size: 16px;
  letter-spacing: 0.06em;
  text-transform: lowercase;
}

.input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--fg);
  padding: 12px 16px;
  font-size: 15px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn:hover:not(:disabled) {
  border-color: #2c3340;
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent), #5e3edb);
  border-color: transparent;
  color: white;
  font-weight: 600;
}

.btn-link {
  background: transparent;
}

.footnote {
  color: var(--fg-dim);
  font-size: 12px;
  margin: 18px 0 0;
}

/* ----- Topbar (scan + view) ----- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 700;
  text-decoration: none;
  color: var(--fg);
}

.room-pill {
  font-size: 13px;
  color: var(--fg-dim);
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 999px;
}

.room-pill code {
  color: var(--fg);
  letter-spacing: 0.08em;
}

.status {
  margin-left: auto;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
}

.status-idle {
  color: var(--fg-dim);
}
.status-ok {
  color: var(--ok);
  border-color: rgba(46, 204, 113, 0.3);
}
.status-err {
  color: var(--err);
  border-color: rgba(239, 83, 80, 0.3);
}

/* ----- Scanner ----- */
.scan-main {
  padding: 16px;
  display: grid;
  gap: 16px;
  max-width: 720px;
  margin: 0 auto;
}

.video-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  text-align: center;
  color: var(--fg-dim);
  background: rgba(0, 0, 0, 0.5);
  font-size: 14px;
}

.overlay-msg {
  margin: 0;
}

.crop-box {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 2px dashed rgba(124, 92, 255, 0.85);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  pointer-events: none;
}

.zoom-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.zoom-label {
  font-size: 13px;
  color: var(--fg-dim);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.zoom-label > span:first-of-type {
  color: var(--fg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 3.2em;
  text-align: right;
}

.zoom-mode {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-dim);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 999px;
}

#zoomSlider {
  flex: 1;
  accent-color: var(--accent);
}

.scan-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.meta {
  display: grid;
  grid-template-columns: 110px 1fr;
  row-gap: 6px;
  column-gap: 12px;
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14px;
}

.meta dt {
  color: var(--fg-dim);
}

.meta dd {
  margin: 0;
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

/* ----- Viewer ----- */
.view-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  min-height: calc(100vh - 56px);
}

.qr-box {
  background: white;
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  place-items: center;
  position: relative;
  width: min(90vmin, 720px);
  aspect-ratio: 1 / 1;
}

.qr-box.qr-empty {
  background: var(--panel);
  border: 1px dashed var(--border);
}

.qr-box canvas {
  width: 100% !important;
  height: 100% !important;
  image-rendering: pixelated;
}

.qr-empty .qr-empty-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--fg-dim);
  font-size: 14px;
  text-align: center;
  padding: 24px;
}

.qr-box:not(.qr-empty) .qr-empty-msg {
  display: none;
}

.view-meta {
  display: flex;
  gap: 8px;
}

.freshness {
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
}

.freshness-live {
  color: var(--ok);
  border-color: rgba(46, 204, 113, 0.3);
}

.freshness-stale {
  color: var(--err);
  border-color: rgba(239, 83, 80, 0.3);
}
