:root {
  --bg: #faf8f5;
  --card-bg: #ffffff;
  --text: #2b2925;
  --muted: #8a8378;
  --accent: #b5654a;
  --accent-soft: #f1e3dc;
  --border: #e8e2d9;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.topbar nav a {
  margin-left: 16px;
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.heatmap-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
  overflow-x: auto;
}

.heatmap-months {
  display: flex;
  gap: 3px;
  margin-bottom: 4px;
}

.heat-month {
  width: 13px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.heatmap {
  display: flex;
  gap: 3px;
}

.heat-week {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.heat-day {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: #ebe7e0;
  flex-shrink: 0;
  display: block;
  text-decoration: none;
}

a.heat-day:hover {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.heat-day.future {
  background: transparent;
}

.heat-day.level-1 { background: #f0d4c8; }
.heat-day.level-2 { background: #e3a98c; }
.heat-day.level-3 { background: #cf7a54; }
.heat-day.level-4 { background: var(--accent); }

@media (max-width: 600px) {
  /* month labels ("12月" etc.) can't be shrunk to fit a single week-column's
     width without becoming illegible, so they're dropped on narrow screens
     instead of overflowing; the summary line below still has the date range. */
  .heatmap-months { display: none; }
  .heatmap, .heat-week { gap: 1px; }
  .heat-day { width: 4px; height: 4px; border-radius: 1px; }
}

.heatmap-summary {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 14px;
}

.today-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

/* day page */
.day-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.day-header h1 {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
}

.today-tag {
  font-size: 0.7rem;
  background: var(--accent);
  color: #fff;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.day-nav {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.day-actions {
  margin-bottom: 28px;
}

.moment-list {
  list-style: none;
  padding: 0;
  margin: 0;
  columns: 3;
  column-gap: 16px;
}

@media (max-width: 900px) {
  .moment-list { columns: 2; }
}

@media (max-width: 600px) {
  .moment-list { columns: 1; }
}

.moment-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  break-inside: avoid;
  margin-bottom: 16px;
  display: inline-block;
  width: 100%;
}

.moment-meta {
  display: flex;
  gap: 12px;
  align-items: baseline;
  font-size: 0.85rem;
  flex-wrap: wrap;
}

.moment-meta span {
  color: var(--muted);
}

.moment-type {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.moment-date {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}

.moment-date:hover {
  color: var(--accent);
}

.entry-thumb {
  width: 96px;
  height: 128px;
  object-fit: cover;
  border-radius: 8px;
  float: left;
  margin: 0 14px 8px 0;
}

.moment-photo {
  max-width: 320px;
  width: 100%;
  border-radius: 10px;
  margin-top: 10px;
  display: block;
}

.warn-box {
  background: #f8ecd8;
  border: 1px solid #e8cfa0;
  color: #8a5a1f;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 0.85rem;
  max-width: 620px;
  margin-bottom: 20px;
  line-height: 1.6;
}

.warn-box code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 6px;
  border-radius: 4px;
}

.scan-form {
  max-width: 720px;
}

.scan-entry {
  display: flex;
  gap: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--card-bg);
}

.scan-entry-preview {
  flex-shrink: 0;
  width: 140px;
}

.scan-entry-preview img {
  width: 100%;
  border-radius: 8px;
  display: block;
}

.scan-entry-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.inline-check {
  flex-direction: row !important;
  align-items: center;
  gap: 6px !important;
  font-size: 0.8rem;
  color: var(--text) !important;
}

.current-username {
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: 16px;
}

.logout-form {
  display: inline;
  margin-left: 10px;
}

.logout-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.logout-btn:hover {
  color: var(--accent);
}

.login-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
}

.public-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
}

.public-banner p {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
}

.pipeline-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
}

.pipeline-title {
  margin: 0 0 16px;
  font-size: 1rem;
}

.pipeline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pipeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 96px;
  text-align: center;
}

.pipeline-icon {
  font-size: 1.6rem;
  background: var(--accent-soft);
  border-radius: 999px;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pipeline-label {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.pipeline-arrow {
  color: var(--accent);
  font-size: 1.2rem;
  flex-shrink: 0;
}

.pipeline-card .hint a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  margin-left: 6px;
}

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

.pipeline-group-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.pipeline-group-traditional {
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.pipeline-duration {
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--muted);
}

.pipeline-duration-fast {
  color: var(--accent);
  font-weight: 600;
}

.pipeline-icon-muted {
  background: #ece7df;
  filter: grayscale(60%);
  opacity: 0.85;
}

.pipeline-arrow-muted {
  color: var(--muted);
}

@media (max-width: 640px) {
  .pipeline {
    flex-direction: column;
  }
  .pipeline-arrow {
    transform: rotate(90deg);
  }
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-form-box {
  width: 100%;
  max-width: 360px;
}

.login-title {
  text-align: center;
  margin: 0 0 8px;
  font-size: 1.3rem;
}

.login-error {
  color: #c0453a;
  font-size: 0.85rem;
  margin: -6px 0 0;
}

.login-back {
  display: block;
  text-align: center;
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
}

.login-back:hover {
  color: var(--accent);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 24px;
}

.sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.chip {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 60px 0;
}

.container h2 {
  margin: 36px 0 14px;
}

.cover {
  aspect-ratio: 3 / 4;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

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

.cover-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  box-shadow: 0 2px 8px rgba(43, 41, 37, 0.08);
}

.quick-status {
  flex: 1;
  min-width: 0;
}

.status-select {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent-soft);
  color: var(--accent);
}

.status-select[data-status="想看"] { background: #ece7df; color: #7a7263; }
.status-select[data-status="进行中"] { background: var(--accent-soft); color: var(--accent); }
.status-select[data-status="已完成"] { background: #dcece0; color: #3d7a51; }
.status-select[data-status="放弃"] { background: #f1dcd8; color: #a34a3d; }

.btn-share {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  overflow: hidden;
  margin-top: 6px;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
}

.progress-text {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

.add-type-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 280px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 20px;
}

.add-type-picker select {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
}

.douban-import {
  max-width: 560px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 24px;
  margin-bottom: 20px;
}

.douban-import label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.douban-import .row {
  display: flex;
  gap: 10px;
}

.douban-import input {
  flex: 1;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
}

.hint {
  margin: 10px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 1em;
}

.hint-error { color: #c0453a; }
.hint-ok { color: #4a8a5e; }

.feed-loading {
  text-align: center;
  visibility: hidden;
  margin: 16px 0 0;
}

/* form */
.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 560px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  flex: 1;
}

.form input, .form select, .form textarea {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
}

/* Chapter editing wants to be as wide as the reading view (.chapter-reader,
   which has no max-width of its own and just fills .container), so what you
   see while writing lines up with what readers will see. */
.form-wide {
  max-width: 960px;
}

.form textarea.chapter-content-input {
  font-size: 1rem;
  line-height: 1.9;
  padding: 20px 22px;
}

.row {
  display: flex;
  gap: 16px;
}

.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}

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

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
}

.btn-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
}

.btn-danger {
  background: #c0453a;
}

.btn-link-danger {
  background: none;
  color: #c0453a;
  padding: 4px 0;
  font-size: 0.78rem;
  font-weight: 600;
}

/* detail */
.detail-header {
  display: flex;
  gap: 28px;
  margin-bottom: 32px;
}

.cover.large {
  width: 180px;
  min-width: 180px;
  border-radius: var(--radius);
  align-self: flex-start;
}

.cover.large:has(img) {
  aspect-ratio: auto;
  height: auto;
  align-items: flex-start;
}

.cover.large img {
  height: auto;
  object-fit: contain;
}

.detail-info h1 {
  margin: 0 0 4px;
}

.creator {
  color: var(--muted);
  margin: 0 0 8px;
}

.detail-info .quick-status {
  display: inline-block;
  margin-bottom: 10px;
}

.detail-info .status-select {
  width: auto;
  font-size: 0.8rem;
  padding: 6px 14px;
}

.rating {
  color: var(--accent);
  margin-bottom: 8px;
}

.stats {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 10px 0;
}

.review {
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 12px 0;
}

.review h3 {
  margin: 0 0 6px;
  font-size: 0.85rem;
  color: var(--accent);
}

.review p {
  margin: 0;
  white-space: pre-wrap;
}

.log-section {
  margin-bottom: 32px;
}

.log-form {
  max-width: 100%;
}

.log-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.log-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  display: flow-root;
}

.log-meta {
  display: flex;
  gap: 14px;
  font-size: 0.85rem;
  align-items: baseline;
}

.log-meta span {
  color: var(--muted);
}

.log-comment {
  margin: 8px 0 4px;
  white-space: pre-wrap;
}

@media (max-width: 640px) {
  .detail-header { flex-direction: column; }
  .cover.large { width: 140px; }
  .row { flex-direction: column; }
}

.changelog-day {
  margin-top: 36px;
}

.changelog-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.changelog-header-row h1 {
  margin: 0;
}

.lang-switch {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--accent-soft);
  border-radius: 999px;
  padding: 4px 14px;
  white-space: nowrap;
}

.lang-switch:hover {
  background: var(--accent-soft);
}

.date-filter {
  margin: 4px 0 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.date-filter label {
  font-size: 0.85rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.date-filter select {
  font-size: 0.9rem;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}

.changelog-search input {
  font-size: 0.9rem;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit;
  width: 200px;
  max-width: 100%;
}

.btn-search-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.9rem;
  line-height: 1;
}

.search-form {
  display: flex;
  gap: 10px;
  max-width: 480px;
  margin: 20px 0 28px;
}

.search-form input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
}

.search-form button {
  flex-shrink: 0;
}

.changelog-day-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
}

.changelog-day-header h2 {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.changelog-day-total {
  font-size: 0.8rem;
  color: var(--muted);
}

.changelog-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.changelog-entry {
  padding: 20px 0;
  border-top: 1px solid var(--border);
}

.changelog-entry:first-child {
  border-top: none;
}

.changelog-entry-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.changelog-entry-head h3 {
  margin: 0;
  font-size: 1.02rem;
}

.lines-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.changelog-body p {
  margin: 0 0 14px;
  line-height: 1.7;
  color: var(--text);
}

.changelog-image {
  max-width: 420px;
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
}

.metrics-summary-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
}

.metrics-summary-card h2 {
  margin: 0 0 14px;
  font-size: 1rem;
}

.metrics-summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.metrics-summary-row > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metrics-summary-row strong {
  font-size: 1.3rem;
  color: var(--accent);
}

.metrics-summary-row span {
  font-size: 0.78rem;
  color: var(--muted);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.metrics-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.metrics-card h2 {
  margin: 0 0 12px;
  font-size: 0.95rem;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

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

.status-breakdown {
  font-size: 0.9rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.metrics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.metrics-table th, .metrics-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}

.metrics-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
}

.architecture-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
}

.architecture-card h2 {
  margin: 0 0 16px;
  font-size: 1rem;
}

.arch-diagram {
  display: block;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  height: auto;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

.novel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.novel-card {
  display: block;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
}

.novel-card-cover {
  aspect-ratio: 3 / 4;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

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

.novel-card-cover-placeholder {
  font-size: 2.5rem;
}

.novel-card-body {
  padding: 12px 14px;
}

.novel-card-body h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

.novel-card-body p {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.reference-grid {
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}

.reference-grid .novel-card-body {
  padding: 8px 10px;
}

.reference-grid .novel-card-body h3 {
  font-size: 0.82rem;
}

.chapter-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.chapter-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  min-width: 0;
}

.chapter-list a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  white-space: normal;
  word-break: break-word;
  min-width: 0;
  flex: 1;
}

.chapter-select {
  flex-shrink: 0;
  display: flex;
}

.chapter-select input {
  margin: 0;
}

.bulk-lock-actions {
  display: flex;
  gap: 14px;
  margin-top: 12px;
}

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

.chapter-list .chapter-meta {
  display: block;
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 2px;
}

.chapter-reader .chapter-meta {
  margin: -12px 0 16px;
  font-size: 0.82rem;
  color: var(--muted);
}

.novel-card-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 4px 0;
}

.volume-heading {
  font-size: 1rem;
  color: var(--text);
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.volume-heading:first-child {
  margin-top: 0;
}

.volume-heading-unassigned {
  color: var(--muted);
  font-weight: 400;
}

.volume-list {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.volume-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.9rem;
}

.volume-add-form {
  display: flex;
  gap: 10px;
}

.volume-add-form input {
  flex: 1;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
}

@media (max-width: 640px) {
  .chapter-list { grid-template-columns: 1fr; }
  .volume-add-form { flex-direction: column; }
}

.inline-delete {
  display: inline;
  flex-shrink: 0;
}

.btn-danger-sm {
  background: none;
  border: none;
  color: #c0453a;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  white-space: nowrap;
}

.btn-secondary-sm {
  background: none;
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.admin-user-row {
  flex-wrap: wrap;
}

.admin-user-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-reset-form {
  display: flex;
  gap: 6px;
}

.inline-reset-form input {
  width: 140px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.78rem;
}

.reset-link-code {
  display: inline-block;
  word-break: break-all;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  margin-top: 4px;
  font-size: 0.78rem;
}

.ref-share-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--muted);
  margin: 4px 0;
  cursor: pointer;
}

.ref-share-toggle input {
  margin: 0;
}

label.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  margin: -8px 0 4px;
}

.checkbox-label input {
  margin: 0;
  flex: none;
}

.lock-badge {
  font-size: 0.85em;
  margin-right: 4px;
}

.character-grid, .video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.character-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}

.character-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 8px;
}

.character-card h3 {
  margin: 0 0 4px;
  font-size: 0.9rem;
}

.character-card p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.character-card-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
}

.video-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  grid-column: span 2;
  min-width: 0;
}

.video-card h3 {
  margin: 0 0 8px;
  font-size: 0.9rem;
}

.video-card video {
  width: 100%;
  border-radius: 8px;
  display: block;
  background: #000;
}

.video-embed {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  border: none;
  display: block;
}

.chapter-reader {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.chapter-reader h2 {
  margin: 0 0 16px;
  font-size: 1.1rem;
}

.tts-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.tts-rate-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.tts-rate-label select {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
}

.tts-autonext {
  margin: 0;
}


.chapter-nav {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

@media (max-width: 640px) {
  .video-card { grid-column: span 1; }
}

.ref-add {
  margin-top: 4px;
}

.ref-search-box {
  position: relative;
  max-width: 420px;
}

.ref-search-box input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
}

.ref-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.ref-results:empty {
  display: none;
}

.ref-result {
  text-align: left;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}

.ref-result:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.ref-result-empty {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 6px 2px;
}

.ref-result-thumb {
  width: 26px;
  height: 26px;
  object-fit: cover;
  border-radius: 5px;
  margin-right: 8px;
  vertical-align: middle;
  background: var(--bg);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 10px;
}

.chip-list:empty {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 6px 4px 4px;
  font-size: 0.85rem;
}

.chip img {
  width: 24px;
  height: 24px;
  object-fit: cover;
  border-radius: 999px;
  background: var(--card-bg);
}

.chip-remove {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 18px;
}

.picker-item {
  position: relative;
  width: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  cursor: pointer;
  font-size: 0.75rem;
  text-align: center;
}

.picker-item:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.picker-item input {
  position: absolute;
  top: 6px;
  left: 6px;
  margin: 0;
}

.picker-item img {
  width: 100%;
  height: 64px;
  object-fit: contain;
  background: var(--bg);
  border-radius: 6px;
}

.picker-video-icon {
  width: 100%;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  background: var(--bg);
  border-radius: 6px;
}

.chapter-body p {
  margin: 0 0 1.2em;
  line-height: 1.9;
  font-size: 1rem;
}

.chapter-body,
.chapter-body * {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.chapter-body-locked {
  position: relative;
  max-height: 340px;
  overflow: hidden;
}

.chapter-lock-fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 140px;
  background: linear-gradient(to bottom, transparent, var(--card-bg));
  pointer-events: none;
}

.chapter-lock-banner {
  text-align: center;
  padding: 12px 0 8px;
  margin-top: -8px;
}

.chapter-lock-banner p {
  color: var(--muted);
  margin: 0 0 14px;
  font-size: 0.95rem;
}

.character-reveal {
  display: flex;
  justify-content: center;
  padding: 20px 16px;
  margin: 4px 0 1.4em;
  background: radial-gradient(ellipse at bottom, var(--accent-soft) 0%, transparent 75%);
  border-radius: var(--radius);
}

.character-standee {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(24px) scale(0.96);
}

.character-standee.is-visible {
  animation: standee-enter 0.7s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
  animation-delay: 0.1s;
}

@keyframes standee-enter {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .character-standee { opacity: 1; transform: none; }
  .character-standee.is-visible { animation: none; }
}

.character-standee img {
  height: 300px;
  width: auto;
  max-width: 240px;
  object-fit: contain;
  filter: drop-shadow(0 12px 16px rgba(43, 41, 37, 0.22));
}

.character-standee-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 3px 14px;
  border-radius: 999px;
}

.unmatched-characters {
  margin-top: 1.4em;
}

@media (max-width: 640px) {
  .character-standee img { height: 210px; max-width: 170px; }
}
