:root {
  --tg-theme-bg-color: #ffffff;
  --tg-theme-text-color: #000000;
  --tg-theme-button-color: #2481cc;
  --tg-theme-button-text-color: #ffffff;
  --tg-theme-hint-color: #999999;
  --tg-theme-secondary-bg-color: #f0f0f0;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--tg-theme-bg-color);
  color: var(--tg-theme-text-color);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.app {
  height: calc(100vh - 72px);
  position: relative;
}

/* ── Screens ── */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px 20px;
  gap: 16px;
  text-align: center;
}

.screen.active {
  display: flex;
}

/* ── Camera screen ── */
.scanner-wrap {
  position: relative;
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
}

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

.scan-frame {
  position: absolute;
  inset: 16px;
  pointer-events: none;
}

.corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: #ffffff;
  border-style: solid;
  border-width: 0;
}

.corner.tl { top: 0; left: 0;  border-top-width: 3px;    border-left-width: 3px; }
.corner.tr { top: 0; right: 0; border-top-width: 3px;    border-right-width: 3px; }
.corner.bl { bottom: 0; left: 0;  border-bottom-width: 3px; border-left-width: 3px; }
.corner.br { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; }

.scan-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.8);
  top: 0;
  animation: scan 2s linear infinite;
}

@keyframes scan {
  0%   { top: 0%; }
  100% { top: 100%; }
}

/* ── Result screen ── */
.result-icon {
  font-size: 56px;
  line-height: 1;
}

h2 {
  font-size: 20px;
  font-weight: 600;
}

.result-text {
  background: var(--tg-theme-secondary-bg-color);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 15px;
  word-break: break-all;
  max-height: 160px;
  overflow-y: auto;
  width: 100%;
  max-width: 360px;
  text-align: left;
}

.hint {
  color: var(--tg-theme-hint-color);
  font-size: 14px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  width: 100%;
  max-width: 360px;
  transition: opacity 0.15s;
}

.btn:active {
  opacity: 0.75;
}

.btn-primary {
  background: var(--tg-theme-button-color);
  color: var(--tg-theme-button-text-color);
}

.btn-secondary {
  background: var(--tg-theme-secondary-bg-color);
  color: var(--tg-theme-text-color);
}

.btn-outline {
  background: transparent;
  color: var(--tg-theme-button-color);
  border: 1.5px solid var(--tg-theme-button-color);
}

/* ── Success overlay ── */
.success-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--tg-theme-bg-color);
  z-index: 100;
  animation: fadeIn 0.2s ease;
  padding: 24px;
  text-align: center;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

.success-icon {
  font-size: 72px;
  line-height: 1;
}

.success-label {
  font-size: 22px;
  font-weight: 600;
}

.success-data {
  font-size: 14px;
  color: var(--tg-theme-hint-color);
  word-break: break-all;
  max-height: 120px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

/* ── Bottom bar ── */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  background: var(--tg-theme-bg-color);
  border-top: 1px solid rgba(0,0,0,0.08);
}
