:root {
  color-scheme: dark;
  --bg: #101114;
  --panel: #191b20;
  --panel-2: #20242b;
  --text: #f2f5f7;
  --muted: #99a3ad;
  --line: #303741;
  --accent: #4cc9a3;
  --accent-2: #f2b84b;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--accent);
  color: #07110e;
  cursor: pointer;
  font-weight: 700;
}

button.secondary {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
}

button.danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--danger) 60%, transparent);
  color: var(--danger);
}

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

button.small-button {
  padding: 6px 9px;
  font-size: 12px;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 5vw, 46px);
  line-height: 1.02;
}

h2 {
  font-size: 18px;
}

.actions,
.form-row,
.order-actions,
.row-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 440px) 1fr;
  gap: 18px;
  margin-top: 22px;
}

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

.panel {
  padding: 18px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: baseline;
  margin-bottom: 14px;
}

.section-title span,
#statusLine {
  color: var(--muted);
  font-size: 13px;
}

.drop-zone {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 320 / 170;
  border: 1px dashed #56616c;
  border-radius: 8px;
  overflow: hidden;
  background: #0c0d10;
  cursor: pointer;
}

.drop-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

#previewCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

#dropHint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  pointer-events: none;
}

.drop-zone.has-image #dropHint {
  display: none;
}

.form-row {
  margin-top: 14px;
}

input[type="text"] {
  min-width: 0;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #111318;
  color: var(--text);
}

.image-list {
  display: grid;
  gap: 10px;
  min-height: 220px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.image-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.image-row.active {
  border-color: var(--accent);
}

.index-badge {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #111318;
  color: var(--accent-2);
  font-weight: 800;
}

.image-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.image-detail {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.order-actions {
  justify-content: flex-end;
  margin-top: 14px;
}

.log-panel {
  margin-top: 18px;
  padding: 13px 16px;
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

#debugLog {
  min-height: 150px;
  max-height: 260px;
  margin: 12px 0 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0d10;
  color: #cbd5df;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

@media (max-width: 860px) {
  .toolbar,
  .workspace {
    display: grid;
    grid-template-columns: 1fr;
  }

  .actions,
  .form-row,
  .row-actions {
    flex-wrap: wrap;
  }

  .image-row {
    grid-template-columns: 38px 1fr;
  }

  .row-actions {
    grid-column: 1 / -1;
  }
}
