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

:root {
  --font-read: 18px;
  --color-bg: #f5f0e8;
  --color-card: #fff;
  --color-primary: #8b4513;
  --header-pad: 14px 24px;
  --main-pad: 24px 16px 48px;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", serif;
  background: var(--color-bg);
  color: #2c2416;
  line-height: 1.7;
  min-height: 100vh;
}

body.device-mobile {
  --header-pad: 12px 14px;
  --main-pad: 16px 12px 32px;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

header {
  background: linear-gradient(135deg, #3d2914, #6b4423);
  color: #fff;
  padding: var(--header-pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 { font-size: 1.15rem; font-weight: 600; }
header nav a { color: #ffd89b; margin-left: 14px; font-size: 0.9rem; }
body.device-mobile header nav a { margin-left: 10px; font-size: 0.85rem; }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--main-pad);
}

body.device-desktop main.read-main {
  max-width: 720px;
}

.card {
  background: var(--color-card);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 20px rgba(61, 41, 20, 0.08);
  margin-bottom: 20px;
}

body.device-mobile .card {
  padding: 16px;
  border-radius: 10px;
}

.btn {
  display: inline-block;
  background: var(--color-primary);
  color: #fff !important;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  text-decoration: none !important;
  touch-action: manipulation;
}

.btn:hover { background: #6b3410; }
.btn:disabled, .btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.btn-outline {
  background: transparent;
  color: var(--color-primary) !important;
  border: 1px solid var(--color-primary);
}

input, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d4c4a8;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 1rem;
}

label { display: block; margin-bottom: 6px; font-weight: 500; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.alert-ok { background: #e8f5e9; color: #2e7d32; }
.alert-err { background: #ffebee; color: #c62828; }
.meta { color: #7a6a52; font-size: 0.9rem; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* 目录：每页 10 章大卡片 */
.catalog-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.catalog-head h3 { font-size: 1.1rem; }

#page-info, #chapter-page-info {
  color: #7a6a52;
  font-size: 0.9rem;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  min-height: 320px;
}

body.device-desktop .chapter-grid {
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  min-height: 380px;
}

body.device-mobile .chapter-grid {
  grid-template-columns: 1fr;
  gap: 12px;
  min-height: auto;
}

.chapter-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 88px;
  padding: 16px 18px;
  background: linear-gradient(145deg, #fffdf8, #f8f0e4);
  border: 1px solid #e8dcc8;
  border-radius: 12px;
  color: #3d2914 !important;
  text-decoration: none !important;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(61, 41, 20, 0.06);
}

body.device-desktop .chapter-card {
  min-height: 96px;
  padding: 18px 20px;
}

.chapter-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(61, 41, 20, 0.12);
  border-color: #c4a574;
}

.chapter-card-num {
  font-size: 0.8rem;
  color: #9a8468;
  margin-bottom: 6px;
}

.chapter-card-title {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

body.device-mobile .chapter-card-title {
  font-size: 1.05rem;
  -webkit-line-clamp: 3;
}

/* 分页 */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #eee5d5;
}

.page-nums {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-width: 100%;
}

.page-btn {
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #d4c4a8;
  border-radius: 8px;
  background: #fff;
  color: #5c4a32;
  font-size: 0.9rem;
  cursor: pointer;
  touch-action: manipulation;
}

.page-btn:hover:not(:disabled) {
  background: #f8f0e4;
  border-color: var(--color-primary);
}

.page-btn.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-btn.page-ellipsis {
  border: none;
  background: transparent;
  min-width: 28px;
  cursor: default;
}

body.device-mobile .page-btn {
  min-width: 44px;
  height: 44px;
}

body.device-mobile .pagination {
  gap: 10px;
}

/* 阅读页 */
.read-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: #f8f0e4;
  border-radius: 10px;
  border: 1px solid #e8dcc8;
}

.read-toolbar-label {
  font-size: 0.9rem;
  color: #7a6a52;
  font-weight: 500;
}

.font-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.font-controls button {
  min-width: 44px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #d4c4a8;
  border-radius: 8px;
  background: #fff;
  font-size: 1rem;
  cursor: pointer;
  color: #3d2914;
  touch-action: manipulation;
}

.font-controls button:hover {
  background: #fffdf8;
  border-color: var(--color-primary);
}

#font-size-label {
  min-width: 48px;
  text-align: center;
  font-size: 0.9rem;
  color: #5c4a32;
}

.read-content {
  white-space: pre-wrap;
  font-size: var(--font-read);
  line-height: 1.9;
  padding: 8px 0 24px;
  word-break: break-word;
}

body.device-mobile .read-content {
  line-height: 2;
  padding: 4px 0 20px;
}

.read-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid #eee5d5;
}

.read-nav .btn {
  flex: 1;
  text-align: center;
  padding: 12px 16px;
}

body.device-mobile .read-nav {
  flex-direction: column;
}

body.device-mobile .read-nav .btn {
  width: 100%;
}

.read-title {
  font-size: 1.35rem;
  margin-bottom: 8px;
  line-height: 1.4;
}

body.device-mobile .read-title {
  font-size: 1.2rem;
}

.novel-list { list-style: none; }
.novel-list li {
  padding: 14px 0;
  border-bottom: 1px solid #eee5d5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
