:root {
  --paper-bg: #f6f0e2;
  --paper-grain: #ece2ce;
  --ink-black: #2b2520;
  --vermilion-red: #c0352b;
  --cinnabar: #a9281f;
  --bamboo-green: #3d6647;
  --gold-accent: #c49a45;
  --line-brown: #5a4b41;
  --border-sepia: #998372;
  --shadow-warm: 0 10px 30px rgba(60, 40, 20, 0.22);
}

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

body {
  font-family: 'Noto Serif SC', 'Songti SC', 'SimSun', serif;
  background-color: #242220;
  background-image: radial-gradient(#3a332c 15%, transparent 16%), radial-gradient(#312922 15%, transparent 16%);
  background-size: 60px 60px;
  background-position: 0 0, 30px 30px;
  color: var(--ink-black);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 顶部导航 */
.top-nav {
  background: linear-gradient(180deg, #1f1d1b, #151312);
  color: #eeddbb;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--gold-accent);
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.seal-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background-color: var(--vermilion-red);
  color: #fff;
  font-family: 'Ma Shan Zheng', cursive;
  font-size: 1.1rem;
  border-radius: 4px;
  box-shadow: inset 0 0 4px rgba(0,0,0,0.3);
  border: 1px solid #7c1a12;
}

.nav-brand h1 {
  font-family: 'Ma Shan Zheng', cursive;
  font-size: 1.5rem;
  font-weight: normal;
  letter-spacing: 2px;
  color: #f7e6c4;
}

/* 顶部藏书阁书架栏 */
.book-shelf-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid #7d633c;
  padding: 4px 10px;
  border-radius: 6px;
}

.shelf-label {
  font-size: 0.9rem;
  color: #e2cfa7;
  font-weight: bold;
}

.book-shelf-select {
  font-family: inherit;
  font-size: 0.95rem;
  background-color: #2b221a;
  color: #f5eedf;
  border: 1px solid #b58d4a;
  border-radius: 4px;
  padding: 4px 8px;
  max-width: 220px;
  cursor: pointer;
}
.book-shelf-select:focus {
  outline: none;
  border-color: #ffd276;
}

.btn-subtle.danger:hover {
  background: #a9281f;
  border-color: #e54b3e;
  color: #fff;
}

.nav-actions {
  display: flex;
  gap: 10px;
}

button {
  cursor: pointer;
  font-family: inherit;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #c79740, #9f7529);
  color: #1a1202;
  border: 1px solid #e5b967;
  font-weight: 600;
  padding: 6px 14px;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #dbab4e, #b88a33);
  transform: translateY(-1px);
}

.btn-subtle {
  background: rgba(255, 255, 255, 0.08);
  color: #ddd;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 6px 12px;
}
.btn-subtle:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.btn-small {
  padding: 4px 10px;
  font-size: 0.85rem;
  background: var(--paper-bg);
  border: 1px solid var(--border-sepia);
  color: var(--ink-black);
}
.btn-small:hover {
  background: #eeddbb;
}

.btn-secondary {
  padding: 6px 12px;
  background: #d8c39e;
  border: 1px solid #8e7a67;
  color: #3b2c1f;
  font-size: 0.9rem;
}
.btn-secondary:hover {
  background: #c5ae87;
}

.btn-danger-outline {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--cinnabar);
  color: var(--cinnabar);
}
.btn-danger-outline:hover {
  background: #fae4e3;
}

.btn-link {
  background: none;
  border: none;
  color: #887465;
  text-decoration: underline;
  font-size: 0.85rem;
  margin-top: 8px;
  cursor: pointer;
}
.btn-link:hover {
  color: var(--cinnabar);
}

/* 主容器 */
.main-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

/* ================================
   小人书经典装帧阅读区 (4:3 比例)
   ================================ */
.reader-section {
  width: 100%;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.book-stage {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ================================
   小人书经典装帧阅读区 (固定黄金比例开本)
   ================================ */
.reader-section {
  width: 100%;
  max-width: 980px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.book-stage {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 小人书卡片：全局固定黄金横开本比例 (例如传统 16:9 ~ 1.8:1 画幅) */
.lianhuanhua-card {
  width: 100%;
  aspect-ratio: 16 / 9; /* 锁定整本小人书每一页的外框比例完全一致 */
  min-height: 520px;
  background-color: var(--paper-bg);
  background-image: 
    radial-gradient(#dfd1ba 8%, transparent 9%),
    linear-gradient(135deg, rgba(255,255,255,0.4) 0%, rgba(0,0,0,0.03) 100%);
  background-size: 20px 20px, 100% 100%;
  border-radius: 8px;
  box-shadow: var(--shadow-warm), 0 0 0 1px #d6c6ad;
  padding: 20px;
  position: relative;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

/* 书卷内线框：经典仿宣纸双层细框，撑满固定比例外框 */
.card-inner-frame {
  border: 2px solid var(--line-brown);
  outline: 1px solid var(--line-brown);
  outline-offset: -5px;
  padding: 16px 22px 14px;
  background-color: rgba(255, 253, 248, 0.7);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  flex: 1;
  height: calc(100% - 10px);
  box-sizing: border-box;
}

/* 顶部回目与印章 */
.chapter-header {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px dashed #af9983;
  padding-bottom: 8px;
  flex-shrink: 0;
}

/* 底部装饰线与落款 */
.card-footer {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid #d9cbba;
  padding-top: 6px;
  margin-top: auto;
  flex-shrink: 0;
}

/* 主内容区结构：撑满中间剩余空间 */
.card-main-body {
  flex: 1;
  display: flex;
  gap: 20px;
  align-items: stretch;
  min-height: 0; /* 允许内部自适应不溢出 */
}

/* ========================================================
   统一典雅版式：左画右文 (四面山阳光草绿与青草纹衬底)
   ======================================================== */
.picture-frame {
  flex: 0 0 46%; /* 图片区固定占 46% 宽度 */
  position: relative;
  /* 明快清新的四面山阳光草绿色 (如公园真实草坪色泽) */
  background-color: #6a9c58;
  /* 运用清新草绿层次渐变与矢量青草交织纹样 */
  background-image: 
    radial-gradient(ellipse at 50% 40%, rgba(135, 185, 110, 0.45) 0%, rgba(82, 126, 68, 0.7) 100%),
    url("data:image/svg+xml,%3Csvg width='36' height='36' viewBox='0 0 36 36' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M18 34c0-7-4-12-10-14 5-1 10 3 10 14zm0 0c0-9 5-15 12-16-6 1-11 6-12 16zm-7-21c-1-4 2-9 6-10-3 2-4 6-3 10zm14 0c1-4-2-9-6-10 3 2 4 6 3 10z' fill='%234a753c' fill-opacity='0.32' fill-rule='evenodd'/%3E%3C/svg%3E");
  background-size: cover, 32px 32px;
  border: 1.5px solid #82aa70;
  box-shadow: inset 0 2px 8px rgba(35, 60, 28, 0.25), 0 1px 3px rgba(0,0,0,0.1);
  border-radius: 5px;
  overflow: hidden;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.picture-inner {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 柔和草青色光晕与斜向草尖微纹 */
  background-color: transparent;
  background-image: 
    linear-gradient(135deg, rgba(142, 194, 118, 0.3) 0%, rgba(85, 133, 72, 0.35) 100%),
    repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(95, 145, 80, 0.16) 10px, rgba(95, 145, 80, 0.16) 12px);
}

.picture-inner img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain; /* 保证原片构图完整不被裁剪，居中雅致呈现 */
  display: block;
  border-radius: 2px;
  box-shadow: 0 4px 14px rgba(25, 45, 20, 0.28); /* 给照片本身加上柔和投影，完美衔接草地照片 */
  transition: transform 0.3s ease;
  z-index: 2;
}

/* 文案区：占据右侧 54%，上下分布雅正文言与温馨白话 */
.story-text-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  gap: 16px;
  padding: 4px 0;
  min-height: 0;
}

.classical-box {
  background: rgba(224, 210, 185, 0.45);
  border-left: 3px solid var(--vermilion-red);
  padding: 12px 16px;
  border-radius: 0 4px 4px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.classical-text {
  font-family: 'Noto Serif SC', serif;
  font-size: 1.1rem;
  line-height: 1.85;
  color: #381a14;
  font-weight: 600;
  letter-spacing: 0.8px;
}

.vernacular-box {
  background: rgba(235, 230, 218, 0.45);
  border-left: 3px solid var(--bamboo-green);
  padding: 12px 16px;
  border-radius: 0 4px 4px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.vernacular-text {
  font-size: 1.02rem;
  line-height: 1.78;
  color: #2c251f;
  letter-spacing: 0.4px;
}

.card-footer {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid #d9cbba;
  padding-top: 6px;
  margin-top: 4px;
}

.signature {
  font-size: 0.8rem;
  color: #8c7664;
  font-style: italic;
}

/* 翻页导航 */
.reader-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 18px;
}

.nav-page-btn {
  background: linear-gradient(180deg, #d8be93, #b89c72);
  color: #2b1f14;
  border: 1px solid #8e734f;
  font-weight: bold;
  font-size: 1rem;
  padding: 8px 20px;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}
.nav-page-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #ead0a7, #c9ad83);
  transform: translateY(-2px);
}
.nav-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.page-selector-wrap select {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 6px 12px;
  background-color: #eae0cf;
  border: 1px solid #8c755c;
  border-radius: 4px;
  color: #2d241c;
}

/* ================================
   制作/编辑工作区
   ================================ */
.editor-section {
  width: 100%;
  max-width: 1200px;
}

.editor-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
}

.page-list-panel {
  background-color: #eedec5;
  border: 1px solid #c2ad92;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #baa287;
}

.panel-header h3 {
  font-size: 1.1rem;
  color: #3b281b;
}

.page-thumbnails {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.thumb-item {
  display: flex;
  gap: 10px;
  padding: 8px;
  background: #fbf7ef;
  border: 1px solid #d4c1a7;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.thumb-item:hover {
  background: #fff;
  border-color: var(--vermilion-red);
}
.thumb-item.active {
  border: 2px solid var(--vermilion-red);
  background: #fff9f6;
}

.thumb-img {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 3px;
  background: #ddd;
}

.thumb-info {
  flex: 1;
  overflow: hidden;
}

.thumb-tag {
  font-size: 0.75rem;
  color: var(--cinnabar);
  font-weight: bold;
}

.thumb-title {
  font-size: 0.85rem;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-io-box {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed #baa287;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.data-io-box h4 {
  font-size: 0.9rem;
  color: #554433;
}
.io-btn-group {
  display: flex;
  gap: 8px;
}
.io-btn-group button {
  flex: 1;
}

/* 右侧编辑表单 */
.page-editor-panel {
  background-color: #faf5ec;
  border: 1px solid #c8b49b;
  border-radius: 8px;
  padding: 24px;
  height: calc(100vh - 120px);
  overflow-y: auto;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #dfcfbc;
  padding-bottom: 12px;
  margin-bottom: 20px;
}

.editor-actions {
  display: flex;
  gap: 10px;
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* 表单多列排版 */
.form-row.col-2 {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
}

.form-row.col-3 {
  display: grid;
  grid-template-columns: 1fr 1.6fr 1.4fr;
  gap: 14px;
}

.form-group select {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 8px 12px;
  border: 1px solid #b8a38c;
  border-radius: 5px;
  background-color: #fffdf9;
  color: #2b221b;
}
.form-group select:focus {
  outline: none;
  border-color: var(--vermilion-red);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-weight: bold;
  font-size: 0.95rem;
  color: #3a2b1f;
}

input[type="text"], textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 8px 12px;
  border: 1px solid #b8a38c;
  border-radius: 5px;
  background-color: #fffdf9;
  color: #2b221b;
}
input[type="text"]:focus, textarea:focus {
  outline: none;
  border-color: var(--vermilion-red);
  box-shadow: 0 0 0 3px rgba(192, 53, 43, 0.15);
}

.image-input-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.image-input-group input {
  flex: 1;
  min-width: 200px;
}

/* 拖拽上传与粘贴区 */
.photo-drop-zone {
  border: 2px dashed #bba48a;
  border-radius: 6px;
  background-color: #f5eedf;
  padding: 12px;
  text-align: center;
  color: #6d5845;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
.photo-drop-zone:hover, .photo-drop-zone.dragover {
  border-color: var(--vermilion-red);
  background-color: #fdf3eb;
  color: var(--cinnabar);
}

/* 快速选图抽屉 */
.photo-picker-drawer {
  background: #ebdcc5;
  border: 1px solid #bba48a;
  border-radius: 6px;
  padding: 12px;
  margin-top: 8px;
}
.picker-tip {
  font-size: 0.85rem;
  color: #554433;
  margin-bottom: 8px;
}
.preset-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  max-height: 220px;
  overflow-y: auto;
}
.photo-pick-card {
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  background: #000;
  position: relative;
  transition: transform 0.2s;
}
.photo-pick-card:hover {
  transform: scale(1.04);
  border-color: var(--vermilion-red);
}
.photo-pick-card img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  display: block;
}
.photo-pick-card span {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 4px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

/* 打印与小人书出版导出样式 */
@media print {
  body {
    background: #fff;
    color: #000;
  }
  .top-nav, .reader-controls, .editor-section {
    display: none !important;
  }
  .main-container {
    padding: 0;
  }
  .lianhuanhua-card {
    box-shadow: none;
    border: none;
    background: #fff;
    page-break-after: always;
  }
  .card-inner-frame {
    border: 2px solid #000;
    outline: 1px solid #000;
    background: #fff;
  }
  .picture-vintage-tint {
    display: none;
  }
}
