@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=Source+Sans+3:wght@300;400;500;600&display=swap');

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

:root {
  --bg: #FAF7F2;
  --surface: #FFFFFF;
  --ink: #1C1C1E;
  --ink-muted: #6B6B6E;
  --accent: #C4603A;
  --accent-hover: #A84E2E;
  --border: #E8E3DC;
  --shadow: 0 2px 12px rgba(28, 28, 30, 0.08);
  --shadow-hover: 0 4px 20px rgba(28, 28, 30, 0.14);
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Source Sans 3', sans-serif;
  font-size: 19px;
  line-height: 1.7;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: 'Playfair Display', serif;
  line-height: 1.2;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 24px;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 17px;
  font-weight: 500;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  letter-spacing: 0.02em;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--ink-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-muted);
  padding: 6px 12px;
}

.btn-ghost:hover {
  color: var(--ink);
}

/* Nav */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}

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

/* Page container */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 40px;
}

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 32px;
  margin-bottom: 6px;
}

.login-card .subtitle {
  color: var(--ink-muted);
  font-size: 17px;
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 18px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--accent);
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

.error-msg {
  color: #C0392B;
  font-size: 14px;
  margin-top: 12px;
  display: none;
}

.error-msg.visible {
  display: block;
}

/* Chapter grid */
.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 32px;
}

.page-header p {
  color: var(--ink-muted);
  margin-top: 6px;
}

.chapters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 24px;
}

.chapter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
  position: relative;
}

.chapter-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
  color: inherit;
}

.chapter-card-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--bg);
  overflow: hidden;
  position: relative;
}

.chapter-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chapter-number-watermark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Playfair Display', serif;
  font-size: 72px;
  font-weight: 700;
  color: rgba(28, 28, 30, 0.07);
  user-select: none;
}

.chapter-card-body {
  padding: 16px;
}

.chapter-card-body h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.chapter-card-meta {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.badge {
  font-size: 14px;
  color: var(--ink-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px 8px;
}

/* Chapter detail */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-muted);
  font-size: 17px;
  margin-bottom: 28px;
}

.back-link:hover {
  color: var(--ink);
}

.chapter-title {
  font-size: 36px;
  margin-bottom: 8px;
}

.chapter-subtitle {
  color: var(--ink-muted);
  margin-bottom: 40px;
}

.images-section h2,
.comments-section h2 {
  font-size: 20px;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.image-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 28px;
  position: relative;
}

.image-card img {
  width: 100%;
  display: block;
}

.image-card-footer {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.image-caption {
  color: var(--ink-muted);
  font-size: 17px;
  font-style: italic;
}

.caption-edit-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 17px;
  color: var(--ink);
  background: var(--bg);
}

.caption-edit-input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-delete {
  background: none;
  border: none;
  color: var(--ink-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.btn-delete:hover {
  color: #C0392B;
  background: #fdf0ef;
}

.no-images {
  color: var(--ink-muted);
  font-size: 15px;
  padding: 32px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 6px;
  margin-bottom: 28px;
}

/* Comments */
.comments-section {
  margin-top: 48px;
}

.comment-list {
  margin-bottom: 32px;
}

.comment {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.comment:first-child {
  border-top: 1px solid var(--border);
}

.comment-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}

.comment-author {
  font-weight: 600;
  font-size: 17px;
}

.comment-time {
  font-size: 15px;
  color: var(--ink-muted);
}

.comment-body {
  font-size: 18px;
  color: var(--ink);
  line-height: 1.6;
}

.no-comments {
  color: var(--ink-muted);
  font-size: 17px;
  font-style: italic;
  padding: 16px 0;
}

.comment-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px;
}

.comment-form h3 {
  font-size: 20px;
  margin-bottom: 16px;
}

/* Admin upload */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 6px;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--surface);
  margin-bottom: 24px;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: #fdf5f2;
}

.upload-zone p {
  color: var(--ink-muted);
  font-size: 15px;
  margin-bottom: 12px;
}

.upload-preview {
  margin-top: 16px;
}

.upload-preview img {
  max-width: 300px;
  max-height: 200px;
  object-fit: contain;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.progress-bar-wrap {
  background: var(--border);
  border-radius: 4px;
  height: 6px;
  margin-top: 12px;
  overflow: hidden;
  display: none;
}

.progress-bar-wrap.visible {
  display: block;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s;
}

.success-msg {
  color: #27AE60;
  font-size: 14px;
  margin-top: 10px;
  display: none;
}

.success-msg.visible {
  display: block;
}

/* Admin image list */
.admin-image-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.admin-image-item {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.admin-image-item img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}

.admin-image-item-footer {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ink-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Section card */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 28px;
  margin-bottom: 28px;
}

.section-card h2 {
  font-size: 18px;
  margin-bottom: 20px;
}

/* Chapter title edit */
.chapter-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.chapter-title-row:last-child {
  border-bottom: none;
}

.chapter-title-row .num {
  font-size: 13px;
  color: var(--ink-muted);
  width: 30px;
  flex-shrink: 0;
}

.chapter-title-row input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 15px;
  background: transparent;
  color: var(--ink);
}

.chapter-title-row input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
}

.chapter-title-row .btn-save-title {
  font-size: 13px;
  padding: 5px 12px;
}

/* Loading state */
.loading {
  text-align: center;
  padding: 60px;
  color: var(--ink-muted);
  font-size: 15px;
}

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 24px 20px;
  }
  .nav {
    padding: 0 20px;
  }
  .chapters-grid {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
}
