:root {
  --blue: #1456f0;
  --blue-hover: #0f46cc;
  --ink: #1f2329;
  --muted: #646a73;
  --line: #dee0e3;
  --line-light: #eff0f1;
  --surface: #ffffff;
  --canvas: #eef1f6;
  --sidebar-width: 380px;
  --radius: 6px;
  --paper-scale: .76;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Noto Sans SC", "PingFang SC", sans-serif;
  font-size: 14px;
}

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

button {
  color: inherit;
}

button:focus-visible,
textarea:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(20, 86, 240, .28);
  outline-offset: 2px;
}

.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(56px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(18px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .95);
  box-shadow: 0 1px 2px rgba(31, 35, 41, .03);
}

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

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 5px);
  grid-template-rows: repeat(3, 5px);
  gap: 2px;
  width: 19px;
  height: 19px;
}

.brand-mark i {
  display: block;
  background: var(--blue);
}

.brand-mark i:nth-child(1) { grid-area: 1 / 1 / 2 / 4; }
.brand-mark i:nth-child(2) { grid-area: 2 / 1; }
.brand-mark i:nth-child(3) { grid-area: 2 / 3; }
.brand-mark i:nth-child(4) { grid-area: 3 / 1 / 4 / 3; }
.brand-mark i:nth-child(5) { grid-area: 3 / 3; opacity: .35; }

.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  object-fit: contain;
  background: #fff;
}

.topbar-actions,
.sidebar-footer,
.canvas-toolbar,
.field-row,
.paper-fields {
  display: flex;
  align-items: center;
}

.topbar-actions {
  gap: 8px;
}

.save-state {
  margin-right: 8px;
  color: #8f959e;
  font-size: 12px;
}

.icon-button,
.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, transform .16s ease;
}

.icon-button {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 5px;
  background: transparent;
}

.icon-button:hover {
  background: #f2f3f5;
}

.icon-button svg,
.primary-button svg,
.secondary-button svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.8;
}

.primary-button,
.secondary-button {
  height: 34px;
  gap: 7px;
  padding: 0 14px;
  border-radius: var(--radius);
  font-weight: 500;
}

.primary-button {
  color: #fff;
  background: var(--blue);
}

.primary-button:hover {
  background: var(--blue-hover);
}

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

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

.secondary-button:hover {
  border-color: #c7c9cc;
  background: #f7f8fa;
}

.workspace {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  height: calc(100vh - 56px - env(safe-area-inset-top));
  height: calc(100dvh - 56px - env(safe-area-inset-top));
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.control-section {
  padding: 20px 22px;
  border-bottom: 1px solid var(--line-light);
}

.intro-section {
  padding-top: 24px;
}

.game-section {
  padding-top: 24px;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.game-option {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 76px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: border-color .16s ease, background-color .16s ease;
}

.game-option:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.game-option:hover:not(:disabled) {
  border-color: #adc6ff;
  background: #f8faff;
}

.game-option.active {
  border-color: var(--blue);
  background: #f5f8ff;
}

.game-option:disabled {
  cursor: not-allowed;
  opacity: .56;
}

.game-option-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 5px;
  color: var(--muted);
  background: #f2f3f5;
}

.game-option.active .game-option-icon {
  color: var(--blue);
  background: #e8f0ff;
}

.game-option-icon svg {
  width: 16px;
  height: 16px;
}

.game-option strong,
.game-option small {
  display: block;
}

.game-option-copy {
  min-width: 0;
}

.game-option-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
}

.game-option strong {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
}

.game-option em {
  flex: none;
  padding: 1px 3px;
  border-radius: 3px;
  color: #245BDB;
  background: #EAF0FF;
  font-size: 9px;
  font-style: normal;
  line-height: 16px;
}

.game-option small {
  overflow: hidden;
  margin-top: 4px;
  color: #8f959e;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-check {
  position: absolute;
  top: 6px;
  right: 6px;
  display: none;
  width: 12px;
  height: 12px;
  color: var(--blue);
  stroke-width: 2.5;
}

.game-option.active .game-check {
  display: block;
}

.game-profile {
  margin-top: 12px;
  padding: 10px 0 0;
  border-top: 1px solid var(--line-light);
}

.game-profile span {
  display: inline-block;
  color: var(--blue);
  font-size: 11px;
  font-weight: 600;
}

.game-profile p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--blue);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  font-size: 21px;
  line-height: 1.35;
  letter-spacing: 0;
}

.control-section h2 {
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
}

.prompt-wrap {
  position: relative;
}

textarea {
  display: block;
  width: 100%;
  min-height: 100px;
  resize: vertical;
  padding: 11px 42px 11px 12px;
  border: 1px solid #c9cdd4;
  border-radius: 7px;
  color: var(--ink);
  background: #fbfcfe;
  line-height: 1.6;
  transition: border-color .16s, box-shadow .16s;
}

textarea::placeholder {
  color: #a0a5ad;
}

textarea:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 3px rgba(20, 86, 240, .1);
}

.prompt-action {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  color: #fff;
  background: var(--blue);
  cursor: pointer;
}

.prompt-action svg {
  width: 15px;
}

.prompt-examples {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.prompt-examples button {
  min-width: 0;
  padding: 4px 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  background: #fff;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.prompt-examples button:hover {
  color: var(--blue);
  border-color: #adc6ff;
  background: #f5f8ff;
}

.instruction-result {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #d6e3ff;
  border-radius: 6px;
  background: #f7f9ff;
}

.instruction-result.unmatched {
  border-color: #f3d6a3;
  background: #fffaf0;
}

.instruction-result-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #41464f;
  font-size: 11px;
}

.instruction-result.unmatched .status-dot {
  background: #d46b08;
  box-shadow: 0 0 0 3px rgba(212, 107, 8, .12);
}

.instruction-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.instruction-tags span {
  padding: 3px 7px;
  border-radius: 3px;
  color: #2456a6;
  background: #e8f0ff;
  font-size: 10px;
  line-height: 1.4;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.optional {
  color: #a0a5ad;
  font-size: 11px;
}

.upload-zone {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 12px;
  padding: 12px;
  border: 1px dashed #c9cdd4;
  border-radius: 6px;
  color: var(--ink);
  background: #fafbfc;
  text-align: left;
  cursor: pointer;
}

.upload-zone.compact {
  padding: 10px 12px;
}

.upload-zone:hover {
  border-color: var(--blue);
  background: #f5f8ff;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 5px;
  color: var(--blue);
  background: #e8f0ff;
}

.upload-icon svg {
  width: 18px;
}

.upload-zone strong,
.upload-zone small,
.image-preview strong,
.image-preview small,
.toggle-row strong,
.toggle-row small {
  display: block;
}

.upload-zone strong,
.image-preview strong,
.toggle-row strong {
  font-size: 13px;
  font-weight: 500;
}

.upload-zone small,
.image-preview small,
.toggle-row small {
  margin-top: 3px;
  color: #8f959e;
  font-size: 11px;
}

.image-preview {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid #adc6ff;
  border-radius: 6px;
  background: #f5f8ff;
}

.image-preview img {
  width: 44px;
  height: 44px;
  border-radius: 4px;
  object-fit: cover;
  background: #fff;
}

.image-preview strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-section {
  border-top: 1px solid var(--line);
}

.background-field {
  margin-top: 16px;
}

.pattern-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.pattern-picker button {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1.5;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background-color: #f7f8fa;
  cursor: pointer;
}

.pattern-picker button.active {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.pattern-picker i {
  width: 28px;
  height: 22px;
  border-radius: 4px;
}

.pattern-picker [data-pattern="grid"] i {
  background-image: linear-gradient(#aab0b8 1px, transparent 1px), linear-gradient(90deg, #aab0b8 1px, transparent 1px);
  background-size: 8px 8px;
}

.pattern-picker [data-pattern="dots"] i {
  background-image: radial-gradient(#7c8da8 1.6px, transparent 1.8px);
  background-size: 8px 8px;
}

.pattern-picker [data-pattern="waves"] i {
  background:
    radial-gradient(12px 8px at 8px 0, transparent 7px, #8f959e 7.5px, #8f959e 8.5px, transparent 9px) 0 10px / 18px 18px;
}

.pattern-picker [data-pattern="plain"] i {
  background: #dfe3eb;
}

.wide-button {
  width: 100%;
  margin-top: 8px;
}

.is-hidden {
  display: none !important;
}

.settings {
  flex: 1;
}

.field {
  display: block;
  margin-bottom: 18px;
}

.field > span:first-child {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 3px;
  border-radius: 6px;
  background: #f2f3f5;
}

.segmented button {
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  cursor: pointer;
}

.segmented button.active {
  color: var(--blue);
  background: #fff;
  box-shadow: 0 1px 3px rgba(31, 35, 41, .12);
  font-weight: 500;
}

.field-row {
  align-items: flex-start;
  gap: 10px;
}

.field-row .field {
  min-width: 0;
  flex: 1;
}

select,
.color-input-wrap {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
}

select {
  padding: 0 30px 0 10px;
  color: var(--ink);
}

.color-input-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 8px;
}

input[type="color"] {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: none;
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 3px;
}

#colorText {
  min-width: 0;
  width: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  text-transform: uppercase;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  cursor: pointer;
}

.toggle-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-row > i {
  position: relative;
  width: 34px;
  height: 20px;
  flex: none;
  border-radius: 10px;
  background: #bbbfc4;
  transition: background .18s;
}

.toggle-row > i::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  content: "";
  transition: transform .18s;
}

.toggle-row input:checked + i {
  background: var(--blue);
}

.toggle-row input:checked + i::after {
  transform: translateX(14px);
}

.sidebar-footer {
  position: sticky;
  bottom: 0;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
}

.sidebar-footer button {
  flex: 1;
}

.canvas-area {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background-color: var(--canvas);
  background-image: linear-gradient(rgba(159, 167, 180, .08) 1px, transparent 1px), linear-gradient(90deg, rgba(159, 167, 180, .08) 1px, transparent 1px);
  background-size: 24px 24px;
}

.canvas-toolbar {
  position: absolute;
  z-index: 5;
  top: 12px;
  left: 16px;
  right: 16px;
  justify-content: space-between;
  height: 38px;
  padding: 0 8px 0 12px;
  border: 1px solid rgba(208, 211, 217, .9);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 4px 12px rgba(31, 35, 41, .06);
  backdrop-filter: blur(12px);
  font-size: 12px;
}

.canvas-toolbar > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34c724;
  box-shadow: 0 0 0 3px rgba(52, 199, 36, .12);
}

.zoom-control {
  gap: 2px !important;
}

.zoom-control .icon-button {
  width: 28px;
  height: 28px;
}

#zoomValue {
  width: 42px;
  text-align: center;
  font-family: "DM Mono", monospace;
  font-size: 11px;
}

.paper-stage {
  width: 100%;
  height: 100%;
  overflow: auto;
  padding: 72px 40px 60px;
}

.paper {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  width: 794px;
  height: 1123px;
  margin: 0 auto;
  padding: 54px 58px 42px;
  transform: scale(var(--paper-scale));
  transform-origin: top center;
  color: #111820;
  background: #fff;
  box-shadow: 0 16px 50px rgba(31, 35, 41, .16), 0 2px 7px rgba(31, 35, 41, .08);
  transition: width .2s, height .2s;
}

.paper::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #fff;
  pointer-events: none;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.paper > * {
  position: relative;
  z-index: 1;
}

.paper.pattern-grid::before {
  background-color: #fff;
  background-image: linear-gradient(rgba(20, 86, 240, .055) 1px, transparent 1px), linear-gradient(90deg, rgba(20, 86, 240, .055) 1px, transparent 1px);
  background-size: 22px 22px;
}

.paper.pattern-dots::before {
  background-color: #fff;
  background-image: radial-gradient(rgba(20, 86, 240, .11) 1.5px, transparent 1.9px);
  background-size: 20px 20px;
}

.paper.pattern-waves::before {
  background-color: #fff;
  background-image:
    radial-gradient(30px 16px at 16px 0, transparent 15px, rgba(20, 86, 240, .08) 15.8px, rgba(20, 86, 240, .08) 17px, transparent 17.8px),
    radial-gradient(30px 16px at 16px 20px, transparent 15px, rgba(255, 180, 0, .1) 15.8px, rgba(255, 180, 0, .1) 17px, transparent 17.8px);
  background-size: 40px 42px;
}

.paper.pattern-plain::before {
  background: #fff;
}

.paper.has-custom-background::before {
  background-color: #fff;
  background-image: linear-gradient(rgba(255, 255, 255, .58), rgba(255, 255, 255, .58)), var(--paper-background-image);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: .9;
}

.paper.landscape {
  width: 1123px;
  height: 794px;
  padding: 42px 58px 34px;
}

.paper-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 22px;
  border-bottom: 2px solid currentColor;
}

.paper-title-block {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.paper-title-block > div {
  min-width: 0;
}

.paper-logo {
  width: 46px;
  height: 46px;
  flex: none;
  object-fit: contain;
}

.paper-header p {
  margin-bottom: 7px;
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: .12em;
}

.paper-header h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.paper-fields {
  gap: 20px;
  font-size: 11px;
}

.maze-sheet {
  display: grid;
  min-height: 0;
  flex: 1;
  place-items: center;
  padding: 34px 4px 26px;
}

.maze-sheet svg {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.difference-placeholder {
  display: grid;
  width: 100%;
  min-height: 420px;
  place-items: center;
  border: 2px dashed #d9dce1;
  color: #8f959e;
  text-align: center;
}

.difference-placeholder svg {
  width: 34px;
  height: 34px;
  margin: 0 auto 12px;
}

.difference-placeholder strong,
.difference-placeholder span {
  display: block;
}

.difference-placeholder strong {
  margin-bottom: 5px;
  color: #41464f;
  font-size: 16px;
}

.difference-placeholder span {
  font-size: 12px;
}

.paper-footer {
  display: flex;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid #d9dce1;
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: .08em;
}

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 24px;
  padding: 9px 14px;
  border-radius: 5px;
  color: #fff;
  background: #1f2329;
  box-shadow: 0 8px 24px rgba(31, 35, 41, .2);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity .2s, transform .2s;
}

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

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .workspace {
    display: block;
    height: auto;
  }

  .sidebar {
    overflow: visible;
    border-right: 0;
  }

  .sidebar-footer {
    position: static;
  }

  .canvas-area {
    height: 760px;
  }

  .save-state {
    display: none;
  }

  .paper-stage {
    padding-inline: 16px;
  }

  .paper {
    margin-right: 0;
    margin-left: max(0px, calc((100% - var(--paper-scaled-width)) / 2));
    transform-origin: top left;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding-right: max(14px, env(safe-area-inset-right));
    padding-left: max(14px, env(safe-area-inset-left));
  }

  .topbar-actions > .icon-button {
    display: none;
  }

  .topbar .primary-button {
    min-height: 44px;
  }

  .control-section {
    padding-inline: 16px;
  }

  .game-option {
    min-height: 76px;
    padding: 8px;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 7px;
  }

  .game-option-icon {
    width: 28px;
    height: 28px;
  }

  .game-option-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 1px;
  }

  .segmented button,
  select,
  .sidebar-footer button {
    min-height: 44px;
  }

  .sidebar-footer {
    position: sticky;
    z-index: 8;
    bottom: 0;
    padding: 12px 16px max(18px, env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 -1px 0 var(--line-light), 0 -10px 24px rgba(31, 35, 41, .06);
  }

  .prompt-examples button {
    flex: 1;
  }

  .canvas-toolbar {
    left: 8px;
    right: 8px;
  }

  #mazeMeta {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (pointer: coarse) {
  .icon-button {
    width: 44px;
    height: 44px;
  }

  .game-option,
  .toggle-row {
    min-height: 76px;
  }

  .primary-button,
  .secondary-button,
  .segmented button,
  select {
    min-height: 44px;
  }

  .game-option:hover:not(:disabled),
  .primary-button:hover,
  .secondary-button:hover,
  .icon-button:hover {
    transform: none;
  }
}

@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  body {
    overflow: visible;
    background: #fff;
  }

  .topbar,
  .sidebar,
  .canvas-toolbar {
    display: none !important;
  }

  .workspace,
  .canvas-area,
  .paper-stage {
    display: block;
    width: auto;
    height: auto;
    overflow: visible;
    padding: 0;
    background: #fff;
  }

  .paper {
    width: 210mm !important;
    height: 297mm !important;
    margin: 0;
    padding: 14mm 15mm 11mm;
    transform: none !important;
    box-shadow: none;
  }

  .paper.landscape {
    width: 297mm !important;
    height: 210mm !important;
    padding: 11mm 15mm 9mm;
  }

  body:has(.paper.landscape) {
    page: landscape;
  }

  @page {
    size: auto;
  }
}
