:root {
  --ink: #17283b;
  --muted: #66788c;
  --line: #dce6e5;
  --soft-line: #e8efee;
  --teal: #079879;
  --teal-dark: #08745f;
  --teal-soft: #e8f8f4;
  --panel: #ffffff;
  --surface: #f6faf9;
  color: var(--ink);
  background: #f3f7f6;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-width: 320px;
  min-height: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(7, 152, 121, 0.07), rgba(7, 152, 121, 0) 34%) 100% 0 / 520px 360px no-repeat,
    linear-gradient(180deg, #fbfdfd 0, #f3f7f6 56%, #edf3f2 100%);
}

button,
textarea,
select,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

svg {
  flex: 0 0 auto;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(1240px, calc(100% - 56px));
  margin: 0 auto;
  padding: 36px 0 46px;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 164px;
  gap: 32px;
}

.header-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 16px;
  color: var(--teal-dark);
  font-size: 15px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  color: var(--ink);
}

h1 {
  font-size: 44px;
  line-height: 1.2;
  font-weight: 800;
}

h2 {
  margin-top: 7px;
  font-size: 18px;
  line-height: 1.4;
}

.subtitle {
  margin: 17px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  color: #526779;
  font-size: 14px;
  white-space: nowrap;
}

.local-badge svg,
.label-with-icon svg,
.primary-button svg,
.secondary-button svg,
.danger-button svg,
.privacy-note svg,
.utility-button svg,
.icon-button svg,
.empty-state svg,
.batch-empty svg,
.history-empty svg,
.result-label svg,
.notice > svg,
.tab-button svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.local-badge svg {
  width: 20px;
  height: 20px;
  color: #286d68;
}

.workspace {
  overflow: visible;
  border: 1px solid #dbe5e3;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 22px 58px rgba(28, 60, 55, 0.1);
}

.tab-list {
  display: flex;
  min-height: 62px;
  align-items: stretch;
  gap: 4px;
  padding: 0 28px;
  border-bottom: 1px solid var(--soft-line);
  background: #fbfcfc;
  border-radius: 8px 8px 0 0;
}

.tab-button {
  position: relative;
  display: inline-flex;
  min-width: 136px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 18px;
  border: 0;
  background: transparent;
  color: #6a7c8d;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.tab-button::after {
  position: absolute;
  right: 18px;
  bottom: 0;
  left: 18px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--teal);
  content: "";
  opacity: 0;
  transform: scaleX(0.5);
  transition: opacity 160ms ease, transform 160ms ease;
}

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

.tab-button.is-active {
  color: var(--teal-dark);
}

.tab-button.is-active::after {
  opacity: 1;
  transform: scaleX(1);
}

.tab-button svg {
  width: 19px;
  height: 19px;
}

.count-badge,
.result-chip {
  display: inline-grid;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  place-items: center;
  border-radius: 11px;
  background: #e7efed;
  color: #5b706d;
  font-size: 11px;
  line-height: 1;
}

.tab-button.is-active .count-badge {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.tab-view {
  min-width: 0;
}

.single-layout,
.batch-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(430px, 0.92fr);
}

.controls,
.batch-controls {
  display: flex;
  min-width: 0;
  min-height: 760px;
  flex-direction: column;
  gap: 26px;
  padding: 38px 36px 34px;
  border-right: 1px solid var(--soft-line);
}

.field-group {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 11px;
}

.field-group label,
.field-label-row,
.checkbox-row {
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
}

.field-label-row {
  display: flex;
  min-height: 22px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.label-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.label-with-icon svg {
  width: 21px;
  height: 21px;
  color: var(--teal);
}

.help-wrap {
  position: relative;
  display: inline-flex;
  z-index: 3;
}

.help-button {
  display: grid;
  width: 21px;
  height: 21px;
  padding: 0;
  place-items: center;
  border: 1px solid #9bb0ad;
  border-radius: 50%;
  background: #ffffff;
  color: #66807a;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.help-button:hover,
.help-button:focus-visible,
.help-button[aria-expanded="true"] {
  border-color: var(--teal);
  outline: none;
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.help-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 8;
  width: min(330px, calc(100vw - 40px));
  padding: 14px 15px;
  border: 1px solid #cfe3de;
  border-radius: 7px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(26, 61, 54, 0.16);
  color: #506776;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.75;
  opacity: 0;
  pointer-events: none;
  transform: translateY(5px);
  visibility: hidden;
  transition: opacity 140ms ease, transform 140ms ease, visibility 140ms ease;
}

.help-popover::after {
  position: absolute;
  right: 5px;
  bottom: -6px;
  width: 10px;
  height: 10px;
  border-right: 1px solid #cfe3de;
  border-bottom: 1px solid #cfe3de;
  background: #ffffff;
  content: "";
  transform: rotate(45deg);
}

.help-popover strong {
  color: var(--teal-dark);
}

.help-wrap:hover .help-popover,
.help-wrap:focus-within .help-popover,
.help-popover.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  visibility: visible;
}

textarea,
select,
.note-input {
  width: 100%;
  border: 1px solid #c9dad7;
  border-radius: 7px;
  outline: none;
  background: #ffffff;
  color: #1f3244;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
  min-height: 218px;
  padding: 18px;
  resize: vertical;
  font-size: 15px;
  line-height: 1.65;
  word-break: break-all;
}

.batch-textarea {
  min-height: 280px;
  font-family: Consolas, "Microsoft YaHei UI", sans-serif;
  font-size: 13px;
}

textarea::placeholder,
.note-input::placeholder {
  color: #8796a6;
  opacity: 1;
}

select {
  height: 52px;
  padding: 0 42px 0 16px;
  cursor: pointer;
}

textarea:focus,
select:focus,
.note-input:focus {
  border-color: #3cbca3;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(7, 152, 121, 0.1);
}

textarea.invalid {
  border-color: #d0574b;
  box-shadow: 0 0 0 3px rgba(208, 87, 75, 0.1);
}

.field-meta {
  display: flex;
  min-height: 19px;
  justify-content: space-between;
  gap: 18px;
  color: #718295;
  font-size: 12px;
}

.field-meta span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.field-meta span:last-child {
  flex: 0 0 auto;
}

.field-meta strong {
  color: inherit;
}

.field-meta .error {
  color: #b84136;
}

.options-row,
.batch-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
}

.compact {
  gap: 10px;
}

.radio-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.radio-option {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 62px;
  align-items: center;
  gap: 11px;
  padding: 10px 13px;
  border: 1px solid #d5e0de;
  border-radius: 7px;
  background: #ffffff;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.radio-option:has(input:checked) {
  border-color: #4ab99f;
  background: #f4fbf9;
  box-shadow: 0 0 0 2px rgba(7, 152, 121, 0.08);
}

.radio-option input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--teal);
}

.radio-option span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.radio-option strong {
  color: #274036;
  font-size: 14px;
}

.radio-option small {
  overflow: hidden;
  color: #7a8c98;
  font-size: 11px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-radios .radio-option {
  min-height: 55px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  font-weight: 500;
}

.checkbox-row input {
  width: 19px;
  height: 19px;
  margin: 0;
  accent-color: var(--teal);
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  border-radius: 7px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 160ms ease, transform 100ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.primary-button {
  width: 100%;
  margin-top: auto;
  border: 0;
  background: linear-gradient(90deg, #078f71 0%, #25b895 100%);
  box-shadow: 0 9px 22px rgba(7, 143, 113, 0.2);
  color: #ffffff;
  font-size: 16px;
}

.primary-button:hover {
  filter: brightness(0.96);
  box-shadow: 0 11px 26px rgba(7, 143, 113, 0.24);
}

.primary-button:active,
.secondary-button:active,
.danger-button:active {
  transform: translateY(1px);
}

.primary-button svg,
.secondary-button svg,
.danger-button svg {
  width: 21px;
  height: 21px;
}

.secondary-button {
  width: 100%;
  border: 1px solid #bdd9d3;
  background: #ffffff;
  color: var(--teal-dark);
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--teal);
  background: #f5fbfa;
}

.secondary-button:disabled,
.danger-button:disabled {
  border-color: #dde5e3;
  background: #f5f7f7;
  color: #a8b4b2;
  cursor: not-allowed;
}

.danger-button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid #e5cbc7;
  background: #ffffff;
  color: #a34f43;
  font-size: 13px;
}

.danger-button:hover:not(:disabled) {
  border-color: #d58c82;
  background: #fff8f7;
}

.privacy-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 20px;
  margin: -14px 0 0;
  color: #6e8292;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.privacy-note svg {
  width: 17px;
  height: 17px;
  color: var(--teal);
}

.preview-panel,
.batch-output {
  display: flex;
  min-width: 0;
  min-height: 760px;
  flex-direction: column;
  padding: 32px 36px 34px;
  background: #fbfcfc;
}

.preview-toolbar,
.section-heading,
.history-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.preview-toolbar {
  min-height: 58px;
}

.preview-heading {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 8px;
}

.preview-label {
  color: #65778a;
  font-size: 13px;
}

#qr-id {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.utility-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
}

.utility-button {
  display: inline-flex;
  min-width: 82px;
  height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid #d7e2e0;
  border-radius: 7px;
  background: #ffffff;
  color: #40586a;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.utility-button:hover:not(:disabled) {
  border-color: #56baa5;
  background: #f6fcfa;
  color: var(--teal-dark);
}

.utility-button:disabled {
  color: #a8b3b8;
  cursor: not-allowed;
}

.utility-button svg {
  width: 19px;
  height: 19px;
  color: var(--teal-dark);
}

.utility-button:disabled svg {
  color: #a8b3b8;
}

.qr-stage {
  position: relative;
  display: grid;
  width: min(100%, 432px);
  aspect-ratio: 1;
  margin: 22px auto 30px;
  place-items: center;
  border: 1px solid #dbe5e4;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(34, 64, 60, 0.08);
}

#qr-canvas {
  display: none;
  width: calc(100% - 52px);
  height: calc(100% - 52px);
  image-rendering: pixelated;
}

.empty-state,
.batch-empty,
.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: #668095;
  text-align: center;
}

.empty-state svg,
.batch-empty svg,
.history-empty svg {
  width: 66px;
  height: 66px;
  color: #7acdbb;
  stroke-width: 1.45;
}

.empty-state p,
.batch-empty p,
.history-empty p {
  margin: 0;
  font-size: 14px;
}

.result-details {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-top: auto;
}

.result-details > div {
  display: flex;
  min-width: 0;
  min-height: 92px;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px;
  border: 1px solid #dce6e4;
  border-radius: 7px;
  background: #ffffff;
  box-shadow: 0 6px 16px rgba(31, 65, 60, 0.05);
}

.result-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #64788a;
  font-size: 13px;
}

.result-label svg {
  width: 18px;
  height: 18px;
  color: var(--teal);
}

.result-details strong {
  min-width: 0;
  overflow: hidden;
  color: #314759;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-controls {
  min-height: 720px;
}

.batch-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 12px;
  margin-top: auto;
}

.batch-actions .primary-button {
  margin-top: 0;
}

.batch-output {
  min-height: 720px;
}

.output-heading {
  min-height: 54px;
}

.result-chip {
  flex: 0 0 auto;
  min-width: 48px;
  color: var(--teal-dark);
}

.batch-empty {
  flex: 1;
  min-height: 430px;
}

.batch-results {
  display: grid;
  gap: 12px;
  max-height: 610px;
  margin-top: 18px;
  overflow: auto;
  scrollbar-width: thin;
}

.batch-result-item {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid #dce5e3;
  border-radius: 7px;
  background: #ffffff;
}

.batch-result-item canvas {
  display: block;
  width: 86px;
  height: 86px;
  border: 1px solid #edf1f0;
  image-rendering: pixelated;
}

.batch-item-info {
  min-width: 0;
}

.batch-item-info strong,
.batch-item-info span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-item-info strong {
  color: #2e4555;
  font-size: 13px;
}

.batch-item-info .batch-link {
  margin-top: 6px;
  color: #718392;
  font-size: 11px;
}

.batch-item-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
}

.status-badge {
  display: inline-flex !important;
  width: fit-content;
  padding: 3px 7px;
  border-radius: 10px;
  background: var(--teal-soft);
  color: var(--teal-dark) !important;
  font-size: 10px !important;
}

.status-badge.reused {
  background: #edf1f5;
  color: #607285 !important;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  border: 1px solid #d8e2e0;
  border-radius: 6px;
  background: #ffffff;
  color: var(--teal-dark);
  cursor: pointer;
}

.icon-button:hover {
  border-color: #5ab9a5;
  background: #f4fbf9;
}

.icon-button.danger {
  color: #a34f43;
}

.icon-button.danger:hover {
  border-color: #d58c82;
  background: #fff8f7;
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.history-view {
  min-height: 660px;
  padding: 34px 36px 38px;
}

.history-toolbar {
  align-items: center;
  margin-bottom: 26px;
}

.history-table-wrap {
  overflow-x: auto;
  border: 1px solid #dce5e3;
  border-radius: 7px;
}

.history-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  table-layout: fixed;
  background: #ffffff;
}

.history-table th,
.history-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #e6edeb;
  text-align: left;
  vertical-align: middle;
}

.history-table th {
  background: #f6f9f8;
  color: #617586;
  font-size: 12px;
  font-weight: 700;
}

.history-table th:nth-child(1) {
  width: 37%;
}

.history-table th:nth-child(2) {
  width: 18%;
}

.history-table th:nth-child(3) {
  width: 19%;
}

.history-table th:nth-child(4) {
  width: 26%;
}

.history-table tbody tr:last-child td {
  border-bottom: 0;
}

.history-link-cell {
  min-width: 0;
}

.history-link-cell strong,
.history-link-cell span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-link-cell strong {
  color: #314859;
  font-size: 13px;
}

.history-link-cell span {
  margin-top: 6px;
  color: #788998;
  font-size: 11px;
}

.history-qr-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-qr-cell canvas {
  display: block;
  width: 72px;
  height: 72px;
  border: 1px solid #edf1f0;
  image-rendering: pixelated;
}

.history-date {
  color: #5d7181;
  font-size: 12px;
  line-height: 1.6;
}

.note-cell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  align-items: center;
  gap: 8px;
}

.note-input {
  height: 40px;
  padding: 0 11px;
  font-size: 12px;
}

.history-empty {
  min-height: 420px;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 28px 28px;
  padding: 18px 20px;
  border: 1px solid #dceeea;
  border-radius: 7px;
  background: #f2faf8;
  color: #546b7a;
}

.notice > svg {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  color: var(--teal);
}

.notice p {
  min-width: 0;
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
}

.notice strong {
  color: var(--teal-dark);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 20;
  max-width: calc(100% - 32px);
  padding: 11px 17px;
  transform: translate(-50%, 16px);
  border-radius: 6px;
  background: #17342d;
  box-shadow: 0 10px 28px rgba(19, 43, 37, 0.22);
  color: #ffffff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (max-width: 980px) {
  .app-shell {
    width: min(760px, calc(100% - 32px));
    padding-top: 28px;
  }

  .app-header {
    min-height: 150px;
  }

  h1 {
    font-size: 38px;
  }

  .single-layout,
  .batch-layout {
    grid-template-columns: 1fr;
  }

  .controls,
  .batch-controls {
    min-height: 700px;
    border-right: 0;
    border-bottom: 1px solid var(--soft-line);
  }

  .preview-panel,
  .batch-output {
    min-height: 700px;
  }

  .batch-results {
    max-height: none;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: 100%;
    padding: 22px 12px 28px;
  }

  .app-header {
    min-height: 170px;
    flex-direction: column;
    justify-content: flex-start;
    gap: 14px;
  }

  .eyebrow {
    margin-bottom: 10px;
  }

  h1 {
    font-size: 30px;
  }

  .subtitle {
    margin-top: 11px;
    font-size: 14px;
  }

  .local-badge {
    margin-top: 0;
  }

  .workspace {
    border-radius: 7px;
  }

  .tab-list {
    min-height: 58px;
    padding: 0 8px;
    justify-content: stretch;
  }

  .tab-button {
    min-width: 0;
    flex: 1 1 0;
    gap: 5px;
    padding: 0 7px;
    font-size: 12px;
  }

  .tab-button::after {
    right: 6px;
    left: 6px;
  }

  .tab-button svg {
    width: 17px;
    height: 17px;
  }

  .count-badge {
    min-width: 20px;
    height: 19px;
    padding: 0 5px;
  }

  .controls,
  .batch-controls,
  .preview-panel,
  .batch-output {
    min-height: auto;
    padding: 26px 20px;
  }

  .controls,
  .batch-controls {
    gap: 24px;
  }

  textarea {
    min-height: 190px;
    font-size: 14px;
  }

  .batch-textarea {
    min-height: 250px;
  }

  .options-row,
  .batch-options {
    grid-template-columns: 1fr;
  }

  .radio-option {
    padding: 9px 10px;
  }

  .primary-button {
    margin-top: 10px;
  }

  .privacy-note {
    margin-top: -10px;
  }

  .preview-toolbar {
    align-items: flex-start;
  }

  .utility-actions {
    gap: 7px;
  }

  .utility-button {
    min-width: 44px;
    width: 44px;
    padding: 0;
    font-size: 0;
  }

  .utility-button svg {
    width: 20px;
    height: 20px;
  }

  .qr-stage {
    width: 100%;
    margin: 20px 0 24px;
  }

  .result-details {
    gap: 10px;
  }

  .result-details > div {
    min-height: 88px;
    padding: 16px 14px;
  }

  .batch-actions {
    grid-template-columns: 1fr;
  }

  .batch-result-item {
    grid-template-columns: 76px minmax(0, 1fr) 36px;
    gap: 10px;
  }

  .batch-result-item canvas {
    width: 70px;
    height: 70px;
  }

  .history-view {
    min-height: 580px;
    padding: 26px 20px 30px;
  }

  .history-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .notice {
    margin: 0 12px 12px;
    padding: 16px;
  }

  .help-popover {
    position: fixed;
    right: 16px;
    bottom: 24px;
    left: 16px;
    width: auto;
  }

  .help-popover::after {
    display: none;
  }
}

@media (max-width: 400px) {
  .field-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .radio-group,
  .result-details {
    grid-template-columns: 1fr;
  }

  #qr-canvas {
    width: calc(100% - 36px);
    height: calc(100% - 36px);
  }

  .tab-button {
    flex-direction: column;
    gap: 3px;
    padding-top: 5px;
    line-height: 1.1;
  }

  .tab-button .count-badge {
    position: absolute;
    top: 5px;
    right: 5px;
  }
}


/* Final sticker editor and portrait preview */
.controls,
.preview-panel {
  min-height: 1010px;
}

.sticker-editor {
  gap: 13px;
}

.field-hint {
  color: #7a8c98;
  font-size: 11px;
  font-weight: 400;
}

.sticker-editor > label,
.sticker-text-grid label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
  color: #5c7180;
  font-size: 12px;
  font-weight: 600;
}

.sticker-text-grid {
  display: grid;
  gap: 12px;
}

.brand-text-grid {
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
}

.bottom-text-grid {
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.5fr) minmax(0, 0.65fr);
}

.batch-brand-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.text-input {
  width: 100%;
  height: 44px;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid #c9dad7;
  border-radius: 7px;
  outline: none;
  background: #ffffff;
  color: #1f3244;
  font-size: 13px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.text-input:focus {
  border-color: #3cbca3;
  box-shadow: 0 0 0 3px rgba(7, 152, 121, 0.1);
}

.qr-stage {
  width: min(100%, 402px);
  aspect-ratio: 5 / 6;
  margin-top: 18px;
}

#qr-canvas {
  width: calc(100% - 28px);
  height: auto;
  max-height: calc(100% - 28px);
}

.batch-controls,
.batch-output {
  min-height: 930px;
}

.batch-result-item {
  grid-template-columns: 82px minmax(0, 1fr) 38px;
}

.batch-result-item canvas {
  width: 74px;
  height: 89px;
  object-fit: contain;
  background: #eaf1ef;
}

.history-qr-cell canvas {
  width: 64px;
  height: 77px;
  object-fit: contain;
  background: #eaf1ef;
}

@media (max-width: 980px) {
  .controls,
  .preview-panel,
  .batch-controls,
  .batch-output {
    min-height: auto;
  }
}

@media (max-width: 680px) {
  .brand-text-grid,
  .batch-brand-grid {
    grid-template-columns: 1fr;
  }

  .bottom-text-grid {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.35fr) minmax(0, 0.7fr);
  }

  .qr-stage {
    width: min(100%, 390px);
    margin-right: auto;
    margin-left: auto;
  }
}

@media (max-width: 430px) {
  .bottom-text-grid {
    grid-template-columns: 1fr;
  }
}
