/* Theme: light by default; dark when the system prefers it, unless the page is forced with data-theme. */
:root {
  color-scheme: light;
  --bg: #f6f7f9; --panel: #ffffff; --text: #1d2430; --muted: #5d6877; --line: #dfe3e9;
  --accent: #1b5fb5; --accent-text: #ffffff; --hover: #eef3fa; --danger: #b3261e;
  --ok: #1a7f43; --warn: #b25e00; --mark: #ffe58a; --mark-active: #ff9d3b; --code-bg: #fbfbfc;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #12161c; --panel: #1a2029; --text: #e6e9ee; --muted: #9aa5b4; --line: #2b3441;
    --accent: #5b9bf0; --accent-text: #0c1117; --hover: #212a36; --danger: #f2877f;
    --ok: #5fd08a; --warn: #f0a550; --mark: #6b5a12; --mark-active: #b86a10; --code-bg: #151a21;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12161c; --panel: #1a2029; --text: #e6e9ee; --muted: #9aa5b4; --line: #2b3441;
  --accent: #5b9bf0; --accent-text: #0c1117; --hover: #212a36; --danger: #f2877f;
  --ok: #5fd08a; --warn: #f0a550; --mark: #6b5a12; --mark-active: #b86a10; --code-bg: #151a21;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.banner { background: #fff4c2; color: #4a3b00; text-align: center; font-size: 13px; padding: 4px 8px; }
header.top { display: flex; align-items: center; gap: 16px; padding: 12px 24px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
header.top h1 { font-size: 17px; margin: 0; }
header.top nav { display: flex; gap: 4px; margin-left: 12px; }
header.top nav a { padding: 6px 12px; border-radius: 6px; color: var(--muted); text-decoration: none; }
header.top nav a.on, header.top nav a:hover { background: var(--hover); color: var(--text); }
header.top .right { margin-left: auto; display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 13px; }
.live { display: inline-flex; align-items: center; gap: 6px; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
main { max-width: 1200px; margin: 0 auto; padding: 20px 24px 48px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px; border-bottom: 1px solid var(--line); }
input, select, button { font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=search] { min-width: 240px; flex: 1; }
button { cursor: pointer; }
button:hover { background: var(--hover); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--danger); }
button.small { padding: 3px 9px; font-size: 13px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr.group { cursor: pointer; }
tr.group:hover { background: var(--hover); }
tr.child td { background: var(--code-bg); font-size: 14px; }
tr.child td:first-child { padding-left: 40px; }
.chev { display: inline-block; width: 18px; color: var(--muted); transition: transform .12s; }
tr.group[aria-expanded=true] .chev { transform: rotate(90deg); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.muted { color: var(--muted); }
.warn { color: var(--warn); }
.actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; color: var(--muted); font-size: 13px; }
.new-flash { animation: flash 2s ease-out; }
@keyframes flash { from { background: var(--mark); } to { background: transparent; } }
.hidden { display: none; }
/* login */
.login { max-width: 360px; margin: 12vh auto; padding: 28px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login label { display: block; margin: 16px 0 6px; font-size: 13px; color: var(--muted); }
.login input { width: 100%; }
.login button { width: 100%; margin-top: 20px; padding: 9px; }
.err { color: var(--danger); font-size: 13px; margin-top: 12px; }
/* viewer */
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; padding: 16px; }
.meta dt { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.meta dd { margin: 2px 0 0; }
.titlebar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 0; flex-wrap: wrap; }
.titlebar h2 { margin: 0; font-size: 18px; }
.findbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; flex-wrap: wrap; }
.findbar input[type=search] { width: 280px; flex: none; min-width: 0; }
.findbar input[type=checkbox] { width: auto; min-width: 0; margin-right: 4px; }
a { color: var(--accent); }
#count { color: var(--muted); font-size: 13px; min-width: 70px; }
.log { background: var(--code-bg); max-height: 62vh; overflow: auto; padding: 8px 0; }
.line { display: flex; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.55; }
.line .n { flex: none; width: 56px; padding-right: 12px; text-align: right; color: var(--muted); user-select: none; }
.line .t { white-space: pre-wrap; word-break: break-all; padding-right: 14px; }
mark { background: var(--mark); color: inherit; border-radius: 2px; }
mark.active { background: var(--mark-active); color: #000; }
/* settings */
.section { padding: 18px; border-bottom: 1px solid var(--line); }
.section:last-child { border-bottom: 0; }
.section h2 { font-size: 16px; margin: 0 0 4px; }
.section p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.field { display: flex; align-items: center; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.field label { min-width: 170px; }
.field input.wide { width: min(420px, 100%); }
.callout { background: var(--hover); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--muted); margin-top: 10px; }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--hover); color: var(--muted); vertical-align: middle; }
.seen { font-size: 12px; }
/* chained entries in the viewer */
.chain { padding: 14px; display: grid; gap: 12px; background: var(--bg); }
.entry { border: 1px solid var(--line); border-radius: 8px; background: var(--code-bg); overflow: hidden; }
.entry.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.entry-head { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; border-radius: 0;
  background: var(--panel); border-bottom: 1px solid var(--line); padding: 9px 12px; }
.entry-head:hover { background: var(--hover); }
.entry-head[aria-expanded=true] .chev { transform: rotate(90deg); }
.entry-head .mcount { margin-left: auto; font-size: 13px; }
.viewing { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }
.entry .log { max-height: none; overflow: visible; }
.entry .log[hidden] { display: none; }
.gap { padding: 12px 16px; border: 1px dashed var(--warn); border-radius: 8px; background: var(--panel); color: var(--muted); font-size: 13px; text-align: center; }
.gap .gap-title { display: block; margin-bottom: 3px; color: var(--text); font-size: 14px; }
.gap .ico { color: var(--warn); }
.gapsum { display: flex; align-items: center; gap: 10px; padding: 9px 14px; font-size: 13px; background: var(--hover); border-bottom: 1px solid var(--line); }
.gapsum[hidden] { display: none; }
.latest { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ok); }
.ttl { font-size: 13px; color: var(--muted); }
.theme { min-width: 84px; }
.theme.floating { position: fixed; top: 44px; right: 16px; }
