/* Dark mode: follows the visitor's device setting (prefers-color-scheme). Loaded after color.css.
   --ink is kept for text; places that used --ink as a dark *background* get the fixed deep colour. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #e4eff0; --secondary: #a3bcc0; --teal: #5cc8cc; --line: #2b464d;
    --wash: #0f242a; --pale: #12303a; --mist: #0f242a;
    --bg: #0a181d; --card: #10242a; --card2: #132c33;
  }
  body { background: var(--bg); color: var(--ink); }
  a { color: inherit; }

  /* header */
  .head { background: #0a181d; border-bottom-color: #1d3940; }
  .head nav a[aria-current] { color: var(--teal); border-color: var(--teal); }
  .msenselogo { content: url(/assets/img/set2/logo/msense-horizontal-white.svg); }
  .orglogo { background: #fff; border-radius: 6px; padding: 3px 6px; mix-blend-mode: normal; }
  .simsec thead th, .simsec thead th:last-child { background: transparent; color: inherit; }
  .simsec tbody td:last-child, .simsec tbody th { background: transparent; }
  .simsec table { background: transparent; }
  .prose thead th:last-child { background: #0b4652; color: #fff; }
  .prose tbody td:last-child { background: transparent; }
  #navMobile { background: #0a181d; }

  /* places that used --ink as a dark background */
  .chathead, .sidebar { background: #0e2a33; }

  /* sections and cards */
  .wash, .subhero {
    background:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='160' viewBox='0 0 600 160'%3E%3Cg fill='none' stroke='%235cc8cc' stroke-opacity='.08' stroke-width='1.2'%3E%3Cpath d='M0 120 Q75 60 150 110 T300 100 T450 90 T600 110'/%3E%3Cpath d='M0 140 Q75 90 150 130 T300 125 T450 115 T600 135'/%3E%3C/g%3E%3C/svg%3E") repeat-x left bottom/600px 160px,
      linear-gradient(180deg, #0e2228 0%, #0b1d22 100%);
  }
  .tile { background: var(--card); border-color: #24434b; box-shadow: none; }
  .tile:after { opacity: .14; }
  .tilelimit { border-top-color: #2b464d; }
  .panel, .formpanel, .graph, .samplepath, .realphoto { background: var(--card); border-color: #24434b; box-shadow: none; }
  .artcard { background: var(--card); border-color: #24434b; }
  .placeholder { background: var(--card); color: var(--secondary); }
  .timeline li:before { color: #fff; }

  /* tables */
  table { background: var(--card); box-shadow: none; }
  td, th { border-bottom-color: #24434b; }
  thead th { background: #0b4652; color: #fff; }
  thead th:last-child { background: #f26b21; color: #10272b; }
  tbody td:last-child { background: #2a1d14; }
  tbody th { background: #132c33; }

  /* forms and chat */
  input:not([type=checkbox]), textarea, select { background: #0f2329; color: var(--ink); border-color: #3a5a62; }
  input::placeholder, textarea::placeholder { color: #7f999e; }
  dialog { background: #0f2228; color: var(--ink); border-color: #24434b; }
  .chatlog { background: #0b1b20; }
  .bubble { background: #132c33; border-color: #24434b; color: var(--ink); }
  .bubble.user { background: #17414a; }
  .bubble.staff { background: #1a3a48; border-color: #2c5562; }
  .bubble.staff:before { color: #8fd3e0; }
  .chip { border-color: #3a5a62; color: var(--ink); background: transparent; }

  /* articles */
  .prose blockquote { background: var(--card); }
  .prose a { color: var(--teal); }

  /* illustrations on white backgrounds: soften so they don't glare */
  .illus img, .prosefig img, .artcard img, .realphoto img { filter: brightness(.9); }
  .illus img { border-color: #24434b; }
  .note, .crumb, .intro { color: var(--secondary); }

  /* chat controls and remaining light boxes from styles.css */
  .chatlog form { background: #10242a; border-color: #2b464d; }
  .composer { background: #0f2228; border-top-color: #24434b; }
  .readbox { background: var(--card); border-color: #24434b; }
  .readbox .chipst.ok { background: #174d3a; color: #a7f0c8; }
  .readbox .chipst.over { background: #5a2c18; color: #ffc7a3; }
  /* teal fills: the light dark-mode teal is too pale under white text, use a deeper teal */
  .action, .composer button,
  .chip[aria-checked="true"], .readbox .chip[aria-checked="true"],
  .formpanel [data-topic] .chip[aria-checked="true"], .chatlog .chip[aria-checked="true"] { background: #0b6f78; border-color: #0b6f78; color: #fff; }
  .mini > span, .demo, .tag { background: #17343c; color: var(--ink); }
  .view details, .unitscale { background: var(--card); border-color: #24434b; }
  .factband, .closing { background: #0e2228; }
  .skip { background: #0a181d; color: var(--ink); }
  ::selection { background: #1f5560; color: #fff; }
}
@media (prefers-color-scheme: dark) {
  .cmpcard, .cmpflow li { background: var(--card); border-color: #24434b; }
  .cmpcard.mine, .cmpflow li.mine { border-color: #5cc8cc; box-shadow: none; }
  .cmptag { background: #0b6f78; }
  .cmpviz { background: #0f2329; color: var(--ink); }
  .cmpviz figcaption, .cmpflow em { color: #7fd6dd; }
  .cmpcard dl > div { border-top-color: #24434b; }
  .cmpflow b { background: #17414a; }
  .cmpflow li.mine b { background: #0b6f78; }
  .cmpflow li:not(:last-child):after { border-color: #5cc8cc; }
}
