/*
 * Automatic light/dark theme for cgit.
 *
 * This stylesheet is intended to be loaded after the stock cgit.css.
 */

:root {
  color-scheme: light dark;

  --black: light-dark(#575279, #393b44);
  --red: light-dark(#b4637a, #c94f6d);
  --green: light-dark(#618774, #81b29a);
  --yellow: light-dark(#ea9d34, #dbc074);
  --blue: light-dark(#286983, #719cd6);
  --magenta: light-dark(#907aa9, #9d79d6);
  --cyan: light-dark(#56949f, #63cdcf);
  --white: light-dark(#e5e9f0, #dfdfe0);
  --orange: light-dark(#d7827e, #f4a261);
  --pink: light-dark(#d685af, #d67ad2);

  --dim-black: light-dark(#504c6b, #30323a);
  --dim-red: light-dark(#a5576d, #ab435d);
  --dim-green: light-dark(#597668, #6e9783);
  --dim-yellow: light-dark(#dd9024, #baa363);
  --dim-blue: light-dark(#295e73, #6085b6);
  --dim-magenta: light-dark(#816b9a, #8567b7);
  --dim-cyan: light-dark(#50848c, #54aeb0);
  --dim-white: light-dark(#c8cfde, #bebebe);
  --dim-foreground: light-dark(#4c4769, #aeafb0);

  --bright-black: light-dark(#5f5695, #575860);
  --bright-red: light-dark(#c26d85, #d16983);
  --bright-green: light-dark(#629f81, #8ebaa4);
  --bright-yellow: light-dark(#eea846, #e0c989);
  --bright-blue: light-dark(#2d81a3, #86abdc);
  --bright-magenta: light-dark(#9a80b9, #baa1e2);
  --bright-cyan: light-dark(#5ca7b4, #7ad5d6);
  --bright-white: light-dark(#e6ebf3, #e4e4e5);
  --bright-foreground: light-dark(#625c87, #d6d6d7);

  --foreground: light-dark(#575279, #cdcecf);
  --background: light-dark(#faf4ed, #192330);

  --surface: light-dark(#f2e9e1, #202b38);
  --surface-alt: light-dark(#ebe1d8, #263341);
  --surface-hover: light-dark(#e3d8cf, #303d4b);

  --border: light-dark(#d6cbc2, #3d4a58);
  --border-strong: light-dark(#bfb3aa, #536171);

  --selection: light-dark(#d9e8ee, #344c68);

  --add-background: light-dark(#e5eee8, #1f3932);
  --add-background-strong: light-dark(#d4e6da, #294a40);
  --delete-background: light-dark(#f1e0e4, #432b35);
  --delete-background-strong: light-dark(#ead0d7, #55303c);
  --change-background: light-dark(#f3ead5, #443e2d);
  --change-background-strong: light-dark(#eadcb8, #554b31);
}

html,
body,
div#cgit {
  color: var(--foreground);
  background: var(--background);
}

::selection {
  color: var(--bright-foreground);
  background: var(--selection);
}

div#cgit {
  accent-color: var(--blue);
}

/* Links */

div#cgit a {
  color: var(--blue);
}

div#cgit a:hover {
  color: var(--bright-blue);
}

div#cgit a:focus-visible,
div#cgit input:focus-visible,
div#cgit select:focus-visible {
  outline: 2px solid var(--bright-blue);
  outline-offset: 2px;
}

/* Header */

div#cgit table#header td.main a {
  color: var(--foreground);
}

div#cgit table#header td.main a:hover {
  color: var(--bright-blue);
}

div#cgit table#header td.sub {
  color: var(--dim-foreground);
}

div#cgit table#header td.form input,
div#cgit table#header td.form select,
div#cgit table.tabs td.form input,
div#cgit table.tabs td.form select,
div#cgit td#sidebar input.txt {
  color: var(--foreground);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
}

/* Navigation tabs */

div#cgit table.tabs {
  border-bottom-color: var(--border);
}

div#cgit table.tabs td a {
  color: var(--dim-foreground);
  border-radius: 3px 3px 0 0;
}

div#cgit table.tabs td a:hover {
  color: var(--bright-foreground);
  background: var(--surface);
}

div#cgit table.tabs td a.active {
  color: var(--bright-foreground);
  background: var(--surface-alt);
  border-bottom: 2px solid var(--blue);
}

/* Repository path */

div#cgit div.path {
  color: var(--foreground);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
}

div#cgit div.content {
  border-bottom-color: var(--border-strong);
}

/* Repository lists */

div#cgit table.list tr,
div#cgit table.list tr.logheader {
  background: var(--background);
}

div#cgit table.list tr:nth-child(even) {
  background: var(--background);
}

div#cgit table.list tr:nth-child(odd) {
  background: var(--surface);
}

div#cgit table.list tr:hover {
  background: var(--surface-hover);
}

div#cgit table.list tr.nohover,
div#cgit table.list tr.nohover:hover {
  background: var(--background);
}

div#cgit table.list tr.nohover-highlight:hover:nth-child(even) {
  background: var(--background);
}

div#cgit table.list tr.nohover-highlight:hover:nth-child(odd) {
  background: var(--surface);
}

div#cgit table.list th {
  color: var(--bright-foreground);
  border-bottom-color: var(--border);
}

div#cgit table.list td a {
  color: var(--foreground);
}

div#cgit table.list td a.ls-dir {
  color: var(--blue);
}

div#cgit table.list td a:hover {
  color: var(--bright-blue);
}

div#cgit table.list td.reposection {
  color: var(--dim-foreground);
  background: var(--surface-alt);
}

/* Commit graph */

div#cgit table.list td.commitgraph .column1 {
  color: var(--bright-red);
}

div#cgit table.list td.commitgraph .column2 {
  color: var(--bright-green);
}

div#cgit table.list td.commitgraph .column3 {
  color: var(--bright-yellow);
}

div#cgit table.list td.commitgraph .column4 {
  color: var(--bright-blue);
}

div#cgit table.list td.commitgraph .column5 {
  color: var(--bright-magenta);
}

div#cgit table.list td.commitgraph .column6 {
  color: var(--bright-cyan);
}

/* Buttons and pager */

div#cgit a.button {
  color: var(--foreground);
  background: var(--surface);
  border-color: var(--border);
  border-radius: 3px;
}

div#cgit a.button:hover {
  color: var(--bright-foreground);
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

div#cgit a.primary {
  color: var(--background);
  background: var(--blue);
  border-color: var(--bright-blue);
}

div#cgit a.primary:hover {
  color: var(--background);
  background: var(--bright-blue);
}

div#cgit a.secondary {
  color: var(--foreground);
  background: var(--surface-alt);
}

div#cgit ul.pager a {
  color: var(--dim-foreground);
  background: var(--surface);
  border-radius: 3px;
}

div#cgit ul.pager a:hover {
  color: var(--bright-foreground);
  background: var(--surface-hover);
}

div#cgit ul.pager .current {
  color: var(--background);
  background: var(--blue);
  border-radius: 3px;
}

/* Downloads */

div#cgit table#downloads {
  border-color: var(--border);
}

div#cgit table#downloads th {
  color: var(--bright-foreground);
  background: var(--surface-alt);
}

/* Source and blobs */

div#cgit div#blob,
div#cgit table.blob,
div#cgit table.bin-blob {
  border-color: var(--border-strong);
}

div#cgit table.blob td.hashes,
div#cgit table.blob td.lines {
  color: var(--foreground);
}

div#cgit table.blob td.lines,
div#cgit table.blob pre {
  background: var(--background);
}

div#cgit table.blob td.linenumbers {
  color: var(--dim-foreground);
  background: var(--surface);
  border-right-color: var(--border);
}

div#cgit table.blob td.linenumbers a,
div#cgit table.ssdiff td.lineno a {
  color: var(--dim-foreground);
}

div#cgit table.blob td.linenumbers a:hover,
div#cgit table.ssdiff td.lineno a:hover {
  color: var(--bright-blue);
}

div#cgit table.bin-blob th {
  color: var(--bright-foreground);
  background: var(--surface-alt);
  border-color: var(--border);
}

div#cgit table.bin-blob td {
  border-left-color: var(--border);
}

/* Blame */

div#cgit table.blame div.alt:nth-child(even) {
  background: var(--background);
}

div#cgit table.blame div.alt:nth-child(odd) {
  background: var(--surface);
}

div#cgit table.blame .oid,
div#cgit .oid {
  color: var(--dim-foreground);
}

/* Commit information */

div#cgit table.commit-info th {
  color: var(--dim-foreground);
}

div#cgit div.commit-subject {
  color: var(--bright-foreground);
}

div#cgit div.commit-msg {
  color: var(--foreground);
}

/* Panels */

div#cgit div.cgit-panel table {
  color: var(--foreground);
  background: var(--surface);
  border-color: var(--border);
  border-radius: 3px;
}

div#cgit div.cgit-panel th {
  color: var(--bright-foreground);
}

/* Notes */

div#cgit div.notes {
  color: var(--foreground);
  background: color-mix(in srgb, var(--yellow) 14%, var(--background));
  border-color: var(--dim-yellow);
}

div#cgit div.notes-header,
div#cgit div.notes-footer {
  color: var(--dim-yellow);
}

/* Errors */

div#cgit div.error {
  color: var(--bright-red);
  background: color-mix(in srgb, var(--red) 12%, var(--background));
  border: 1px solid var(--dim-red);
  border-radius: 3px;
}

/* Diffstat */

div#cgit table.diffstat {
  color: var(--foreground);
  background: var(--surface);
  border-color: var(--border);
}

div#cgit table.diffstat td span.modechange {
  color: var(--orange);
}

div#cgit table.diffstat td.add a {
  color: var(--green);
}

div#cgit table.diffstat td.del a {
  color: var(--red);
}

div#cgit table.diffstat td.upd a {
  color: var(--blue);
}

div#cgit table.diffstat td.graph td.add {
  background: var(--green);
}

div#cgit table.diffstat td.graph td.rem {
  background: var(--red);
}

div#cgit div.diffstat-summary {
  color: var(--dim-foreground);
}

/* Unified diff */

div#cgit table.diff td div.head {
  color: var(--bright-foreground);
  background: var(--surface-alt);
}

div#cgit table.diff td div.hunk {
  color: var(--bright-magenta);
  background: color-mix(in srgb, var(--magenta) 10%, var(--background));
}

div#cgit table.diff td div.add {
  color: var(--bright-green);
  background: var(--add-background);
}

div#cgit table.diff td div.del {
  color: var(--bright-red);
  background: var(--delete-background);
}

/* Side-by-side diff */

div#cgit table.ssdiff td {
  border-left-color: var(--border);
  border-right-color: var(--border);
}

div#cgit table.ssdiff td.add {
  color: var(--foreground);
  background: var(--add-background);
}

div#cgit table.ssdiff td.add_dark,
div#cgit table.ssdiff span.add {
  color: var(--bright-foreground);
  background: var(--add-background-strong);
}

div#cgit table.ssdiff td.del {
  color: var(--foreground);
  background: var(--delete-background);
}

div#cgit table.ssdiff td.del_dark,
div#cgit table.ssdiff span.del {
  color: var(--bright-foreground);
  background: var(--delete-background-strong);
}

div#cgit table.ssdiff td.changed {
  color: var(--foreground);
  background: var(--change-background);
}

div#cgit table.ssdiff td.changed_dark {
  color: var(--bright-foreground);
  background: var(--change-background-strong);
}

div#cgit table.ssdiff td.lineno {
  color: var(--dim-foreground);
  background: var(--surface);
}

div#cgit table.ssdiff td.hunk {
  color: var(--bright-blue);
  background: color-mix(in srgb, var(--blue) 16%, var(--background));
  border-top-color: var(--border);
  border-bottom-color: var(--border);
}

div#cgit table.ssdiff td.head {
  background: var(--surface-alt);
  border-top-color: var(--border);
  border-bottom-color: var(--border);
}

div#cgit table.ssdiff td.head div.head {
  color: var(--bright-foreground);
}

div#cgit table.ssdiff td.foot {
  border-top-color: var(--border);
}

/* Reference decorations */

div#cgit a.branch-deco {
  color: var(--bright-green);
  background: color-mix(in srgb, var(--green) 18%, var(--background));
  border-color: var(--green);
  border-radius: 3px;
}

div#cgit a.tag-deco {
  color: var(--bright-yellow);
  background: color-mix(in srgb, var(--yellow) 18%, var(--background));
  border-color: var(--yellow);
  border-radius: 3px;
}

div#cgit a.tag-annotated-deco {
  color: var(--orange);
  background: color-mix(in srgb, var(--orange) 18%, var(--background));
  border-color: var(--orange);
  border-radius: 3px;
}

div#cgit a.remote-deco {
  color: var(--bright-blue);
  background: color-mix(in srgb, var(--blue) 18%, var(--background));
  border-color: var(--blue);
  border-radius: 3px;
}

div#cgit a.deco {
  color: var(--bright-red);
  background: color-mix(in srgb, var(--red) 18%, var(--background));
  border-color: var(--red);
  border-radius: 3px;
}

div#cgit a.branch-deco:hover,
div#cgit table.list td a.branch-deco:hover,
div#cgit a.tag-deco:hover,
div#cgit table.list td a.tag-deco:hover,
div#cgit a.tag-annotated-deco:hover,
div#cgit table.list td a.tag-annotated-deco:hover,
div#cgit a.remote-deco:hover,
div#cgit table.list td a.remote-deco:hover,
div#cgit a.deco:hover,
div#cgit table.list td a.deco:hover {
  color: var(--bright-foreground);
}

/* Ages and change counts */

div#cgit span.age-mins {
  color: var(--bright-green);
}

div#cgit span.age-hours {
  color: var(--green);
}

div#cgit span.age-days {
  color: var(--dim-green);
}

div#cgit span.age-weeks {
  color: var(--dim-foreground);
}

div#cgit span.age-months {
  color: var(--bright-black);
}

div#cgit span.age-years {
  color: var(--black);
}

div#cgit span.insertions {
  color: var(--bright-green);
}

div#cgit span.deletions {
  color: var(--bright-red);
}

/* Statistics */

div#cgit table.stats,
div#cgit table.vgraph,
div#cgit table.hgraph {
  border-color: var(--border);
}

div#cgit table.stats th,
div#cgit table.vgraph th,
div#cgit table.hgraph th {
  color: var(--bright-foreground);
  background: var(--surface-alt);
  border-color: var(--border);
}

div#cgit table.stats td {
  border-color: var(--border);
}

div#cgit table.stats td.sum {
  color: var(--blue);
}

div#cgit table.vgraph div.bar,
div#cgit table.hgraph div.bar {
  background: var(--blue);
}

/* Footer */

div#cgit div.footer,
div#cgit div.footer a {
  color: var(--dim-foreground);
}

div#cgit div.footer a:hover {
  color: var(--bright-blue);
}

/* -------------------------------------------------------------------------
 * Pygments syntax highlighting
 * ---------------------------------------------------------------------- */

div#cgit .highlight {
  color: var(--foreground);
  background: transparent;
}

div#cgit .highlight pre {
  color: inherit;
  background: transparent;
  margin: 0;
  padding: 0;
  border: 0;
}

/* Highlighted line */

div#cgit .highlight .hll {
  background: color-mix(
    in srgb,
    var(--blue) 16%,
    var(--background)
  );
}

/* Plain text and punctuation */

div#cgit .highlight .pyg-p {
  color: var(--dim-foreground);
}

div#cgit .highlight .pyg-w {
  color: var(--dim-foreground);
}

/* Errors */

div#cgit .highlight .pyg-err {
  color: var(--bright-red);
  background: color-mix(
    in srgb,
    var(--red) 18%,
    transparent
  );
  text-decoration: underline wavy var(--red);
}

/* Comments */

div#cgit .highlight :is(
  .pyg-c,
  .pyg-ch,
  .pyg-cm,
  .pyg-cp,
  .pyg-cpf,
  .pyg-c1,
  .pyg-cs
) {
  color: var(--dim-foreground);
  font-style: italic;
}

/* Preprocessor comments and directives */

div#cgit .highlight :is(
  .pyg-cp,
  .pyg-cpf
) {
  color: var(--dim-cyan);
}

/* Keywords */

div#cgit .highlight :is(
  .pyg-k,
  .pyg-kc,
  .pyg-kd,
  .pyg-kn,
  .pyg-kp,
  .pyg-kr,
  .pyg-kt
) {
  color: var(--magenta);
  font-weight: 600;
}

/* Types */

div#cgit .highlight .pyg-kt {
  color: var(--yellow);
}

/* Operators */

div#cgit .highlight :is(
  .pyg-o,
  .pyg-ow
) {
  color: var(--cyan);
}

div#cgit .highlight .pyg-ow {
  font-weight: 600;
}

/* Names */

div#cgit .highlight .pyg-n {
  color: var(--foreground);
}

/* Attributes */

div#cgit .highlight .pyg-na {
  color: var(--cyan);
}

/* Built-in names */

div#cgit .highlight :is(
  .pyg-nb,
  .pyg-bp
) {
  color: var(--blue);
}

/* Class names */

div#cgit .highlight .pyg-nc {
  color: var(--yellow);
  font-weight: 600;
}

/* Constants */

div#cgit .highlight .pyg-no {
  color: var(--orange);
}

/* Decorators */

div#cgit .highlight .pyg-nd {
  color: var(--bright-yellow);
}

/* Entities */

div#cgit .highlight .pyg-ni {
  color: var(--pink);
}

/* Exceptions */

div#cgit .highlight .pyg-ne {
  color: var(--bright-red);
  font-weight: 600;
}

/* Functions and methods */

div#cgit .highlight :is(
  .pyg-nf,
  .pyg-fm
) {
  color: var(--blue);
  font-weight: 600;
}

/* Labels */

div#cgit .highlight .pyg-nl {
  color: var(--bright-yellow);
}

/* Namespaces and modules */

div#cgit .highlight .pyg-nn {
  color: var(--cyan);
}

/* HTML/XML tags */

div#cgit .highlight .pyg-nt {
  color: var(--blue);
  font-weight: 600;
}

/* Variables */

div#cgit .highlight :is(
  .pyg-nv,
  .pyg-vc,
  .pyg-vg,
  .pyg-vi,
  .pyg-vm
) {
  color: var(--foreground);
}

/* Numbers */

div#cgit .highlight :is(
  .pyg-m,
  .pyg-mb,
  .pyg-mf,
  .pyg-mh,
  .pyg-mi,
  .pyg-mo,
  .pyg-il
) {
  color: var(--orange);
}

/* Strings */

div#cgit .highlight :is(
  .pyg-s,
  .pyg-sa,
  .pyg-sb,
  .pyg-sc,
  .pyg-dl,
  .pyg-sd,
  .pyg-s2,
  .pyg-sh,
  .pyg-sx,
  .pyg-sr,
  .pyg-s1,
  .pyg-ss
) {
  color: var(--green);
}

/* String interpolation */

div#cgit .highlight .pyg-si {
  color: var(--bright-green);
  font-weight: 600;
}

/* Escape sequences */

div#cgit .highlight .pyg-se {
  color: var(--bright-cyan);
  font-weight: 600;
}

/* Regular expressions */

div#cgit .highlight .pyg-sr {
  color: var(--bright-green);
}

/* Documentation strings */

div#cgit .highlight .pyg-sd {
  color: var(--dim-green);
  font-style: italic;
}

/* Generic diff and console tokens */

div#cgit .highlight .pyg-gd {
  color: var(--bright-red);
  background: var(--delete-background);
}

div#cgit .highlight .pyg-gi {
  color: var(--bright-green);
  background: var(--add-background);
}

div#cgit .highlight .pyg-gh {
  color: var(--bright-blue);
  font-weight: 700;
}

div#cgit .highlight .pyg-gu {
  color: var(--bright-magenta);
  font-weight: 700;
}

div#cgit .highlight .pyg-ge {
  font-style: italic;
}

div#cgit .highlight :is(
  .pyg-gs,
  .pyg-ges
) {
  font-weight: 700;
}

div#cgit .highlight :is(
  .pyg-gr,
  .pyg-gt
) {
  color: var(--bright-red);
}

div#cgit .highlight .pyg-go {
  color: var(--dim-foreground);
}

div#cgit .highlight .pyg-gp {
  color: var(--bright-cyan);
  font-weight: 600;
}
