:root {
  --fg: #1d1c1a; --muted: #6b6760; --bg: #fbfaf7; --rule: #e4e0d8; --code-bg: #f1eee8;
  --link: #2a5db0;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e8e6e1; --muted: #9a958c; --bg: #151514; --rule: #2c2b28; --code-bg: #1e1e1c;
    --link: #8ab4f8;
  }
}
body { margin: 0; background: var(--bg); color: var(--fg);
  font: 18px/1.65 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; }
main { max-width: 36rem; margin: 4rem auto 3rem; padding: 0 16px; }
header { display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
h1 { font-size: 1.6rem; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
nav a { margin-left: 1rem; color: var(--muted); text-decoration: none; }
nav a:first-child { margin-left: 0; }
nav a[aria-current] { color: var(--fg); }
a { color: var(--link); text-underline-offset: 0.15em; }
ul { padding-left: 1.2rem; }
li { margin-bottom: 0.5rem; }
.small { font-size: 0.85em; color: var(--muted); }
footer { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.live { font: 0.8rem/1.4 ui-monospace, "SF Mono", Menlo, monospace; color: var(--muted); }
h2 { font-size: 1.05rem; font-weight: 600; margin: 2.2rem 0 0.6rem; }
dl.stats { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 1.2rem; margin: 0; }
dl.stats dt { color: var(--muted); }
dl.stats dd { margin: 0; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.9em; }
ul.plain { list-style: none; padding: 0; }
ul.plain li { margin-bottom: 0.25rem; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.85em; overflow-wrap: anywhere; }
.live a { color: inherit; }

/* docs (built by site/build-docs) */
main.doc { max-width: 44rem; }
.crumbs { margin: 0; color: var(--muted); font-size: 0.9rem; }
.crumbs a { color: var(--muted); }
main.doc h1 { font-size: 1.8rem; margin: 1.5rem 0 1rem; }
main.doc h2 { font-size: 1.3rem; margin-top: 2.4rem; }
main.doc h3 { font-size: 1.08rem; margin-top: 1.8rem; }
pre { background: var(--code-bg); border: 1px solid var(--rule); border-radius: 6px;
  padding: 0.8rem 1rem; overflow-x: auto; font-size: 0.82rem; line-height: 1.5; }
pre code { font-size: inherit; overflow-wrap: normal; }
:not(pre) > code { background: var(--code-bg); padding: 0.05em 0.3em; border-radius: 4px; }
table { border-collapse: collapse; display: block; overflow-x: auto; font-size: 0.88rem; margin: 1rem 0; }
th, td { border: 1px solid var(--rule); padding: 0.35rem 0.6rem; text-align: left; vertical-align: top; }
th { background: var(--code-bg); }
blockquote { margin: 1rem 0; padding: 0 1rem; border-left: 3px solid var(--rule); color: var(--muted); }
details.toc { border: 1px solid var(--rule); border-radius: 6px; padding: 0.5rem 1rem; margin: 1rem 0 2rem; font-size: 0.92rem; }
details.toc summary { cursor: pointer; color: var(--muted); }
details.toc ul { padding-left: 1.1rem; }
details.toc li { margin-bottom: 0.15rem; }
img { max-width: 100%; }

/* private pages (site/private.wisp): login and log out */
form.login { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 1.5rem 0; }
form.login label { width: 100%; color: var(--muted); font-size: 0.92rem; }
input[type=password] { font: inherit; padding: 0.45rem 0.6rem; border: 1px solid var(--rule); border-radius: 6px;
  background: var(--code-bg); color: var(--fg); flex: 1 1 14rem; min-width: 0; }
button { font: inherit; padding: 0.45rem 0.9rem; border: 1px solid var(--rule); border-radius: 6px;
  background: var(--bg); color: var(--fg); cursor: pointer; }
button:hover { border-color: var(--muted); }

/* /today */
.today section { margin-bottom: 1.75rem; }
.today h2 { margin-bottom: 0.4rem; }
.today h3 { font-size: 0.95rem; margin: 0.3rem 0; color: var(--muted); font-weight: 600; }
.today .cols { display: flex; flex-wrap: wrap; gap: 0.5rem 2.5rem; }
.today ul.trains, .today ul.hours { list-style: none; padding: 0; margin: 0; }
.today ul.trains li { margin: 0.25rem 0; font-variant-numeric: tabular-nums; }
.today ul.hours { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; font-variant-numeric: tabular-nums; }
.bullet { display: inline-block; width: 1.5em; height: 1.5em; line-height: 1.5em; border-radius: 50%;
  text-align: center; font-weight: 700; font-size: 0.85rem; color: #fff; background: #808183; }
.bullet.r1, .bullet.r2, .bullet.r3 { background: #ee352e; }
.bullet.r4, .bullet.r5, .bullet.r6 { background: #00933c; }
.bullet.rA, .bullet.rC, .bullet.rE { background: #0039a6; }
.bullet.rN, .bullet.rQ, .bullet.rR, .bullet.rW { background: #fccc0a; color: #000; }
table.bikes { border-collapse: collapse; font-variant-numeric: tabular-nums; width: 100%; max-width: 32rem; }
table.bikes th { font-weight: 600; color: var(--muted); font-size: 0.85rem; text-align: right; }
table.bikes td { padding: 0.2rem 0; text-align: right; }
table.bikes td:first-child, table.bikes th:first-child { text-align: left; }
table.sky { border-collapse: collapse; font-variant-numeric: tabular-nums; margin-bottom: 0.5rem; }
table.sky th { font-weight: 600; color: var(--muted); font-size: 0.85rem; text-align: left; }
table.sky td { padding: 0.15rem 1rem 0.15rem 0; vertical-align: top; }
ul.events li { margin-bottom: 0.35rem; }
details { margin-top: 1rem; }
details summary { cursor: pointer; font-weight: 600; }
details h4 { margin: 1rem 0 0.3rem; }
details dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 1rem; margin: 0; }
details dt { font-weight: 600; }
details dd { margin: 0; }
@media (max-width: 30rem) { details dl { grid-template-columns: 1fr; } details dd { margin-bottom: 0.4rem; } }
.today-nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.92rem; margin-bottom: 1.25rem; }
.part-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.part-head button { font-size: 0.85rem; padding: 0.3rem 0.75rem; }
button:disabled { color: var(--muted); cursor: default; }
ul.hub { list-style: none; padding: 0; }
ul.hub li { margin: 0.6rem 0; font-size: 1.1rem; }
pre.event-body { white-space: pre-wrap; overflow-wrap: anywhere; }
#fq { width: 100%; max-width: 28rem; }
#fl a { font-weight: 600; }
/* chat (/today/chat): branches beside the room */
main:has(.chat-app) { max-width: 70rem; }
.chat-app { display: grid; grid-template-columns: 12rem minmax(0, 1fr); gap: 1.5rem; }
.chat-side h2 { font-size: 0.85rem; color: var(--muted); margin: 0.4rem 0; text-transform: uppercase; letter-spacing: 0.04em; }
ul.branches { list-style: none; padding: 0; margin: 0 0 1rem; }
ul.branches li { margin: 0.15rem 0; display: flex; justify-content: space-between; gap: 0.5rem; }
ul.branches a { color: var(--muted); text-decoration: none; overflow-wrap: anywhere; }
ul.branches a[aria-current] { color: var(--fg); font-weight: 600; }
.badge { background: var(--link); color: var(--bg); border-radius: 999px; padding: 0 0.45em; font-size: 0.78em; font-weight: 600; align-self: center; }
.chat-main h1 { margin: 0.2rem 0 0; font-size: 1.3rem; }
ul.chat { list-style: none; padding: 0; margin: 0.5rem 0; }
.chat-msg { padding: 0.45rem 0.6rem; border-radius: 8px; margin: 0 0 0.35rem; }
.chat-msg:hover { background: var(--code-bg); }
.chat-msg.me .chat-head b { color: var(--link); }
.chat-msg.reply { margin: 0.3rem 0 0.3rem 0.4rem; padding-left: 0.7rem; border-left: 2px solid var(--rule); border-radius: 0; }
.chat-anchor { border-left: 3px solid var(--rule); padding: 0.3rem 0.7rem; margin-bottom: 0.8rem; }
.chat-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 0.15rem; }
details.thread { display: inline-block; margin: 0.25rem 1rem 0 0; vertical-align: top; }
details.thread[open] { display: block; margin-right: 0; }
details.thread summary { cursor: pointer; color: var(--muted); font-size: 0.85em; }
details.thread form, details.chat-newb form { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0 0.6rem; }
details.chat-newb summary { cursor: pointer; color: var(--muted); font-size: 0.9em; }
form.chat-say { display: flex; gap: 0.5rem; align-items: flex-end; position: sticky; bottom: 0;
  background: var(--bg); padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom, 0px)); }
.chat-app textarea, .chat-app input[type=text] { font: inherit; padding: 0.4rem 0.55rem; border: 1px solid var(--rule);
  border-radius: 6px; background: var(--code-bg); color: var(--fg); flex: 1 1 10rem; min-width: 0; }
button.linkish { font: inherit; color: var(--link); background: none; border: 0; padding: 0; cursor: pointer; }
button.linkish:disabled { color: var(--muted); cursor: default; }
.chat-foot { margin-top: 0.2rem; font-size: 0.85em; }
a.chat-replies { font-weight: 600; text-decoration: none; }
a.chat-replies.quiet { font-weight: normal; margin-left: 0.4rem; opacity: 0; }
.chat-msg:hover a.chat-replies.quiet, a.chat-replies.quiet:focus { opacity: 1; }
@media (hover: none) { a.chat-replies.quiet { opacity: 1; } }
.chat-msg.open { background: var(--code-bg); box-shadow: inset 3px 0 var(--link); }
/* a thread opens beside the branch, like Slack */
main:has(.chat-app.has-thread) { max-width: 90rem; }
.chat-app.has-thread { grid-template-columns: 12rem minmax(0, 1fr) minmax(18rem, 26rem); }
.chat-thread { border-left: 1px solid var(--rule); padding-left: 1.2rem; position: sticky; top: env(safe-area-inset-top, 0px);
  align-self: start; max-height: 100vh; display: flex; flex-direction: column; }
.chat-thread #tmsgs { overflow-y: auto; flex: 1 1 auto; }
.thread-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.thread-head h2 { font-size: 1.05rem; margin: 0.3rem 0; }
.chat-thread .chat-msg.reply { margin-left: 0; }
.chat-thread details.thread:not([open]) { opacity: 0; }
.chat-thread .chat-msg:hover details.thread, .chat-thread details.thread:focus-within { opacity: 1; }
@media (hover: none) { .chat-thread details.thread:not([open]) { opacity: 1; } }
main:has(.tree) { max-width: 70rem; }
.tree { display: flex; gap: 0.6rem; overflow-x: auto; }
.tree-g { flex: none; }
.tree-svg { display: block; }
ul.tree-list { list-style: none; padding: 0; margin: 0; min-width: 0; flex: 1; }
.tree-row { display: flex; align-items: center; gap: 0.4rem; white-space: nowrap; overflow: hidden; font-size: 0.9rem;
  margin: 0; padding: 0; line-height: 30px; box-sizing: border-box; }
.tree-row a { color: var(--fg); text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
.tree-row:not(.here) a { color: var(--muted); }
.tree-b { flex: none; font-size: 0.78rem; font-weight: 600; color: hsl(var(--h) 55% 45%); }
@media (max-width: 64rem) {
  /* no room for three columns: the thread takes the branch's place */
  .chat-app.has-thread { grid-template-columns: 12rem minmax(0, 1fr); }
  .chat-app.has-thread .chat-main { display: none; }
  .chat-thread { border-left: 0; padding-left: 0; position: static; max-height: none; }
}
@media (max-width: 44rem) {
  .chat-app, .chat-app.has-thread { grid-template-columns: minmax(0, 1fr); gap: 0.5rem; }
  ul.branches { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; }
  ul.branches li { margin: 0; }
}
