:root {
  --red: #990000; --red-dark: #6f0000; --ink: #2a2a2a; --muted: #6b6b6b; --line: #ddd;
  --bg: #fff; --soft: #f4f1ee; --link: #900; --tag: #2a2a2a;
  --btn-grad-1: #fff; --btn-grad-2: #e6e6e6; --btn-border: #bbb; --btn-hover: #ddd;
  --input-bg: #fff; --input-border: #bbb;
  --flash-bg: #fff8d6; --flash-border: #e6d17a;
  --flash-err-bg: #fde8e8; --flash-err-border: #e5a5a5;
  --inc-bg: #eef7ee; --inc-border: #9bc79b;
  --exc-bg: #fbeeee; --exc-border: #e0a3a3;
  --current-row-bg: #f5fbf2;
  --fmt-bg: #eee; --fmt-html-bg: #e6efff; --fmt-epub-bg: #e9f6e5; --fmt-pdf-bg: #fde9e2;
  --st-added-bg: #dff3d8; --st-version-bg: #dfe9fb; --st-duplicate-bg: #eee; --st-error-bg: #fadede;
  --dropzone-over-bg: #fff3f0;
  --reader-bg: #fbfaf7;
  --danger: #b00;
  --none-swatch: #fff; --none-swatch-border: rgba(0,0,0,.15);
  color-scheme: light;
  font-size: 15px;
}
:root[data-theme="dark"] {
  --ink: #e4e4e4; --muted: #a3a3a3; --line: #3a3430;
  --bg: #15110f; --soft: #221c19; --link: #ff8d82; --tag: #d8d8d8;
  --btn-grad-1: #3a3330; --btn-grad-2: #262220; --btn-border: #4a423e; --btn-hover: #463e3a;
  --input-bg: #1e1a17; --input-border: #4a423e;
  --flash-bg: #4a3f16; --flash-border: #7a662a;
  --flash-err-bg: #4a1f1f; --flash-err-border: #7a3333;
  --inc-bg: #1c3320; --inc-border: #3f7a4a;
  --exc-bg: #3a1f1f; --exc-border: #7a3f3f;
  --current-row-bg: #1c2e1c;
  --fmt-bg: #2a2522; --fmt-html-bg: #1c2c42; --fmt-epub-bg: #1c3320; --fmt-pdf-bg: #42281c;
  --st-added-bg: #1c3320; --st-version-bg: #1c2c42; --st-duplicate-bg: #2a2522; --st-error-bg: #4a1f1f;
  --dropzone-over-bg: #3a2420;
  --reader-bg: #171310;
  --danger: #ff6b6b;
  --none-swatch: #2a2522; --none-swatch-border: rgba(255,255,255,.15);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg);
  font-family: "Lucida Grande", "Lucida Sans Unicode", Verdana, "Helvetica Neue", Helvetica, sans-serif; line-height: 1.45; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.inner { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
button, .button { font: inherit; font-size: .9rem; background: linear-gradient(var(--btn-grad-1), var(--btn-grad-2)); border: 1px solid var(--btn-border);
  border-radius: 4px; padding: 4px 12px; color: var(--ink); cursor: pointer; display: inline-block; }
button:hover, .button:hover { background: var(--btn-hover); text-decoration: none; }
.button.primary { background: var(--red); border-color: var(--red-dark); color: #fff; }
input[type=text], input[type=search], input[type=date], select { font: inherit; font-size: .9rem; padding: 4px 6px;
  border: 1px solid var(--input-border); border-radius: 3px; background: var(--input-bg); color: var(--ink); max-width: 100%; }
code { background: var(--soft); padding: 0 3px; border-radius: 2px; font-size: .85em; }

/* header */
#header { background: var(--red); color: #fff; border-bottom: 1px solid #500; }
#header .inner { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
#header > .inner { padding-top: 12px; padding-bottom: 12px; }
.logo { color: #fff; font-family: Georgia, serif; font-size: 1.6rem; letter-spacing: .5px; }
.logo:hover { text-decoration: none; }
.quicksearch { margin-left: auto; display: flex; gap: 6px; }
.quicksearch input { width: 320px; border: 0; }
.theme-toggle { background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.3); color: #fff;
  border-radius: 999px; width: 32px; height: 32px; padding: 0; font-size: 1rem; line-height: 1; display: flex;
  align-items: center; justify-content: center; }
.theme-toggle:hover { background: rgba(255,255,255,.26); }
nav.primary { background: var(--red-dark); }
nav.primary .inner { gap: 4px; }
nav.primary a { color: #fff; padding: 8px 10px; font-size: .9rem; }
nav.primary a:hover { background: rgba(255,255,255,.12); text-decoration: none; }
nav.primary .upload-link { margin-left: auto; font-weight: bold; }
#main { padding-top: 18px; padding-bottom: 40px; }
footer { color: var(--muted); font-size: .8rem; padding: 20px 16px 40px; border-top: 1px solid var(--line); }
h2.heading { font-family: Georgia, serif; font-weight: normal; font-size: 1.5rem; margin: 0 0 12px; }
.intag { font-style: italic; }
.count { color: var(--muted); font-size: .85em; }
.flash { background: var(--flash-bg); border: 1px solid var(--flash-border); padding: 8px 12px; border-radius: 3px; }
.flash.error { background: var(--flash-err-bg); border-color: var(--flash-err-border); }
.hint { color: var(--muted); font-size: .82rem; }

/* layout */
.works-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 28px; }
@media (max-width: 860px) { .works-layout { grid-template-columns: 1fr; } .filters { order: -1; } .quicksearch input { width: 200px; } }

/* filters */
.filters form { background: var(--soft); border: 1px solid var(--line); border-radius: 4px; padding: 12px; font-size: .88rem; }
.filters fieldset { border: 0; border-top: 1px solid var(--line); margin: 12px 0 0; padding: 10px 0 0; }
.filters legend { font-weight: bold; font-family: Georgia, serif; font-size: 1rem; padding: 0 4px 0 0; }
.filters details { margin: 4px 0; }
.filters summary { cursor: pointer; font-weight: bold; color: var(--ink); padding: 2px 0; }
.filters details ul { list-style: none; margin: 4px 0 6px; padding: 0 0 0 6px; max-height: 260px; overflow: auto; }
.filters details li { margin: 2px 0; }
.filters label.block { display: block; margin: 8px 0; }
.filters label.block input, .filters label.block select { display: block; width: 100%; margin-top: 3px; }
.filters input[type=search] { width: 100%; }
.radio-group, .range { margin: 8px 0; }
.radio-group > span, .range > span { display: block; font-weight: bold; margin-bottom: 2px; }
.radio-group label { display: block; }
.range input { width: 48%; }
.submit-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; }

/* active filter chips */
.active-filters { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.active-filters:empty { display: none; }
.active-filters li { background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 1px 10px; font-size: .82rem; }
.active-filters li.inc { border-color: var(--inc-border); background: var(--inc-bg); }
.active-filters li.exc { border-color: var(--exc-border); background: var(--exc-bg); }
.active-filters a { color: var(--muted); margin-left: 3px; font-weight: bold; }

/* blurbs */
ol.work.index { list-style: none; padding: 0; margin: 0; }
li.none { padding: 20px; color: var(--muted); }
.blurb { border: 1px solid var(--line); border-radius: 4px; padding: 10px 14px 10px; margin-bottom: 14px; position: relative; }
.blurb .header { position: relative; padding-left: 64px; min-height: 56px; }
.blurb h4.heading { margin: 0; font-size: 1.05rem; font-weight: normal; }
.blurb h4.heading a:first-child { font-weight: bold; }
.blurb h5.fandoms { margin: 2px 0 0; font-size: .85rem; font-weight: normal; }
.blurb .datetime { position: absolute; right: 0; top: 0; margin: 0; font-size: .8rem; color: var(--muted); }
.blurb h4.heading { padding-right: 90px; }
.mark-read { position: absolute; right: 0; top: 20px; margin: 0; }
.mark-read button { border: 0; cursor: pointer; font: inherit; }
ul.required-tags { position: absolute; left: 0; top: 2px; width: 54px; height: 54px; list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: 26px 26px; grid-template-rows: 26px 26px; gap: 2px; }
ul.required-tags li { border-radius: 3px; display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: bold; color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.2); border: 1px solid rgba(0,0,0,.15); }
.r-g { background: #78a600; } .r-t { background: #d8b400; } .r-m { background: #e07a00; } .r-e { background: #b80000; } .r-nr { background: var(--none-swatch); border-color: var(--none-swatch-border) !important; }
.c-ff { background: #c21a1a; } .c-fm { background: #8a1fa8; } .c-mm { background: #1f62b6; } .c-gen { background: #3d9a3d; }
.c-multi { background: conic-gradient(#c21a1a 0 25%, #8a1fa8 0 50%, #1f62b6 0 75%, #3d9a3d 0); } .c-other { background: #333; } .c-none { background: var(--none-swatch); border-color: var(--none-swatch-border) !important; }
.w-none { background: var(--none-swatch); border-color: var(--none-swatch-border) !important; } .w-choose { background: #e07a00; } .w-yes { background: #b80000; }
.done { background: #3d9a3d; } .wip { background: var(--none-swatch); border: 2px solid #b80000 !important; }

ul.tags.commas { list-style: none; padding: 0; margin: 8px 0 4px; font-size: .85rem; }
ul.commas { list-style: none; padding: 0; margin: 0; display: inline; }
ul.commas li { display: inline; }
ul.commas li:not(:last-child)::after { content: ", "; }
ul.tags li a { color: var(--tag); border-bottom: 1px dotted #999; }
ul.tags li.warnings a strong { color: var(--ink); }
ul.tags li a:hover { color: var(--link); text-decoration: none; }
blockquote.summary { margin: 6px 0 6px 12px; font-family: Georgia, serif; font-size: .92rem; }
blockquote.summary p { margin: .3em 0; }
ul.series { list-style: none; padding: 0; margin: 4px 0; font-size: .85rem; }
dl.stats { margin: 6px 0 0; font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0 4px; }
dl.stats dt { margin: 0; } dl.stats dd { margin: 0 10px 0 0; color: var(--ink); }

.pagination { list-style: none; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; padding: 0; margin: 20px 0; }
.pagination a, .pagination span { padding: 2px 8px; border: 1px solid var(--line); border-radius: 3px; display: inline-block; }
.pagination .current { background: var(--red); color: #fff; border-color: var(--red); }
.pagination .gap { padding: 2px 4px; }

.empty { text-align: center; padding: 60px 20px; border: 2px dashed var(--line); border-radius: 6px; }

/* work page */
.work-nav { list-style: none; padding: 0; margin: 0 0 12px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.wrapper { border: 1px solid var(--line); background: var(--soft); border-radius: 4px; padding: 10px 14px; }
dl.work.meta { display: grid; grid-template-columns: 150px 1fr; gap: 6px 10px; margin: 0; font-size: .9rem; }
dl.work.meta > dt { text-align: right; font-weight: normal; color: var(--muted); }
dl.work.meta > dd { margin: 0; }
dl.work.meta a.tag { color: var(--ink); border-bottom: 1px dotted #999; }
dl.work.meta dl.stats { justify-content: flex-start; font-size: .85rem; }
@media (max-width: 600px) { dl.work.meta { grid-template-columns: 1fr; } dl.work.meta > dt { text-align: left; } }
.preface { text-align: center; margin: 24px auto; max-width: 760px; }
.preface h2.title { font-family: Georgia, serif; font-weight: normal; font-size: 1.9rem; margin: 10px 0 4px; }
.preface h3.byline { font-weight: normal; font-size: 1.05rem; margin: 0 0 18px; }
.preface .module { text-align: left; }
.preface .module h3 { font-size: 1rem; margin: 14px 0 4px; }
.preface blockquote { font-family: Georgia, serif; margin: 0 0 0 20px; }
h3.landmark { font-family: Georgia, serif; font-weight: normal; font-size: 1.25rem; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
table.versions, table.results-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.versions th, table.versions td, table.results-table th, table.results-table td { border-bottom: 1px solid var(--line); padding: 6px; text-align: left; vertical-align: top; }
table.versions tr.current { background: var(--current-row-bg); }
.fmt { font-weight: bold; font-size: .75rem; padding: 1px 5px; border-radius: 3px; background: var(--fmt-bg); }
.fmt-html { background: var(--fmt-html-bg); } .fmt-epub { background: var(--fmt-epub-bg); } .fmt-pdf { background: var(--fmt-pdf-bg); }
.badge { font-size: .7rem; background: #3d9a3d; color: #fff; padding: 1px 5px; border-radius: 8px; }
.note-form { display: flex; gap: 4px; } .note-form input { flex: 1; min-width: 120px; }
.note-form button { padding: 2px 6px; font-size: .75rem; }
.diff { margin: 4px 0 0; padding-left: 16px; color: var(--muted); font-size: .78rem; }
.orig { color: var(--muted); font-size: .72rem; margin-top: 2px; word-break: break-all; }
td.actions { white-space: nowrap; }
td.actions a, td.actions form { display: block; }
button.link { background: none; border: 0; padding: 0; color: var(--link); font-size: .85rem; }
.danger { color: var(--danger) !important; }
.add-version { margin-top: 18px; padding: 12px; border: 1px solid var(--line); border-radius: 4px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.add-version h4, .add-version p { width: 100%; margin: 0; }
.delete-work { margin-top: 18px; text-align: right; }

/* upload */
.dropzone { display: block; border: 2px dashed var(--btn-border); border-radius: 8px; padding: 40px 20px; text-align: center; cursor: pointer; background: var(--soft); margin-bottom: 12px; }
.dropzone.over { border-color: var(--red); background: var(--dropzone-over-bg); }
.dropzone input[type=file] { display: block; margin: 0 auto 12px; }
#choose-folder { display: block; margin: 0 0 16px; }
#picked { display: block; margin-top: 8px; font-weight: bold; }
.upload-form label.block input { display: block; width: 100%; margin: 4px 0 12px; }
#progress { margin-left: 10px; color: var(--muted); }
.summary-line { display: flex; gap: 8px; flex-wrap: wrap; }
.st { font-size: .78rem; padding: 1px 7px; border-radius: 9px; background: var(--fmt-bg); white-space: nowrap; }
.st-added { background: var(--st-added-bg); } .st-version { background: var(--st-version-bg); } .st-duplicate { background: var(--st-duplicate-bg); } .st-error { background: var(--st-error-bg); }
.results-table .msg { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.results-table .by { color: var(--muted); }
.upload-results { margin-bottom: 24px; }

/* tag index */
.tag-filter { margin-bottom: 10px; display: flex; gap: 6px; }
.letters a { margin-right: 6px; font-weight: bold; }
.letter-group h3 { font-family: Georgia, serif; border-bottom: 1px solid var(--line); margin: 18px 0 6px; }
ul.tag-index { columns: 3 260px; list-style: none; padding: 0; margin: 0; font-size: .9rem; }
ul.tag-index li { break-inside: avoid; margin: 2px 0; }

/* reader */
body.reader { background: var(--reader-bg); }
.reader-bar { position: sticky; top: 0; background: var(--red); color: #fff; padding: 8px 16px; font-size: .85rem; display: flex; gap: 16px; align-items: center; }
.reader-bar a { color: #fff; }
.reader-text { max-width: 720px; margin: 0 auto; padding: 20px 18px 80px; font-family: Georgia, serif; font-size: 1.08rem; line-height: 1.6; }
.reader-text .part { border-bottom: 1px solid var(--line); padding-bottom: 20px; margin-bottom: 20px; }

.filter-summary { display: none; }
@media (max-width: 860px) {
  .filter-summary { display: block; cursor: pointer; font-weight: bold; padding: 8px 12px; background: var(--soft);
    border: 1px solid var(--line); border-radius: 4px; margin-bottom: 6px; }
  nav.primary a { padding: 6px 8px; font-size: .85rem; }
  nav.primary .upload-link { margin-left: 0; }
  .blurb .datetime { position: static; }
  .mark-read { position: static; margin-top: 4px; }
  .blurb h4.heading { padding-right: 0; }
}
