/* ── Compile / Export Overlay ── */

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.compile-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.15s var(--ease-out);
  font-family: var(--font-ui);
}

/* ── Header ── */

.compile-header {
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
}

.compile-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.compile-close-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.1s var(--ease-out), background 0.1s var(--ease-out);
}

.compile-close-btn:hover {
  color: var(--text);
  background: var(--surface);
}

/* ── Body ── */

.compile-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Scenes panel (left) ── */

.compile-scenes-panel {
  width: 360px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.compile-scenes-header {
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

.compile-scenes-header label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 400;
  cursor: pointer;
}

.compile-scene-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

/* ── Scene rows ── */

.compile-scene-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 1rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s var(--ease-out);
}

.compile-scene-row:hover {
  background: var(--surface);
}

.compile-scene-row.is-folder {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--muted);
  padding-top: 0.6rem;
  cursor: default;
}

.compile-scene-row.is-folder:hover {
  background: transparent;
}

.compile-scene-icon {
  font-size: 0.85rem;
  flex-shrink: 0;
}

.compile-scene-title {
  flex: 1;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.compile-scene-row.is-folder .compile-scene-title {
  color: var(--muted);
}

.compile-scene-wc {
  font-size: 0.7rem;
  color: var(--muted);
  flex-shrink: 0;
  opacity: 0.7;
}

/* ── Settings panel (right) ── */

.compile-settings-panel {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  max-width: 560px;
}

.compile-settings-section {
  margin-bottom: 1.5rem;
}

.compile-settings-section h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 0.75rem 0;
  font-weight: 600;
}

.compile-settings-section label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
}

.compile-settings-section label input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--accent);
}

.compile-settings-section input[type="text"] {
  flex: 1;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-family: var(--font-ui);
  outline: none;
  transition: border-color 0.15s;
}

.compile-settings-section input[type="text"]:focus {
  border-color: var(--accent);
}

.compile-settings-section select {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-family: var(--font-ui);
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
  appearance: auto;
}

.compile-settings-section select:focus {
  border-color: var(--accent);
}

/* ── Actions ── */

.compile-actions {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.compile-word-count {
  font-size: 0.85rem;
  color: var(--muted);
}

.compile-error-msg {
  color: #ef4444;
  font-size: 0.8rem;
  display: none;
}

.compile-btn-epub {
  width: 100%;
  padding: 0.75rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 600;
  font-family: var(--font-ui);
  transition: opacity 0.15s, filter 0.15s;
}

.compile-btn-epub:hover {
  filter: brightness(1.1);
}

.compile-btn-epub:active {
  filter: brightness(0.9);
}

.compile-btn-pdf {
  width: 100%;
  padding: 0.75rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 600;
  font-family: var(--font-ui);
  transition: background 0.15s, border-color 0.15s;
}

.compile-btn-pdf:hover {
  background: var(--surface-2);
  border-color: var(--accent);
}

.compile-btn-epub:disabled,
.compile-btn-pdf:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

/* ── Responsive: narrow screens ── */

@media (max-width: 680px) {
  .compile-scenes-panel {
    width: 200px;
  }
  .compile-settings-panel {
    max-width: none;
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .compile-body {
    flex-direction: column;
  }
  .compile-scenes-panel {
    width: 100%;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}
