:root {
  color-scheme: light;
  font-family: "Inter", system-ui, sans-serif;
  background: #f8f7fd;
  color: #201c31;
  --accent: #5838d2;
  --border: #e6e1f0;
  --muted: #5e5871;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, input { font: inherit; }
button, input { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #8f79f1; outline-offset: 3px; }

.ring-icon { display: block; width: 20px; height: 20px; border: 4px double currentColor; border-radius: 50%; }
main { width: min(1056px, calc(100% - 48px)); margin: 0 auto; padding: clamp(16px, 4vw, 36px) 0 48px; }
h2, p { margin: 0; }
.brand { margin: 0 0 16px; color: var(--accent); font-size: 1.6rem; letter-spacing: .06em; }
.workspace { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: clamp(18px, 3vw, 28px);
  box-shadow: 0 8px 24px #2c234907;
}
h2 { font-size: 1.4rem; letter-spacing: -.035em; margin-bottom: 22px; }
.generator-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.generator-heading h2 { margin: 0; }
.language-options { display: flex; gap: 3px; padding: 3px; border-radius: 10px; background: #f4f1fd; }
.language-options button {
  min-width: 38px;
  min-height: 34px;
  padding: 3px 6px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-size: .875rem;
  font-weight: 675;
}
.language-options button[aria-pressed="true"] { color: var(--accent); background: #fff; box-shadow: 0 1px 4px #2c234919; }
.input-label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-weight: 650; font-size: .9375rem; margin-bottom: 7px; }
#count { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 500; }
#count.over, .error { color: #ae2352; }
#message {
  width: 100%;
  background: #fff;
  border: 1px solid #d8d0e6;
  border-radius: 11px;
  color: inherit;
  min-height: 46px;
  padding: 10px 13px;
}
#message[aria-invalid="true"] { border-color: #ae2352; }
small { display: block; color: var(--muted); margin-top: 7px; font-size: .875rem; line-height: 1.45; }
.formats { min-width: 0; margin: 14px 0 0; padding: 0; border: 0; }
.formats legend { padding: 0; margin-bottom: 7px; font-size: .9375rem; font-weight: 650; }
.format-options { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.4fr) minmax(0, 1.05fr); gap: 4px; padding: 4px; border-radius: 11px; background: #f4f1fd; }
.format-options label { position: relative; cursor: pointer; }
.format-options input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.format-options span {
  display: grid;
  place-items: center;
  min-height: 40px;
  padding: 5px 3px;
  border-radius: 8px;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 650;
  text-align: center;
}
.format-options input:checked + span { background: #fff; color: var(--accent); box-shadow: 0 1px 4px #2c234919; }
.format-options input:focus-visible + span { outline: 3px solid #8f79f1; outline-offset: -2px; }
.controls { margin-top: 13px; }
.controls > button { width: 100%; }
.error { margin-top: 10px; font-size: .9375rem; line-height: 1.4; }

.primary, .secondary, .text-button {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 9px 14px;
  font-weight: 675;
  line-height: 1.25;
}
.primary { background: var(--accent); color: #fff; }
.primary:hover { background: #4729b8; }
.secondary { background: #f0ebff; color: #4b2fb7; }
.secondary:hover { background: #e8dfff; }
.text-button { background: #fff; color: var(--accent); }
.text-button:hover { background: #f8f5ff; }

.marker-stage {
  display: grid;
  place-items: center;
  padding: 14px;
  margin: 18px 0 12px;
  background: #f4f1fd;
  border-radius: 16px;
}
#marker { width: min(100%, 348px); height: auto; border-radius: 12px; }
#marker[data-format="rectangle"] { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.scanner-stage {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #25203b;
  aspect-ratio: 4 / 3;
  border-radius: 16px;
}
.scanner-stage video, .scanner-stage img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.viewfinder {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(96px, 19vw, 144px);
  aspect-ratio: 1;
  color: #d5caff;
}
.viewfinder .ring-icon { width: 52px; height: 52px; border-width: 8px; }
.viewfinder i { position: absolute; width: 23px; height: 23px; border: solid #ac95ff; border-width: 3px 0 0 3px; border-radius: 7px 0 0 0; }
.viewfinder i:nth-child(1) { top: 0; left: 0; }
.viewfinder i:nth-child(2) { top: 0; right: 0; transform: rotate(90deg); }
.viewfinder i:nth-child(3) { bottom: 0; right: 0; transform: rotate(180deg); }
.viewfinder i:nth-child(4) { bottom: 0; left: 0; transform: rotate(270deg); }
.scan-result { margin: 14px 0; line-height: 1.45; color: var(--muted); }
#decoded {
  display: block;
  margin-top: 4px;
  padding: 11px 14px;
  border-radius: 11px;
  background: #f0ebff;
  color: #332275;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 750;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
#scanner { scroll-margin-top: 16px; }

@media (max-width: 740px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  main { width: min(540px, calc(100% - 28px)); }
}

@media (max-width: 340px) {
  .format-options { grid-template-columns: 1fr; }
}
