:root {
  color-scheme: light;
  --bg-top: #0b1730;
  --bg-bottom: #e8eee7;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --text: #142033;
  --muted: #617086;
  --primary: #d95d39;
  --primary-dark: #9f3f25;
  --secondary: #dfe6ef;
  --border: rgba(16, 36, 63, 0.12);
  --shadow: 0 24px 60px rgba(8, 20, 38, 0.16);
  font-family: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(217, 93, 57, 0.22), transparent 28%),
    linear-gradient(180deg, var(--bg-top) 0%, #17345c 28%, var(--bg-bottom) 100%);
}

button,
input {
  font: inherit;
}

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

.scanner-card,
.result-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.scanner-card {
  padding: 10px;
  height: calc(100dvh - max(20px, env(safe-area-inset-top)) - max(20px, env(safe-area-inset-bottom)));
}

.eyebrow,
.section-label {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.9rem, 6vw, 2.7rem);
  line-height: 1;
}

h2 {
  font-size: 1.35rem;
}

.intro {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.result-header,
.action-row,
.result-grid {
  display: flex;
  gap: 12px;
}

.result-header {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.reader {
  overflow: hidden;
  border-radius: 22px;
  background: #071221;
  position: relative;
  height: 100%;
}

.camera-preview {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 22px;
}

.torch-button {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: rgba(7, 18, 33, 0.68);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  backdrop-filter: blur(10px);
}

.rotate-button {
  position: absolute;
  top: 14px;
  right: 66px;
  z-index: 3;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: rgba(7, 18, 33, 0.68);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  backdrop-filter: blur(10px);
}

.torch-button[disabled] {
  opacity: 0.45;
}

.status-bubble {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 124px;
  z-index: 3;
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(7, 18, 33, 0.68);
  color: #fff;
  font-size: 0.92rem;
  line-height: 1.35;
  backdrop-filter: blur(10px);
}

.mode-badge {
  position: absolute;
  left: 14px;
  bottom: 116px;
  z-index: 3;
  display: none;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(217, 93, 57, 0.9);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.meter-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10%;
  pointer-events: none;
  background:
    linear-gradient(rgba(7, 18, 33, 0.2), rgba(7, 18, 33, 0.2));
}

.meter-frame {
  width: min(84%, 520px);
  aspect-ratio: 2.9 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width 120ms ease;
}

.meter-frame-inner {
  width: 100%;
  height: 100%;
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 20px;
  box-shadow:
    0 0 0 9999px rgba(7, 18, 33, 0.28),
    0 0 0 1px rgba(255, 255, 255, 0.28) inset;
  transition: transform 120ms ease;
  position: relative;
}

.meter-frame-marker {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 72px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.35);
}

.meter-frame.is-rotated {
  width: min(34%, 190px);
  aspect-ratio: 1 / 2.9;
}

.capture-button {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 3;
  width: 78px;
  height: 78px;
  border: 6px solid rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  background: rgba(217, 93, 57, 0.9);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
}

.hidden {
  display: none;
}

.result-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(7, 18, 33, 0.52);
  backdrop-filter: blur(8px);
}

.result-overlay.hidden {
  display: none;
}

body.quick-mode .mode-badge {
  display: inline-flex;
}

body.quick-mode .result-overlay {
  display: none !important;
}

.result-card {
  width: min(100%, 540px);
  max-height: 100%;
  overflow: auto;
  padding: 20px;
}

.field {
  display: block;
  margin-top: 18px;
}

.field span {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.field input {
  width: 100%;
  border: 1px solid rgba(16, 36, 63, 0.14);
  border-radius: 16px;
  padding: 14px 16px;
  background: var(--panel-strong);
}

.result-grid {
  margin-top: 16px;
}

.info-box {
  flex: 1;
  padding: 14px;
  border-radius: 18px;
  background: #f4f7fb;
}

.info-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.code-badge {
  max-width: 48%;
  padding: 10px 14px;
  border-radius: 999px;
  background: #edf2f8;
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.primary-button,
.secondary-button {
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  font-weight: 700;
}

.primary-button {
  flex: 1;
  background: var(--primary);
  color: #fff;
}

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

.secondary-button {
  background: var(--secondary);
  color: var(--text);
}

.secondary-button[disabled],
.primary-button[disabled] {
  opacity: 0.5;
}

@media (max-width: 540px) {
  .result-header,
  .action-row,
  .result-grid {
    flex-direction: column;
  }

  .code-badge {
    max-width: 100%;
  }

  .reader {
    height: 100%;
  }

  .capture-button {
    width: 74px;
    height: 74px;
    bottom: 14px;
  }
}
