:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #657085;
  --line: #d8dde8;
  --panel: #ffffff;
  --page: #f3f5f8;
  --accent: #0d448d;
}

@font-face {
  font-family: "HandelsonD1";
  src: url("./fonts/Handelson-Three-Exfontbd5c.otf") format("opentype");
  font-display: block;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--page);
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.controls {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

h1 {
  font-size: 20px;
  margin: 0;
  letter-spacing: 0;
}

#status {
  color: var(--muted);
  font-size: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

input[type="range"] {
  padding: 0;
}

input.emptyTextWarning::placeholder,
textarea.emptyTextWarning::placeholder {
  color: #000000;
  font-family: "SimHei", "Microsoft YaHei", Arial, sans-serif;
  font-weight: 700;
  opacity: 1;
}

.productPickerField {
  position: relative;
  display: grid;
  gap: 6px;
}

.productTypeNative {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
  pointer-events: none;
}

.productPicker {
  position: relative;
  min-width: 0;
}

.productPickerTrigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 40px;
  padding: 10px 11px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: left;
  transform: none;
}

.productPickerTrigger:hover {
  color: var(--ink);
  background: #ffffff;
  border-color: #b7c1d1;
}

.productPickerTrigger:focus-visible {
  outline: 2px solid rgba(13, 68, 141, 0.18);
  border-color: var(--accent);
}

.productPickerChevron {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin: -4px 3px 0 12px;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: rotate(45deg);
  transition: transform 140ms ease;
}

.productPickerTrigger[aria-expanded="true"] .productPickerChevron {
  margin-top: 4px;
  transform: rotate(225deg);
}

.productPickerMenu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  display: grid;
  gap: 2px;
  padding: 4px;
  overflow: visible;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 10px 24px rgba(23, 32, 51, 0.16);
}

.productPickerOption {
  width: 100%;
  padding: 9px 10px;
  color: var(--ink);
  background: #ffffff;
  border: 0;
  border-radius: 4px;
  text-align: left;
  white-space: normal;
  transform: none;
}

.productPickerOption:hover,
.productPickerOption:focus-visible,
.productPickerOption.selected {
  color: var(--ink);
  background: #eaf0f8;
}

.productPickerOption:focus-visible {
  outline: 2px solid rgba(13, 68, 141, 0.22);
  outline-offset: -2px;
}

.productPickerOption:active {
  transform: none;
}

.sliderRow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  align-items: center;
  gap: 10px;
}

.sliderValue {
  color: var(--ink);
  font-size: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#customPennantText,
.golfTextDragTarget,
.customPennantOrnament,
.signatureTextDragTarget,
.embroideredTextDragTarget {
  cursor: move;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(13, 68, 141, 0.18);
  border-color: var(--accent);
}

textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.45;
}

.compactTextarea {
  min-height: 72px;
}

.modeSwitch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.modeSwitch button {
  color: var(--accent);
  background: #ffffff;
  border-color: var(--line);
}

.modeSwitch button.active {
  color: #ffffff;
  background: var(--accent);
  border-color: #0b3b7b;
}

.modePanel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.checkboxRow {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.checkboxRow input {
  width: auto;
  margin: 0;
}

.controlDetails {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  display: grid;
  gap: 12px;
}

.controlDetails summary {
  cursor: pointer;
  color: var(--ink);
  font-size: 13px;
}

.dynamicLineControls {
  display: grid;
  gap: 12px;
}

.ornamentBlock {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbfc;
}

.ornamentBlock button {
  width: 100%;
}

.ornamentList {
  display: grid;
  gap: 8px;
}

.ornamentEmpty {
  color: var(--muted);
  font-size: 12px;
}

.ornamentItem {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  padding: 9px;
}

.ornamentItem summary {
  cursor: pointer;
  color: var(--ink);
  font-size: 13px;
}

.ornamentControls {
  display: grid;
  gap: 10px;
  padding-top: 10px;
}

.ornamentDelete {
  color: #a6192e;
  background: #ffffff;
  border-color: #e2b8c0;
}

.lineModeList {
  display: grid;
  gap: 8px;
}

.lineModeItem {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbfc;
}

.lineModeText {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lineModeItem select {
  padding: 7px 8px;
}

.hidden {
  display: none !important;
}

.meta {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  background: #fafbfc;
}

.meta strong {
  color: var(--ink);
  font-weight: 600;
}

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

.secondary-actions button {
  color: var(--accent);
  background: #ffffff;
  border-color: var(--line);
}

button {
  position: relative;
  overflow: hidden;
  border: 1px solid #0b3b7b;
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  transform: translateY(0) scale(1);
  transition: transform 120ms ease, box-shadow 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

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

button.exportPulse {
  animation: exportPulse 520ms ease;
}

button.exportBusy {
  background: #1260bd;
  border-color: #0e56ad;
  box-shadow: 0 0 0 3px rgba(13, 68, 141, 0.14);
}

button.exportBusy::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, 0.34) 45%, transparent 70%);
  transform: translateX(-120%);
  animation: exportSweep 900ms ease-in-out infinite;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

@keyframes exportPulse {
  0% {
    transform: translateY(1px) scale(0.97);
    box-shadow: 0 0 0 0 rgba(13, 68, 141, 0.25);
  }
  55% {
    transform: translateY(0) scale(1.025);
    box-shadow: 0 0 0 5px rgba(13, 68, 141, 0.13);
  }
  100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 0 0 0 rgba(13, 68, 141, 0);
  }
}

@keyframes exportSweep {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(120%);
  }
}

.hint {
  min-height: 38px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.exportsBox {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbfc;
}

.exportsTitle {
  font-size: 13px;
  color: var(--muted);
}

.exportsList {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.exportsList span {
  color: var(--muted);
}

.batchSummary {
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbfc;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.batchTable {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  font-size: 12px;
}

.batchTable table {
  width: 100%;
  border-collapse: collapse;
}

.batchTable th,
.batchTable td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.batchTable th {
  position: sticky;
  top: 0;
  background: #fafbfc;
  color: var(--muted);
  font-weight: 600;
}

.batchTable .ok {
  color: #126b3a;
}

.batchTable .error {
  color: #a23b2a;
}

.previewWrap {
  min-width: 0;
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
}

/* 越界提示条。
   位置放在预览区底部居中 —— 旗面是居中的，底部是白边，压不到字。
   pointer-events: none 是硬要求：它绝对不能挡住客户拖文字和图案。 */
.pennantFrameWarn {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  z-index: 6;
  width: max-content;
  max-width: calc(100% - 16px);
  box-sizing: border-box;
  height: 24px;
  max-height: 24px;
  padding: 4px 12px;
  border-radius: 8px;
  background: #d92d20;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
  white-space: nowrap;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: none;
  pointer-events: none;
}

.pennantFrameWarn[hidden] {
  display: none;
}

.previewToolbar {
  min-height: 38px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.preview {
  min-height: 540px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

.preview svg {
  width: min(100%, 900px);
  height: auto;
  display: block;
}

@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
  }

  .preview {
    min-height: 380px;
  }
}
