:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --field: #f7f8fa;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #171a1f;
  --muted: #636b77;
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-contrast: #ffffff;
  --error: #b42318;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px -12px rgba(16, 24, 40, 0.12);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f12;
    --card: #15181d;
    --field: #1b1f25;
    --border: #262b33;
    --border-strong: #343b45;
    --text: #e6e9ee;
    --muted: #9aa3b0;
    --accent: #2dd4bf;
    --accent-hover: #5eead4;
    --accent-contrast: #062a26;
    --error: #fda29b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -16px rgba(0, 0, 0, 0.6);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 20px 64px;
}

.intro {
  max-width: 620px;
  margin: 0 auto 28px;
  text-align: center;
}

.intro h1 {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 650;
  letter-spacing: -0.02em;
}

.intro p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.generator {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 9px 4px;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.tab svg {
  width: 18px;
  height: 18px;
}

.tab:hover {
  color: var(--text);
}

.tab.is-active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.1);
}

@media (prefers-color-scheme: dark) {
  .tab.is-active {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  }
}

.field {
  margin-top: 20px;
}

.field label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input::placeholder {
  color: var(--muted);
  opacity: 0.75;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.hint {
  margin: 9px 2px 0;
  min-height: 1.2em;
  font-size: 0.8rem;
  color: var(--muted);
}

.hint.is-error {
  color: var(--error);
  font-weight: 500;
}

.qr-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.qr-frame {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1;
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.qr-frame:not(.has-code) {
  background: var(--field);
  border-style: dashed;
}

#qrCanvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
}

.qr-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px;
  text-align: center;
  color: var(--muted);
}

.qr-empty svg {
  width: 44px;
  height: 44px;
  opacity: 0.5;
}

.qr-empty p {
  max-width: 210px;
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.4;
}

.encoded {
  width: 100%;
  max-width: 320px;
  margin: 0;
  padding: 7px 11px;
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.7rem;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 320px;
  padding: 12px 18px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--accent-contrast);
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.qr-note {
  max-width: 280px;
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url("watermark.svg");
  background-repeat: repeat;
  opacity: 0.05;
}

@media (prefers-color-scheme: dark) {
  body::before {
    filter: invert(1);
    opacity: 0.06;
  }
}

@media (max-width: 520px) {
  body::before {
    background-size: 330px auto;
  }
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.field input:focus-visible {
  outline: none;
}

@media (max-width: 780px) {
  .app {
    padding: 32px 16px 48px;
  }

  .generator {
    grid-template-columns: 1fr;
  }
}
