:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f7f2;
  color: #10201d;
  --panel: #ffffff;
  --ink-soft: #5a6862;
  --line: #d9e1dc;
  --brand: #146b5d;
  --brand-strong: #0d4e44;
  --accent: #d97a35;
  --danger: #9c2f2f;
  --shadow: 0 18px 45px rgba(27, 48, 42, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #10201d;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.app-shell {
  width: min(960px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(20px, env(safe-area-inset-bottom));
  display: grid;
  gap: 14px;
  align-content: start;
}

.scanner-panel,
.result-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.scanner-panel {
  padding: 16px;
}

.result-panel {
  padding: 14px;
}

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

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.45rem, 1.25rem + 1vw, 2.2rem);
}

h2 {
  font-size: 1rem;
}

.status-pill {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 999px;
  background: #edf4f0;
  color: var(--brand-strong);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.warning {
  background: #fff1dd;
  color: #815018;
}

.camera-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  margin-top: 16px;
  overflow: hidden;
  border-radius: 8px;
  background: #17221f;
  border: 1px solid #203531;
}

video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-line {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 2px;
  background: #f2b76b;
  box-shadow: 0 0 16px rgba(242, 183, 107, 0.95);
  transform: translateY(-50%);
}

.camera-placeholder {
  position: absolute;
  inset: auto 18px 18px;
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: #23312d;
  font-weight: 700;
}

.camera-placeholder.hidden {
  display: none;
}

.status-message {
  min-height: 44px;
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #edf4f0;
  color: #28443d;
  line-height: 1.45;
}

.status-message.error {
  background: #fff0ed;
  color: var(--danger);
}

.controls {
  display: grid;
  grid-template-columns: 1.3fr 0.85fr 0.85fr;
  gap: 10px;
}

.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.ghost {
  min-height: 36px;
  padding: 0 10px;
  color: var(--brand-strong);
}

.latest-result {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.label,
.format {
  display: block;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 800;
}

output {
  display: block;
  min-height: 42px;
  margin: 8px 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(1.35rem, 1.1rem + 1vw, 2rem);
  font-weight: 800;
}

.history {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.history li {
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.history strong {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.history span {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

@media (min-width: 760px) {
  .app-shell {
    grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
    align-items: start;
    padding-top: 28px;
  }
}

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