:root {
  --bg: #f4f0e8;
  --text: #1a1814;
  --accent: #8b4513;
  --muted: #6b6560;
  --card: #fffdf8;
  --border: #ddd5c8;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }
.site-header {
  padding: 1rem 1.5rem;
  background: #2c2419;
  color: #f5efe6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem 1.25rem;
}
.site-footer {
  padding: 1rem 1.5rem;
  background: #2c2419;
  color: #f5efe6;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: .75rem 1.25rem;
}
.site-header a, .site-footer a {
  color: #f5efe6;
  text-decoration: none;
  margin-right: 1rem;
}
.site-footer a:last-child { margin-right: 0; }
.site-footer a:hover { text-decoration: underline; }
.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem 0;
  justify-self: start;
}
.site-footer-affiliate {
  margin: 0;
  color: #cfc4b4;
  font-size: .85rem;
  text-align: center;
  justify-self: center;
  max-width: 28rem;
}
.site-footer-copy {
  margin: 0;
  color: #cfc4b4;
  font-size: .9rem;
  justify-self: end;
  text-align: right;
}
@media (max-width: 720px) {
  .site-footer {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .site-footer-links,
  .site-footer-affiliate,
  .site-footer-copy {
    justify-self: center;
    text-align: center;
  }
}
.legal-page {
  max-width: 42rem;
}
.legal-page h1 { margin-top: 0; }
.legal-page h2 {
  margin-top: 1.75rem;
  font-size: 1.15rem;
}
.legal-page ul { padding-left: 1.25rem; }
.brand { font-weight: 700; font-size: 1.25rem; letter-spacing: .04em; }
.dash-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: .5rem;
}
.dash-top h1 { margin: 0; }
.main { max-width: 960px; margin: 0 auto; padding: 1.5rem; }
.hero { text-align: center; padding: 3rem 1rem; background: linear-gradient(180deg, #3d3228 0%, #2c2419 100%); color: #f5efe6; border-radius: 0 0 1rem 1rem; margin: -1.5rem -1.5rem 2rem; }
.hero h1 { font-size: 2.5rem; margin: 0 0 .5rem; }
.btn { display: inline-block; background: var(--accent); color: #fff; padding: .6rem 1.2rem; border: none; border-radius: 4px; text-decoration: none; cursor: pointer; }
.btn-secondary { background: #5c4d3e; }
.btn-danger { background: #8b3a2a; }
.btn-danger:hover { background: #6e2d21; }
.delete-warning {
  color: #8b3a2a;
  font-weight: 600;
  margin: .75rem 0 1rem;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.story-card { background: var(--card); border: 1px solid var(--border); padding: 1rem; text-decoration: none; color: inherit; border-radius: 6px; }
.story-card img { width: 100%; height: 140px; object-fit: cover; border-radius: 4px; }
.auth-form, .form-stack { max-width: 420px; }
.auth-form label, .form-stack label { display: block; margin-bottom: .75rem; }
input, textarea, select { width: 100%; padding: .5rem; margin-top: .25rem; }
.flash-wrap { padding: 0 1.5rem; }
.flash { padding: .5rem 1rem; border-radius: 4px; }
.flash-error { background: #fde8e8; }
.flash-success { background: #e8f5e9; }
.board-tabs a { margin-right: 1rem; }
.board-tabs a.active { font-weight: 700; }
.inbox-list { list-style: none; padding: 0; }
.inbox-list li { padding: .75rem 0; border-bottom: 1px solid var(--border); }
.badge { background: var(--accent); color: #fff; font-size: .75rem; padding: .15rem .5rem; border-radius: 999px; margin-left: .5rem; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { border: 1px solid var(--border); padding: .5rem; }
.muted { color: var(--muted); }

/* Author Write dashboard carousels */
body.author-dashboard .main { max-width: 1100px; }
.carousel-section { margin-bottom: 2.5rem; }
.carousel-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: .75rem;
}
.carousel-header h2 { margin: 0; flex: 1; font-size: 1.25rem; }
.carousel-status { font-size: .85rem; color: var(--muted); min-width: 4rem; }
.carousel-nav { display: flex; gap: .25rem; }
.carousel-btn {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--text);
}
.carousel-track-wrap {
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: .5rem;
}
.carousel-track {
  display: flex;
  gap: 1rem;
  padding: .25rem 0;
  min-height: 220px;
}
.shelf-tile {
  flex: 0 0 160px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem;
  cursor: pointer;
}
.shelf-tile-add {
  justify-content: center;
  align-items: stretch;
  gap: .5rem;
  cursor: default;
  min-height: 200px;
}
.shelf-tile-add .btn-block {
  display: block;
  text-align: center;
  width: 100%;
  font-size: .85rem;
  padding: .5rem .75rem;
}
.shelf-tile-item { transition: box-shadow .15s, opacity .15s; }
.shelf-tile-item:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.shelf-tile-item.dragging { opacity: .5; }
.shelf-tile-item.drag-over { box-shadow: 0 0 0 2px var(--accent); }
.shelf-cover {
  width: 100%;
  aspect-ratio: 2/3;
  background: #e8e0d4;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: .5rem;
}
.shelf-cover img { width: 100%; height: 100%; object-fit: cover; }
.shelf-placeholder {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}
.shelf-title {
  font-weight: 600;
  font-size: .9rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.shelf-meta {
  font-size: .75rem;
  color: var(--muted);
  margin-top: .25rem;
}

/* Story / Series overview */
.work-overview {
  display: grid;
  grid-template-columns: 136px 1fr;
  gap: 1.5rem;
  align-items: start;
  margin-bottom: 2rem;
}
.work-cover-col {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  width: 136px;
}
.work-cover-box {
  /* Match carousel .shelf-cover (160px tile − .75rem padding each side) */
  width: 136px;
  aspect-ratio: 2/3;
  background: #e8e0d4;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cover-upload { margin: 0; width: 100%; }
.cover-upload-btn {
  display: block;
  text-align: center;
  width: 100%;
  font-size: .8rem;
  padding: .4rem .5rem;
  cursor: pointer;
}
.star-rating {
  display: flex;
  justify-content: center;
  gap: .1rem;
  line-height: 1;
  font-size: 1rem;
  letter-spacing: .02em;
}
.star-rating .star {
  color: #d4c8b8;
}
.star-rating .star.is-full {
  color: #c9a227;
}
.star-rating .star.is-half {
  background: linear-gradient(90deg, #c9a227 50%, #d4c8b8 50%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.star-rating .star.is-empty {
  color: #d4c8b8;
}

.edit-two-col {
  display: grid;
  grid-template-columns: 1fr minmax(180px, 240px);
  gap: 1.5rem 2rem;
  align-items: start;
  max-width: 820px;
}
.edit-col-main label,
.edit-col-side label {
  display: block;
  margin-bottom: .85rem;
}
.edit-col-side {
  padding-top: .15rem;
}
.edit-subnav {
  margin: -.25rem 0 1rem;
}
.edit-subnav a {
  font-size: .95rem;
}
.edit-page-actions {
  margin: -.25rem 0 1.25rem;
}
.edit-col-footer {
  margin-top: 1rem;
}
.edit-check {
  display: flex !important;
  align-items: center;
  gap: .5rem;
  margin-top: .35rem;
}
.edit-check input {
  width: auto;
  margin: 0;
}
@media (max-width: 640px) {
  .edit-two-col { grid-template-columns: 1fr; }
}

.chapter-form {
  display: grid;
  grid-template-columns: 1fr minmax(200px, 260px);
  gap: 1.5rem 2rem;
  align-items: start;
  max-width: 960px;
}
.chapter-form-main label,
.chapter-form-side label {
  display: block;
  margin-bottom: .85rem;
}
.chapter-form-actions {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-top: .5rem;
}
.chapter-form-actions .btn { text-align: center; }
.chapter-form-actions .btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.chapter-body-tools { margin: .5rem 0 .65rem; }
.chapter-view-tabs {
  display: inline-flex;
  gap: .25rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .15rem;
  background: #f7f3ec;
}
.chapter-tab {
  border: none;
  background: transparent;
  padding: .35rem .75rem;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-size: .85rem;
  color: var(--muted);
}
.chapter-tab.is-active {
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.chapter-html-preview {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.15rem;
  min-height: 16rem;
  max-height: 70vh;
  overflow: auto;
  line-height: 1.65;
  font-size: 1.05rem;
}
.chapter-html-preview a { color: var(--accent); }
.chapter-html-preview strong { font-weight: 700; }
.chapter-html-preview em { font-style: italic; }
.chapter-html-preview h1,
.chapter-html-preview h2,
.chapter-html-preview h3 { margin: 1.1em 0 .4em; line-height: 1.25; }
.chapter-html-preview p { margin: 0 0 .85em; }
.chapter-html-preview ul,
.chapter-html-preview ol { margin: 0 0 .85em; padding-left: 1.35rem; }
.chapter-html-preview blockquote {
  margin: 0 0 .85em;
  padding-left: .85rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}
.chapter-html-preview img { max-width: 100%; height: auto; }
.chapter-md-label { display: block; }
.chapter-import-box {
  margin-bottom: 1.25rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7f3ec;
}
.chapter-import-heading {
  margin: 0 0 .35rem;
  font-size: 1.05rem;
}
.chapter-import-box label { display: block; margin-bottom: .75rem; }
.form-hint { font-size: .85rem; margin: 0 0 .75rem; }
.contact-form { margin: 1.25rem 0 1.5rem; max-width: 520px; }
.contact-form textarea { width: 100%; }
.import-banner {
  background: #e8f5e9;
  border: 1px solid #c8e6c9;
  padding: .75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}
.import-banner p { margin: 0; }
@media (max-width: 720px) {
  .chapter-form { grid-template-columns: 1fr; }
}

.schedule-panel {
  margin: 2rem 0;
  padding: 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 720px;
}
.schedule-panel h2 { margin-top: 0; }
.schedule-modal-dialog {
  max-width: 560px;
  max-height: min(90vh, 720px);
  overflow-y: auto;
}
.schedule-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .5rem;
}
.schedule-modal-header h3 { margin: 0; }
.schedule-modal-x {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 .25rem;
}
.schedule-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .25rem;
}
.schedule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .85rem 1rem;
  margin-bottom: 1rem;
}
.schedule-grid label { display: block; }
.schedule-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .85rem 1rem;
  margin-bottom: 1rem;
}
.schedule-fields label { display: block; }
.schedule-stack-label {
  grid-column: 1 / 2;
}
.schedule-weekdays {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: .35rem 0 .75rem;
}
.schedule-weekday {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  min-width: 2rem;
  font-size: .85rem;
  margin: 0;
}
.schedule-weekday input {
  width: auto;
  margin: 0;
}
.schedule-after {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .75rem 1rem 1rem;
  margin: 0 0 1rem;
}
.schedule-after legend { padding: 0 .35rem; font-weight: 600; }
.schedule-radio {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem .6rem;
  margin-bottom: .65rem;
}
.schedule-radio input[type="radio"] { width: auto; margin: 0; }
.schedule-radio select { width: auto; min-width: 8rem; margin: 0; }
.schedule-after textarea { margin-top: .25rem; }
.schedule-check {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
}
.schedule-check input { width: auto; margin: 0; }
@media (max-width: 560px) {
  .schedule-grid,
  .schedule-fields { grid-template-columns: 1fr; }
}
.work-cover-box img { width: 100%; height: 100%; object-fit: cover; }
.work-overview-body h1 { margin: 0 0 .75rem; font-size: 1.75rem; }
.series-books-carousel {
  margin: 0 0 1.5rem;
}
.series-books-carousel .carousel-header {
  margin-bottom: .5rem;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.work-stats {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1.25rem;
  list-style: none;
  padding: 0;
  margin: 0 0 .75rem;
}
.work-stats li { display: flex; flex-direction: column; min-width: 4.5rem; }
.stat-val { font-weight: 700; font-size: .95rem; }
.stat-label { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.freq-days {
  display: inline-flex;
  gap: .12rem;
  font-size: .8rem;
  letter-spacing: .02em;
  font-weight: 700;
}
.freq-day.is-on { color: #2e7d32; }
.freq-day.is-off { color: #b0a89c; }
.work-genre { margin: 0 0 .5rem; font-size: .9rem; }
.work-synopsis {
  margin: 0 0 1rem;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.45;
  max-width: 42rem;
}
.work-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.work-actions .btn {
  font-size: inherit;
  line-height: inherit;
  padding: .6rem 1.2rem;
  box-sizing: border-box;
}
.work-actions .btn.is-disabled,
.work-actions a.btn.is-disabled {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: auto;
}
.work-actions .btn.is-active {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.stub-form label {
  display: block;
  margin-bottom: .85rem;
}
.stub-form .edit-check {
  margin-bottom: .85rem;
}
.stub-modal-dialog {
  max-height: min(90vh, 640px);
  overflow: auto;
}
.work-actions-end { justify-content: flex-end; }
.work-list ul { list-style: none; padding: 0; }
.work-list li { padding: .4rem 0; border-bottom: 1px solid var(--border); }
.work-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .35rem;
}
.work-list-header h2 { margin: 0; }
.chapter-order-btn {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 4px;
  padding: .15rem .55rem;
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
  min-width: 2rem;
}
.chapter-order-btn:hover { border-color: var(--accent); }
.cover-preview { max-width: 160px; margin-top: .5rem; border-radius: 4px; }

.work-genre { margin: 0 0 .5rem; font-size: .9rem; }
.genre-btn {
  background: none;
  border: 1px dashed var(--border);
  border-radius: 4px;
  padding: .2rem .55rem;
  font: inherit;
  font-size: .9rem;
  color: var(--accent);
  cursor: pointer;
}
.genre-btn.is-empty { color: var(--muted); }
.genre-btn:hover { border-color: var(--accent); background: var(--card); }
.genre-modal[hidden] { display: none !important; }
.genre-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}
.genre-modal.is-open {
  display: flex !important;
}
.genre-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 22, 16, .45);
}
.genre-modal-dialog {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  width: min(560px, calc(100vw - 2rem));
  max-height: min(80vh, 560px);
  display: flex;
  flex-direction: column;
  gap: .75rem;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
}
.genre-modal-dialog-wide {
  width: min(720px, calc(100vw - 2rem));
  max-height: min(85vh, 640px);
}
.work-tags { margin-top: -.25rem; }
.work-content-filter {
  margin: .35rem 0 .75rem;
  font-size: .92rem;
}
.cw-modal-dialog {
  max-height: min(90vh, 720px);
  overflow: auto;
}
.cw-modal-actions {
  justify-content: flex-end;
}
.cw-rating,
.cw-group {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .75rem 1rem;
  margin: 0 0 1rem;
}
.cw-rating legend,
.cw-group legend {
  padding: 0 .35rem;
  font-weight: 600;
}
.cw-rating-option,
.cw-check {
  display: flex;
  gap: .65rem;
  align-items: flex-start;
  margin: .55rem 0;
  cursor: pointer;
}
.cw-rating-option input,
.cw-check input {
  width: auto;
  min-width: 1rem;
  margin: .2rem 0 0;
  padding: 0;
  flex-shrink: 0;
  align-self: flex-start;
}
.cw-rating-text,
.cw-check > span {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .1rem;
  line-height: 1.35;
}
.cw-dot {
  width: .7rem;
  height: .7rem;
  border-radius: 50%;
  margin-top: .35rem;
  flex-shrink: 0;
}
.cw-dot-green { background: #2e7d32; }
.cw-dot-yellow { background: #c9a227; }
.cw-dot-red { background: #c62828; }
.cw-prohibited {
  background: #f7efe6;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .75rem 1rem;
  margin-bottom: 1rem;
}
.cw-prohibited h4 {
  margin: 0 0 .5rem;
  font-size: .95rem;
}
.cw-prohibited ul {
  margin: 0;
  padding-left: 1.1rem;
}
.cw-prohibited li { margin: .35rem 0; }
.genre-modal-dialog h3 { margin: 0; }
.genre-checklist {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .35rem .75rem;
  padding: .25rem 0;
}
.genre-checklist label {
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  font-size: .9rem;
}
.genre-checklist input { width: auto; margin: 0; flex-shrink: 0; }
@media (max-width: 520px) {
  .genre-checklist { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
body.modal-open { overflow: hidden; }

.profile-form-layout {
  display: grid;
  grid-template-columns: 136px 1fr;
  gap: 1.5rem;
  align-items: start;
}
.profile-avatar-box,
.author-avatar-box {
  width: 136px;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #e8e0d4;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.profile-avatar-box img,
.author-avatar-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-fields label {
  display: block;
  margin-bottom: .85rem;
}
.author-profile {
  margin-bottom: 2rem;
}
.author-profile-main {
  display: grid;
  grid-template-columns: 136px 1fr;
  gap: 1.25rem;
  align-items: start;
}
.author-profile-body h1 { margin-top: 0; }
.author-about {
  white-space: pre-wrap;
  margin: .75rem 0 1rem;
}
.author-links {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: .75rem 0 1rem;
}
.story-author-links { margin-top: .25rem; }
@media (max-width: 640px) {
  .work-overview { grid-template-columns: 1fr; }
  .work-cover-box { width: 136px; margin: 0 auto; }
  .profile-form-layout,
  .author-profile-main { grid-template-columns: 1fr; }
  .profile-avatar-box,
  .author-avatar-box { margin: 0 auto; }
}
