:root {
  --bg: #0f1115;
  --fg: #e7e9ee;
  --muted: #8a8f9b;
  --accent: #6ee7b7;
  --error: #f87171;
  --border: #2a2f3a;
  --panel: #1a1d24;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

main {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  min-height: 100vh;
}

.slots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  flex: 1;
  min-height: 0;
}

.slot {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  transition: border-color 120ms, background 120ms;
  min-height: 60vh;
  overflow: hidden;
}

.slot .preview,
.slot .example {
  margin-block: auto;
}

.slot.dragover { border-color: var(--accent); background: rgba(110, 231, 183, 0.06); }
.slot.busy     { border-color: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.slot.error    { border-color: var(--error); }
.slot.filled   { border-style: solid; }
.slot.target   { border-color: var(--accent); }

.slot.split {
  padding: 0;
  align-items: stretch;
}
.slot.split .drop-zone {
  position: relative;
  flex: 1 1 50%;
  min-height: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  border-bottom: 1px dashed var(--border);
  overflow: hidden;
}
.slot.split .drop-zone .preview,
.slot.split .drop-zone .example {
  max-height: 100%;
  max-width: 100%;
}
.slot.split.filled .drop-zone { border-bottom-style: solid; }

.slot.split .text-zone {
  flex: 1 1 50%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
}
.slot.split .text-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}
.slot.split .items-example {
  position: absolute;
  inset: 44px 0 0 0;
  margin: 0;
  width: 100%;
  max-height: none;
  object-fit: contain;
  object-position: center top;
  background: transparent;
}
.slot.split:has(.items:not(:placeholder-shown)) .items-example {
  display: none;
}
.slot.split .items {
  position: relative;
  flex: 1;
}
.slot.split .items {
  flex: 1;
  min-height: 0;
  width: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  outline: 0;
  resize: none;
  color: var(--fg);
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow: auto;
}
.slot.split .items::placeholder { color: var(--muted); }
.slot.split .items:focus { background: rgba(110, 231, 183, 0.04); }

@keyframes pulse {
  0%, 100% { background: rgba(110, 231, 183, 0.04); }
  50%      { background: rgba(110, 231, 183, 0.14); }
}

.slot h2 {
  margin: 0 0 4px;
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.slot .hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.slot.filled h2,
.slot.filled .hint {
  position: absolute;
  top: 12px;
  left: 16px;
  margin: 0;
  background: rgba(15, 17, 21, 0.7);
  padding: 2px 8px;
  border-radius: 6px;
}
.slot.filled .hint {
  top: 38px;
  font-size: 11px;
}

.slot .preview,
.slot .example {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  background: white;
}

.slot .preview {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* Landscape source images get rotated 90° for display only — the file uploaded
   to the server is unchanged, and src/image.js handles print orientation. */
.slot,
.slot.split .drop-zone {
  container-type: size;
}
.slot .preview.rotated {
  transform: rotate(90deg);
  max-width: 100cqh;
  max-height: 100cqw;
}

.slot .example {
  opacity: 0.35;
  filter: grayscale(0.4);
  transition: opacity 120ms;
  pointer-events: none;
}

.slot.dragover .example { opacity: 0.6; }
.slot.filled .example   { display: none; }

.slot-actions {
  display: flex;
  gap: 8px;
  align-self: center;
  margin-top: 16px;
}
.slot-actions button {
  padding: 6px 18px;
  font-size: 13px;
}

.controls {
  display: flex;
  gap: 12px;
  justify-content: center;
}

button {
  padding: 12px 28px;
  font: inherit;
  font-weight: 600;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 120ms, transform 120ms;
}
button:disabled { opacity: 0.3; cursor: not-allowed; }
button:not(:disabled):hover { transform: translateY(-1px); }

button.secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}
button.secondary:not(:disabled):hover { border-color: var(--accent); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(40px);
  padding: 10px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  opacity: 0;
  transition: transform 200ms, opacity 200ms;
  pointer-events: none;
  white-space: pre-wrap;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok    { border-color: var(--accent); }
.toast.error { border-color: var(--error); color: var(--error); }
