:root {
  --bg: #e8edf2;
  --panel: #f7f9fb;
  --ink: #1a2332;
  --muted: #5c6b7a;
  --line: #c9d3de;
  --accent: #0b6e4f;
  --accent-ink: #fff;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(26, 35, 50, 0.08);
  --font: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #d7e6ef 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #dfece4 0%, transparent 50%),
    var(--bg);
}

body {
  min-height: 100vh;
}

.app {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 16px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
  align-items: stretch;
  box-sizing: border-box;
  overflow-x: clip;
}

.panel {
  position: relative;
  z-index: 2;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-content: flex-start;
  gap: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.brand {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  line-height: 1.25;
  text-align: center;
}

.sub {
  margin: 2px 0 10px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  text-align: center;
}

.field {
  margin-bottom: 8px;
}

.field label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.wm-toggle {
  display: flex !important;
  align-items: center;
  gap: 6px;
  margin: 0 !important;
  font-size: 0.82rem !important;
  color: var(--ink) !important;
  cursor: pointer;
}

.wm-toggle input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

.wm-opts {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}

.wm-opts.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.wm-text {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.86rem;
}

.wm-slider {
  display: grid !important;
  grid-template-columns: 3.2em 1fr;
  align-items: center;
  gap: 8px;
  margin: 0 !important;
  font-size: 0.75rem !important;
  color: var(--muted) !important;
}

.wm-slider input[type='range'] {
  width: 100%;
  accent-color: var(--accent);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.size-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.size-input {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.size-input span {
  flex: 0 0 auto;
}

.size-input input[type="number"] {
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
}

.size-x {
  color: var(--muted);
  font-size: 0.85rem;
}

.size-hint {
  margin: 4px 0 0;
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.3;
}

#btnSwapWH {
  flex: 0 0 auto;
  padding: 6px 8px;
  font-size: 0.95rem;
  line-height: 1;
}

select,
button,
input[type="range"],
input[type="number"] {
  font: inherit;
}

select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 0.88rem;
}

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: #eef2f6;
  padding: 3px;
  border-radius: 10px;
}

.seg.seg-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.seg button {
  border: 0;
  background: transparent;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.86rem;
}

.seg button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.upload {
  border: 1.5px dashed #9db0c2;
  border-radius: 10px;
  padding: 8px 10px;
  text-align: center;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.upload:hover,
.upload.dragover {
  border-color: var(--accent);
  background: #f2faf6;
}

.upload strong {
  display: block;
  margin-bottom: 2px;
  font-size: 0.88rem;
}

.upload span {
  color: var(--muted);
  font-size: 0.75rem;
}

.upload input {
  display: none;
}

.slots {
  display: grid;
  gap: 6px;
  flex: 0 0 auto;
}

.preview-mount {
  display: none;
  width: 100%;
  min-width: 0;
}

.preview-mount:not([hidden]) {
  display: block;
}

.mobile-back-edit {
  display: none;
  width: 100%;
  margin: 0 0 8px;
  min-height: 40px;
}

.preview-desktop {
  position: relative;
  z-index: 1;
  min-width: 0;
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  overflow: hidden;
}

.slot {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 8px;
}

.slot-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 0.8rem;
}

.slot-actions {
  display: flex;
  gap: 2px;
}

.thumb-wrap {
  position: relative;
  width: 100%;
  max-width: 260px;
  aspect-ratio: 85.6 / 54;
  height: auto;
  margin: 0 auto;
  background: #eef2f6;
  border-radius: 6px;
  overflow: hidden;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #fff;
}

.thumb-wrap .empty {
  color: var(--muted);
  font-size: 0.75rem;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 0.86rem;
}

.btn:hover {
  border-color: #9db0c2;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.primary:hover {
  filter: brightness(1.05);
}

.btn.ghost {
  background: transparent;
  padding: 3px 5px;
  font-size: 0.72rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
  padding-top: 0;
  flex: 0 0 auto;
}

.actions .btn:last-child {
  grid-column: 1 / -1;
}

.panel-credit {
  margin: auto 0 0;
  padding-top: 12px;
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.4;
  flex: 0 0 auto;
}

.panel-credit a {
  color: var(--accent);
  text-decoration: none;
}

.panel-credit a:hover {
  text-decoration: underline;
}

.hint {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

.hint code {
  font-size: 0.72rem;
  padding: 0 3px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--muted) 14%, transparent);
}

.preview-pane {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.preview-toolbar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.a4-wrap {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  overflow: hidden;
  /* 未跑 JS 时先按比例占位，避免整页被撑开 */
  aspect-ratio: 210 / 297;
  container-type: inline-size;
  container-name: a4;
}

.a4-status {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92%, 440px);
  padding: 9px 14px 9px 12px;
  border-radius: 8px;
  color: var(--accent);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  box-shadow: 0 8px 22px rgba(26, 35, 50, 0.1);
  pointer-events: none;
  transform: translate3d(-50%, 0, 0);
  animation: status-in 0.2s ease-out both;
}

.a4-status[hidden] {
  display: none !important;
}

.a4-status.error {
  color: var(--danger);
  border-color: #f0c4c0;
  background: rgba(255, 246, 245, 0.96);
}

.a4-status.busy {
  color: #d7f5e8;
  letter-spacing: 0.04em;
  background: #0c241c;
  border-color: rgba(80, 230, 170, 0.65);
  box-shadow: 0 8px 24px rgba(8, 28, 22, 0.35);
}

.a4-status.busy::before,
.a4-status.busy::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  border: 1.5px solid rgba(90, 220, 160, 0.75);
  pointer-events: none;
}

.a4-status.busy::before {
  top: -1px;
  left: -1px;
  border-right: 0;
  border-bottom: 0;
}

.a4-status.busy::after {
  right: -1px;
  bottom: -1px;
  border-left: 0;
  border-top: 0;
}

.a4-status-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.a4-status-led {
  display: none;
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #3dcf96;
  box-shadow: 0 0 8px rgba(61, 207, 150, 0.7);
}

.a4-status.busy .a4-status-led {
  display: inline-block;
  animation: status-led 1s ease-in-out infinite;
  will-change: opacity;
}

.a4-status.error .a4-status-led {
  display: inline-block;
  background: #ff7a6a;
  box-shadow: 0 0 8px rgba(255, 122, 106, 0.7);
  animation: none;
}

.a4-status-bars {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
  margin-left: 2px;
}

.a4-status.busy .a4-status-bars {
  display: inline-flex;
}

.a4-status-bars i {
  display: block;
  width: 2px;
  height: 12px;
  border-radius: 1px;
  background: #5ce0a8;
  transform-origin: bottom center;
  transform: scaleY(0.35);
  animation: status-bar 0.9s ease-in-out infinite;
  will-change: transform, opacity;
}

.a4-status-bars i:nth-child(2) {
  animation-delay: 0.12s;
}
.a4-status-bars i:nth-child(3) {
  animation-delay: 0.24s;
}
.a4-status-bars i:nth-child(4) {
  animation-delay: 0.36s;
}

@keyframes status-in {
  from {
    opacity: 0;
    transform: translate3d(-50%, -6px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(-50%, 0, 0);
  }
}

@keyframes status-led {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

@keyframes status-bar {
  0%,
  100% {
    transform: scaleY(0.35);
    opacity: 0.45;
  }
  50% {
    transform: scaleY(1);
    opacity: 1;
  }
}

.a4-scale {
  /* 绝对定位：794px 画布不参与文档流，手机不会出现横向大页面 */
  position: absolute;
  top: 0;
  left: 0;
  width: 794px;
  height: 1123px;
  transform-origin: top left;
  /* JS 覆盖前按容器宽度缩放；无 cqi 时先用约手机宽 */
  transform: scale(0.45);
  transform: scale(calc(100cqi / 794));
  pointer-events: none;
}

.a4-page {
  width: 794px;
  height: 1123px;
  background: #fff;
  color: #000;
  position: relative;
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* 叠在 a4-wrap 上（不在 scale 内），尺寸由 fitPreview 写入 */
.a4-busy {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 4;
  width: 210px;
  height: 297px;
  margin: 0;
  padding: 0;
  border-radius: 2px;
  pointer-events: none;
  overflow: hidden;
  background: rgba(8, 28, 22, 0.14);
  box-shadow: inset 0 0 0 1px rgba(61, 207, 150, 0.2);
  animation: a4-busy-in 0.28s ease-out both;
}

.a4-busy[hidden] {
  display: none !important;
}

.a4-busy-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  overflow: hidden;
  background: rgba(61, 207, 150, 0.12);
  transform: translateZ(0);
}

.a4-busy-bar i {
  display: block;
  width: 38%;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(61, 207, 150, 0.35) 25%,
    #7ef0c0 50%,
    rgba(61, 207, 150, 0.35) 75%,
    transparent 100%
  );
  transform: translate3d(-120%, 0, 0);
  animation: a4-bar 1.45s linear infinite;
  will-change: transform;
  backface-visibility: hidden;
}

.a4-busy-spinner {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  transform: translate3d(-50%, -50%, 0);
  transform-style: preserve-3d;
}

.a4-busy-spinner .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  transform: translateZ(0);
  backface-visibility: hidden;
  will-change: transform;
}

.a4-busy-spinner .ring-a {
  border-top-color: #3dcf96;
  border-right-color: rgba(61, 207, 150, 0.22);
  animation: a4-spin 1.05s linear infinite;
}

.a4-busy-spinner .ring-b {
  inset: 7px;
  border-bottom-color: rgba(157, 255, 208, 0.95);
  border-left-color: rgba(157, 255, 208, 0.18);
  animation: a4-spin-rev 1.55s linear infinite;
}

.a4-busy-spinner .core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3dcf96;
  box-shadow: 0 0 8px rgba(61, 207, 150, 0.65);
  transform: translate3d(-50%, -50%, 0);
  animation: a4-core 1.6s ease-in-out infinite;
  will-change: opacity;
}

.a4-busy-corner {
  position: absolute;
  width: 13px;
  height: 13px;
  border: 1.5px solid rgba(61, 207, 150, 0.8);
  animation: a4-corner 2.2s ease-in-out infinite;
  will-change: opacity;
}

.a4-busy-corner.tl {
  top: 8px;
  left: 8px;
  border-right: 0;
  border-bottom: 0;
}
.a4-busy-corner.tr {
  top: 8px;
  right: 8px;
  border-left: 0;
  border-bottom: 0;
  animation-delay: 0.15s;
}
.a4-busy-corner.bl {
  bottom: 8px;
  left: 8px;
  border-right: 0;
  border-top: 0;
  animation-delay: 0.3s;
}
.a4-busy-corner.br {
  bottom: 8px;
  right: 8px;
  border-left: 0;
  border-top: 0;
  animation-delay: 0.45s;
}

@keyframes a4-busy-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes a4-bar {
  0% {
    transform: translate3d(-120%, 0, 0);
  }
  100% {
    transform: translate3d(320%, 0, 0);
  }
}

@keyframes a4-spin {
  to {
    transform: translateZ(0) rotate(360deg);
  }
}

@keyframes a4-spin-rev {
  to {
    transform: translateZ(0) rotate(-360deg);
  }
}

@keyframes a4-core {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

@keyframes a4-corner {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 0.95;
  }
}

.card-slot {
  position: absolute;
  width: 85.6mm;
  height: 54mm;
  background: #fff;
  overflow: hidden;
  border-radius: 0;
}
.card-slot.radius-3 {
  /* 身份证 / 银行卡物理圆角约 3mm */
  border-radius: 3mm;
}
.card-slot.radius-0 {
  border-radius: 0;
}

.card-slot img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
}

.card-slot.placeholder {
  outline: 1px dashed #b8c4d0;
  display: grid;
  place-items: center;
  color: #8a97a6;
  font-size: 12px;
  background: #fafbfc;
}

.card-slot.placeholder span {
  pointer-events: none;
}

.editor-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 32, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 16px;
  pointer-events: none;
}

.editor-backdrop.open {
  display: flex;
  pointer-events: auto;
}

.pwd-dialog {
  width: min(360px, 100%);
  background: #fff;
  border-radius: 14px;
  padding: 18px 18px 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.pwd-dialog h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.pwd-hint {
  margin: 0 0 12px;
  font-size: 0.88rem;
  color: #5a6670;
  line-height: 1.4;
}

.pwd-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #c8d0d8;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.95rem;
  outline: none;
}

.pwd-input:focus {
  border-color: #2f6fed;
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.15);
}

.pwd-error {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: #c0392b;
}

.pwd-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.editor {
  width: min(920px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.editor h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.editor-canvas-wrap {
  width: 100%;
  max-height: 55vh;
  overflow: auto;
  background: #111;
  border-radius: 10px;
  display: grid;
  place-items: center;
}

.editor-canvas-wrap canvas {
  max-width: 100%;
  cursor: default;
  touch-action: none;
}

.editor-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}

.editor-tools label {
  font-size: 0.85rem;
  color: var(--muted);
}

@media (max-width: 900px) {
  html,
  body {
    overflow-x: hidden;
  }

  .app {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 10px;
    padding-left: max(10px, env(safe-area-inset-left, 0px));
    padding-right: max(10px, env(safe-area-inset-right, 0px));
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    min-height: 100dvh;
  }

  .panel {
    height: auto !important;
    max-height: none;
    overflow: visible;
    padding: 12px;
    border-radius: 12px;
  }

  .brand {
    font-size: 1.08rem;
  }

  .sub {
    margin-bottom: 8px;
  }

  .seg button {
    padding: 9px 6px;
    font-size: 0.8rem;
    min-height: 40px;
  }

  .size-row {
    flex-wrap: wrap;
  }

  .size-input {
    flex: 1 1 calc(50% - 20px);
    min-width: 120px;
  }

  .size-input input[type="number"] {
    font-size: 16px; /* 避免 iOS 聚焦自动放大 */
    min-height: 40px;
  }

  #btnSwapWH {
    min-height: 40px;
    min-width: 40px;
  }

  /* 手机：slots 输入不变，仅把 A4 输出插到 slots 下方 */
  .slots {
    gap: 8px;
  }

  .slot {
    padding: 8px 10px;
  }

  .slot-head {
    flex-wrap: wrap;
    gap: 6px 8px;
    font-size: 0.84rem;
  }

  .slot-actions {
    gap: 4px;
    width: 100%;
    justify-content: flex-end;
  }

  .slot-actions .btn.ghost {
    padding: 8px 10px;
    font-size: 0.78rem;
    min-height: 36px;
    border: 1px solid var(--line);
    background: #fff;
  }

  .thumb-wrap {
    max-width: none;
    width: 100%;
  }

  /* 默认隐藏 A4；处理完成后由 JS 打开 .preview-mount 并藏起 slots */
  .preview-mount:not([hidden]) {
    display: block;
    margin: 0;
  }

  .app.is-mobile-output .slots {
    display: none !important;
  }

  .mobile-back-edit:not([hidden]) {
    display: block;
  }

  .preview-desktop {
    display: none;
  }

  .app {
    display: flex;
    flex-direction: column;
  }

  .panel {
    order: 1;
    width: 100%;
  }

  .preview-pane {
    width: 100%;
    padding: 0;
  }

  .a4-wrap {
    width: 100%;
    max-width: 100%;
  }

  .actions {
    gap: 8px;
    margin-top: 10px;
    position: sticky;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    z-index: 6;
    padding: 8px;
    background: rgba(247, 249, 251, 0.94);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(26, 35, 50, 0.1);
    backdrop-filter: blur(8px);
  }

  .actions .btn {
    min-height: 44px;
    font-size: 0.9rem;
    padding: 10px 12px;
  }

  .panel-credit {
    margin-top: 14px;
    padding-top: 4px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .a4-status {
    top: 8px;
    max-width: min(94%, 360px);
    padding: 8px 12px;
    font-size: 0.78rem;
    gap: 8px;
  }

  .a4-busy-spinner {
    width: 44px;
    height: 44px;
  }

  .editor-backdrop {
    padding: 0;
    align-items: stretch;
  }

  .editor {
    width: 100%;
    min-height: 100dvh;
    min-height: 100svh;
    border-radius: 0;
    padding: 12px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
  }

  .editor-canvas-wrap {
    flex: 1 1 auto;
    max-height: none;
    min-height: 45vh;
  }

  .editor-tools {
    gap: 8px;
    margin-top: 10px;
  }

  .editor-tools > span {
    width: 100%;
    font-size: 0.78rem;
    line-height: 1.35;
  }

  .editor-tools .btn {
    flex: 1 1 calc(50% - 8px);
    min-height: 44px;
  }

  .pwd-dialog {
    width: min(400px, calc(100% - 24px));
    margin: auto;
  }

  .pwd-input {
    font-size: 16px;
    min-height: 44px;
  }

  .pwd-actions .btn {
    min-height: 44px;
    min-width: 88px;
  }
}

@media (max-width: 420px) {
  .app {
    padding: 8px;
    gap: 10px;
  }

  .seg.seg-3 {
    gap: 3px;
  }

  .seg button {
    padding: 8px 4px;
    font-size: 0.74rem;
  }

  .actions {
    grid-template-columns: 1fr 1fr;
  }

  .actions .btn.primary {
    grid-column: 1 / -1;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  html,
  body {
    background: #fff !important;
    margin: 0;
    padding: 0;
  }

  .no-print {
    display: none !important;
  }

  .app {
    display: block;
    padding: 0;
    max-width: none;
  }

  /* 手机端平时隐藏，打印时必须露出 */
  .preview-desktop {
    display: block !important;
  }

  .preview-mount {
    display: none !important;
  }

  .preview-pane,
  .a4-wrap {
    width: 210mm !important;
    max-width: none !important;
    height: 297mm !important;
    margin: 0 !important;
    overflow: visible !important;
    padding: 0 !important;
  }

  .a4-scale {
    position: static !important;
    transform: none !important;
    width: 210mm !important;
    height: 297mm !important;
  }

  .a4-page {
    width: 210mm !important;
    height: 297mm !important;
    box-shadow: none;
    margin: 0;
    page-break-after: always;
  }
}
