:root {
  color-scheme: light;
  --navy: #071d2b;
  --navy-2: #0b2b3b;
  --mint: #55e2ae;
  --mint-dark: #157b68;
  --paper: #f0f2ec;
  --surface: #ffffff;
  --line: #d9e1dc;
  --muted: #687b7b;
  --danger: #a23e36;
  --danger-bg: #fbe5e1;
  --success: #176e52;
  --success-bg: #def4e8;
  --warning: #86610c;
  --warning-bg: #fff2ca;
  --shadow: 0 22px 70px rgba(7, 29, 43, .13);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 8%, rgba(85, 226, 174, .10), transparent 28rem),
    var(--paper);
  color: var(--navy);
  font-family: Vazirmatn, Tahoma, Arial, sans-serif;
}
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid rgba(21, 123, 104, .35);
  outline-offset: 3px;
}
.skip-link {
  position: fixed;
  top: -80px;
  right: 16px;
  z-index: 100;
  background: var(--mint);
  color: var(--navy);
  padding: 10px 16px;
}
.skip-link:focus { top: 10px; }
.site-header {
  min-height: 74px;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px max(18px, calc((100vw - 600px) / 2));
}
.brand {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--mint);
  color: var(--mint);
  transform: rotate(45deg);
  font: 800 20px Arial;
}
.brand strong { display: block; font: 800 16px Arial; letter-spacing: 2px; }
.brand small { display: block; margin-top: 4px; color: #9eb0b2; font: 8px Arial; letter-spacing: 1px; }
.connection { color: #b6c6c6; font-size: 10px; white-space: nowrap; }
.connection i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 7px;
  border-radius: 50%;
  background: #aeb8b8;
}
.connection.valid i { background: var(--mint); box-shadow: 0 0 0 4px rgba(85, 226, 174, .15); }
.connection.invalid i { background: #ef7568; }
main { width: min(600px, 100%); margin: auto; padding: 34px 16px 42px; }
.intro { text-align: center; margin: 0 auto 24px; max-width: 520px; }
.intro p { margin: 0; color: var(--mint-dark); font-size: 11px; font-weight: 800; }
.intro h1 { margin: 8px 0; font-size: clamp(24px, 6vw, 34px); line-height: 1.45; }
.intro span { color: var(--muted); font-size: 12px; line-height: 1.9; }
.scanner-card { padding: 16px; background: var(--surface); box-shadow: var(--shadow); border: 1px solid rgba(7, 29, 43, .04); }
.camera { position: relative; aspect-ratio: 1; overflow: hidden; background: #07151d; }
.camera video, .fallback-reader, .fallback-reader > div { width: 100%; height: 100%; }
.camera video { object-fit: cover; }
.fallback-reader { position: absolute; inset: 0; display: none; }
.fallback-reader.active { display: block; }
.fallback-reader video { width: 100% !important; height: 100% !important; object-fit: cover; }
.fallback-reader img, .fallback-reader button, .fallback-reader select { display: none !important; }
.camera-message {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px;
  color: #fff;
  background: radial-gradient(circle, rgba(11, 43, 59, .25), rgba(7, 21, 29, .78));
}
.camera-message[hidden] { display: none; }
.camera-message strong { font-size: 17px; }
.camera-message span { margin-top: 8px; color: #aec0c1; font-size: 11px; line-height: 1.8; }
.frame { position: absolute; z-index: 2; inset: 17%; pointer-events: none; }
.frame i { position: absolute; width: 44px; height: 44px; border-color: var(--mint); border-style: solid; }
.frame i:nth-child(1) { top: 0; right: 0; border-width: 3px 3px 0 0; }
.frame i:nth-child(2) { top: 0; left: 0; border-width: 3px 0 0 3px; }
.frame i:nth-child(3) { bottom: 0; right: 0; border-width: 0 3px 3px 0; }
.frame i:nth-child(4) { bottom: 0; left: 0; border-width: 0 0 3px 3px; }
.frame span {
  position: absolute;
  top: 12%;
  right: 4px;
  left: 4px;
  height: 1px;
  background: var(--mint);
  box-shadow: 0 0 14px var(--mint);
  animation: scan-line 2.2s ease-in-out infinite;
}
@keyframes scan-line { 0%, 100% { top: 12%; } 50% { top: 88%; } }
.camera-controls { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-top: 12px; }
.primary-action, .secondary-action, .icon-action, .manual-row button {
  min-height: 44px;
  border: 0;
  border-radius: 4px;
  font-weight: 800;
  font-size: 12px;
}
.primary-action { background: var(--mint); color: var(--navy); }
.icon-action { padding: 0 16px; background: #e7eeea; color: var(--navy); }
button:disabled { cursor: wait; opacity: .65; }
.support-note { padding: 10px 12px; margin-top: 10px; color: var(--muted); background: #f4f6f2; font-size: 9px; line-height: 1.8; }
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: #82918f; font-size: 10px; }
.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
form label { display: block; margin-bottom: 8px; font-size: 11px; font-weight: 800; }
.manual-row { display: flex; }
.manual-row input {
  min-width: 0;
  flex: 1;
  min-height: 46px;
  border: 1px solid #c9d4cf;
  border-left: 0;
  padding: 10px 12px;
  color: var(--navy);
  background: #fbfcfa;
  font: 13px Arial;
}
.manual-row button { min-width: 84px; padding: 0 18px; border-radius: 4px 0 0 4px; background: var(--navy); color: #fff; }
.result { display: none; margin-top: 14px; padding: 12px; font-size: 11px; line-height: 1.8; }
.result.show { display: block; }
.result.info { background: #e9eff0; color: #294957; }
.result.success { background: var(--success-bg); color: var(--success); }
.result.warning { background: var(--warning-bg); color: var(--warning); }
.result.error { background: var(--danger-bg); color: var(--danger); }
.parsed-card { margin-top: 14px; padding: 15px; border: 1px solid var(--line); background: #fbfcfa; }
.parsed-head { display: flex; align-items: center; justify-content: space-between; }
.parsed-head h2 { margin: 0; font-size: 14px; }
.parsed-head span { padding: 3px 8px; color: var(--mint-dark); background: #dcf4e9; font-size: 9px; font-weight: 800; }
.parsed-card dl { margin: 14px 0; }
.parsed-card dl > div { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 8px 0; border-top: 1px solid #e5ebe7; }
.parsed-card dt { color: var(--muted); font-size: 10px; }
.parsed-card dd { margin: 0; overflow-wrap: anywhere; font: 700 11px Arial; text-align: left; }
.secondary-action { width: 100%; background: var(--navy); color: #fff; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.secondary-action.quiet { background: #e7eeea; color: var(--navy); }
.privacy, .version { text-align: center; color: var(--muted); font-size: 9px; line-height: 1.9; }
.privacy { margin: 20px 24px 5px; }
.version { margin: 0; font: 8px Arial; letter-spacing: 1px; }

@media (max-width: 520px) {
  .site-header { padding-inline: 16px; flex-wrap: wrap; justify-content: center; gap: 8px; }
  .connection { width: 100%; text-align: center; }
  .brand strong { font-size: 14px; }
  main { padding-top: 24px; }
  .scanner-card { padding: 10px; }
  .camera-controls { grid-template-columns: 1fr 1fr; }
  .primary-action { grid-column: 1 / -1; }
  .parsed-card dl > div { grid-template-columns: 90px 1fr; }
  .result-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .frame span { animation: none; top: 50%; }
}
