:root {
  --page: #eef1f4;
  --panel: #ffffff;
  --panel-soft: #f8fafb;
  --ink: #172027;
  --muted: #66727c;
  --line: #d8dee5;
  --line-strong: #aab5bf;
  --rail: #111820;
  --accent: #0d6f80;
  --accent-dark: #084d59;
  --danger: #e50012;
  --shadow: 0 18px 48px rgba(18, 26, 34, 0.14);
}

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

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--page);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: #fbfcfc;
}

button:active {
  transform: translateY(1px);
}

button svg,
.file-drop-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  background: var(--page);
}

.control-rail {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 20px;
  padding: 26px;
  color: #e9eef2;
  background: #111820;
  border-right: 1px solid #0b1117;
}

.brand {
  min-width: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  font-size: 18px;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.brand p {
  margin: 5px 0 0;
  color: #91a0ab;
  font-size: 12px;
}

.control-form {
  display: grid;
  align-content: start;
  gap: 14px;
}

.panel {
  min-width: 0;
  display: grid;
  gap: 13px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.045);
}

.panel-title,
details > summary {
  color: #f5f8fa;
  font-size: 13px;
  font-weight: 700;
}

details > summary {
  cursor: pointer;
}

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

.wide {
  grid-column: 1 / -1;
}

label {
  min-width: 0;
  display: grid;
  gap: 7px;
}

label span {
  color: #aeb9c2;
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
  outline: none;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

input {
  height: 38px;
  padding: 0 10px;
}

select {
  height: 38px;
  padding: 0 10px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #d7edf1 50%), linear-gradient(135deg, #d7edf1 50%, transparent 50%);
  background-position: calc(100% - 18px) 16px, calc(100% - 12px) 16px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

textarea {
  resize: vertical;
  min-height: 82px;
  padding: 10px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(67, 185, 201, 0.95);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 3px rgba(13, 111, 128, 0.22);
}

.file-drop {
  min-height: 82px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px dashed rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.file-drop:hover,
.file-drop.is-dragging {
  border-color: rgba(67, 185, 201, 0.95);
  background: rgba(67, 185, 201, 0.1);
}

.file-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-drop-icon {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  color: #d7edf1;
  background: rgba(255, 255, 255, 0.08);
}

#fileName {
  overflow: hidden;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.actions .primary-btn {
  grid-column: 1 / -1;
}

.actions .pdf-btn {
  grid-column: 1 / -1;
}

.primary-btn {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.primary-btn:hover {
  border-color: #0a5d6c;
  background: #0a5d6c;
  color: #ffffff;
}

.preview-shell {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.preview-toolbar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.preview-toolbar div {
  display: grid;
  gap: 3px;
}

.preview-toolbar span {
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.preview-toolbar strong {
  font-size: 17px;
}

#statusText {
  overflow: hidden;
  max-width: 44vw;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.paper-frame {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  display: grid;
  place-items: start center;
  padding: 24px;
}

#proofCanvas {
  display: block;
  width: min(100%, 760px);
  height: auto;
  background: #ffffff;
  box-shadow: var(--shadow);
}

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

  .app-shell {
    min-height: 100%;
    height: auto;
    grid-template-columns: 1fr;
  }

  .control-rail {
    min-height: auto;
    overflow: visible;
  }

  .preview-shell {
    min-height: 620px;
  }

  .paper-frame {
    padding: 16px;
  }
}

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

  .control-rail,
  .preview-toolbar {
    display: none !important;
  }

  .app-shell,
  .preview-shell,
  .paper-frame {
    display: block;
    height: auto;
    padding: 0;
    overflow: visible;
    background: #ffffff;
  }

  #proofCanvas {
    width: auto;
    height: 297mm;
    max-width: 210mm;
    max-height: 297mm;
    margin: 0 auto;
    box-shadow: none;
  }
}
