*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%);
  color: #fff;
  padding: 2rem 1.5rem;
  text-align: center;
}
header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}
header p {
  margin-top: .5rem;
  font-size: .95rem;
  opacity: .75;
}

/* ── Main ── */
main {
  max-width: 960px;
  margin: 2rem auto;
  padding: 0 1rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Section ── */
.section {
  background: #fff;
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
}
.section-title {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: #0f3460;
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid #e8eaf0;
}

/* ── Slots row ── */
.slots-row {
  display: flex;
  gap: 1rem;
}
.slots-row.two-col .slot-card {
  flex: 1;
}
@media (max-width: 600px) {
  .slots-row.two-col {
    flex-direction: column;
  }
}

/* ── Slot card ── */
.slot-card {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.slot-label {
  font-size: .85rem;
  font-weight: 600;
  color: #555;
}

/* ── Upload area ── */
.upload-area {
  border: 2px dashed #c0c8d8;
  border-radius: 10px;
  padding: 1.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
  background: #fafbfd;
}
.upload-area:hover,
.upload-area.dragover {
  border-color: #0f3460;
  background: #f0f4ff;
}
.upload-area.has-file {
  border-color: #28a745;
  background: #f0fff4;
}
.upload-icon {
  font-size: 2rem;
  margin-bottom: .4rem;
}
.upload-text {
  font-size: .9rem;
  font-weight: 600;
  color: #333;
}
.upload-hint {
  font-size: .78rem;
  color: #888;
  margin-top: .2rem;
}
.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* ── Slot info ── */
.slot-info {
  font-size: .82rem;
  color: #444;
  background: #f5f7fa;
  border-radius: 6px;
  padding: .4rem .7rem;
}
.slot-info strong {
  color: #0f3460;
}

/* ── Page preview ── */
.page-preview {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #e0e5ef;
  max-height: 220px;
}
.preview-thumb {
  width: 100%;
  display: block;
  object-fit: contain;
  max-height: 220px;
  background: #f0f0f0;
}
.page-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(15,52,96,.85);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  padding: .2rem .5rem;
  border-radius: 20px;
}

/* ── Buttons ── */
.btn-select-page {
  background: #0f3460;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .5rem 1rem;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
.btn-select-page:hover {
  background: #16213e;
}
.btn-clear {
  background: none;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: .4rem .8rem;
  font-size: .8rem;
  color: #999;
  cursor: pointer;
  transition: color .2s, border-color .2s;
}
.btn-clear:hover {
  color: #c0392b;
  border-color: #c0392b;
}

/* ── Generate section ── */
.generate-section {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.btn-generate {
  background: linear-gradient(135deg, #0f3460, #1a6faf);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: .85rem 2.5rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .2s, transform .1s;
  letter-spacing: .3px;
}
.btn-generate:disabled {
  opacity: .4;
  cursor: not-allowed;
}
.btn-generate:not(:disabled):hover {
  opacity: .9;
  transform: translateY(-1px);
}
.btn-download {
  display: inline-block;
  background: #28a745;
  color: #fff;
  border-radius: 10px;
  padding: .85rem 2.5rem;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  transition: opacity .2s;
}
.btn-download:hover {
  opacity: .88;
}

/* ── Status ── */
.status-msg {
  font-size: .9rem;
  padding: .6rem 1.2rem;
  border-radius: 8px;
  font-weight: 500;
}
.status-msg.info   { background: #e8f4fd; color: #0f6ea0; }
.status-msg.success{ background: #eafaf1; color: #1d7a3e; }
.status-msg.error  { background: #fdecea; color: #c0392b; }

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden {
  display: none;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
}
.modal-box {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 14px;
  padding: 1.5rem;
  width: min(520px, 95vw);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f3460;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: #888;
  padding: .2rem .4rem;
  border-radius: 4px;
}
.modal-close:hover { color: #333; }
.modal-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}
.nav-btn {
  background: #f0f2f5;
  border: none;
  border-radius: 8px;
  width: 2.2rem;
  height: 2.2rem;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.nav-btn:hover { background: #dde1e9; }
.nav-btn:disabled { opacity: .3; cursor: default; }
#modal-page-info {
  font-size: .9rem;
  font-weight: 600;
  min-width: 60px;
  text-align: center;
}
.modal-preview {
  width: 100%;
  max-height: 420px;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid #e0e5ef;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
}
#modal-img {
  max-width: 100%;
  max-height: 420px;
  object-fit: contain;
}
.btn-modal-select {
  background: #0f3460;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: .75rem 1.5rem;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: background .2s;
}
.btn-modal-select:hover { background: #16213e; }

/* ── Utility ── */
.hidden { display: none !important; }
