:root {
  --ink: #241433;
  --paper: #fffaf5;
  --purple: #6d3bd1;
  --purple-dark: #4a248f;
  --line: #eadfce;
  --muted: #5c5168;
  color: var(--ink);
  background: var(--paper);
  font-family: "Segoe UI", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
}

img,
svg,
canvas,
video {
  max-width: 100%;
  height: auto;
}

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

.skip-link {
  position: absolute;
  top: 0;
  left: 1rem;
  z-index: 1;
  padding: 0.75rem 1rem;
  color: #fff;
  background: var(--purple-dark);
  transform: translateY(-120%);
}

.skip-link:focus {
  transform: translateY(0);
}

.hero h1 {
  font-size: clamp(1.7rem, 4vw, 2.25rem);
  line-height: 1.2;
  text-wrap: balance;
}

.content-section h2 {
  font-size: 1.3rem;
  line-height: 1.3;
}

.content-section p,
.content-section li {
  overflow-wrap: anywhere;
}

.content-section summary {
  padding: 0.65rem 0;
  cursor: pointer;
  font-weight: 600;
}

.site-header,
.site-footer,
.hero,
.content-section,
#qr-app {
  width: min(1080px, calc(100% - 2rem));
  margin-right: auto;
  margin-left: auto;
}

.site-header,
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 1rem 0;
}

.site-header {
  position: relative;
  border-bottom: 1px solid var(--line);
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  min-width: 0;
  max-width: 100%;
}

.site-header nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.6rem;
  color: var(--purple-dark);
  text-decoration: none;
}

.lang-menu {
  position: relative;
  margin-inline-start: auto;
}

.lang-menu__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--purple-dark);
  background: #fff;
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
}

.lang-menu__btn::-webkit-details-marker {
  display: none;
}

.lang-menu__short {
  display: none;
}

.lang-menu__caret {
  transition: transform 0.15s ease;
}

.lang-menu[open] .lang-menu__caret {
  transform: rotate(180deg);
}

.lang-menu__list {
  position: absolute;
  top: calc(100% + 0.35rem);
  inset-inline-end: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(2, minmax(9rem, 1fr));
  gap: 0.15rem;
  margin: 0;
  padding: 0.5rem;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgb(36 20 51 / 16%);
}

.lang-menu__list a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 0.6rem;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}

.lang-menu__list a:hover,
.lang-menu__list a[aria-current="true"] {
  color: var(--purple-dark);
  background: var(--paper);
}

.lang-menu__list a[aria-current="true"] {
  font-weight: 700;
}

@media (max-width: 899px) {
  .site-header nav {
    order: 1;
    flex-basis: 100%;
  }
}

@media (max-width: 599px) {
  .site-header .lang-menu {
    position: static;
  }

  .lang-menu__list {
    top: 100%;
    inset-inline: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .lang-menu__short {
    display: inline;
  }
}

.hero,
.content-section {
  padding: 1.25rem 0 2rem;
}

.content-section {
  display: grid;
  gap: 1rem;
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
}

.button,
button.button,
a.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; margin: 0; padding: 0.55rem 0.9rem;
  border: 1.5px solid transparent; border-radius: 999px;
  background: var(--purple); color: #fff; font: inherit; text-decoration: none; cursor: pointer;
}
.button:hover, button.button:hover { background: var(--purple-dark); }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
button[data-qr-action="generate"] { font-weight: 600; }
button[data-qr-action^="download-"] {
  background: transparent; border-color: var(--purple); color: var(--purple); font-weight: 600;
}
button[data-qr-action^="download-"]:hover:not(:disabled) { background: rgba(109, 59, 209, 0.08); }
button[data-qr-action^="download-"]:disabled {
  border-color: var(--line); color: var(--muted); background: transparent;
}

.muted {
  color: var(--muted);
}

.qr-tool,
.qr-layout,
.qr-form,
.qr-preview {
  min-width: 0;
  max-width: 100%;
}

.qr-tool h2 {
  margin: 0 0 0.35rem;
  font-size: 1.6rem;
}

.qr-layout {
  display: grid;
  gap: 1rem;
}

.qr-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.8rem;
}

.qr-check {
  flex-direction: row;
  align-items: center;
}

.qr-field input,
.qr-field textarea,
.qr-field select {
  width: 100%;
  max-width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid #d9cbb8;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.qr-field textarea {
  min-height: 8rem;
  resize: vertical;
}

.qr-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.25rem 0 0.8rem; }
@media (max-width: 640px) {
  .qr-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .qr-actions button[data-qr-action="generate"] { grid-column: 1 / -1; width: 100%; }
  .qr-actions button[data-qr-action^="download-"] { width: 100%; padding: 0.55rem 0.5rem; font-size: 0.88rem; }
}
@media (max-width: 360px) {
  .qr-actions { display: flex; flex-direction: column; }
  .qr-actions button { width: 100%; }
}

.qr-status {
  min-height: 1.5rem;
  font-weight: 650;
}

canvas[data-qr-preview] {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
}

@media (min-width: 900px) {
  .qr-layout {
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
  }

  .qr-preview {
    position: sticky;
    top: 1rem;
  }
}

.lang-switch {
  width: 100%;
  margin: 0.5rem 0;
}

.lang-switch summary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  color: var(--purple-dark);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  list-style: none;
  font-size: 0.9rem;
  font-weight: 500;
  user-select: none;
}

.lang-switch summary::-webkit-details-marker {
  display: none;
}

.lang-switch summary:hover {
  border-color: var(--purple);
  color: var(--purple);
}

.lang-switch ul {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.lang-switch li {
  margin: 0;
  padding: 0;
}

.lang-switch a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.2rem 0.4rem;
  color: var(--purple-dark);
  text-decoration: none;
  font-size: 0.9rem;
}

.lang-switch a:hover {
  text-decoration: underline;
  color: var(--purple);
}

.lang-switch a[aria-current="true"] {
  font-weight: 700;
  color: var(--ink);
  text-decoration: underline;
}

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

[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

[dir="rtl"] .site-header,
[dir="rtl"] .site-footer {
  direction: rtl;
}

[dir="rtl"] .site-header nav,
[dir="rtl"] .lang-switch ul {
  direction: rtl;
}

[dir="rtl"] [dir="ltr"] {
  text-align: left;
}

[dir="rtl"] .qr-actions {
  flex-direction: row-reverse;
}
