* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: #fff7ed; color: #3c2415; }

#app { display: flex; height: 100vh; }

#sidebar {
  width: 300px; background: #fde6c4; padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
  border-right: 2px solid #f5c98a; overflow-y: auto;
}
#sidebar h1 { font-size: 20px; color: #b45309; }
#sidebar h2 { font-size: 14px; color: #92400e; margin-top: 10px; }

.input-group { display: flex; flex-direction: column; gap: 8px; }
#titleInput, #synopsisInput {
  padding: 10px 12px; border-radius: 10px; border: 2px solid #f5c98a;
  font-size: 14px; background: #fff; font-family: inherit;
  resize: vertical;
}
#titleInput { font-size: 15px; }
#synopsisInput { line-height: 1.5; min-height: 100px; }
#generateBtn {
  padding: 10px; border-radius: 10px; border: none; cursor: pointer;
  background: #f97316; color: #fff; font-size: 15px; font-weight: 600;
}
#generateBtn:hover { background: #ea580c; }
#generateBtn:disabled { background: #d4a373; cursor: not-allowed; }

.status { font-size: 13px; color: #92400e; min-height: 18px; line-height: 1.6; }

#bookList { list-style: none; display: flex; flex-direction: column; gap: 4px; }
#bookList li {
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  background: #fff8ef; font-size: 13px;
}
#bookList li:hover { background: #fff; }
#bookList li.active { background: #f97316; color: #fff; }
#bookList .meta { font-size: 11px; opacity: 0.6; }

#reader { flex: 1; padding: 28px; overflow-y: auto; }
.empty { text-align: center; margin-top: 30vh; color: #b45309; font-size: 18px; }

.book-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px;
}
.book-header h2 { color: #b45309; font-size: 22px; }
.book-meta { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #92400e; }
.export-group { position: relative; display: inline-block; }
#exportBtn, #retryBtn {
  padding: 6px 12px; border: 1px solid #f5c98a; border-radius: 6px;
  background: #fff; cursor: pointer; font-size: 13px;
}
.export-menu {
  position: absolute; top: 100%; right: 0; margin-top: 4px;
  background: #fff; border: 1px solid #f5c98a; border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1); min-width: 140px;
  overflow: hidden; z-index: 10;
}
.export-menu a {
  display: block; padding: 8px 14px; font-size: 13px;
  color: #3c2415; cursor: pointer; text-decoration: none;
}
.export-menu a:hover { background: #fef3c7; }
#retryBtn { background: #fef3c7; color: #b45309; font-weight: 600; }
#retryBtn:hover { background: #fde68a; }
#retryBtn:disabled { opacity: 0.5; cursor: not-allowed; }

.page-stage { display: flex; align-items: center; gap: 12px; }
.nav {
  width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
  background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  font-size: 24px; color: #b45309;
}
.nav:hover { background: #f97316; color: #fff; }
.nav:disabled { opacity: 0.3; cursor: not-allowed; }

.page-card {
  flex: 1; background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 4px 16px rgba(180, 83, 9, 0.15);
  display: flex; flex-direction: column;
}
.page-image {
  width: 100%; aspect-ratio: 3 / 2; background: #fef3c7;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.page-image img { width: 100%; height: 100%; object-fit: cover; }
.image-placeholder { color: #92400e; font-size: 16px; }
.image-placeholder.error { color: #c2410c; }

.page-image { position: relative; }
.placeholder-tag {
  position: absolute; top: 10px; right: 10px;
  background: rgba(124, 45, 18, 0.7); color: #fff;
  font-size: 11px; padding: 3px 8px; border-radius: 4px;
}
.page-body { padding: 22px 28px; }
.page-number { font-size: 12px; color: #b45309; margin-bottom: 6px; }
.narration { font-size: 20px; line-height: 1.7; color: #3c2415; margin-bottom: 16px; }

.interaction {
  background: #fef3c7; border-radius: 12px; padding: 14px 16px;
  border-left: 4px solid #f97316;
}
.interaction-type {
  display: inline-block; font-size: 11px; padding: 2px 8px;
  background: #f97316; color: #fff; border-radius: 4px; margin-bottom: 6px;
}
.question { font-size: 16px; color: #b45309; font-weight: 600; margin-bottom: 6px; }
.encouragement { font-size: 13px; color: #92400e; font-style: italic; }

.thumbs {
  display: flex; gap: 6px; margin-top: 16px; overflow-x: auto; padding-bottom: 6px;
}
.thumb {
  flex-shrink: 0; width: 80px; height: 54px; border-radius: 6px;
  background: #fef3c7; cursor: pointer; overflow: hidden;
  border: 2px solid transparent; display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #b45309;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.active { border-color: #f97316; }
.thumb.missing { border-color: #dc2626; background: #fee2e2; color: #991b1b; }
.thumb { position: relative; }
.thumb-warn {
  position: absolute; bottom: 2px; right: 2px;
  background: rgba(180, 83, 9, 0.75); color: #fff;
  font-size: 10px; padding: 1px 5px; border-radius: 3px;
}
