/* Plain HTML edition: layered on top of the EPUB's own style.css. */
:root {
  --bg: #ffffff; --fg: #111111; --muted: #5d6066; --line: #dedbd3; --bar: #f7f5f0; --link: #003366; --th: #e8e8e8;
  color-scheme: light;
}
:root[data-theme="sepia"] { --bg: #f6eedb; --fg: #3b2f22; --muted: #7a6a55; --line: #d9cbb0; --bar: #efe6d2; --link: #7a3d12; --th: #e8dcc2; }
:root[data-theme="dark"] { --bg: #1d2025; --fg: #e3e4e6; --muted: #9a9ea6; --line: #3a3f47; --bar: #16181c; --link: #8fbef0; --th: #2a2e35; color-scheme: dark; }

html { background: var(--bg); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { margin: 0 !important; background: var(--bg); color: var(--fg); }
main { max-width: 40em; margin: 0 auto; padding: 28px 20px 40px; box-sizing: border-box; }
article img { max-width: 100%; height: auto; }
[id] { scroll-margin-top: 72px; }
body.cover-page main { max-width: 32em; text-align: center; }

:root[data-theme="sepia"] article *, :root[data-theme="dark"] article * { color: inherit !important; background-color: transparent !important; border-color: var(--line) !important; }
:root[data-theme="sepia"] article a, :root[data-theme="dark"] article a,
:root[data-theme="sepia"] article a *, :root[data-theme="dark"] article a * { color: var(--link) !important; }
:root[data-theme="sepia"] th, :root[data-theme="dark"] th { background-color: var(--th) !important; }

.doc-bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: var(--bar); border-bottom: 1px solid var(--line);
  font: 14px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
.doc-bar a { color: var(--fg); text-decoration: none; }
.doc-home { font-family: Georgia, serif; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-tools { display: flex; align-items: center; gap: 4px; flex: none; }
.doc-tools a { padding: 8px 9px; border-radius: 8px; color: var(--muted); }
.doc-tools a:hover { background: var(--line); color: var(--fg); }
#doc-theme { width: 38px; height: 38px; border: 0; border-radius: 8px; background: transparent; color: var(--fg); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
#doc-theme svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#doc-theme .sun, :root[data-theme="dark"] #doc-theme .moon { display: none; }
:root[data-theme="dark"] #doc-theme .sun { display: block; }

.doc-nav {
  max-width: 40em; margin: 0 auto; padding: 0 20px 24px; box-sizing: border-box;
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  font: 14px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
.doc-nav a { display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--fg); text-decoration: none; }
.doc-nav a:hover { border-color: var(--muted); }
.doc-nav small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.doc-next { text-align: right; grid-column: 2; }
.doc-foot { max-width: 40em; margin: 0 auto; padding: 16px 20px 40px; box-sizing: border-box; border-top: 1px solid var(--line); color: var(--muted); font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
.doc-foot a { color: var(--muted); }

@media (max-width: 560px) {
  .doc-tools a:nth-child(3) { display: none; }
  p, li { text-align: left !important; }
  .doc-nav { grid-template-columns: 1fr; }
  .doc-next { grid-column: auto; }
}
@media print {
  .doc-bar, .doc-nav, .doc-foot { display: none; }
  main { max-width: none; padding: 0; }
}
