/* Theme: midnight */
:root[data-theme="midnight"],
.theme-menu__option[data-theme-option="midnight"] {
  color-scheme: dark;
  --page-bg: #063a3a;
  --body-background: linear-gradient(180deg, #063a3a 0%, #042b2b 100%);
  --ink: #c8c8c8;
  --ink-soft: #9a9a9a;
  --line: #5a5a5a;
  --panel: #2b2b2b;
  --input-bg: #121212;
  --button-bg: #2b2b2b;
  --button-alt-bg: #343434;
  --feedback-ok-bg: #1d2f26;
  --feedback-error-bg: #3a1f1f;
  --status-error: #ff9d9d;
  --status-ok: #8fe3a8;
  --status-warning: #e6c26a;
  --active-bg: #4a4a4a;
  --active-ink: #ffffff;
  --active-line: #8a8a8a;
  --active-ring: rgba(138, 138, 138, 0.3);
  --body-font: "Times New Roman", Times, serif;
  --ui-font: Tahoma, "MS Sans Serif", Geneva, sans-serif;
  --code-font: "Courier New", monospace;
}

.theme-swatch[data-theme="midnight"] {
  background:
    linear-gradient(180deg, #1c3f9e 0 28%, #2b2b2b 28% 52%, #121212 52% 100%);
  border-color: #000000;
  box-shadow:
    inset -1px -1px 0 0 #000000,
    inset 1px 1px 0 0 #6a6a6a;
}

.theme-menu__option[data-theme-option="midnight"] {
  background: #2b2b2b;
  color: #c8c8c8;
  box-shadow: inset -1px -1px 0 #000000, inset 1px 1px 0 #6a6a6a;
}

:root[data-theme="midnight"] .shell {
  width: min(100%, 860px);
}

:root[data-theme="midnight"] .site-header {
  /* Clear the frame's ring and drop shadow before the first window below. */
  margin-bottom: 1.25rem;
  padding: 0.45rem 0.6rem 0.6rem;
  border: 2px solid;
  border-color: #4e4e4e #1a1a1a #1a1a1a #4e4e4e;
  background: #2b2b2b;
  box-shadow:
    -1px -1px 0 0 #686868,
    1px 1px 0 0 #000000,
    6px 6px 0 0 #000000;
}

/* One window frame for every surface: cards, feedback, Account's card, and the
   dark lists (thread rows, grouped account rows). */
:root[data-theme="midnight"] .card,
:root[data-theme="midnight"] .feedback,
:root[data-theme="midnight"] .account-card,
:root[data-theme="midnight"] .thread-rows,
:root[data-theme="midnight"] .account-group,
:root[data-theme="midnight"] .account-page > .account-key-advanced,
:root[data-theme="midnight"] .board-toolbar,
:root[data-theme="midnight"] .stack > .board-filter {
  border: 2px solid;
  border-color: #4e4e4e #1a1a1a #1a1a1a #4e4e4e;
  border-radius: 0;
  background: #2b2b2b;
  box-shadow:
    -1px -1px 0 0 #686868,
    1px 1px 0 0 #000000,
    6px 6px 0 0 #000000;
}

:root[data-theme="midnight"] .thread-rows,
:root[data-theme="midnight"] .account-group,
:root[data-theme="midnight"] .account-page > .account-key-advanced {
  background: #121212;
}

/* Account's Advanced disclosure sits between grouped rows, so it takes the same
   frame and a row-height summary instead of floating on the page background. */
:root[data-theme="midnight"] .account-page > .account-key-advanced {
  padding-top: 0;
}

:root[data-theme="midnight"] .account-page > .account-key-advanced summary {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.35rem 1rem;
}

:root[data-theme="midnight"] .account-page > .account-key-advanced > div {
  margin-top: 0;
  padding: 0.25rem 1rem 1rem;
}

:root[data-theme="midnight"] .card {
  padding: 1.5rem;
}

:root[data-theme="midnight"] .post-card {
  padding-bottom: 2.25rem;
}

:root[data-theme="midnight"] .post-card:has(+ .continuation) {
  padding-bottom: 0.5rem;
}

:root[data-theme="midnight"] .post-card.continuation {
  padding-top: 0.85rem;
}

:root[data-theme="midnight"] .inline-reply-composer {
  padding: 0;
}

:root[data-theme="midnight"] .stack > * + * {
  margin-top: 1.5rem;
}

:root[data-theme="midnight"] .post-card.continuation {
  margin-top: 0;
}

:root[data-theme="midnight"] .tags-section-card {
  background: #2b2b2b;
}

:root[data-theme="midnight"] .card > .body:not(:empty),
:root[data-theme="midnight"] .card > p:not([class]) {
  margin: 0.9rem 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid #5a5a5a;
  background: #1b1b1b;
}

:root[data-theme="midnight"] .card > p:not([class]) + p:not([class]) {
  margin-top: 0.9rem;
}

:root[data-theme="midnight"] .tool-launcher-button {
  border: 1px solid #000000;
  background: #2b2b2b;
  color: #c8c8c8;
  font-weight: 600;
  box-shadow:
    inset 1px 1px 0 0 #6a6a6a,
    inset -1px -1px 0 0 #000000;
}

:root[data-theme="midnight"] .tool-launcher-button:active {
  box-shadow:
    inset -1px -1px 0 0 #6a6a6a,
    inset 1px 1px 0 0 #000000;
}

:root[data-theme="midnight"] a {
  color: #7aa8ff;
}

/* Grouped account rows (`button.account-row`) stay flat list rows, not buttons. */
:root[data-theme="midnight"] button:not(.theme-swatch):not(.theme-menu__trigger):not(.theme-menu__option):not(.account-row) {
  border: 1px solid #000000;
  background: #2b2b2b;
  color: #c8c8c8;
  box-shadow:
    inset 1px 1px 0 0 #6a6a6a,
    inset -1px -1px 0 0 #000000;
}

:root[data-theme="midnight"] button:not(.theme-swatch):not(.theme-menu__trigger):not(.theme-menu__option):not(.account-row):active {
  box-shadow:
    inset -1px -1px 0 0 #6a6a6a,
    inset 1px 1px 0 0 #000000;
}

:root[data-theme="midnight"] .nav-link {
  border: 1px solid transparent;
  background: transparent;
  color: #c8c8c8;
  text-decoration: none;
}

:root[data-theme="midnight"] .nav-link:hover {
  border-color: #6a6a6a #000000 #000000 #6a6a6a;
}

:root[data-theme="midnight"] .nav-link.is-active {
  color: #c8c8c8;
  background: #3c3c3c;
  border-color: #000000 #6a6a6a #6a6a6a #000000;
  box-shadow: none;
  font-weight: 700;
}

:root[data-theme="midnight"] input,
:root[data-theme="midnight"] textarea,
:root[data-theme="midnight"] [data-role="public-key-viewer"],
:root[data-theme="midnight"] [data-role="private-key-viewer"] {
  border: 1px solid #000000;
  background: #121212;
  box-shadow:
    inset 1px 1px 0 0 #000000,
    inset -1px -1px 0 0 #3c3c3c;
}

:root[data-theme="midnight"] ::selection {
  background: #000080;
  color: #ffffff;
}

:root[data-theme="midnight"] a:focus-visible {
  outline: 1px dotted #c8c8c8;
  outline-offset: 1px;
}

:root[data-theme="midnight"] button:not(.theme-menu__option):focus-visible,
:root[data-theme="midnight"] .nav-link:focus-visible {
  outline: 1px dotted #c8c8c8;
  outline-offset: -4px;
}

:root[data-theme="midnight"] button[disabled]:not(.theme-swatch):not(.theme-menu__trigger):not(.theme-menu__option) {
  color: #7a7a7a;
  text-shadow: 1px 1px 0 #000000;
}

:root[data-theme="midnight"] .site-header::after {
  content: "";
  display: block;
  margin-top: 0.65rem;
  height: 0.9rem;
  border: 1px solid #000000;
  background:
    repeating-linear-gradient(90deg, #8a8a8a 0 1px, transparent 1px 32px)
      4px 50% / calc(100% - 8px) 72% no-repeat,
    repeating-linear-gradient(90deg, #8a8a8a 0 1px, transparent 1px 8px)
      4px 50% / calc(100% - 8px) 34% no-repeat,
    linear-gradient(
      90deg,
      #2b2b2b 0 2.25rem,
      #1a1a1a 2.25rem calc(100% - 2.25rem),
      #2b2b2b calc(100% - 2.25rem) 100%
    ),
    #1a1a1a;
  box-shadow: inset -1px -1px 0 0 #3c3c3c;
}

:root[data-theme="midnight"] .eyebrow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: -0.45rem -0.6rem 0.65rem;
  padding: 0.18rem 0.2rem 0.18rem 0.45rem;
  color: #ffffff;
  background: linear-gradient(90deg, #00004a 0%, #0a3d6b 100%);
  font-weight: 700;
  letter-spacing: 0.04em;
}

:root[data-theme="midnight"] .eyebrow::before {
  content: "";
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-right: -0.1rem;
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16' shape-rendering='crispEdges'><rect x='2' y='0' width='12' height='16' fill='%23000000'/><rect x='3' y='1' width='10' height='14' fill='%23ffffff'/><rect x='4' y='3' width='8' height='2' fill='%232b579a'/><rect x='4' y='5' width='2' height='1' fill='%232b579a'/><rect x='9' y='5' width='2' height='1' fill='%232b579a'/><rect x='8' y='6' width='2' height='1' fill='%232b579a'/><rect x='7' y='7' width='2' height='1' fill='%232b579a'/><rect x='6' y='8' width='2' height='1' fill='%232b579a'/><rect x='5' y='9' width='2' height='1' fill='%232b579a'/><rect x='4' y='10' width='2' height='1' fill='%232b579a'/><rect x='10' y='10' width='2' height='1' fill='%232b579a'/><rect x='4' y='11' width='8' height='2' fill='%232b579a'/></svg>")
    no-repeat;
}

:root[data-theme="midnight"] .eyebrow::after {
  content: "\2013 \00a0 \274F \00a0 \2715";
  flex: 0 0 auto;
  margin-left: auto;
  padding: 0.06rem 0.3rem;
  border: 1px solid #000000;
  color: #c8c8c8;
  background: #2b2b2b;
  font-size: 0.62rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  box-shadow:
    inset 1px 1px 0 0 #6a6a6a,
    inset -1px -1px 0 0 #000000;
}

:root[data-theme="midnight"] .nav::before {
  content: "";
  flex: 0 0 auto;
  width: 3px;
  align-self: stretch;
  margin-right: 0.15rem;
  border-left: 1px solid #6a6a6a;
  border-right: 1px solid #000000;
}

:root[data-theme="midnight"] .card > h1:first-child,
:root[data-theme="midnight"] .card > h2:first-child,
:root[data-theme="midnight"] .post-card > .meta:first-child,
:root[data-theme="midnight"] .post-card > .post-resolution > .post-resolution-summary + .meta {
  display: block;
  margin: -1.5rem -1.5rem 1.1rem;
  padding: 0.22rem 0.55rem;
  background: linear-gradient(90deg, #00004a 0%, #0a3d6b 100%);
  color: #ffffff;
  font-family: var(--ui-font);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.45;
}

:root[data-theme="midnight"] .card > h1:first-child a,
:root[data-theme="midnight"] .card > h2:first-child a,
:root[data-theme="midnight"] .post-card > .meta:first-child a,
:root[data-theme="midnight"] .post-card > .post-resolution > .post-resolution-summary + .meta a {
  color: #ffffff;
  text-decoration: none;
}

:root[data-theme="midnight"] .compact-thread-compose {
  position: relative;
}

:root[data-theme="midnight"] .compact-thread-compose::before {
  content: "New Thread";
  display: block;
  padding: 0.22rem 0.55rem;
  background: linear-gradient(90deg, #00004a 0%, #0a3d6b 100%);
  color: #ffffff;
  font-family: var(--ui-font);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.45;
}

:root[data-theme="midnight"] .compact-thread-compose::after {
  content: "\2715";
  position: absolute;
  top: 0.3rem;
  right: 0.32rem;
  padding: 0.05rem 0.3rem;
  border: 1px solid #000000;
  color: #c8c8c8;
  background: #2b2b2b;
  font-family: var(--ui-font);
  font-size: 0.62rem;
  line-height: 1.35;
  box-shadow:
    inset 1px 1px 0 0 #6a6a6a,
    inset -1px -1px 0 0 #000000;
}

:root[data-theme="midnight"] .theme-menu {
  gap: 2px;
  padding: 2px;
  border: 1px solid #000000;
  border-radius: 0;
  background: #121212;
  box-shadow:
    inset 1px 1px 0 0 #000000,
    inset -1px -1px 0 0 #3c3c3c;
}

:root[data-theme="midnight"] .theme-menu > .theme-toggle {
  border-radius: 0;
}

:root[data-theme="midnight"] .theme-menu__trigger {
  width: 17px;
  min-width: 17px;
  padding: 0;
  border: 1px solid #000000;
  border-radius: 0;
  color: transparent;
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16' shape-rendering='crispEdges'><rect x='4' y='6' width='7' height='1' fill='%23c8c8c8'/><rect x='5' y='7' width='5' height='1' fill='%23c8c8c8'/><rect x='6' y='8' width='3' height='1' fill='%23c8c8c8'/><rect x='7' y='9' width='1' height='1' fill='%23c8c8c8'/></svg>")
    center no-repeat #2b2b2b;
  box-shadow:
    inset 1px 1px 0 0 #6a6a6a,
    inset -1px -1px 0 0 #000000;
}

:root[data-theme="midnight"] .theme-menu__trigger:hover {
  color: transparent;
}

:root[data-theme="midnight"] .theme-menu__trigger:active,
:root[data-theme="midnight"] .theme-menu__trigger[aria-expanded="true"] {
  color: transparent;
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16' shape-rendering='crispEdges'><rect x='4' y='6' width='7' height='1' fill='%23c8c8c8'/><rect x='5' y='7' width='5' height='1' fill='%23c8c8c8'/><rect x='6' y='8' width='3' height='1' fill='%23c8c8c8'/><rect x='7' y='9' width='1' height='1' fill='%23c8c8c8'/></svg>")
    center no-repeat #2b2b2b;
  box-shadow:
    inset -1px -1px 0 0 #6a6a6a,
    inset 1px 1px 0 0 #000000;
}

:root[data-theme="midnight"] .post-card:target {
  border-color: #000080;
  box-shadow:
    0 0 0 3px #2b2b2b,
    0 0 0 4px #000080,
    7px 7px 0 4px #000000;
}

:root[data-theme="midnight"] body {
  padding-bottom: 2.2rem;
}

:root[data-theme="midnight"] .site-status-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  gap: 2px;
  align-items: stretch;
  padding: 2px 3px 3px;
  overflow: hidden;
  border-top: 1px solid #6a6a6a;
  background: #2b2b2b;
  color: #c8c8c8;
  font-family: var(--ui-font);
  font-size: 0.72rem;
  line-height: 1.35;
}

:root[data-theme="midnight"] .site-status-bar__panel {
  padding: 0.08rem 0.5rem;
  border: 1px solid;
  border-color: #000000 #6a6a6a #6a6a6a #000000;
  white-space: nowrap;
}

:root[data-theme="midnight"] .site-status-bar__panel--wide {
  min-width: 12rem;
}

:root[data-theme="midnight"] .site-status-bar__panel--dim {
  color: #7a7a7a;
  text-shadow: 1px 1px 0 #000000;
}

:root[data-theme="midnight"] .theme-menu__popover {
  padding: 4px;
  border: 1px solid #000000;
  background-color: #2b2b2b;
  background-image: none;
  box-shadow:
    inset 1px 1px 0 0 #6a6a6a,
    inset -1px -1px 0 0 #000000,
    3px 3px 0 0 #000000;
}

html[data-theme="midnight"]::-webkit-scrollbar,
html[data-theme="midnight"] ::-webkit-scrollbar {
  width: 16px;
  height: 16px;
  background:
    conic-gradient(#3c3c3c 25%, #2b2b2b 0 50%, #3c3c3c 0 75%, #2b2b2b 0)
    0 0 / 2px 2px;
}

html[data-theme="midnight"]::-webkit-scrollbar-thumb,
html[data-theme="midnight"] ::-webkit-scrollbar-thumb {
  background: #2b2b2b;
  border: 1px solid #000000;
  box-shadow:
    inset 1px 1px 0 0 #6a6a6a,
    inset -1px -1px 0 0 #000000;
}

html[data-theme="midnight"]::-webkit-scrollbar-button,
html[data-theme="midnight"] ::-webkit-scrollbar-button {
  display: block;
  width: 16px;
  height: 16px;
  background-color: #2b2b2b;
  background-repeat: no-repeat;
  background-position: center;
  border: 1px solid #000000;
  box-shadow:
    inset 1px 1px 0 0 #6a6a6a,
    inset -1px -1px 0 0 #000000;
}

html[data-theme="midnight"]::-webkit-scrollbar-button:vertical:start:increment,
html[data-theme="midnight"] ::-webkit-scrollbar-button:vertical:start:increment,
html[data-theme="midnight"]::-webkit-scrollbar-button:vertical:end:decrement,
html[data-theme="midnight"] ::-webkit-scrollbar-button:vertical:end:decrement,
html[data-theme="midnight"]::-webkit-scrollbar-button:horizontal:start:increment,
html[data-theme="midnight"] ::-webkit-scrollbar-button:horizontal:start:increment,
html[data-theme="midnight"]::-webkit-scrollbar-button:horizontal:end:decrement,
html[data-theme="midnight"] ::-webkit-scrollbar-button:horizontal:end:decrement {
  display: none;
}

html[data-theme="midnight"]::-webkit-scrollbar-button:vertical:decrement,
html[data-theme="midnight"] ::-webkit-scrollbar-button:vertical:decrement {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16' shape-rendering='crispEdges'><rect x='7' y='6' width='1' height='1' fill='%23c8c8c8'/><rect x='6' y='7' width='3' height='1' fill='%23c8c8c8'/><rect x='5' y='8' width='5' height='1' fill='%23c8c8c8'/><rect x='4' y='9' width='7' height='1' fill='%23c8c8c8'/></svg>");
}

html[data-theme="midnight"]::-webkit-scrollbar-button:vertical:increment,
html[data-theme="midnight"] ::-webkit-scrollbar-button:vertical:increment {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16' shape-rendering='crispEdges'><rect x='4' y='6' width='7' height='1' fill='%23c8c8c8'/><rect x='5' y='7' width='5' height='1' fill='%23c8c8c8'/><rect x='6' y='8' width='3' height='1' fill='%23c8c8c8'/><rect x='7' y='9' width='1' height='1' fill='%23c8c8c8'/></svg>");
}

html[data-theme="midnight"]::-webkit-scrollbar-button:horizontal:decrement,
html[data-theme="midnight"] ::-webkit-scrollbar-button:horizontal:decrement {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16' shape-rendering='crispEdges'><rect x='6' y='7' width='1' height='1' fill='%23c8c8c8'/><rect x='7' y='6' width='1' height='3' fill='%23c8c8c8'/><rect x='8' y='5' width='1' height='5' fill='%23c8c8c8'/><rect x='9' y='4' width='1' height='7' fill='%23c8c8c8'/></svg>");
}

html[data-theme="midnight"]::-webkit-scrollbar-button:horizontal:increment,
html[data-theme="midnight"] ::-webkit-scrollbar-button:horizontal:increment {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='16' height='16' shape-rendering='crispEdges'><rect x='6' y='4' width='1' height='7' fill='%23c8c8c8'/><rect x='7' y='5' width='1' height='5' fill='%23c8c8c8'/><rect x='8' y='6' width='1' height='3' fill='%23c8c8c8'/><rect x='9' y='7' width='1' height='1' fill='%23c8c8c8'/></svg>");
}

html[data-theme="midnight"]::-webkit-scrollbar-corner,
html[data-theme="midnight"] ::-webkit-scrollbar-corner {
  background: #2b2b2b;
}

@supports not selector(::-webkit-scrollbar) {
  :root[data-theme="midnight"] {
    scrollbar-color: #2b2b2b #3c3c3c;
  }}

:root[data-theme="midnight"] .eyebrow .site-brand {
  color: #ffffff;
  text-decoration: none;
}

/* App shell: the title bar spans the frame, the toolbar row sits beneath it and
   the ruler beneath that. The app shell's flex row would otherwise squeeze all
   three onto one line. */
:root[data-theme="midnight"] .site-header--app {
  flex-wrap: wrap;
  gap: 0;
}

:root[data-theme="midnight"] .site-header--app .eyebrow {
  flex: 1 1 100%;
  margin: -0.45rem -0.6rem 0.65rem;
}

:root[data-theme="midnight"] .site-header--app .site-header-actions,
:root[data-theme="midnight"] .site-header--app::after {
  flex: 1 1 100%;
}

/* Toolbar buttons: New post and You are bevelled buttons like every other
   control; a pressed look marks the open menu and the current compose page. */
:root[data-theme="midnight"] [data-shell="app"] .new-post-button,
:root[data-theme="midnight"] .account-menu__trigger {
  border: 1px solid #000000;
  background: #2b2b2b;
  color: #c8c8c8;
  box-shadow:
    inset 1px 1px 0 0 #6a6a6a,
    inset -1px -1px 0 0 #000000;
}

:root[data-theme="midnight"] [data-shell="app"] .new-post-button.is-active,
:root[data-theme="midnight"] .account-menu[open] > .account-menu__trigger {
  background: #3c3c3c;
  box-shadow:
    inset -1px -1px 0 0 #6a6a6a,
    inset 1px 1px 0 0 #000000;
}

:root[data-theme="midnight"] .account-menu__panel,
:root[data-theme="midnight"] .board-sort__menu {
  border: 1px solid #000000;
  background: #2b2b2b;
  box-shadow:
    inset 1px 1px 0 0 #6a6a6a,
    inset -1px -1px 0 0 #000000,
    3px 3px 0 0 #000000;
}

/* List board: the filter strip is a toolbar; thread rows are the dark document
   inside a window whose title bar is the section label pulled over the frame. */
:root[data-theme="midnight"] .board-toolbar,
:root[data-theme="midnight"] .stack > .board-filter {
  padding: 0.3rem 0.4rem;
}

:root[data-theme="midnight"] .thread-row + .thread-row,
:root[data-theme="midnight"] .account-row {
  border-top-color: #3c3c3c;
}

:root[data-theme="midnight"] .account-row {
  /* `button[type="button"]` would otherwise paint the row with the button colour. */
  background: transparent;
}

:root[data-theme="midnight"] .thread-row__count,
:root[data-theme="midnight"] .thread-row__meta {
  font-family: var(--body-font);
}

:root[data-theme="midnight"] .section-label,
:root[data-theme="midnight"] .account-key-header {
  position: relative;
  z-index: 1;
  height: 1.75rem;
  margin: 1.5rem 2px calc(-1.75rem - 2px);
  padding: 0 0.55rem;
  background: linear-gradient(90deg, #00004a 0%, #0a3d6b 100%);
  color: #ffffff;
  font-family: var(--ui-font);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.75rem;
  letter-spacing: 0;
  text-transform: none;
}

:root[data-theme="midnight"] .account-key-header h1 {
  margin: 0;
  font-family: var(--ui-font);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.75rem;
}

:root[data-theme="midnight"] .section-label + .thread-rows {
  margin-top: 0;
  padding-top: 1.75rem;
}

/* Account: the heading is the title bar of the first window below it, which is
   the feedback notice when one renders, otherwise the visible account card. */
:root[data-theme="midnight"] .account-key-header + .feedback,
:root[data-theme="midnight"] .account-key-header ~ .account-card {
  margin-top: 0;
  padding-top: calc(1.75rem + 1.25rem);
}

:root[data-theme="midnight"] .account-key-header + .feedback ~ .account-card {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
}

/* Status chips are flat form fields, not pills. */
:root[data-theme="midnight"] .chip {
  padding: 0 0.35rem;
  border: 1px solid #6a6a6a;
  border-radius: 0;
  background: #343434;
  color: #c8c8c8;
}

/* Users and person pages: grouped rows lose the chevron, the avatar is a bevelled tile. */
:root[data-theme="midnight"] .account-row--link::after {
  display: none;
}

:root[data-theme="midnight"] .account-avatar {
  width: 2rem;
  height: 2rem;
  border: 1px solid #000000;
  border-radius: 0;
  background: #2b2b2b;
  color: #c8c8c8;
  font-size: 1.1rem;
  box-shadow:
    inset 1px 1px 0 0 #6a6a6a,
    inset -1px -1px 0 0 #000000;
}

:root[data-theme="midnight"] select,
:root[data-theme="midnight"] .board-toolbar__search {
  border: 1px solid #000000;
  border-radius: 0;
  background: #121212;
  color: #c8c8c8;
  font-family: var(--ui-font);
  box-shadow:
    inset 1px 1px 0 0 #000000,
    inset -1px -1px 0 0 #3c3c3c;
}

:root[data-theme="midnight"] .pinned-thread-marker {
  color: #000000;
  background: #ffff00;
  border-color: #000000;
}

:root[data-theme="midnight"][data-thread-density="compact"] .thread-list .thread-card > h1:first-child,
:root[data-theme="midnight"][data-thread-density="compact"] .thread-list .thread-card > h2:first-child {
  margin: -0.35rem -0.5rem 0.25rem;
  padding: 0.15rem 0.4rem;
  font-size: 0.8rem;
  line-height: 1.3;
}

:root[data-theme="midnight"][data-thread-density="compact"] .thread-list > .card {
  box-shadow:
    0 0 0 2px #2b2b2b,
    0 0 0 3px #6a6a6a;
}

:root[data-theme="midnight"][data-thread-density="compact"] .thread-list .thread-card + .thread-card {
  margin-top: 0.5rem;
}

/* Phones: the tab bar is a raised toolbar strip; the current tab is pressed. */
@media (max-width: 639px) {
  :root[data-theme="midnight"] [data-shell="app"] .site-header--app .site-header-actions {
    border-top: 1px solid #6a6a6a;
    background: #2b2b2b;
    box-shadow: 0 -1px 0 0 #000000;
  }

  :root[data-theme="midnight"] [data-shell="app"] .site-header--app .nav > .nav-link.is-active,
  :root[data-theme="midnight"] [data-shell="app"] .account-menu[open] > .account-menu__trigger {
    color: #c8c8c8;
    background: #3c3c3c;
    border-color: #000000 #6a6a6a #6a6a6a #000000;
  }
}

/* Gallery: a dark document page in the theme's window frame, with the
   tiles laid out as a Word table (even cells, gridlines) and each title set
   as a numbered figure caption. Thumbnails share one box; --gallery-fit
   switches between cropping (cover) and letterboxing (contain). */
:root[data-theme="midnight"] .gallery-grid {
  --gallery-fit: cover;
  counter-reset: gallery-figure;
  --gallery-columns: 4;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  /* --gallery-zoom (gallery_zoom.js) trades columns for size; browsers without
     round() keep the line above. */
  grid-template-columns: repeat(max(1, round(nearest, calc(var(--gallery-columns) / var(--gallery-zoom, 1)), 1)), minmax(0, 1fr));
  gap: 0;
  padding: 1.5rem calc(1.75rem + 1px) calc(1.5rem + 1px) 1.75rem;
  border: 2px solid;
  border-color: #4e4e4e #1a1a1a #1a1a1a #4e4e4e;
  background: #121212;
  box-shadow:
    -1px -1px 0 0 #686868,
    1px 1px 0 0 #000000,
    6px 6px 0 0 #000000;
}

:root[data-theme="midnight"] .gallery-grid::after {
  display: none;
}

/* Cell borders overlap by a pixel so neighbours share one gridline. */
:root[data-theme="midnight"] .gallery-tile {
  counter-increment: gallery-figure;
  max-width: none;
  margin: 0 -1px -1px 0;
  padding: 0.5rem 0.5rem 0.45rem;
  border: 1px solid #5a5a5a;
  background: #121212;
  color: #c8c8c8;
}

:root[data-theme="midnight"] .gallery-tile:hover,
:root[data-theme="midnight"] .gallery-tile:focus-visible {
  border-color: #5a5a5a;
}

:root[data-theme="midnight"] .gallery-tile img {
  aspect-ratio: 4 / 3;
  object-fit: var(--gallery-fit);
  border: 1px solid #000000;
  background: #000000;
}

:root[data-theme="midnight"] .gallery-tile:hover img {
  outline: 2px solid #7aa8ff;
  outline-offset: -1px;
}

:root[data-theme="midnight"] .gallery-tile:focus-visible {
  outline: 1px dotted #c8c8c8;
  outline-offset: -4px;
}

:root[data-theme="midnight"] .gallery-tile__caption {
  padding: 0.4rem 0 0;
  font-family: var(--body-font);
  font-size: calc(0.86rem * var(--gallery-text-scale, 1));
  line-height: 1.25;
}

:root[data-theme="midnight"] .gallery-tile__title {
  display: -webkit-box;
  font-weight: 400;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

:root[data-theme="midnight"] .gallery-tile__title::before {
  content: "Figure " counter(gallery-figure) ": ";
  font-weight: 700;
}

:root[data-theme="midnight"] .gallery-tile:hover .gallery-tile__title {
  text-decoration: underline;
}

:root[data-theme="midnight"] .gallery-tile__meta {
  margin-top: 0.15rem;
  color: #9a9a9a;
  font-family: var(--ui-font);
  font-size: calc(0.72rem * var(--gallery-text-scale, 1));
}

@media (max-width: 40rem) {
  :root[data-theme="midnight"] .gallery-grid {
    --gallery-columns: 2;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-columns: repeat(max(1, round(nearest, calc(var(--gallery-columns) / var(--gallery-zoom, 1)), 1)), minmax(0, 1fr));
    padding: 0.75rem calc(0.75rem + 1px) calc(0.75rem + 1px) 0.75rem;
  }
}

/* Pagination is a dialog's button row (Back / Next), not a toolbar: raised
   buttons, no grip; site.css puts them at the row's edges. */
:root[data-theme="midnight"] .pagination-nav {
  gap: 0.4rem;
}

:root[data-theme="midnight"] .pagination-nav::before {
  display: none;
}

:root[data-theme="midnight"] .pagination-nav .nav-link {
  min-width: 5.5rem;
  padding: 0.25rem 0.9rem;
  border: 1px solid #000000;
  background: #2b2b2b;
  color: #c8c8c8;
  font-family: var(--ui-font);
  text-align: center;
  box-shadow:
    inset 1px 1px 0 0 #6a6a6a,
    inset -1px -1px 0 0 #000000;
}

:root[data-theme="midnight"] .pagination-nav .nav-link:hover {
  border-color: #000000;
}

:root[data-theme="midnight"] .pagination-nav .nav-link:active {
  box-shadow:
    inset -1px -1px 0 0 #6a6a6a,
    inset 1px 1px 0 0 #000000;
}

/* A list inside a module is sunken, not a second raised window. */
:root[data-theme="midnight"] .card > .thread-rows {
  border-color: #1a1a1a #4e4e4e #4e4e4e #1a1a1a;
  box-shadow: none;
}
