:root {
  --bg: #f4f4f2;
  --panel: #ffffff;
  --border: #e0e0dc;
  --text: #1c1c1a;
  --muted: #767670;
  --accent: #3E63F0;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; margin: 0; }
.template-picker { font-size: 14px; color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(420px, 560px);
  gap: 20px;
  padding: 20px;
  align-items: start;
}
.col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}
.panel h2 { font-size: 15px; margin: 0 0 12px; }
.hint { color: var(--muted); font-weight: 400; font-size: 12px; }

.row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
button:hover { opacity: .9; }
button:disabled { background: #ccc; cursor: not-allowed; }

input[type="file"], select {
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.hidden { display: none !important; }

.mapping-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 12px; table-layout: fixed; }
.mapping-table th, .mapping-table td { border-bottom: 1px solid var(--border); padding: 6px 4px; text-align: left; vertical-align: top; overflow-wrap: break-word; }
.mapping-table th:nth-child(1), .mapping-table td:nth-child(1) { width: 32%; }
.mapping-table th:nth-child(2), .mapping-table td:nth-child(2) { width: 34%; }
.mapping-table th:nth-child(3), .mapping-table td:nth-child(3) { width: 34%; }
.mapping-table select { width: 100%; max-width: 100%; }
.mapping-preview { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mapping-conf-0 { background: #fff2f0; }
.mapping-conf-low { background: #fff9e6; }

.batch { margin-top: 10px; font-size: 13px; }
.batch-list { max-height: 160px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; margin: 8px 0; }
.batch-list label { display: block; font-size: 12px; padding: 2px 0; }

fieldset {
  border: none;
  padding: 0;
  margin: 0 0 18px;
}
fieldset legend {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--accent);
  padding: 0;
  margin-bottom: 8px;
}
.field-row { margin-bottom: 10px; }
.field-row label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field-row input[type="text"], .field-row textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}
.field-row textarea { min-height: 56px; }
.field-hint { color: var(--muted); font-size: 11px; margin-top: 2px; }

.preview-frame-wrap {
  width: 100%;
  max-height: 72vh;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #eee;
}
.preview-frame-inner {
  width: 1080px;
  transform-origin: top left;
  transform: scale(var(--preview-scale, 0.35));
}
#previewFrame {
  display: block;
  width: 1080px;
  height: 1350px;
  border: 0;
}

.downloads { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; }
.downloads a { color: var(--accent); font-size: 13px; }
