:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans", "Noto Sans CJK SC", "Microsoft YaHei", Arial, sans-serif;
  color: #23262d;
  background: #f5f4f2;
  font-synthesis: none;
  --border: #dedbd7;
  --muted: #6e7076;
  --accent: #e98bac;
  --accent-dark: #b33b68;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: #f5f4f2;
}

button,
textarea,
input {
  font: inherit;
}

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

.app-header {
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 42px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.app-header h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.04em;
}

.app-header p {
  margin: 0;
  color: #555861;
  font-size: 15px;
}

.workspace {
  min-height: calc(100vh - 70px);
  display: grid;
  grid-template-columns: 324px minmax(0, 1fr);
}

.editor {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 70px);
  padding: 26px 20px 22px;
  background: #fff;
  border-right: 1px solid var(--border);
}

.field-heading,
.control-label,
.capacity {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.field-heading label,
.control-label label {
  display: block;
  color: #25272c;
  font-size: 15px;
  font-weight: 750;
}

.field-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

#nameCount {
  color: #555861;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

#namesInput {
  width: 100%;
  min-height: 330px;
  flex: 1;
  resize: none;
  margin-top: 12px;
  padding: 14px 13px;
  border: 1px solid #b9b7b4;
  border-radius: 7px;
  outline: none;
  color: #23262d;
  background: #fff;
  font-family:
    "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

#namesInput:focus {
  border-color: #4b84e6;
  box-shadow: 0 0 0 3px rgba(75, 132, 230, 0.13);
}

.input-help {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.overflow-notice {
  margin-top: 10px;
  padding: 9px 10px;
  color: #a12323;
  background: #fff0f0;
  border: 1px solid #f2c6c6;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 750;
  transition:
    transform 140ms ease,
    background-color 140ms ease,
    box-shadow 140ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button.secondary {
  color: #363940;
  background: #f3f2f0;
  border: 1px solid #dddad6;
}

.button.secondary:hover {
  background: #ebe9e6;
}

.font-control {
  margin-top: 22px;
}

.control-label output {
  color: #555861;
  font-size: 13px;
}

#fontSize {
  width: 100%;
  margin-top: 10px;
  accent-color: var(--accent-dark);
}

.capacity {
  align-items: center;
  margin: 18px 0 14px;
  padding-top: 16px;
  border-top: 1px solid #eceae7;
  color: #5f6268;
  font-size: 12px;
}

.capacity span:first-child {
  color: #303238;
  font-weight: 750;
}

.button.primary {
  min-height: 48px;
  color: #fff;
  background: #20242b;
  box-shadow: 0 8px 18px rgba(32, 36, 43, 0.14);
}

.button.primary:hover {
  background: #11141a;
  box-shadow: 0 10px 22px rgba(32, 36, 43, 0.2);
}

.print-help {
  margin: 9px 2px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
}

.button.primary svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.preview-area {
  min-width: 0;
  padding: 20px 28px 30px;
}

.preview-toolbar {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.preview-toolbar h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.preview-toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.page-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #555861;
  font-size: 13px;
}

.page-nav strong {
  color: #24272d;
}

.page-nav button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #d9d6d2;
  border-radius: 6px;
  color: #45484f;
  background: #fff;
  cursor: pointer;
}

.page-nav button:hover:not(:disabled) {
  border-color: #b9b5b0;
  background: #f8f7f5;
}

.page-nav button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.page-nav svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.preview-stage {
  min-height: calc(100vh - 174px);
  display: grid;
  place-items: center;
  padding: 22px;
  overflow: hidden;
  background: #e8e6e3;
  border: 1px solid #dedbd7;
}

.canvas-mount {
  width: 100%;
  display: grid;
  place-items: center;
}

.form-canvas {
  display: block;
  width: min(100%, 1491px);
  height: auto;
  background: #f2a7c3;
  box-shadow: 0 16px 44px rgba(40, 30, 33, 0.2);
}

.blank-back-canvas {
  background: #f2a7c3;
}

.print-pages {
  display: none;
}

@media (max-width: 900px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
    padding: 16px 18px;
  }

  .workspace {
    display: block;
  }

  .editor {
    min-height: auto;
    padding: 22px 18px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  #namesInput {
    min-height: 240px;
  }

  .preview-area {
    padding: 16px;
  }

  .preview-stage {
    min-height: 0;
    padding: 10px;
    overflow: auto;
  }
}

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

@media print {
  html,
  body {
    width: 297mm;
    height: 210mm;
    margin: 0;
    padding: 0;
    background: #fff;
  }

  body {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .app-header,
  .workspace {
    display: none !important;
  }

  .print-pages {
    display: block;
  }

  .print-pages .form-canvas {
    width: 297mm;
    height: 210mm;
    margin: 0;
    box-shadow: none;
    break-after: page;
    page-break-after: always;
  }

  .print-pages .form-canvas:last-child {
    break-after: auto;
    page-break-after: auto;
  }
}
