:root {
  --bg: #f3efe7;
  --surface: #fbf9f4;
  --text: #1f1c17;
  --muted: #6b6457;
  --line: #d9d1c2;
  --accent: #7a4b16;        /* warm ink — the book's own space */
  --accent-2: #2f5d50;
  --ext-bg: #eaf0f4;        /* reader-created extensions: cool, clearly different */
  --ext-ink: #183247;
  --ext-line: #9bb6c9;
  --ext-mark: #2b6a95;
  --focus: #b8661c;
  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17150f; --surface: #201d17; --text: #ece6da; --muted: #a8a091; --line: #3a352b;
    --accent: #e0a25a; --accent-2: #8fc2b2; --ext-bg: #16222b; --ext-ink: #d6e6f2; --ext-line: #355269; --ext-mark: #7fb6dc; --focus: #f0b36a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.55 var(--sans); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.page { padding-top: 1.5rem; padding-bottom: 3rem; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; font-weight: 600; }
h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); margin: .6em 0 .4em; }
h2 { font-size: 1.35rem; margin: 1.6em 0 .5em; }
.lede { font-size: 1.08rem; color: var(--muted); max-width: 60ch; }
.empty { color: var(--muted); font-style: italic; }

.banner { padding: .55rem 16px; font-size: .92rem; text-align: center; }
.banner.private { background: #3a352b; color: #f3efe7; }
.banner.private a { color: #f6c98d; }
.banner.preview { background: #fff2c7; color: #3d2f00; border-bottom: 2px solid #e2b33a; }
.pv-tag { display: inline-block; background: #fff2c7; color: #4a3800; border: 1px dashed #c99a1d; border-radius: 3px; font: 600 .72rem/1.5 var(--sans); padding: 0 .4rem; letter-spacing: .02em; vertical-align: middle; }
.pv-tag.big { display: block; font-size: .9rem; padding: .4rem .7rem; margin: .6rem 0; }

.site-head { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-head .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem 1rem; padding-top: .7rem; padding-bottom: .7rem; }
.brand { text-decoration: none; color: var(--text); font-family: var(--serif); }
.brand-title { font-size: 1.45rem; font-weight: 700; letter-spacing: .01em; }
.brand-sub { color: var(--muted); font-style: italic; }
.site-head ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .2rem 1.1rem; }
.site-head nav a { text-decoration: none; color: var(--text); padding: .2rem 0; border-bottom: 2px solid transparent; }
.site-head nav a[aria-current="page"], .site-head nav a:hover { border-bottom-color: var(--accent); }

.hero { padding: 3rem 0 2rem; }
.hero .kicker { color: var(--muted); text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; margin: 0; }
.hero h1 { font-size: clamp(2.4rem, 7vw, 4.2rem); margin: .2em 0 .3em; }
.hero h1 .sub { display: block; font-weight: 400; font-style: italic; color: var(--accent); font-size: .55em; }
.btn { display: inline-block; padding: .55rem 1.1rem; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none; font: inherit; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #17150f; } }
.btn:hover { filter: brightness(1.05); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; padding-bottom: 3rem; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; gap: 1rem; } }
.toc { padding-left: 1.4rem; }
.toc li { margin: .3rem 0; }
.toc.big li { font-size: 1.1rem; margin: .5rem 0; }

/* Original book */
.origin-label { font: 600 .78rem/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); text-align: center; margin: 1.5rem 0 .8rem; }
.ob-mark { color: var(--accent); border: 1px solid var(--accent); border-radius: 3px; padding: .2rem .45rem; margin-right: .4rem; }
.reading { padding-bottom: 3rem; }
.reader-tools { display: flex; justify-content: center; gap: .4rem; margin: 0 0 .9rem; }
.reader-tools button { font: .85rem var(--sans); padding: .25rem .7rem; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 4px; cursor: pointer; }
.chap-nav { display: flex; justify-content: space-between; gap: 1rem; margin: 1.5rem auto 0; max-width: calc(360pt * 1.55); font-size: .95rem; flex-wrap: wrap; }
.title-paper { margin-top: 1rem; }

/* Reader-created extensions: a visibly different zone */
.ext-zone { --zone: var(--ext-bg); }
.ext-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.ext-grid.compact { grid-template-columns: 1fr; gap: .6rem; }
.ext-card a { display: flex; flex-direction: column; gap: .2rem; height: 100%; padding: .9rem 1rem 1rem; background: var(--ext-bg); color: var(--ext-ink); text-decoration: none; border: 1px solid var(--ext-line); border-left: 5px solid var(--ext-mark); border-radius: 6px; font-family: var(--sans); }
.ext-card a:hover { border-color: var(--ext-mark); }
.ext-ribbon { font: 700 .66rem/1.4 var(--sans); text-transform: uppercase; letter-spacing: .12em; color: var(--ext-mark); }
.ext-type { font-size: .8rem; color: var(--ext-mark); }
.ext-title { font-size: 1.08rem; }
.ext-by, .ext-rel { font-size: .88rem; opacity: .85; }
.ext-sum { font-size: .9rem; margin-top: .3rem; }
.sample-tag { display: inline-block; font: 600 .7rem var(--sans); background: #f3e3ff; color: #4b1a66; border: 1px solid #c8a2dd; border-radius: 3px; padding: 0 .35rem; width: fit-content; }
.ext-article { background: var(--ext-bg); color: var(--ext-ink); border: 1px solid var(--ext-line); border-top: 6px solid var(--ext-mark); border-radius: 8px; padding: 1.3rem clamp(1rem, 4vw, 2.2rem) 1.8rem; margin: 1.2rem 0; font-family: var(--sans); }
.ext-article a { color: var(--ext-mark); }
.ext-banner { background: rgba(43, 106, 149, .1); border: 1px solid var(--ext-line); border-radius: 6px; padding: .6rem .8rem; font-size: .92rem; margin: 0 0 1rem; }
.sample-banner { background: #f3e3ff; color: #3a1050; border: 1px solid #c8a2dd; border-radius: 6px; padding: .6rem .8rem; font-size: .92rem; }
.ext-head h1 { margin: .1em 0 .2em; }
.ext-head .ext-type { text-transform: uppercase; letter-spacing: .1em; font-size: .78rem; margin: 0; }
.ext-head .ext-by { font-size: 1rem; margin: 0 0 .6rem; }
.ext-head .ext-sum { font-size: 1.05rem; font-style: italic; }
.ext-body { font-size: 1.05rem; line-height: 1.65; max-width: 68ch; }
.ext-credits { margin-top: 2rem; border-top: 1px solid var(--ext-line); padding-top: 1rem; font-size: .93rem; }
.ext-credits h2 { margin-top: 0; font-size: 1.1rem; }
.ext-credits dl { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: .35rem 1rem; }
.ext-credits dt { font-weight: 600; }
.ext-credits dd { margin: 0; }
.ext-credits ul { margin: 0; padding-left: 1.1rem; }
@media (max-width: 560px) { .ext-credits dl { grid-template-columns: 1fr; } .ext-credits dd { margin-bottom: .5rem; } }
.related-ext { margin: 2.2rem auto 0; max-width: calc(360pt * 1.55); border-top: 1px dashed var(--ext-line); padding-top: 1rem; }
.related-ext summary { cursor: pointer; color: var(--ext-mark); font-weight: 600; }

/* media */
.ext-media { display: grid; gap: 1.4rem; margin-top: 1.5rem; }
.m { margin: 0; }
.m img, .m video { max-width: 100%; height: auto; border-radius: 4px; background: #000; display: block; }
.m img { background: transparent; }
.m audio { width: 100%; }
.m figcaption { font-size: .88rem; margin-top: .4rem; }
.m .credit { opacity: .8; }
.m-desc, .m-hint, .m-alt { font-size: .85rem; margin: .3rem 0; opacity: .9; }
model-viewer { width: 100%; height: min(70vh, 480px); background: radial-gradient(circle at 50% 40%, #fff, #d7e2ea); border-radius: 6px; --poster-color: transparent; }
.mv-poster { display: grid; place-items: center; height: 100%; color: #345; }
.fallback { background: rgba(0, 0, 0, .05); padding: .8rem; border-radius: 4px; }
.dl { font-size: .9rem; }
.transcript summary { cursor: pointer; }

/* forms */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1.1rem 1.2rem; margin: 1rem 0; }
.ext-zone .card { color: var(--text); }
.field { margin: 0 0 1rem; display: flex; flex-direction: column; gap: .25rem; }
.field label { font-weight: 600; }
.req { color: #b3261e; }
.hint { color: var(--muted); font-size: .86rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=datetime-local], select, textarea {
  font: inherit; padding: .5rem .6rem; border: 1px solid #a59c8b; border-radius: 5px; background: var(--bg); color: var(--text); width: 100%; max-width: 100%;
}
textarea { resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 1.2rem; padding: .8rem 1rem; }
legend { font-weight: 700; padding: 0 .3rem; }
.check { display: flex; gap: .55rem; align-items: flex-start; margin: .45rem 0; }
.check input { margin-top: .3rem; width: 1.1rem; height: 1.1rem; flex: none; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: flex-end; margin: 1rem 0; }
.filters .field { margin: 0; min-width: 160px; }
.flash { padding: .7rem 1rem; border-radius: 6px; margin: 1rem 0; }
.flash.ok { background: #e2f1e5; color: #173d20; border: 1px solid #9fcca8; }
.flash.err { background: #fbe4e2; color: #5c1310; border: 1px solid #e3a19b; }
.flash.warn { background: #fff4d6; color: #4a3600; border: 1px solid #e6c56c; }
.note { background: rgba(122, 75, 22, .08); padding: .6rem .8rem; border-radius: 6px; }
.hp { position: absolute; left: -5000px; }
.tbl { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tbl th, .tbl td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.badge { display: inline-block; font: 600 .74rem/1.6 var(--sans); padding: 0 .45rem; border-radius: 999px; background: #e6e1d6; color: #333; }
.st-published { background: #d8efdc; color: #14522a; }
.st-submitted, .st-under_review { background: #dbe8fb; color: #163e74; }
.st-changes_requested { background: #fff0c9; color: #5b4300; }
.st-approved, .st-scheduled { background: #e2dcfb; color: #35206e; }
.st-rejected { background: #fbdcdc; color: #6e1414; }
.media-item { border-top: 1px solid var(--line); padding: 1rem 0; }
.draft-banner { background: #fff4d6; border: 1px solid #e6c56c; padding: .7rem 1rem; border-radius: 6px; color: #4a3600; }
.legal h2 { font-size: 1.15rem; }

.site-foot { border-top: 1px solid var(--line); margin-top: 3rem; padding: 1.5rem 0 2.5rem; color: var(--muted); font-size: .88rem; }
.site-foot a { color: var(--muted); }
.draft-note { color: #9a6a00; }
@media print { .site-head, .site-foot, .reader-tools, .chap-nav, .banner, .related-ext { display: none; } body { background: #fff; } }
