:root {
  color-scheme: dark;
  --bg: #101418;
  --panel: #171d22;
  --panel-soft: #202830;
  --text: #f5f7f8;
  --muted: #aeb8c2;
  --line: #34404a;
  --accent: #4cc38a;
  --accent-dark: #20945b;
  --danger: #f06b5f;
}

* {
  box-sizing: border-box;
}

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

button {
  border: 0;
  font: inherit;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
}

.decode-sandbox {
  position: fixed;
  left: -10000px;
  top: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.topbar,
.document-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.document-header {
  display: block;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-size: 1.7rem;
  line-height: 1.12;
}

.status-pill {
  flex: 0 0 auto;
  min-width: 74px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.camera-stage {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 68svh;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #050607;
}

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

.scan-frame {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(68vw, 300px);
  height: min(68vw, 300px);
  transform: translate(-50%, -50%);
  border: 4px solid rgba(245, 247, 248, 0.92);
  border-radius: 10px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.28);
}

.camera-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.camera-empty strong {
  color: var(--text);
  font-size: 1.05rem;
}

.camera-empty.hidden,
.hidden {
  display: none;
}

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

.single-action {
  grid-template-columns: 1fr;
  margin-top: 10px;
}

input[type="file"] {
  display: none;
}

.api-key-field {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

.api-key-field input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
}

.api-key-field input:focus {
  border-color: var(--accent);
  outline: 0;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 700;
}

.primary-button {
  background: var(--accent);
  color: #06110b;
}

.primary-button:active {
  background: var(--accent-dark);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

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

.hint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.4;
}

.virtual-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  color: var(--muted);
}

.card-row strong {
  color: var(--accent);
}

.raw-box {
  min-height: 180px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.45;
}

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

  h1,
  h2 {
    font-size: 1.45rem;
  }
}
