:root {
  color-scheme: dark;
  --bg: #08110e;
  --panel: #111a20;
  --panel-soft: #16242b;
  --line: #2c4650;
  --text: #eef7f2;
  --muted: #a9bbb5;
  --accent: #54d48f;
  --accent-strong: #1e7b4c;
  --blue: #2d66aa;
  --danger: #6d2830;
  --warn: #ffbd4a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  touch-action: manipulation;
}

button:disabled {
  opacity: 0.45;
}

button.primary {
  background: var(--accent-strong);
  border-color: #35a86c;
}

button.return-button {
  background: var(--blue);
  border-color: #4382cf;
}

button.danger {
  background: var(--danger);
  border-color: #a3424b;
}

.scanner-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topbar,
.controls,
.handoff-panel,
.queue-panel,
.result-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar > div {
  min-width: 0;
}

.eyebrow,
.label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.camera-panel {
  position: relative;
  min-height: 360px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #020705;
}

video {
  width: 100%;
  height: min(64vh, 600px);
  min-height: 360px;
  display: block;
  object-fit: cover;
}

.reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(72%, 360px);
  height: min(40%, 220px);
  transform: translate(-50%, -50%);
  border: 2px solid rgba(84, 212, 143, 0.9);
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.22);
}

.status {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(3, 8, 6, 0.84);
  color: var(--muted);
  font-size: 14px;
}

.controls,
.handoff-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.handoff-panel {
  grid-template-columns: 1.2fr 1fr repeat(3, minmax(0, 0.78fr));
}

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

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

.queue-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.queue-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.queue-raw {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-details {
  color: var(--muted);
  font-size: 12px;
}

.queue-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(58px, 1fr));
  gap: 6px;
}

.queue-actions button {
  min-height: 38px;
  padding: 0 10px;
  font-size: 13px;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--accent);
}

@media (max-width: 640px) {
  h1 {
    font-size: 20px;
  }

  .controls,
  .handoff-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .handoff-panel .primary,
  .handoff-panel .return-button {
    grid-column: span 1;
  }

  .queue-item {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 380px) {
  .controls,
  .handoff-panel {
    grid-template-columns: 1fr;
  }
}
