/* curldb viewer */
  :root {
    --paper: #FFFFFF;
    --ink: #1B1D22;
    --muted: #6B6E76;
    --rule: #D9DAD6;
    --ok: #1F7A4D;
    --warn: #A65A1E;
    --code-bg: #F3F4F1;
    --key: #5B4A9E;
    --str: #1F7A4D;
    --num: #A65A1E;
    --add-bg: #E4F3E9;
    --del-bg: #F8E4E0;
    --unread: #2E6FD8;
    --serif: "Newsreader", "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", Georgia, "Times New Roman", serif;
    --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --paper: #14161A; --ink: #E8E6E1; --muted: #9A9DA5; --rule: #2A2D33;
      --ok: #62C08F; --warn: #E0955A; --code-bg: #1C1F24;
      --key: #B3A5EE; --str: #62C08F; --num: #E0955A; --add-bg: #1B2E22; --del-bg: #33201C; --unread: #6EA8FF;
    }
  }
  :root[data-theme="dark"] {
    --paper: #14161A; --ink: #E8E6E1; --muted: #9A9DA5; --rule: #2A2D33;
    --ok: #62C08F; --warn: #E0955A; --code-bg: #1C1F24;
    --key: #B3A5EE; --str: #62C08F; --num: #E0955A; --add-bg: #1B2E22; --del-bg: #33201C; --unread: #6EA8FF;
  }
  * { box-sizing: border-box; }
  html, body { height: 100%; }
  body {
    margin: 0; background: var(--paper); color: var(--ink);
    font-family: var(--serif); font-size: 1rem; line-height: 1.5;
    display: flex; flex-direction: column;
  }
  a { color: inherit; }
  :focus-visible { outline: 2px solid var(--ok); outline-offset: 2px; }
  button.plain {
    font: inherit; font-family: var(--mono); font-size: 0.8rem; background: none; border: 1px solid var(--rule);
    color: var(--muted); cursor: pointer; padding: 0.1rem 0.5rem; border-radius: 3px;
  }
  button.plain:hover { color: var(--ink); border-color: var(--ink); }
  button.plain.on { color: var(--paper); background: var(--ink); border-color: var(--ink); }

  header {
    display: flex; align-items: baseline; gap: 1.25rem; flex-wrap: wrap;
    padding: 0.8rem 1.5rem; border-bottom: 1px solid var(--rule);
  }
  header .brand { font-family: var(--mono); font-size: 0.95rem; }
  header .file { color: var(--muted); font-size: 0.95rem; flex: 1; min-width: 12rem; }
  header .file b { color: var(--ink); font-weight: 500; }
  header label.pick {
    font-size: 0.9rem; text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer;
  }
  header input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
  header button.pick { font: inherit; font-family: var(--serif); background: none; border: 0; padding: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer; }
  header .mode { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
  header .mode.live { color: var(--ok); }
  header .mode.live::before { content: "CF "; }
  header .panes { display: none; gap: 0.35rem; }
  header .panes.on { display: flex; }

  .drop {
    flex: 1; display: flex; align-items: center; justify-content: center;
    padding: 3rem 1.5rem; text-align: center;
  }
  .drop.over { background: var(--code-bg); }
  .drop .inner { max-width: 34rem; }
  .drop h1 { font-weight: 500; font-style: italic; font-size: 2rem; margin: 0 0 0.75rem; }
  .drop p { margin: 0 0 0.5rem; color: var(--muted); }
  .drop code { font-family: var(--mono); font-size: 0.9em; background: var(--code-bg); padding: 0.08em 0.35em; }
  .drop button.pick { font: inherit; background: none; border: 0; padding: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer; }

  /* Three panes, mail-client style: tags | list | reading pane. Each side
     collapses; the reading pane can also take the whole width. */
  .app { flex: 1; display: none; min-height: 0; }
  .app.on { display: grid; grid-template-columns: var(--side, 17rem) 6px minmax(0, 1fr); }
  /* A hidden pane leaves the grid, so the template shrinks to the panes
     that remain; otherwise the next item would land in the empty column. */
  .app.on.no-side { grid-template-columns: minmax(0, 1fr); }
  .app.no-side aside, .app.no-side #gutter { display: none; }
  .gutter { cursor: col-resize; background: transparent; }
  .gutter:hover, .gutter.drag { background: var(--rule); }
  @media (max-width: 52rem) { .app.on { grid-template-columns: 1fr; } aside { max-height: 14rem; } .gutter { display: none; } }

  aside {
    border-right: 1px solid var(--rule); overflow: auto; padding: 1rem 1.25rem; min-width: 0;
    font-size: 0.9rem; scrollbar-width: none;
  }
  aside h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 0.6rem; font-weight: 500; display: flex; align-items: baseline; gap: 0.5rem; }
  aside h2 .fold { margin-left: auto; font-family: var(--mono); font-size: 0.75rem; text-transform: none; letter-spacing: 0; cursor: pointer; background: none; border: 0; color: var(--muted); padding: 0; }
  aside h2 .fold:hover { color: var(--ink); }
  aside .tag { margin: 0 0 0.75rem; }
  aside .tag .name { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }
  aside button.t {
    font: inherit; font-family: var(--serif); background: none; border: 0; padding: 0 0.15rem;
    color: var(--ink); cursor: pointer; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 0.2em;
  }
  aside button.t:hover { text-decoration-color: var(--ink); }
  aside button.t.active { background: var(--ink); color: var(--paper); text-decoration: none; padding: 0 0.3rem; }
  aside .n { color: var(--muted); font-variant-numeric: tabular-nums; }
  aside .kinds { margin-bottom: 1.25rem; }

  main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
  .query { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--rule); }
  .query [hidden] { display: none !important; }
  .query-bar, .query-editor { display: flex; gap: 0.5rem; align-items: center; min-width: 0; }
  .query-editor { margin-top: 0.6rem; }
  .query-bar .count { margin-left: auto; white-space: nowrap; }
  .query button, header button.plain, header button.pick, header label.pick {
    border: 1px solid var(--rule); border-radius: 6px; background: var(--code-bg); color: var(--ink);
    font: inherit; font-family: var(--mono); font-size: 0.78rem; line-height: 1.4;
    padding: 0.35rem 0.6rem; text-decoration: none; cursor: pointer;
  }
  .query button:hover, header button.plain:hover, header button.pick:hover, header label.pick:hover { border-color: var(--muted); }
  .query button[aria-expanded="true"], header button.plain.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
  .query .filter-summary { min-width: 0; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-color: var(--ok); }
  .filter-summary code { font: inherit; }
  .query .help-toggle { flex: 0 0 auto; min-width: 2rem; }
  .query #toggle-search, .query #close-search, .query #clear-query { flex-shrink: 0; }
  kbd { font: inherit; font-size: 0.8em; opacity: 0.65; }
  .query-help { margin-top: 0.6rem; padding: 0.6rem 0.8rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--code-bg); font-size: 0.83rem; color: var(--muted); }
  .query-help p { margin: 0.3rem 0; }
  .query-help code { font-family: var(--mono); overflow-wrap: anywhere; }
  .query-help b { color: var(--ink); font-weight: 500; margin-right: 0.5rem; }
  .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .query input {
    flex: 1; min-width: 0; width: 100%; font: inherit; font-family: var(--mono); font-size: 0.9rem;
    background: var(--code-bg); color: var(--ink); border: 1px solid var(--rule); padding: 0.5rem 0.7rem;
  }
  .query .count { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }

  .split { flex: 1; display: grid; grid-template-columns: minmax(26rem, var(--listw, 46%)) 6px minmax(0, 1fr); min-height: 0; }
  .split.no-detail { grid-template-columns: minmax(0, 1fr); }
  .split.no-detail .detail, .split.no-detail #gutter2 { display: none; }
  .split.focus { grid-template-columns: minmax(0, 1fr); }
  .split.focus .list, .split.focus #gutter2 { display: none; }
  @media (max-width: 64rem) { .split { grid-template-columns: 1fr; } .list { max-height: 40vh; } #gutter2 { display: none; } .split.no-detail, .split.focus { grid-template-columns: 1fr; } }
  .list { --list-head-height: 2.25rem; overflow: auto; border-right: 1px solid var(--rule); scrollbar-width: none; min-width: 0; }
  .list-head, .row { display: grid; grid-template-columns: 2.4rem 2.25rem 5.25rem 4.5rem 3.5rem minmax(0, 1fr); column-gap: 0.5rem; }
  .list-head { position: sticky; top: 0; z-index: 3; height: var(--list-head-height); align-items: center; padding: 0 0.75rem; background: var(--code-bg); border-bottom: 1px solid var(--rule); font-family: var(--mono); font-size: 0.7rem; color: var(--muted); }
  .day { padding: 0.35rem 1.5rem 0.2rem; font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); border-bottom: 1px solid var(--rule); background: var(--paper); position: sticky; top: var(--list-head-height); z-index: 2; }
  .row {
    row-gap: 0.25rem; align-items: baseline;
    padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--rule); cursor: pointer;
    font-size: 0.88rem;
  }
  .row:hover { background: var(--code-bg); }
  .row.sel { background: var(--code-bg); box-shadow: inset 3px 0 0 var(--ok); }
  /* Unread, the way a mail client shows it: a bar on the left and the
     preview line in the accent colour, so it reads at a glance. */
  .row.unread { box-shadow: inset 3px 0 0 var(--unread); }
  .row.unread .preview { font-weight: 600; color: var(--unread); }
  .row.unread .id { color: var(--unread); }
  .row.sel { box-shadow: inset 3px 0 0 var(--ok); }
  /* The flag column, Outlook style: hollow until set, solid when set.
     Glyphs are CSS escapes so the file stays ASCII. */
  .row .mark { font: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; color: var(--muted); line-height: 1; align-self: center; opacity: 0; }
  .row:hover .mark, .row.flagged .mark, .row .mark:focus-visible { opacity: 1; }
  .row .marks { display: flex; gap: 0.25rem; align-self: center; }
  .row .mark.flag::before { content: "\2690"; font-size: 0.95rem; }
  .row .mark.archive::before { content: "\25A1"; font-size: 0.85rem; }
  .row.archived .mark.archive { color: var(--ink); opacity: 1; }
  .row.archived .mark.archive::before { content: "\25A0"; }
  aside .folders button.t.folder { padding: 0 0.3rem; }
  .row .mark:hover { color: var(--warn); }
  .row .mark:disabled { cursor: default; }
  .row.flagged .mark.flag { color: var(--warn); }
  .row.flagged .mark.flag::before { content: "\2691"; }
  .row.archived .id, .row.archived .preview { color: var(--muted); }
  .row .chip { font-family: var(--mono); font-size: 0.7rem; padding: 0.05rem 0.35rem; border: 1px solid var(--rule); border-radius: 4px; color: var(--muted); vertical-align: middle; }
  .detail .meta.mail { background: var(--code-bg); }
  .row .id { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
  .row .kind, .row .method, .row .status, .row .resource { font-family: var(--mono); font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .row .kind { justify-self: start; padding: 0.05rem 0.3rem; border: 1px solid var(--rule); border-radius: 4px; background: var(--code-bg); }
  .row .kind-request { color: var(--key); }
  .row .kind-response { color: var(--ink); border-color: var(--muted); }
  .row .kind-note, .row .kind-raw { color: var(--muted); }
  .row .status { font-weight: 600; }
  .row .status.ok { color: var(--ok); }
  .row .status.err { color: var(--warn); }
  .row .preview { grid-column: 3 / -1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .row .ts { grid-column: 3 / -1; color: var(--muted); font-size: 0.78rem; font-family: var(--mono); }
  .empty { padding: 2rem 1.5rem; color: var(--muted); }

  .detail { overflow: auto; scrollbar-width: none; min-width: 0; }
  .detail pre {
    margin: 0; padding: 1.25rem 1.5rem; font-family: var(--mono); font-size: 0.85rem; line-height: 1.55;
    white-space: pre-wrap; overflow-wrap: anywhere;
  }
  .detail pre code.hljs { display: inline; padding: 0; background: transparent; font: inherit; white-space: inherit; }
  .detail .md pre code.hljs { background: transparent; }
  .detail pre .start { color: var(--ok); }
  .detail pre .start.err { color: var(--warn); }
  .detail pre .hn { color: var(--muted); }
  .detail pre.stamp { padding-bottom: 0.5rem; border-bottom: 1px dashed var(--rule); color: var(--muted); font-size: 0.8rem; }
  .detail .meta { padding: 0.6rem 1.5rem; border-bottom: 1px solid var(--rule); color: var(--muted); font-size: 0.82rem; font-family: var(--mono); display: flex; gap: 1rem; flex-wrap: wrap; align-items: baseline; }
  .detail .meta.actions { gap: 0.5rem 1rem; }
  .detail .meta .id { color: var(--ink); }
  .detail .meta button, .detail .meta a, .pairhead button {
    font: inherit; font-size: 0.78rem; line-height: 1.4; background: var(--code-bg); border: 1px solid var(--rule);
    border-radius: 5px; color: var(--ink); text-decoration: none; cursor: pointer; padding: 0.28rem 0.5rem;
  }
  .detail .meta button:hover, .detail .meta a:hover, .pairhead button:hover { border-color: var(--muted); }
  .detail .meta button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
  .detail .meta #close { background: none; color: var(--muted); }
  .detail .meta #full { border-color: var(--ok); }
  .detail .meta button:focus-visible, .query button:focus-visible { outline: 2px solid var(--ok); outline-offset: 2px; }
  .related { margin: 0.6rem 1rem; border: 1px solid var(--rule); border-radius: 6px; }
  .related > summary { padding: 0.6rem 0.75rem; cursor: pointer; background: var(--code-bg); font-family: var(--mono); font-size: 0.8rem; border-radius: 6px; }
  .related[open] > summary { border-bottom: 1px solid var(--rule); border-radius: 6px 6px 0 0; }
  .badge { display: inline-block; min-width: 1.4em; text-align: center; margin-left: 0.4em; padding: 0.05em 0.35em; border: 1px solid var(--rule); border-radius: 4px; color: var(--ink); }
  .summary-hint { color: var(--muted); font-size: 0.75rem; margin-left: 0.6rem; }
  #related-body { padding: 0.5rem; }
  .related .thread { gap: 0.6rem; }
  @media (max-width: 38rem) {
    .list-head, .row { grid-template-columns: 2.4rem 2rem 5.25rem 4.5rem minmax(3rem, 1fr); }
    .resource-heading { display: none; }
    .row .resource { grid-column: 3 / -1; }
    .query-bar { flex-wrap: wrap; }
    .query .filter-summary { max-width: calc(100% - 8rem); }
    .related .summary-hint { display: none; }
    .detail .meta .right { margin-left: 0; flex-wrap: wrap; }
  }
  .detail .meta button:disabled { opacity: 0.4; cursor: default; text-decoration: none; }
  .detail .meta .right { margin-left: auto; display: flex; gap: 1rem; }
  .err-box { padding: 1rem 1.5rem; color: var(--warn); font-family: var(--mono); font-size: 0.85rem; }
  .detail .media { padding: 0.5rem 1.5rem 1.5rem; }
  .detail .media img, .detail .media video { max-width: 100%; height: auto; display: block; }
  .detail .media audio { width: 100%; }
  .detail .media iframe { width: 100%; height: 60vh; border: 1px solid var(--rule); background: #fff; }
  .detail .media embed { width: 100%; height: 70vh; border: 1px solid var(--rule); }
  .detail .media .note { color: var(--muted); font-family: var(--mono); font-size: 0.85rem; }
  .detail .media details { margin-top: 0.75rem; }
  .detail .media summary { cursor: pointer; color: var(--muted); font-family: var(--mono); font-size: 0.8rem; }
  .detail .media details pre { padding: 0.5rem 0 0; }
  .detail .media pre { padding: 0; }
  .detail .nested { margin: 0.5rem 0 0; border-left: 3px solid var(--rule); padding-left: 1rem; }
  .detail .nested .media { padding: 0.5rem 0 0; }
  .detail .part { margin: 0.75rem 0; border: 1px solid var(--rule); padding: 0.75rem 1rem; }
  .detail .part .ph { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); margin-bottom: 0.4rem; }
  .detail table { border-collapse: collapse; font-size: 0.85rem; max-width: 100%; }
  .detail th, .detail td { border: 1px solid var(--rule); padding: 0.2rem 0.6rem; text-align: left; vertical-align: top; font-family: var(--mono); }
  .detail th { color: var(--muted); font-weight: 500; }
  .detail .tablewrap { overflow: auto; }
  .detail .j-k { color: var(--key); }
  .detail .j-s { color: var(--str); }
  .detail .j-n { color: var(--num); }
  .detail .d-add { background: var(--add-bg); display: block; }
  .detail .d-del { background: var(--del-bg); display: block; }
  .detail .d-hunk { color: var(--key); display: block; }
  .detail .d-meta { color: var(--muted); display: block; }
  .detail .hex { color: var(--muted); }
  .detail .hex b { color: var(--ink); font-weight: 400; }
  .detail .md { max-width: 46rem; }
  .detail .md h1, .detail .md h2, .detail .md h3, .detail .md h4 { font-weight: 500; line-height: 1.25; margin: 1.2em 0 0.4em; }
  .detail .md h1 { font-size: 1.6rem; } .detail .md h2 { font-size: 1.3rem; } .detail .md h3 { font-size: 1.1rem; } .detail .md h4 { font-size: 1rem; }
  .detail .md p { margin: 0 0 0.8em; }
  .detail .md pre { background: var(--code-bg); padding: 0.75rem 1rem; overflow: auto; font-size: 0.82rem; margin: 0 0 0.9em; }
  .detail .md code { font-family: var(--mono); font-size: 0.88em; background: var(--code-bg); padding: 0.05em 0.3em; }
  .detail .md pre code { background: none; padding: 0; }
  .detail .md blockquote { margin: 0 0 0.8em; padding-left: 1rem; border-left: 3px solid var(--rule); color: var(--muted); }
  .detail .md ul, .detail .md ol { margin: 0 0 0.8em; padding-left: 1.5rem; }
  .detail .md hr { border: 0; border-top: 1px solid var(--rule); margin: 1.2em 0; }
  .detail .md a { text-decoration: underline; text-underline-offset: 0.2em; }
  .detail .md .img { color: var(--muted); font-family: var(--mono); font-size: 0.85em; }
  .detail .md table { margin: 0 0 0.9em; }
  .detail .md th, .detail .md td { font-family: inherit; }
  aside::-webkit-scrollbar, .list::-webkit-scrollbar, .detail::-webkit-scrollbar { display: none; }

  aside details { margin: 0 0 0.45rem; }
  aside summary {
    cursor: pointer; list-style: none; font-family: var(--mono); font-size: 0.8rem; color: var(--muted);
    padding: 0.1rem 0; user-select: none;
  }
  aside summary::-webkit-details-marker { display: none; }
  aside summary::marker { content: ""; }
  aside summary .sum { display: flex; gap: 0.4rem; align-items: baseline; }
  aside summary .sum::before { content: "+"; width: 0.8em; display: inline-block; color: var(--muted); }
  aside details[open] summary .sum::before { content: "-"; }
  aside summary:hover { color: var(--ink); }
  aside summary .n { margin-left: auto; }
  aside details .vals { padding: 0.15rem 0 0.2rem 1.2em; }
  aside details .vals button { display: inline; }
  aside .more { color: var(--muted); font-size: 0.8rem; }
  .row .took, .detail .took { color: var(--muted); font-size: 0.75rem; }
  .row .re { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
  .detail .meta.thread button { color: var(--ink); }
  .detail .pair { border-top: 3px double var(--rule); margin-top: 1rem; }
  .detail .pairhead { padding: 0.5rem 1.5rem; font-family: var(--mono); font-size: 0.8rem; color: var(--muted); background: var(--code-bg); }
  .detail .pairhead button { font: inherit; background: var(--paper); border: 1px solid var(--rule); border-radius: 5px; color: var(--ink); text-decoration: none; cursor: pointer; padding: 0.25rem 0.5rem; }

