@font-face {
  font-family: "ToolDengXian";
  src: url("./assets/Deng.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #17202b;
  background: #eef1f4;
  font-synthesis: none;
  --ink: #17202b;
  --muted: #66717e;
  --line: #dce2e7;
  --paper: #ffffff;
  --accent: #ff6b38;
  --accent-dark: #e95322;
  --navy: #183348;
  --success: #1f8a5b;
  --danger: #c53c3c;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 1040px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.9), transparent 25%),
    linear-gradient(135deg, #edf2f4 0%, #e6eaee 100%);
}

body.startup-blocked {
  overflow: hidden;
}

.startup-block {
  position: fixed;
  z-index: 9999;
  inset: 0;
  display: grid;
  padding: 24px;
  place-items: center;
  background: rgba(232, 237, 240, 0.94);
  backdrop-filter: blur(10px);
}

.startup-card {
  width: min(480px, 100%);
  padding: 36px;
  border: 1px solid #d4dce1;
  border-radius: 20px;
  background: white;
  box-shadow: 0 24px 70px rgba(35, 48, 58, 0.2);
  text-align: center;
}

.startup-icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  place-items: center;
  border-radius: 50%;
  background: #fff0ea;
  color: var(--accent-dark);
  font-size: 24px;
  font-weight: 900;
}

.startup-card h2 {
  margin: 0 0 10px;
  font-size: 22px;
}

.startup-card p {
  margin: 0;
  color: #68747d;
  font-size: 13px;
  line-height: 1.7;
}

.startup-command {
  display: block;
  width: 100%;
  margin: 22px 0 10px;
  padding: 13px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--navy);
  color: white;
  font-weight: 800;
}

.startup-reload:active {
  transform: translateY(1px);
}

.startup-card small {
  color: #8b959c;
  font-size: 11px;
}

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

button {
  cursor: pointer;
}

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

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 2px 24px;
}

.eyebrow,
.preview-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--accent);
}

.hero h1 {
  margin: 7px 0 4px;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: 35px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.privacy-pill {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  padding: 9px 14px;
  border: 1px solid #d6dedf;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: #51606b;
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(10px);
}

.privacy-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #33a56f;
  box-shadow: 0 0 0 4px rgba(51, 165, 111, 0.12);
}

.workspace {
  display: grid;
  grid-template-columns: 430px minmax(0, 1fr);
  min-height: 760px;
  overflow: hidden;
  border: 1px solid rgba(194, 203, 210, 0.78);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 22px 65px rgba(37, 51, 63, 0.13);
}

.control-panel {
  padding: 27px 28px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: #fbfcfc;
}

.panel-section {
  padding-bottom: 24px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.settings-section {
  margin-bottom: 20px;
  padding-bottom: 19px;
}

.section-heading {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 17px;
}

.section-heading.compact {
  margin-bottom: 15px;
}

.step-number {
  display: inline-grid;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  background: var(--navy);
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.section-heading h2 {
  margin: 0 0 3px;
  font-size: 15px;
  line-height: 1.2;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 128px;
  padding: 18px;
  border: 1.5px dashed #b8c2ca;
  border-radius: 14px;
  background: #f7f9fa;
  transition: 160ms ease;
  text-align: center;
  cursor: pointer;
}

.pdf-file-input {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--accent);
  background: #fff8f5;
  transform: translateY(-1px);
}

.upload-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  margin-bottom: 8px;
  border-radius: 50%;
  background: #e8eef1;
  color: var(--navy);
  font-size: 21px;
  font-weight: 600;
}

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

.drop-zone > span:last-child {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.drop-zone > span.file-error {
  color: var(--danger);
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  padding: 13px 14px;
  border: 1px solid #cfd6dc;
  border-radius: 11px;
  outline: none;
  background: white;
  color: var(--ink);
  font-family: "ToolDengXian", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  line-height: 1.75;
  transition: 150ms ease;
}

textarea:focus,
input:focus,
select:focus {
  border-color: #6c8798;
  box-shadow: 0 0 0 3px rgba(82, 114, 134, 0.11);
}

.line-summary {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.status-chip {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.status-chip.neutral {
  background: #eef2f4;
  color: #61707a;
}

.status-chip.success {
  background: #e4f5ec;
  color: #20754f;
}

.status-chip.danger {
  background: #fbe9e7;
  color: #a23832;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 12px;
}

.field-group {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
  color: #4c5964;
  font-size: 11px;
  font-weight: 700;
}

.field-group small {
  overflow: hidden;
  color: #88919a;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.number-field,
.color-field {
  display: flex;
  align-items: center;
  height: 39px;
  overflow: hidden;
  border: 1px solid #cfd6dc;
  border-radius: 9px;
  background: white;
}

.number-field input,
.color-field input[type="text"] {
  width: 100%;
  height: 100%;
  min-width: 0;
  padding: 0 9px;
  border: 0;
  outline: none;
  background: transparent;
}

.number-field span {
  padding-right: 10px;
  color: #88919a;
  font-weight: 600;
}

.color-field input[type="color"] {
  width: 40px;
  height: 100%;
  flex: 0 0 auto;
  padding: 6px;
  border: 0;
  border-right: 1px solid #e0e5e8;
  background: white;
  cursor: pointer;
}

.color-presets {
  display: flex;
  min-height: 18px;
  align-items: center;
  gap: 5px;
}

.color-presets button {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 50%;
  background: var(--preset);
  box-shadow: 0 0 0 1px white inset;
}

.color-presets button.active {
  outline: 2px solid #647986;
  outline-offset: 1px;
}

.color-presets span {
  min-width: 0;
  margin-left: 2px;
  overflow: hidden;
  color: #76828a;
  font-size: 9px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

select,
.secondary-button {
  width: 100%;
  height: 39px;
  padding: 0 10px;
  border: 1px solid #cfd6dc;
  border-radius: 9px;
  outline: none;
  background: white;
  color: #33414c;
  font-size: 12px;
}

.secondary-button {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toggle-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 17px;
  color: #384650;
  cursor: pointer;
}

.toggle-row > input {
  position: absolute;
  opacity: 0;
}

.toggle-ui {
  position: relative;
  width: 38px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #bdc7cd;
  transition: 150ms ease;
}

.toggle-ui::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
  content: "";
  transition: 150ms ease;
}

.toggle-row input:checked + .toggle-ui {
  background: var(--navy);
}

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

.toggle-row strong,
.toggle-row small {
  display: block;
}

.toggle-row strong {
  font-size: 12px;
}

.toggle-row small {
  margin-top: 2px;
  color: #818b93;
  font-size: 10px;
}

.advanced-settings {
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid #e2e7ea;
}

.advanced-settings summary {
  color: #52616c;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.advanced-settings p {
  margin: 9px 0;
  color: #8a949c;
  font-size: 10px;
}

.region-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.region-grid label {
  color: #77828b;
  font-size: 10px;
  font-weight: 700;
}

.region-grid input {
  width: 100%;
  height: 32px;
  margin-top: 4px;
  padding: 0 6px;
  border: 1px solid #d4dadd;
  border-radius: 7px;
  outline: none;
}

.text-button {
  padding: 8px 0 0;
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
}

.generate-button {
  display: flex;
  width: 100%;
  height: 50px;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border: 0;
  border-radius: 11px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  box-shadow: 0 10px 20px rgba(255, 107, 56, 0.22);
  transition: 150ms ease;
}

.generate-button:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.generate-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.message {
  min-height: 19px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--success);
}

.diagnostics-panel {
  margin-top: 8px;
  padding: 9px 10px;
  border: 1px solid #efcfca;
  border-radius: 8px;
  background: #fff8f7;
}

.diagnostics-panel summary {
  color: #9b4037;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.diagnostics-panel pre {
  max-height: 130px;
  margin: 9px 0 0;
  padding: 8px;
  overflow: auto;
  border-radius: 6px;
  background: #f7ecea;
  color: #644640;
  font: 10px/1.5 Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-all;
}

.preview-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  background: #eff2f3;
}

.preview-toolbar {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  padding: 15px 24px;
  border-bottom: 1px solid #d7dde1;
  background: rgba(255, 255, 255, 0.72);
}

.preview-toolbar strong {
  display: block;
  max-width: 520px;
  margin-top: 4px;
  overflow: hidden;
  color: #35424b;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-count-pill {
  padding: 7px 11px;
  border: 1px solid #d3dade;
  border-radius: 999px;
  background: white;
  color: #53616b;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.preview-stage {
  display: block;
  min-height: 0;
  flex: 1;
  padding: 30px;
  overflow: auto;
  background:
    linear-gradient(45deg, rgba(189, 198, 203, 0.16) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(189, 198, 203, 0.16) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(189, 198, 203, 0.16) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(189, 198, 203, 0.16) 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.empty-preview {
  display: grid;
  min-height: 560px;
  place-items: center;
  color: #68747c;
  text-align: center;
}

.empty-preview p {
  margin: 5px 0 0;
  color: #929aa0;
  font-size: 12px;
}

.empty-sheet {
  width: 125px;
  height: 156px;
  margin-bottom: 18px;
  padding: 34px 20px;
  border: 1px solid #d6dde0;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 30px rgba(50, 63, 73, 0.08);
}

.empty-sheet span {
  display: block;
  height: 5px;
  margin-bottom: 12px;
  border-radius: 3px;
  background: #dfe5e8;
}

.page-preview-grid {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(auto-fit, minmax(min(290px, 100%), 1fr));
  gap: 22px;
  align-items: start;
}

.page-preview-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #d1d8dc;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 28px rgba(35, 48, 58, 0.12);
}

.page-preview-meta {
  display: flex;
  height: 38px;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid #dbe1e4;
  color: #4b5963;
  font-size: 11px;
  font-weight: 800;
}

.page-preview-meta span:last-child {
  color: #82909a;
  font-weight: 700;
}

.page-canvas-wrap {
  position: relative;
  width: 100%;
  line-height: 0;
  user-select: none;
}

.page-pdf-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: white;
}

.text-region {
  position: absolute;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
  border: 1.5px dashed var(--accent);
  background: rgba(255, 107, 56, 0.045);
  color: #000;
  font-family: "ToolDengXian", "Microsoft YaHei", sans-serif;
  line-height: 1;
  white-space: nowrap;
  cursor: move;
  touch-action: none;
}

.text-region[data-align="left"] {
  justify-content: flex-start;
}

.text-region[data-align="right"] {
  justify-content: flex-end;
}

.text-region > span {
  display: block;
  max-width: 100%;
  line-height: 1;
}

.resize-handle {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 0;
  border-radius: 7px 0 0;
  background: var(--accent);
  cursor: nwse-resize;
  touch-action: none;
}

.preview-footer {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-top: 1px solid #d7dde1;
  background: rgba(255, 255, 255, 0.74);
  color: #65727b;
  font-size: 11px;
}

.legend-box {
  display: inline-block;
  width: 13px;
  height: 9px;
  margin-right: 5px;
  border: 1px dashed var(--accent);
  vertical-align: -1px;
}

@media (max-width: 1180px) {
  .app-shell {
    width: calc(100% - 24px);
  }

  .workspace {
    grid-template-columns: 400px minmax(0, 1fr);
  }

  .control-panel {
    padding: 24px 22px;
  }
}

@media (max-width: 1100px) {
  .page-preview-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
    gap: 16px;
  }

  .preview-stage {
    padding: 20px;
  }
}

@media (max-width: 900px) {
  body {
    min-width: 0;
  }

  .app-shell {
    width: calc(100% - 20px);
    padding: 18px 0 28px;
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    padding: 0 2px 18px;
  }

  .hero h1 {
    font-size: clamp(27px, 8vw, 35px);
  }

  .privacy-pill {
    align-self: flex-start;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    overflow: visible;
    border-radius: 16px;
  }

  .control-panel {
    padding: 24px 20px;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .preview-panel {
    min-width: 0;
  }

  .preview-toolbar {
    padding: 17px 18px;
  }

  .preview-stage {
    min-height: 320px;
    padding: 14px;
  }

  .empty-preview {
    min-height: 360px;
  }

  .page-preview-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .preview-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
    padding: 13px 18px;
  }
}

@media (max-width: 520px) {
  .startup-block {
    padding: 12px;
  }

  .startup-card {
    padding: 28px 20px;
  }

  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .line-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .region-grid {
    grid-template-columns: 1fr 1fr;
  }

  .preview-toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .page-count-pill {
    align-self: flex-start;
  }
}
