@font-face {
  font-family: "Literata";
  src: url("/f/Literata-VariableFont_opsz,wght.ttf")
    format("truetype");
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
}

@font-face {
  font-family: "Literata";
  src: url("/f/Literata-Italic-VariableFont_opsz,wght.ttf")
    format("truetype");
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
}
:root {
  color-scheme: light dark;
  --bg: #faf9f6;
  --surface: #fff;
  --text: #17212f;
  --muted: #4b5563;
  --border: #667085;
  --accent: #174ea6;
  --on-accent: #fff;
  --focus: #6b21a8;
  --danger: #b42318;
  --error-bg: #fff1f0;
  --code: #e8edf5;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10151d;
    --surface: #19212c;
    --text: #eef2f6;
    --muted: #b7c3d1;
    --border: #7b8ba1;
    --accent: #a9c7ff;
    --on-accent: #10264b;
    --focus: #f6bd60;
    --danger: #ffb4ab;
    --error-bg: #381b1c;
    --code: #283447;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10151d;
  --surface: #19212c;
  --text: #eef2f6;
  --muted: #b7c3d1;
  --border: #7b8ba1;
  --accent: #a9c7ff;
  --on-accent: #10264b;
  --focus: #f6bd60;
  --danger: #ffb4ab;
  --error-bg: #381b1c;
  --code: #283447;
}
:root[data-theme="light"] {
  color-scheme: light;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.6 "Literata", Georgia, serif;
  font-optical-sizing: auto;
}
header,
main {
  max-width: 76rem;
  margin: auto;
  padding: 0.5rem;
}
#site-header {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: nowrap;
  border-bottom: 1px solid var(--border);
}
#site-header nav {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: nowrap;
  margin-left: 0;
}
header [aria-current="page"] {
  font-weight: 700;
  text-decoration-thickness: 0.18em;
}
a {
  color: var(--accent);
  text-underline-offset: 0.18em;
}
h1,
h2,
h3 {
  line-height: 1.25;
}
button,
input,
textarea,
select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  padding: 0.55rem 0.7rem;
}
button {
  cursor: pointer;
}
[data-theme-toggle] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.625rem;
}
.theme-icon {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask: url("/moon.svg") center / contain no-repeat;
  mask: url("/moon.svg") center / contain no-repeat;
}
:root[data-theme="dark"] .theme-icon {
  -webkit-mask-image: url("/sun.svg");
  mask-image: url("/sun.svg");
}
button.primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}
button.danger {
  color: var(--danger);
}
button:disabled {
  cursor: default;
  opacity: 0.6;
}
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
label {
  display: block;
  margin: 0.7rem 0;
  font-weight: 600;
}
label input,
label textarea,
label select {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  font-weight: 400;
}
textarea {
  min-height: 8rem;
  resize: vertical;
}
#chapter-source {
  min-height: 22rem;
  font:
    1rem/1.6 ui-monospace,
    monospace;
}
section.panel {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 0.5rem;
  padding: 1.25rem;
  margin: 1rem 0;
}
.grid {
  display: grid;
  grid-template-columns: minmax(15rem, 1fr) minmax(0, 2fr);
  gap: 1.5rem;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 1rem 0;
}
.muted,
small {
  color: var(--muted);
}
#reader-status:empty,
#reader-error:empty,
#bookmark-status:empty {
  display: none;
}
[role="alert"]:not(:empty) {
  color: var(--danger);
  background: var(--error-bg);
  border: 1px solid var(--danger);
  padding: 0.75rem;
  border-radius: 0.35rem;
}
ul.contents {
  list-style: none;
  padding: 0;
}
.contents li {
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 0;
  overflow-wrap: anywhere;
}
.contents .actions {
  margin: 0.5rem 0;
}
.markdown {
  overflow-wrap: anywhere;
}
.markdown p.novelwriter-center {
  text-align: center;
}
.markdown img {
  max-width: 100%;
  height: auto;
}
.markdown pre {
  overflow: auto;
  padding: 1rem;
  background: var(--code);
  border: 1px solid var(--border);
}
.markdown code {
  background: var(--code);
  padding: 0.1rem 0.25rem;
}
.markdown blockquote {
  margin-left: 0;
  border-left: 4px solid var(--border);
  padding-left: 1rem;
  color: var(--muted);
}
.markdown table {
  border-collapse: collapse;
  width: 100%;
}
.markdown th,
.markdown td {
  border: 1px solid var(--border);
  padding: 0.4rem;
  text-align: left;
}
[hidden] {
  display: none !important;
}
@media (max-width: 55rem) {
  .grid {
    grid-template-columns: 1fr;
  }
}
.reader {
  max-width: 64rem;
}
.reader #chapter-view {
  max-width: 46rem;
  margin: 2rem auto;
  font-size: 1.1rem;
  line-height: 1.8;
}
.reader #cover {
  max-width: 12rem;
  max-height: 18rem;
  object-fit: contain;
}
.reader h1,
.reader h2,
.reader a {
  overflow-wrap: anywhere;
}
.reader #chapter-view .actions {
  font-size: 1rem;
}

.reader #chapter-body {
  hyphens: auto;
  text-align: justify;
}

/* Shared navigation keeps semantic links and the existing theme control. */
#site-header nav a,
#contents-link,
.icon-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
#site-header nav a:hover,
#site-header [data-theme-toggle]:hover,
.icon-control:hover:not(:disabled),
#contents-link:hover {
  background: var(--code);
  border-color: var(--accent);
}
#site-header nav a[aria-current="page"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.reader .book-header,
.reader #book-details,
.reader .chapter-navigation {
  max-width: 46rem;
  margin-left: auto;
  margin-right: auto;
}
#description {
  hyphens: auto;
  text-align: justify;
}
.book-header {
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr);
  gap: 1rem 1.5rem;
  align-items: start;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}
.book-header.is-catalog {
  display: block;
}
.book-heading {
  min-width: 0;
}
.book-heading h1 {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin: 0 0 0.5rem;
}
#page-title {
  min-width: 0;
}
#author-byline {
  margin: 0 0 0.5rem;
  overflow-wrap: anywhere;
}
.reader .book-header #cover {
  width: 12rem;
  max-width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
}
#description-section {
  grid-column: 1 / -1;
  min-width: 0;
}
#description-heading {
  font-size: 1.2rem;
  margin: 0 0 0.5rem;
}
.book-header.is-compact {
  grid-template-columns: 6rem minmax(0, 1fr);
  align-items: center;
}
.reader .book-header.is-compact #cover {
  grid-row: auto;
  width: 6rem;
  max-height: 9rem;
}
.book-header.is-compact h1 {
  font-size: 1.6rem;
}
.chapter-navigation {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}
.previous-link {
  grid-column: 1;
  justify-self: start;
}
.next-link {
  grid-column: 3;
  justify-self: end;
}
.bookmark-control {
  grid-column: 2;
  justify-self: center;
  grid-row: 1;
}
.control-icon {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.previous-icon {
  --icon: url("/prev.svg");
}
.next-icon {
  --icon: url("/next.svg");
}
.bookmark-icon {
  --icon: url("/bookmark.svg");
}
#site-header nav a[aria-current="page"]:hover {
  text-decoration: underline;
}

.reader > p {
  max-width: 46rem;
  margin-left: auto;
  margin-right: auto;
}
.reader .book-header.is-catalog {
  max-width: none;
}
.description-content > :first-child {
  margin-top: 0;
}
.description-content > :last-child {
  margin-bottom: 0;
}

/* Catalog cards contain only a linked cover and title. */
#catalog .catalog-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1.5rem;
  list-style: none;
  padding: 0;
}
#catalog .catalog-grid li {
  min-width: 0;
}
#catalog .catalog-grid a {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
  border-radius: 0.35rem;
  color: var(--text);
  text-align: center;
  text-decoration: none;
}
#catalog .catalog-grid img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: contain;
  background: var(--surface);
}
#catalog .catalog-title {
  overflow-wrap: anywhere;
}
#catalog .catalog-grid a:hover .catalog-title {
  text-decoration: underline;
}
@media (max-width: 60rem) {
  #catalog .catalog-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
@media (max-width: 45rem) {
  #catalog .catalog-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 32rem) {
  #catalog .catalog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 22rem) {
  #catalog .catalog-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Compact contents preserve verbatim wrapping titles and separate accessible metadata. */
#reader-contents li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 0;
}
.contents-title {
  min-width: 0;
  overflow-wrap: anywhere;
}
.small-icon {
  display: inline-block;
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.page-icon {
  --icon: url("/page.svg");
}
.bonus-icon {
  --icon: url("/star.svg");
}
.locked-icon {
  --icon: url("/padlock.svg");
}
.draft-icon {
  --icon: url("/quill.svg");
}
#book-draft {
  display: inline-block;
  flex: 0 0 auto;
}
#book-draft[hidden] {
  display: none;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.continue-indicator {
  display: inline-flex;
  flex: 0 0 auto;
  margin-left: auto;
}
.bookmark-control.is-saved,
.bookmark-control.is-saved:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
#chapter-heading {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
#chapter-heading #chapter-title {
  min-width: 0;
  overflow-wrap: anywhere;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  max-width: 100%;
}
.site-brand img {
  display: block;
  height: 3rem;
  width: auto;
  flex: 0 0 auto;
}
.site-brand a {
  color: var(--text);
  text-decoration: none;
}
:root[data-theme="dark"] .site-brand img {
  filter: invert(1);
}

/* The theme control precedes navigation in both DOM and visual order. */
#site-header [data-theme-toggle] {
  margin-left: auto;
}
@media (max-width: 40rem) {
  #site-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
  }
  .site-brand {
    min-width: 0;
    gap: 0.5rem;
  }
  .site-brand img {
    height: 2rem;
  }
  .site-brand a {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
  }
  #site-header nav {
    grid-column: 1 / -1;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 0.5rem;
  }
  #site-header nav a {
    padding: 0.5rem 0.35rem;
  }
  /* Keep focus rings inside controls at the deliberate 0.5rem page edges. */
  :focus-visible {
    outline-offset: -3px;
  }
  .book-header {
    grid-template-columns: 4.5rem minmax(0, 1fr);
    gap: 1rem 0.75rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
  }
  .book-heading h1,
  .book-header.is-compact h1 {
    font-size: 1.4rem;
    line-height: 1.2;
  }
  .reader .book-header #cover {
    width: 4.5rem;
    max-height: 6.75rem;
  }
  .author-email {
    display: block;
  }
  .byline-separator {
    display: none;
  }
  .book-header.is-compact {
    grid-template-columns: 4rem minmax(0, 1fr);
    align-items: start;
  }
  .reader .book-header.is-compact #cover {
    width: 4rem;
    max-height: 6rem;
  }
}


/* Author selection rows share reader masks without changing reader Contents. */
#workspace #books li,
#workspace #chapters li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  padding: 0.4rem 0;
}
#workspace .author-selection {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0.4rem;
  text-align: left;
}
#workspace .selection-title {
  min-width: 0;
  overflow-wrap: anywhere;
}
#workspace .chapter-moves {
  display: flex;
  flex: 0 0 auto;
  gap: 0.25rem;
}
#workspace .chapter-move {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0.4rem;
}
#workspace .chapter-move[aria-disabled="true"]:not(:disabled) {
  cursor: default;
  opacity: 0.6;
}
#workspace .plus-icon {
  --icon: url("/plus.svg");
}
#workspace .minus-icon {
  --icon: url("/minus.svg");
}

#workspace .grid > .panel {
  min-width: 0;
}
#workspace #book-url,
#workspace #chapter-url {
  overflow-wrap: anywhere;
}
