:root {
  color-scheme: light;
  --bg: #F5F8FD;
  --bg2: #EAF0FB;
  --surface: #FFFFFF;
  --ink: #081A30;
  --ink-muted: #5B6B85;
  --blue: #0057E4;
  --blue-dark: #0041AE;
  --border: #DEE6F5;
  --qr-dark: #081A30;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #081A30;
    --bg2: #0F2545;
    --surface: #0E2140;
    --ink: #F3F7FF;
    --ink-muted: #93A6C7;
    --blue: #4D8CFF;
    --blue-dark: #7AA6FF;
    --border: #1D3766;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #081A30;
  --bg2: #0F2545;
  --surface: #0E2140;
  --ink: #F3F7FF;
  --ink-muted: #93A6C7;
  --blue: #4D8CFF;
  --blue-dark: #7AA6FF;
  --border: #1D3766;
}

* { box-sizing: border-box; }

html {
  scroll-padding-top: env(safe-area-inset-top, 0px);
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transition: background .2s ease, color .2s ease;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

.app {
  max-width: 440px;
  margin: 0 auto;
  padding: 32px 20px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.mark {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 10px;
  object-fit: cover;
  border: 1.5px solid var(--border);
}

.brand-text { min-width: 0; }

.brand-name {
  display: block;
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-weight: 700;
  font-size: 21px;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.brand-tag {
  display: block;
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 1px;
}

.theme-toggle {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .sun { display: none; }
.theme-toggle .moon { display: block; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }

main { margin-top: 24px; }

.panel {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 18px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 8px;
}

.field {
  width: 100%;
  resize: vertical;
  min-height: 76px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  color: var(--ink);
}
.field:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent);
}
.field::placeholder { color: var(--ink-muted); }

.btn-primary {
  width: 100%;
  margin-top: 12px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 13px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:active { transform: scale(0.99); }

.viewfinder {
  position: relative;
  margin-top: 18px;
  border-radius: 20px;
  background: var(--bg2);
  padding: 30px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 210px;
}
.corner { position: absolute; width: 22px; height: 22px; border-color: var(--blue); }
.corner.tl { top: 14px; left: 14px; border-top: 3px solid; border-left: 3px solid; border-top-left-radius: 8px; }
.corner.tr { top: 14px; right: 14px; border-top: 3px solid; border-right: 3px solid; border-top-right-radius: 8px; }
.corner.bl { bottom: 14px; left: 14px; border-bottom: 3px solid; border-left: 3px solid; border-bottom-left-radius: 8px; }
.corner.br { bottom: 14px; right: 14px; border-bottom: 3px solid; border-right: 3px solid; border-bottom-right-radius: 8px; }

.qr-stage {
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-empty {
  margin: 0;
  font-size: 13px;
  color: var(--ink-muted);
  text-align: center;
  max-width: 180px;
}

#qrCanvas {
  display: block;
  width: 176px;
  height: 176px;
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  box-sizing: border-box;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn-secondary {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--ink);
  border-radius: 12px;
  padding: 12px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.btn-secondary:hover { border-color: var(--blue); color: var(--blue); }

.toast {
  margin: 10px 0 0;
  min-height: 18px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--blue);
  opacity: 0;
  transition: opacity .2s ease;
}

.footnote {
  margin-top: 26px;
}
.footnote p {
  margin: 0;
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-muted);
}

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