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

:root {
  --bg: #0c0f14;
  --surface: #13171f;
  --surface2: #1a1f28;
  --border: #242b38;
  --muted: #6e7d93;
  --text: #dce3ef;
  --accent: #5b9cf5;
  --accent-dim: rgba(91, 156, 245, 0.1);
  --danger: #f55b5b;
  --radius: 5px;
}

body {
  font-family:
    Inter,
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  overflow: hidden;
  height: 100vh;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 36px;
}
.brand {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.3px;
  margin-right: 4px;
  white-space: nowrap;
}
.toolbar-hint {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 4px;
}
.toolbar-group {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar-left {
  flex: 1;
}
.toolbar-right {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-left: auto;
}
.toolbar-link {
  text-decoration: none;
  font-size: 11px;
}
.status-text {
  display: none; /* replaced by status-bar */
}

/* Status bar — full width below toolbar */
.status-bar {
  padding: 4px 12px;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-height: 24px;
  line-height: 1.5;
}
.status-bar.status-onboarding {
  display: none;
}
.status-bar.status-hidden {
  display: none;
}
.status-bar.status-success {
  color: #6ecf6e;
}
.status-bar.status-progress {
  color: #e8c44a;
}
.status-bar.status-error {
  color: var(--danger);
  font-weight: 600;
}

/* Buttons */
button,
select,
label.btn {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  padding: 3px 10px;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  white-space: nowrap;
  line-height: 1.6;
}
button:hover,
select:hover,
label.btn:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}
button:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}
.btn-primary {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
  font-weight: 600;
}
.btn-primary:hover {
  background: #4a8be4 !important;
}
.btn-secondary {
  color: var(--muted);
  font-size: 10px;
}
.toolbar-sep {
  color: var(--border);
  font-size: 14px;
  user-select: none;
  margin: 0 2px;
}
.btn-danger {
  color: var(--danger);
}
.btn-danger:hover {
  border-color: var(--danger);
  background: rgba(245, 91, 91, 0.1);
}
.btn-confirm {
  background: var(--danger) !important;
  color: #fff !important;
  border-color: var(--danger) !important;
  animation: pulse-confirm 0.6s ease-in-out infinite alternate;
}
@keyframes pulse-confirm {
  from {
    opacity: 1;
  }
  to {
    opacity: 0.7;
  }
}
.btn-export {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
  font-weight: 600;
}
.btn-export:hover {
  background: #4a8be4 !important;
}
.btn-export:disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

/* Layout picker */
.layout-picker {
  display: flex;
  gap: 2px;
}
.layout-btn {
  width: 28px;
  height: 26px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface2);
  cursor: pointer;
}
.layout-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.layout-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

input[type="file"] {
  display: none;
}

/* Drop overlay */
.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: rgba(91, 156, 245, 0.12);
  border: 3px dashed var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}
.drop-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.drop-icon {
  font-size: 48px;
}
.drop-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
}

/* Empty state CTA */
.empty-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 48px 24px 40px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition:
    border-color 0.2s,
    background 0.2s;
}
.empty-drop-zone:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.drop-zone-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}
.drop-zone-steps {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.5px;
}
.drop-zone-privacy {
  font-size: 11px;
  color: var(--muted);
}
.drop-zone-divider {
  width: 48px;
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}
.drop-zone-icon {
  font-size: 36px;
  opacity: 0.6;
}
.drop-zone-text {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* Workspace */
.workspace {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: calc(100vh - 60px);
  overflow: hidden;
}
.left-pane,
.right-pane {
  padding: 6px;
}
.left-pane {
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.right-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Sections */
.section-bar {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 4px 2px 3px;
  flex-shrink: 0;
}
.section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.section-count {
  font-size: 10px;
  color: var(--muted);
}

/* Page navigation (right-pane preview pagination) */
.page-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.page-nav-btn {
  width: 24px;
  height: 22px;
  padding: 0;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.page-nav-label {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

/* Report info */
.meta-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 4px;
}
.meta-panel summary {
  padding: 5px 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  list-style: none;
}
.meta-panel summary::before {
  content: "\25B8 ";
}
.meta-panel[open] summary::before {
  content: "\25BE ";
}
.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 0 6px 6px;
}
.meta-field {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.meta-field span {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.meta-field.full-width {
  grid-column: 1 / -1;
}
.pdf-grid {
  align-items: start;
}
.meta-field input,
.meta-field textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  padding: 3px 6px;
  font-size: 11px;
  font-family: inherit;
  resize: none;
  overflow: hidden;
}
.meta-field input:focus,
.meta-field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.token-hint {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.4;
}
.support-panel {
  margin-bottom: 4px;
}
.support-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 8px 8px;
}
.support-links a {
  color: var(--accent);
  font-size: 11px;
  text-decoration: none;
}
.support-links a:hover {
  text-decoration: underline;
}

/* Photo list */
.photo-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
/* During reorder: collapse gaps and make all children pass-through */
.photo-list.reordering {
  gap: 0;
}
.photo-list.reordering .photo-row > * {
  pointer-events: none;
}
.photo-row {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 5px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: grab;
  content-visibility: auto;
  contain-intrinsic-size: auto 60px;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.15s ease,
    opacity 0.15s ease;
}
.photo-row:hover {
  border-color: color-mix(in srgb, var(--border) 50%, var(--accent));
}
.photo-row.dragging {
  opacity: 0.3;
  cursor: grabbing;
  transform: scale(0.97);
}
.photo-row.drag-above {
  box-shadow: 0 -3px 0 0 var(--accent);
  transform: translateY(2px);
}
.photo-row.drag-below {
  box-shadow: 0 3px 0 0 var(--accent);
  transform: translateY(-2px);
}
.thumb {
  width: 48px;
  height: 48px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--bg);
  flex-shrink: 0;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center center;
}
.row-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.row-top {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.row-idx {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}
.row-file {
  font-size: 10px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.row-size {
  font-size: 9px;
  color: var(--muted);
  flex-shrink: 0;
}
.row-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  margin-left: auto;
}
.row-actions button {
  width: 20px;
  height: 20px;
  padding: 0;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.title-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  padding: 2px 5px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  width: 100%;
}
.title-input:focus {
  outline: none;
  border-color: var(--accent);
}
.desc-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  padding: 2px 5px;
  font-size: 10px;
  font-family: inherit;
  resize: none;
  min-height: 20px;
  width: 100%;
  overflow: hidden;
}
.desc-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Preview pane */
.page-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.page-label {
  font-size: 9px;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.matrix {
  display: grid;
  gap: 6px;
  flex: 1;
}
.matrix.cols-1 {
  grid-template-columns: 1fr;
}
.matrix.cols-2 {
  grid-template-columns: 1fr 1fr;
}

.slot {
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.slot.filled {
  cursor: grab;
  position: relative;
  transition: opacity 0.15s;
}
.slot.filled.dragging {
  opacity: 0.35;
  cursor: grabbing;
}
.slot.filled.drag-above {
  box-shadow: inset 0 3px 0 0 var(--accent);
}
.slot.filled.drag-below {
  box-shadow: inset 0 -3px 0 0 var(--accent);
}
.slot-media {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a2e;
  padding: 8px;
}
.slot.filled img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  transform-origin: center center;
}
.slot-info {
  padding: 4px 6px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex: 0 0 auto;
  min-height: fit-content;
}
.slot-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  line-height: 1.3;
}
.slot-desc {
  font-size: 9px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  margin-top: 1px;
  line-height: 1.3;
}
.slot.empty {
  flex: 1;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 10px;
  border-style: dashed;
}

/* Progress bar */
.progress-bar-wrap {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 4px;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.15s ease;
  border-radius: 2px;
}

/* Responsive */
@media (max-width: 800px) {
  body {
    overflow: auto;
    height: auto;
  }
  .workspace {
    grid-template-columns: 1fr;
    height: auto;
  }
  .left-pane {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .meta-grid {
    grid-template-columns: 1fr;
  }
}

/* Logo upload */
.logo-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.logo-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.logo-preview {
  max-width: 80px;
  max-height: 40px;
  object-fit: contain;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.logo-btn input[type="file"] {
  display: none;
}
.btn-sm {
  padding: 1px 6px;
  font-size: 10px;
}

/* Checkbox field */
.checkbox-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  grid-column: 1 / -1;
}
.checkbox-field input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Title page badge */
.title-page-badge {
  font-size: 10px;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: auto;
}

/* Cover page preview */
.cover-preview {
  justify-content: center;
  align-items: center;
}
.cover-preview .page-label {
  position: absolute;
  top: 12px;
  left: 12px;
}
.cover-preview-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 20px;
  width: 100%;
}
.cover-preview-logo {
  max-width: 120px;
  max-height: 60px;
  object-fit: contain;
  margin-bottom: 6px;
}
.cover-preview-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin: 0;
}
.cover-preview-detail {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  line-height: 1.4;
}
.cover-preview-detail strong {
  color: var(--text);
}
.cover-preview-notes {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}
.cover-preview-notes strong {
  color: var(--text);
}
.cover-preview-notes p {
  margin: 2px 0 0;
}

/* ---------- Support modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.modal-title {
  font-size: 16px;
  color: var(--text);
  margin: 0 0 10px;
}
.modal-body {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 20px;
}
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.btn-accent {
  background: #ffdd00;
  color: #1a1a1a;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  padding: 10px 24px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn-accent:hover {
  background: #e6c800;
}
.btn-text {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px;
}
.btn-text:hover {
  color: var(--text);
}
