:root {
  --bg: #f6f6ef; --fg: #1b1b1b; --muted: #6f6f6f; --line: #e2e2d8; --card: #fff;
  --accent: #ff6600; --link: #1a4fb3; --fs: 18px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151515; --fg: #e8e6e3; --muted: #9a9a9a; --line: #2c2c2c; --card: #1d1d1d; --link: #8ab4ff; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 system-ui, -apple-system, sans-serif; }
a { color: var(--link); }
.muted { color: var(--muted); }
.pad { padding: 16px; }

#bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; background: var(--accent); color: #fff;
}
#bar a, #bar button { color: #fff; text-decoration: none; }
#bar .t { font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#bar button { background: rgba(255,255,255,.18); border: 0; border-radius: 6px; padding: 4px 9px; font: inherit; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #9f9; flex: none; }
.dot.off { background: #222; }

main { max-width: 760px; margin: 0 auto; padding-bottom: calc(env(safe-area-inset-bottom) + 40px); }

/* download panel */
details.dl { margin: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
details.dl > summary { padding: 12px 14px; font-weight: 600; cursor: pointer; }
.dlbody { padding: 0 14px 14px; display: grid; gap: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
select, button.btn {
  font: inherit; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--fg);
}
button.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
button.btn:disabled { opacity: .5; }
progress { width: 100%; height: 10px; }
.log { font-size: 12px; max-height: 140px; overflow: auto; white-space: pre-wrap; }

/* list */
ol.list { list-style: none; margin: 0; padding: 0 4px; }
.story { display: flex; gap: 8px; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.story .rank { color: var(--muted); min-width: 1.8em; text-align: right; }
.story .title { color: var(--fg); text-decoration: none; font-weight: 500; font-size: 16px; }
.story.read .title { color: var(--muted); font-weight: 400; }
.story .dom { color: var(--muted); font-size: 12px; }
.story .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.story .sub a { color: var(--muted); }
.badge { font-size: 11px; padding: 0 5px; border-radius: 4px; border: 1px solid var(--line); }
.badge.ok { color: #2a8a2a; border-color: #2a8a2a55; }
.badge.err { color: #b44; border-color: #b4444455; }

/* article */
.ahead { padding: 16px 16px 4px; }
.ahead h1 { font-size: 1.45em; line-height: 1.25; margin: 0 0 6px; }
.ahead .meta { color: var(--muted); font-size: 13px; }
.prose { padding: 0 16px; font: var(--fs)/1.65 Charter, 'Iowan Old Style', Georgia, serif; overflow-wrap: anywhere; }
.prose img, .prose video, .prose svg { max-width: 100%; height: auto; }
.prose pre { overflow-x: auto; font-size: .8em; background: var(--card); padding: 10px; border-radius: 6px; }
.prose code { font-size: .88em; }
.prose table { display: block; overflow-x: auto; border-collapse: collapse; font-size: .85em; }
.prose td, .prose th { border: 1px solid var(--line); padding: 4px 6px; }
.prose blockquote { margin-left: 0; padding-left: 14px; border-left: 3px solid var(--line); color: var(--muted); }
.prose figure { margin: 1em 0; }
iframe.pdf { width: 100%; height: 75vh; border: 1px solid var(--line); background: #fff; }
.tocomments { display: block; margin: 24px 16px; padding: 14px; text-align: center; border-radius: 10px;
  background: var(--accent); color: #fff; font-weight: 600; text-decoration: none; }

/* comments */
.ctext { padding: 0 16px; }
.comments { padding: 0 10px 0 6px; }
details.c { margin: 6px 0 0 8px; padding-left: 8px; border-left: 2px solid var(--line); }
details.c > summary { list-style: none; cursor: pointer; font-size: 12.5px; color: var(--muted); padding: 4px 0; }
details.c > summary::-webkit-details-marker { display: none; }
details.c > summary b { color: var(--fg); font-weight: 600; }
details.c:not([open]) > summary::after { content: ' [+]'; }
details.c.d0 { border-color: #ff660088; } details.c.d1 { border-color: #3b82f688; } details.c.d2 { border-color: #22c55e88; }
details.c.d3 { border-color: #a855f788; } details.c.d4 { border-color: #eab30888; } details.c.d5 { border-color: #ec489988; }
.ct { font-size: calc(var(--fs) * .86); overflow-wrap: anywhere; }
.ct p { margin: .5em 0; }
.ct pre { overflow-x: auto; font-size: .85em; white-space: pre-wrap; }
.op { color: var(--accent) !important; }
