:root {
  color-scheme: dark;
  --bg: #111714;
  --surface: #1a231e;
  --text: #f3f4ec;
  --muted: #b1b9af;
  --line: #354137;
  --accent: #d2e8ad;
  --header: 65px;
  font-family: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, a, summary { font: inherit; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
a, button { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a:focus-visible, button:focus-visible, summary:focus-visible, #story-panel:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.number, .page-links a, .page-label { font-variant-numeric: tabular-nums; }
.number { font-family: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace; }
.skip, .sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip:focus { position: fixed; top: 10px; left: 10px; z-index: 8; width: auto; height: auto; padding: 10px 16px; clip-path: none; background: var(--accent); color: var(--bg); }
.masthead { position: sticky; top: 0; z-index: 4; background: var(--bg); border-bottom: 1px solid var(--line); }
.sitebar, .layout { width: min(100%, 1312px); margin-inline: auto; padding-inline: clamp(20px, 4vw, 64px); }
.sitebar { min-height: var(--header); display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 730; font-size: 1.27rem; letter-spacing: .055em; color: #f3f5ec; }
.brandmark { display: grid; place-items: center; position: relative; width: 30px; height: 26px; color: var(--accent); }
.brandmark::before, .brandmark::after, .brandmark i::before, .brandmark i::after { content: ""; position: absolute; width: 8px; height: 7px; border: 0 solid currentColor; }
.brandmark::before { top: 0; left: 0; border-width: 2px 0 0 2px; }
.brandmark::after { top: 0; right: 0; border-width: 2px 2px 0 0; }
.brandmark i::before { bottom: 0; left: 0; border-width: 0 0 2px 2px; }
.brandmark i::after { bottom: 0; right: 0; border-width: 0 2px 2px 0; }
.brandmark i { display: block; width: 8px; height: 8px; border: 1.5px solid currentColor; border-radius: 50%; }
.totals { display: flex; align-items: center; gap: 16px; margin: 0; color: var(--muted); font-size: .89rem; }
.totals b { font-weight: 600; color: var(--text); }
.totals i { width: 1px; height: 13px; background: var(--line); }
.layout { display: grid; grid-template-columns: clamp(246px, 24vw, 304px) minmax(0, 1fr); gap: clamp(24px, 3vw, 44px); align-items: start; }
.directory { position: sticky; top: calc(var(--header) + 1px); height: calc(100vh - var(--header) - 1px); height: calc(100dvh - var(--header) - 1px); min-height: 0; padding: 28px clamp(16px, 2vw, 29px) 14px 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
#story-directory { position: relative; height: 100%; min-height: 0; }
#directory-body { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; }
.directory-bar { display: flex; align-items: center; gap: 12px; cursor: pointer; list-style: none; }
.directory-bar::-webkit-details-marker { display: none; }
#story-directory[open] > .directory-bar { display: none; }
.directory-label { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 650; }
.directory-label i { display: inline-block; width: 15px; height: 11px; border-block: 1.5px solid; position: relative; }
.directory-label i::after { content: ""; position: absolute; top: 3.5px; left: 0; right: 0; border-top: 1.5px solid; }
#reading-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#reading-position { margin-inline-start: auto; white-space: nowrap; color: var(--muted); font-size: .85rem; }
.nav-title { font-size: .92rem; font-weight: 650; margin: 0; letter-spacing: .04em; }
#filters { display: flex; flex-wrap: wrap; gap: 7px 6px; margin: 12px 0 22px; }
.filter { padding: 6px 11px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); white-space: nowrap; font-size: .87rem; line-height: 1.4; }
.filter:hover { border-color: #758270; color: var(--text); }
.filter[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: #1c2a1b; font-weight: 650; }
.directory-heading { display: flex; justify-content: space-between; align-items: center; padding: 18px 2px 12px 0; border-top: 1px solid var(--line); }
.directory-heading .number { font-size: .82rem; color: var(--muted); }
#story-tabs { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #4f5d4e transparent; padding: 2px 3px 12px 0; }
.story-tab { display: grid; grid-template-columns: 23px 48px minmax(0, 1fr); gap: 10px; align-items: center; flex: none; border: 1px solid transparent; padding: 7px 8px; border-radius: 6px; color: var(--muted); }
.story-tab:hover { background: #1b241e; }
.story-tab[aria-selected="true"] { border-color: #4a5b45; background: #273326; color: var(--text); }
.story-tab .number { font-size: .81rem; color: #929f90; line-height: 1; }
.story-tab[aria-selected="true"] .number { color: var(--accent); }
.story-tab img { display: block; width: 48px; height: 44px; object-fit: cover; border-radius: 3px; }
.tab-text { min-width: 0; }
.tab-text strong, .tab-text small { display: block; white-space: normal; }
.tab-text strong { color: #e3e8dd; font-size: .97rem; line-height: 1.35; font-weight: 570; }
.tab-text small { font-size: .78rem; line-height: 1.55; color: #a6b0a2; }
.story-tab[aria-selected="true"] .tab-text strong { color: #f4f6ef; }
.reader { min-width: 0; padding: 26px 0 44px; }
#story-panel { min-width: 0; }
.story-cover { position: relative; isolation: isolate; overflow: hidden; min-height: 250px; display: flex; align-items: flex-end; border: 1px solid #41483e; border-radius: 10px; background: #24302b; }
.cover-image, .cover-shade { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -2; }
.cover-image { display: block; object-fit: cover; object-position: 58% 46%; }
.cover-shade { z-index: -1; background: linear-gradient(90deg,rgba(6,13,11,.92) 0%,rgba(8,15,12,.65) 39%,rgba(8,15,12,.11) 83%), linear-gradient(0deg,rgba(6,13,10,.51),rgba(6,13,10,.04) 60%); }
.cover-content { padding: clamp(22px, 2.5vw, 34px); width: 100%; }
.cover-meta { display: flex; align-items: center; gap: 11px; font-size: .83rem; font-weight: 600; color: #e0edcd; }
.cover-meta .number { font-weight: 600; }
.cover-meta i { width: 19px; height: 1px; background: #93a68c; }
h1 { font-size: clamp(2.15rem, 3.85vw, 3.55rem); font-weight: 730; line-height: 1.2; margin: 9px 0 10px; letter-spacing: -.025em; text-wrap: balance; color: #fafaf1; }
.cover-content p { max-width: 35em; margin: 0 0 18px; color: #eff0e7; font-size: 1rem; line-height: 1.65; text-shadow: 0 1px 4px #141a14; }
.save-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 40px; min-width: 126px; padding: 8px 15px; vertical-align: middle; border: 1px solid #d9e7c1; border-radius: 5px; background: #e0ebc9; color: #172416; font-weight: 650; font-size: .92rem; line-height: 1.35; }
.save-button:hover { background: #edf5de; }
.save-button:disabled { cursor: progress; opacity: .77; }
.stack-icon { display: inline-block; position: relative; width: 17px; height: 15px; flex: none; }
.stack-icon::before, .stack-icon::after { content: ""; position: absolute; width: 11px; height: 9px; border: 1.5px solid currentColor; border-radius: 2px; }
.stack-icon::before { left: 0; top: 0; }
.stack-icon::after { bottom: 0; right: 0; background: #e0ebc9; }
.save-status { display: inline-block; padding-left: 10px; margin-top: 2px; max-width: 37em; vertical-align: middle; color: #f1f3e9; font-size: .86rem; line-height: 1.5; }
.save-status:empty { display: none; }
.page-toolbar { display: flex; align-items: center; gap: 13px; padding-block: 10px; }
.page-label { flex: none; color: var(--muted); font-size: .89rem; }
.page-links { display: flex; align-items: center; min-width: 0; overflow-x: auto; scrollbar-width: thin; gap: 2px; }
.page-links a { display: grid; place-items: center; min-width: 35px; height: 35px; font-family: ui-monospace, monospace; font-size: .89rem; border-radius: 4px; color: #b8c2b5; }
.page-links a:hover { background: var(--surface); }
.page-links a[aria-current="location"] { background: #2d3c2b; color: var(--accent); font-weight: 650; }
.photo-link, .photo-link picture { display: block; }
.photo-link { cursor: zoom-in; }
.end-actions { margin-top: 20px; }
.original-links { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.original-links a { display: grid; place-items: center; min-height: 44px; padding-inline: 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--text); font-size: .875rem; }
.photo-flow { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
figure { margin: 0; scroll-margin-top: calc(var(--header) + 8px); }
figure img { width: 100%; height: auto; display: block; aspect-ratio: 3/4; background: var(--surface); border-radius: 5px; }
.neighbors { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(178px,100%),1fr)); gap: 12px; padding-top: 18px; }
.neighbor { min-width: 0; border-top: 1px solid var(--line); padding: 14px 1px; }
.neighbor span, .neighbor strong { display: block; }
.neighbor span { color: var(--muted); font-size: .84rem; margin-bottom: 6px; }
.neighbor strong { font-size: 1rem; font-weight: 610; }
.neighbor .number { color: var(--accent); font-size: .86rem; margin-right: 4px; font-weight: 500; }
.neighbor:hover strong { color: var(--accent); }
@media (min-width: 801px) and (max-height: 620px) {
  .directory { padding-top: 12px; }
  #filters { margin-bottom: 8px; }
  .directory-heading { padding: 7px 0; }
}
@media (max-width: 800px), (max-width: 1000px) and (max-height: 500px) and (orientation: landscape) {
  :root { --header: 48px; --side: max(16px, env(safe-area-inset-left)); --right: max(16px, env(safe-area-inset-right)); }
  .masthead { position: relative; padding-top: env(safe-area-inset-top); }
  .sitebar { padding-inline: var(--side) var(--right); }
  .brand { gap: 8px; font-size: 1.03rem; }
  .brandmark { width: 22px; height: 19px; }
  .totals { gap: 7px; font-size: .8rem; }
  .layout { display: block; width: 100%; padding: 0; }
  .directory { top: 0; z-index: 5; height: auto; padding: env(safe-area-inset-top) 0 0; background: var(--bg); border: 0; border-bottom: 1px solid var(--line); }
  #story-directory { height: auto; }
  .directory-bar, #story-directory[open] > .directory-bar { display: flex; min-height: 48px; padding: 4px var(--right) 4px var(--side); gap: 12px; }
  .directory-label { flex: none; font-size: .94rem; }
  #reading-title { color: var(--muted); border-inline-start: 1px solid var(--line); padding-inline-start: 12px; font-size: .9rem; }
  #directory-body { position: absolute; z-index: 1; inset: 100% 0 auto; height: auto; max-height: calc(85vh - 50px); max-height: calc(85dvh - 50px - env(safe-area-inset-top)); padding: 10px var(--right) 8px var(--side); border-block: 1px solid var(--line); background: #18201b; box-shadow: 0 12px 26px #070c09aa; overflow-y: auto; overscroll-behavior: contain; }
  .filter-block h2 { display: none; }
  #filters { gap: 2px 5px; margin: 0; }
  .filter { display: grid; place-items: center; padding: 5px 10px; min-height: 44px; border: 0; font-size: .9rem; }
  .directory-heading { flex: none; padding: 10px 4px 8px; margin-top: 6px; }
  #story-tabs { min-height: 48px; padding: 0 2px 4px; }
  .story-tab { grid-template-columns: 26px 48px minmax(0, 1fr); min-height: 54px; padding: 5px 8px; }
  .reader { margin-inline: auto; max-width: 740px; padding: 10px env(safe-area-inset-right) calc(24px + env(safe-area-inset-bottom)) env(safe-area-inset-left); }
  .story-cover { margin-inline: 10px; min-height: 165px; border-radius: 7px; }
  .cover-content { padding: 17px 16px; }
  .cover-meta { font-size: .82rem; gap: 8px; }
  h1 { font-size: clamp(1.75rem, 6vw, 2.45rem); margin: 6px 0; }
  .cover-content p { margin: 0 0 12px; font-size: 1rem; line-height: 1.5; }
  .save-button { min-height: 44px; padding: 7px 12px; }
  .save-status { display: block; padding: 5px 0 0; }
  .save-status:empty { display: none; }
  .page-toolbar { gap: 8px; padding: 4px 12px; }
  .page-links { scrollbar-width: none; }
  .page-links a { flex: 0 0 44px; height: 44px; }
  .page-label { font-size: .86rem; }
  .photo-flow { gap: 6px; }
  figure { scroll-margin-top: calc(55px + env(safe-area-inset-top)); }
  figure img { border-radius: 0; }
  .end-actions, .neighbors { margin-inline: 16px; }
  .neighbors { gap: 13px; grid-template-columns: repeat(auto-fit,minmax(min(125px,100%),1fr)); }
}
@media (max-width: 359px) {
  .totals { gap: 4px; font-size: .75rem; }
  .sitebar { gap: 6px; }
  .brand { letter-spacing: 0; }
  .directory-bar { gap: 8px; }
}
@media (pointer: coarse) {
  .save-button, .story-tab, .filter { min-height: 44px; }
  .page-links a { min-width: 40px; height: 44px; }
}
@media (prefers-reduced-motion: no-preference) {
  .filter, .story-tab, .page-links a, .save-button { transition: background-color .14s ease, border-color .14s ease, color .14s ease; }
}
