:root {
  color-scheme: light;
  --bg: #f3f7fb;
  --bg-top: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --surface-strong: #eef5ff;
  --text: #0b1220;
  --muted: #5d6879;
  --faint: #8895a8;
  --line: #d8e2ee;
  --line-strong: #c7d4e4;
  --blue: #0b6fff;
  --blue-dark: #075ad1;
  --blue-soft: #eef5ff;
  --green: #17b37e;
  --green-dark: #0c8e63;
  --green-soft: #ebfbf5;
  --amber: #f2aa18;
  --amber-soft: #fff7df;
  --danger: #c2410c;
  --shadow: 0 36px 110px rgba(13, 24, 42, 0.16);
  --soft-shadow: 0 18px 44px rgba(13, 24, 42, 0.1);
  --radius: 8px;
}

body.dark {
  color-scheme: dark;
  --bg: #10161f;
  --bg-top: #151c27;
  --surface: #161f2b;
  --surface-soft: #121923;
  --surface-strong: #10233e;
  --text: #f5f8fc;
  --muted: #a7b3c4;
  --faint: #7f8b9d;
  --line: #2b394b;
  --line-strong: #3a4a60;
  --blue: #5ba4ff;
  --blue-dark: #89bfff;
  --blue-soft: #142943;
  --green: #42d29c;
  --green-dark: #65e1b5;
  --green-soft: #12342b;
  --amber: #f4be3d;
  --amber-soft: #352917;
  --shadow: 0 36px 110px rgba(0, 0, 0, 0.42);
  --soft-shadow: 0 18px 44px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(90deg, rgba(11, 111, 255, 0.055) 0 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 179, 126, 0.045) 0 1px, transparent 1px),
    linear-gradient(180deg, var(--bg-top) 0, var(--bg) 520px, var(--bg) 100%);
  background-size: 56px 56px, 56px 56px, auto;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
.drop-zone:focus-visible {
  outline: 3px solid rgba(11, 111, 255, 0.24);
  outline-offset: 3px;
}

.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;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1280px) / 2));
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 91%, transparent);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
  padding: 6px;
  border: 1px solid color-mix(in srgb, var(--blue) 32%, var(--line));
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--blue);
  box-shadow: var(--soft-shadow);
}

.brand-mark span {
  border: 3px solid currentColor;
  border-radius: 4px;
}

.brand-mark span:nth-child(4) {
  color: var(--green);
}

.brand strong {
  display: block;
  font-size: 24px;
  font-weight: 950;
  line-height: 1;
}

.brand small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 760;
}

.icon-button {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--soft-shadow);
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.icon-button:hover {
  border-color: var(--blue);
  transform: translateY(-1px);
}

.page {
  width: min(calc(100% - 48px), 1280px);
  margin: 0 auto;
  padding: 58px 0 84px;
}

.intro {
  display: grid;
  gap: 16px;
  max-width: 820px;
  margin-bottom: 34px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(64px, 8vw, 108px);
  line-height: 0.95;
  font-weight: 950;
}

.intro p,
.panel-title p,
.active-url {
  color: var(--muted);
}

.intro p {
  font-size: clamp(19px, 2.2vw, 25px);
  line-height: 1.45;
  font-weight: 620;
}

.tool-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 96%, var(--surface-soft));
  box-shadow: var(--shadow);
}

.tool-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: linear-gradient(90deg, var(--blue), var(--green) 58%, var(--amber));
}

.mode-tabs {
  min-height: 88px;
  display: flex;
  align-items: end;
  gap: 38px;
  padding: 6px 42px 0;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-soft) 75%, var(--surface)) 0, var(--surface) 100%);
}

.mode-tab {
  position: relative;
  min-height: 82px;
  display: inline-flex;
  align-items: center;
  border: 0;
  border-radius: 0;
  padding: 0 2px;
  background: transparent;
  color: var(--muted);
  font-size: 21px;
  font-weight: 900;
  transition:
    color 160ms ease,
    transform 160ms ease;
}

.mode-tab::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 4px;
  border-radius: 999px 999px 0 0;
  background: transparent;
}

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

.mode-tab.is-active {
  color: var(--blue);
}

.mode-tab.is-active::after {
  background: var(--blue);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--blue) 16%, transparent);
}

.tool-panel {
  position: relative;
  padding: 42px;
}

.decode-layout,
.encode-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 34px;
  align-items: stretch;
}

.encode-layout {
  grid-template-columns: minmax(360px, 0.86fr) minmax(420px, 1.14fr);
}

.panel-main,
.encode-controls {
  min-width: 0;
}

.encode-controls {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.panel-title {
  display: grid;
  gap: 10px;
  margin-bottom: 26px;
}

.panel-title h2 {
  font-size: clamp(32px, 4vw, 44px);
  line-height: 1.12;
  font-weight: 950;
}

.panel-title p {
  font-size: 18px;
  line-height: 1.48;
  font-weight: 650;
}

.drop-zone {
  position: relative;
  min-height: 460px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 20px;
  padding: 42px;
  border: 2px dashed color-mix(in srgb, var(--blue) 66%, var(--line));
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(11, 111, 255, 0.06) 0 1px, transparent 1px),
    linear-gradient(180deg, rgba(11, 111, 255, 0.05) 0 1px, transparent 1px),
    var(--blue-soft);
  background-size: 36px 36px, 36px 36px, auto;
  text-align: center;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    transform 160ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging,
.drop-zone.is-focused {
  border-color: var(--blue);
  transform: translateY(-1px);
}

.drop-icon {
  width: 86px;
  height: 86px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--blue) 24%, var(--line));
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--blue);
  box-shadow: var(--soft-shadow);
}

.drop-icon svg {
  width: 38px;
  height: 38px;
}

.drop-zone strong {
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 950;
  line-height: 1.22;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.button-row.left {
  justify-content: flex-start;
}

.primary-button,
.secondary-button,
.download-button {
  min-height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: var(--radius);
  padding: 0 26px;
  font-size: 16px;
  font-weight: 870;
  text-decoration: none;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.primary-button {
  border: 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--blue) 88%, white), var(--blue));
  color: #fff;
  box-shadow: 0 16px 32px rgba(11, 111, 255, 0.24);
}

.primary-button:hover {
  background: var(--blue-dark);
  transform: translateY(-1px);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.secondary-button:hover {
  border-color: var(--blue);
  color: var(--blue);
  transform: translateY(-1px);
}

.download-button {
  border: 1px solid color-mix(in srgb, var(--green) 42%, var(--line));
  background: var(--green-soft);
  color: var(--green-dark);
}

.download-button:hover {
  border-color: var(--green);
  transform: translateY(-1px);
}

.wide {
  width: 100%;
}

.decode-preview {
  margin-top: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.decode-preview img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
}

.result-panel {
  min-width: 0;
  min-height: 460px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-soft) 78%, var(--surface)) 0, var(--surface) 100%);
}

.result-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.result-panel-head span {
  font-size: 18px;
  font-weight: 930;
}

#decodeStatus {
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
  white-space: nowrap;
}

#decodeStatus.is-error {
  color: var(--danger);
}

.result-box {
  display: grid;
  gap: 14px;
  padding: 18px 0 0;
}

.result-box span {
  color: var(--green);
  font-size: 14px;
  font-weight: 950;
}

#decodedLink,
#decodedText {
  color: var(--text);
  font-size: 20px;
  font-weight: 850;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.result-box:not([hidden]) + .empty-result {
  display: none;
}

.empty-result {
  flex: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  min-height: 320px;
  color: var(--muted);
  text-align: center;
}

.empty-result strong {
  max-width: 260px;
  font-size: 18px;
  line-height: 1.5;
}

.empty-qr {
  width: 152px;
  height: 152px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.empty-qr span {
  border: 9px solid color-mix(in srgb, var(--faint) 54%, transparent);
  border-radius: 5px;
}

.empty-qr span:nth-child(4) {
  width: 28px;
  height: 28px;
  align-self: center;
  justify-self: center;
  border-color: color-mix(in srgb, var(--green) 70%, var(--faint));
}

.qr-form {
  display: grid;
  gap: 16px;
}

.url-field {
  position: relative;
}

input {
  width: 100%;
  min-height: 70px;
  padding: 0 60px 0 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 19px;
  font-weight: 650;
  outline: none;
  box-shadow: 0 1px 0 rgba(13, 24, 42, 0.03);
}

input::placeholder {
  color: var(--faint);
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(11, 111, 255, 0.12);
}

.clear-input {
  position: absolute;
  top: 50%;
  right: 9px;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  transform: translateY(-50%);
}

.clear-input:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.qr-preview {
  min-width: 0;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 20px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(11, 111, 255, 0.04) 0 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 179, 126, 0.04) 0 1px, transparent 1px),
    color-mix(in srgb, var(--surface-soft) 70%, var(--surface));
  background-size: 34px 34px, 34px 34px, auto;
}

.qr-frame {
  width: min(100%, 430px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.qr-code,
.qr-code canvas,
.qr-code img {
  width: 320px;
  height: 320px;
  image-rendering: pixelated;
}

.active-url {
  width: 100%;
  font-size: 16px;
  line-height: 1.5;
  text-align: center;
  overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (max-width: 980px) {
  .decode-layout,
  .encode-layout {
    grid-template-columns: 1fr;
  }

  .result-panel {
    min-height: 320px;
  }

  .empty-result {
    min-height: 220px;
  }
}

@media (max-width: 640px) {
  .site-header {
    min-height: 68px;
    padding: 0 12px;
  }

  .brand {
    gap: 10px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    gap: 4px;
    padding: 5px;
  }

  .brand-mark span {
    border-width: 2.5px;
  }

  .brand small {
    display: none;
  }

  .brand strong {
    font-size: 20px;
  }

  .icon-button {
    width: 44px;
    height: 44px;
  }

  .page {
    width: calc(100% - 20px);
    padding: 38px 0 56px;
  }

  .intro {
    gap: 10px;
    margin-bottom: 22px;
  }

  h1 {
    font-size: clamp(52px, 16vw, 72px);
  }

  .intro p {
    font-size: 17px;
  }

  .mode-tabs {
    min-height: 66px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    padding: 6px 18px 0;
  }

  .mode-tab {
    min-height: 60px;
    justify-content: center;
    font-size: 17px;
  }

  .tool-panel {
    padding: 22px 18px;
  }

  .panel-title {
    margin-bottom: 18px;
  }

  .panel-title h2 {
    font-size: 30px;
  }

  .panel-title p {
    font-size: 16px;
  }

  .drop-zone {
    min-height: 330px;
    gap: 16px;
    padding: 26px 16px;
  }

  .drop-icon {
    width: 70px;
    height: 70px;
  }

  .drop-icon svg {
    width: 32px;
    height: 32px;
  }

  .drop-zone strong {
    font-size: 24px;
  }

  .button-row > button {
    flex: 1 1 100%;
  }

  .primary-button,
  .secondary-button,
  .download-button {
    min-height: 54px;
    padding: 0 18px;
    font-size: 15px;
  }

  .result-panel,
  .qr-preview {
    padding: 20px;
  }

  .result-panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  input {
    min-height: 60px;
    padding-left: 16px;
    font-size: 16px;
  }

  .qr-frame {
    width: min(100%, 312px);
  }

  .qr-code,
  .qr-code canvas,
  .qr-code img {
    width: 242px;
    height: 242px;
  }
}
