:root {
  color-scheme: light;
  --bg: #f6f8f7;
  --panel: #ffffff;
  --text: #17201b;
  --muted: #67736d;
  --line: #dbe3df;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 700;
}

.topbar p,
.section-title span,
.properties p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 18px;
  padding: 18px;
  height: calc(100vh - 100px);
  overflow: hidden;
}

.upload-panel { overflow-y: auto; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.preview-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-title h2 {
  font-size: 18px;
}

.upload-box {
  display: grid;
  gap: 12px;
}

input[type="file"],
input[type="text"],
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  padding: 8px 10px;
}

button,
.ghost-button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 8px 14px;
  color: white;
  background: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.ghost-button:hover {
  background: var(--accent-dark);
}

.ghost-button {
  color: var(--accent);
  background: white;
}

.ghost-button:hover {
  color: white;
}

.disabled {
  pointer-events: none;
  opacity: 0.5;
}

.file-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.file-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.file-item strong {
  font-size: 14px;
  word-break: break-word;
}

.file-item button,
.file-item a {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

#pdfFrame {
  width: 100%;
  height: 570px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f1f4f2;
}

.preview-actions {
  display: grid;
  grid-template-columns: minmax(130px, 170px) minmax(120px, 160px) auto auto auto auto auto auto auto;
  gap: 8px;
}

.pdf-editor {
  flex: 1;
  position: relative;
  width: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f1f4f2;
  overflow: auto;
}

.preview-stage {
  position: relative;
  width: max-content;
  min-width: 100%;
  padding: 16px;
}

.edit-canvas {
  display: block;
  max-width: none;
  box-shadow: 0 8px 22px rgba(17, 24, 39, 0.12);
  background: #fff;
  cursor: crosshair;
}

.empty-preview {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 200px;
  color: var(--muted);
}

#propertyFields {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.field {
  display: grid;
  gap: 5px;
}

.field label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.field input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
}

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

.hidden {
  display: none;
}

.float-panel {
  position: absolute;
  top: 75px;
  right: 28px;
  z-index: 20;
  width: min(360px, calc(100% - 40px));
  max-height: calc(100% - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 16px 36px rgba(17, 24, 39, 0.18);
  padding: 14px;
}

.float-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  cursor: move;
  user-select: none;
}

.float-header h3 {
  font-size: 16px;
}

.float-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  width: 30px;
  min-height: 30px;
  padding: 0;
  border-color: var(--line);
  color: var(--muted);
  background: white;
  font-size: 20px;
  line-height: 1;
}

.icon-button:hover {
  color: white;
}

@media (max-width: 980px) {
  .topbar,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

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

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