html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, sans-serif;
  background: #1a1a1a;
  color: #e0e0e0;
}

.app {
  display: flex;
  min-height: 100vh;
  gap: 0;
}

.controls {
  width: 280px;
  padding: 1.5rem;
  background: #252525;
  border-right: 1px solid #333;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.controls h1 {
  margin: 0 0 0.5rem 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.875rem;
}

.controls input[type="text"],
.controls input[type="number"],
.controls textarea {
  padding: 0.5rem;
  border: 1px solid #444;
  border-radius: 6px;
  background: #1a1a1a;
  color: #e0e0e0;
  font-size: 0.9rem;
}

.controls textarea {
  min-height: 140px;
  resize: vertical;
  width: 100%;
  box-sizing: border-box;
}

.controls #pathInput {
  min-height: 80px;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
}

.controls select {
  padding: 0.5rem;
  border: 1px solid #444;
  border-radius: 6px;
  background: #1a1a1a;
  color: #e0e0e0;
  font-size: 0.9rem;
  width: 100%;
  cursor: pointer;
}

.controls .font-upload-row {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  display: none;
}

.controls .font-upload-row.visible {
  display: flex;
}

.controls .font-upload-row input[type="file"] {
  flex: 1;
  min-width: 0;
  font-size: 0.8rem;
  padding: 0.25rem 0;
}

.controls .font-file-name {
  font-size: 0.75rem;
  color: #888;
  word-break: break-all;
}

.controls input[type="number"] {
  width: 6ch;
}

.controls .hex {
  width: 7ch;
  font-family: ui-monospace, monospace;
}

.controls input[type="color"] {
  width: 100%;
  height: 32px;
  padding: 0;
  border: 1px solid #444;
  border-radius: 6px;
  cursor: pointer;
  background: #1a1a1a;
}

.controls fieldset.colors {
  border: 1px solid #444;
  border-radius: 8px;
  padding: 0.75rem;
  margin: 0;
}

.controls fieldset.colors legend {
  padding: 0 0.5rem;
  font-size: 0.875rem;
}

.controls .color-row,
.controls .fill-row,
.controls .bg-row {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
}

.controls .color-row span,
.controls .fill-row span,
.controls .bg-row span {
  min-width: 4.5rem;
}

.controls .color-row input[type="color"],
.controls .fill-row input[type="color"],
.controls .bg-row input[type="color"] {
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.controls .hint {
  margin: 0.5rem 0 0 0;
  font-size: 0.75rem;
  color: #888;
}

.controls .checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.controls .checkbox-row input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: #e85d04;
}

.controls .download-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.controls .download-row button {
  flex: 1;
  min-width: 120px;
  padding: 0.6rem 0.75rem;
  border: 1px solid #444;
  border-radius: 6px;
  background: #333;
  color: #e0e0e0;
  font-size: 0.875rem;
  cursor: pointer;
}

.controls .download-row button:hover {
  background: #444;
}

.output-wrap {
  flex: 1;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
}

.a4 {
  width: 210mm;
  max-width: 100%;
  height: 297mm;
  max-height: calc(100vh - 5rem);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  border-radius: 2px;
  overflow: hidden;
  background: #000;
}

.a4.transparent-bg {
  background: transparent;
  background-image:
    linear-gradient(45deg, #333 25%, transparent 25%),
    linear-gradient(-45deg, #333 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #333 75%),
    linear-gradient(-45deg, transparent 75%, #333 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: #252525;
}

.a4 svg {
  width: 100%;
  height: 100%;
  display: block;
}

.a4-label {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: #888;
}

@media (max-width: 900px) {
  .app {
    flex-direction: column;
  }

  .controls {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #333;
  }

  .output-wrap {
    padding: 1rem;
  }

  .a4 {
    height: 297mm;
    max-height: 80vh;
  }
}
