:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #1f232c;
  --border: #2a2f3a;
  --text: #e7ebf2;
  --muted: #9aa3b2;
  --accent: #ffb020;
  --accent-2: #4ea1ff;
  --good: #38c172;
  --danger: #ff5d5d;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 70% -10%, #1b2230 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { margin: 0; font-weight: 650; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 17, 21, 0.6);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  font-size: 30px;
  color: var(--accent);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 46px; height: 46px;
  display: grid; place-items: center;
}
.topbar h1 { font-size: 18px; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(380px, 460px) 1fr;
  gap: 18px;
  padding: 18px;
  align-items: start;
}
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.config-panel h2 { font-size: 15px; margin-top: 18px; }
.config-panel h2:first-child { margin-top: 0; }

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0;
}
.field-grid label {
  display: flex;
  flex-direction: column;
  font-size: 12.5px;
  color: var(--muted);
  gap: 5px;
}
.field-grid input,
.field-grid select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  width: 100%;
}
.field-grid small { color: #6c7484; font-size: 11px; }
.checkbox-field {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  color: var(--text) !important;
  font-size: 13px !important;
}
.checkbox-field input { width: auto !important; }
.checkbox-field.inline { font-size: 12.5px !important; }

.advanced { margin: 6px 0 4px; border-top: 1px solid var(--border); padding-top: 8px; }
.advanced summary { cursor: pointer; color: var(--muted); font-size: 13px; }

.hint, .print-note { color: var(--muted); font-size: 12.5px; }
.muted { color: var(--muted); }

/* Photo slots */
.slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 10px 0;
}
.slot {
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  padding: 8px;
  text-align: center;
  position: relative;
}
.slot .slot-label { font-size: 11.5px; color: var(--muted); display: block; margin-bottom: 6px; letter-spacing: .04em; text-transform: uppercase; }
.slot .thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  background: #0c0e12 center/cover no-repeat;
  display: grid;
  place-items: center;
  cursor: pointer;
  overflow: hidden;
  border: 1px solid var(--border);
}
.slot .thumb.empty::after { content: "＋"; font-size: 26px; color: #4a5160; }
.slot .thumb img { width: 100%; height: 100%; object-fit: cover; }
.slot .slot-actions { display: flex; gap: 6px; margin-top: 6px; justify-content: center; }
.slot .mini { font-size: 11px; color: var(--accent-2); cursor: pointer; background: none; border: none; }
.slot .mini.del { color: var(--danger); }
.slot input[type=file] { display: none; }

.primary-btn {
  background: linear-gradient(180deg, var(--accent), #e69a12);
  color: #1a1300;
  border: none;
  border-radius: 9px;
  padding: 11px 16px;
  font-weight: 650;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
}
.primary-btn:hover { filter: brightness(1.05); }
.primary-btn:disabled { opacity: .4; cursor: not-allowed; }
.primary-btn.outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.ghost-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
}
.downloads { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.gen-status { font-size: 12.5px; color: var(--muted); min-height: 18px; margin: 8px 0; }
.gen-status.busy { color: var(--accent); }
.gen-status.error { color: var(--danger); }
.gen-status.done { color: var(--good); }

/* Preview */
.preview-panel { position: sticky; top: 78px; }
.preview-head { display: flex; align-items: center; justify-content: space-between; }
.preview-controls { display: flex; gap: 14px; }
.viewport {
  margin-top: 12px;
  position: relative;
  width: 100%;
  height: 540px;
  border-radius: 10px;
  overflow: hidden;
  background: #0a0c10;
  border: 1px solid var(--border);
}
.viewport canvas { display: block; }
.viewport-empty {
  position: absolute; inset: 0;
  display: grid; place-content: center; text-align: center;
  gap: 6px; padding: 20px;
}
.print-note { margin: 12px 2px 0; line-height: 1.5; }

/* Modals */
.modal {
  position: fixed; inset: 0;
  background: rgba(6, 8, 12, 0.72);
  display: grid; place-items: center;
  z-index: 20;
  padding: 16px;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  width: min(480px, 100%);
}
.modal-card h3 { margin-bottom: 14px; }
.crop-stage { display: grid; place-items: center; background: #0a0c10; border-radius: 10px; padding: 10px; }
#cropCanvas { touch-action: none; cursor: grab; border-radius: 6px; }
.crop-controls { display: grid; gap: 10px; margin: 14px 0; }
.crop-controls label { display: grid; grid-template-columns: 64px 1fr; align-items: center; font-size: 13px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.modal-actions .primary-btn, .modal-actions .ghost-btn { width: auto; }
.help-list, .help-list + p { font-size: 13.5px; line-height: 1.6; }
.help-list { padding-left: 18px; }

.footer {
  border-top: 1px solid var(--border);
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.bmc { display: flex; align-items: center; }
