/* SAIL's optional night palette. The light palette is the initial render. */
.theme-switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: end;
  gap: 8px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  margin-inline: 8px;
  border: 1px solid #acaab3;
  background: transparent;
  color: #34323e;
  font: 600 .76rem/1 var(--sans, sans-serif);
  white-space: nowrap;
  cursor: pointer;
}
.theme-switch[hidden] { display: none; }
.theme-switch:hover { background: #eeedf6; }
.theme-switch:focus-visible { outline: 3px solid #5747c9; outline-offset: 2px; }
.theme-glyph {
  width: 16px;
  height: 16px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}
html[data-skin="gridline"] .masthead__inner:has(.theme-switch:not([hidden])) {
  grid-template-columns: minmax(max-content, .75fr) auto minmax(max-content, 1fr) auto;
}
@media (min-width:801px) and (max-width:1100px) {
  html[data-skin="gridline"] .masthead__inner .sail-practice-label { display:none; }
  html[data-skin="gridline"] .masthead .nav a { min-width:85px; }
}
@media (min-width:801px) and (max-width:1000px) {
  html[data-skin="gridline"] .masthead .contact-link { display:none; }
}
@media (max-width:800px) {
  html[data-skin="gridline"] .masthead__inner:has(.theme-switch:not([hidden])) { grid-template-columns:1fr auto auto; }
  .theme-switch { margin:0 0 0 8px; padding:0 10px; }
}
@media (max-width:420px) { .theme-label { display:none; } }
@media print { .theme-switch { display:none; } }

@media screen {
  html[data-theme="dark"][data-skin="gridline"] {
    color-scheme:dark;
    background:#15151c;
    & body {
      --grid-paper:#15151c;
      --grid-ink:#f5f3fa;
      --grid-accent:#443caa;
      --surface-page:var(--grid-paper);
      --surface-panel:#22222e;
      --surface-muted:#2c2b3b;
      --text-primary:var(--grid-ink);
      --text-secondary:#c6c3d2;
      --border-default:#585565;
      --action:#c1b8ff;
      --action-soft:#38314f;
      --status-accepted:#8ce1c3;
      --status-question:#ffb793;
      --focus:#d5caff;
      --theme-link:#c1b8ff;
      --theme-band:#352f86;
      --theme-tint:#292538;
      color:var(--grid-ink);
      background:var(--grid-paper);
    }
    & .masthead, & .masthead .nav { background:#1a1a23; border-color:var(--border-default); }
    & .masthead :is(.brand,.nav a,.menu) { color:var(--grid-ink); border-color:var(--border-default); }
    & .brand .sail-brand-logo { content:url("sail-logo-reverse.svg"); }
    & .brand .sail-practice-label, & .footer { color:var(--text-secondary); }
    & .masthead .nav a:hover { background:var(--surface-muted); }
    & .masthead .nav a[aria-current="page"], & .masthead .contact-link { color:white; background:var(--grid-accent); }
    & .theme-switch { color:#e5e0ff; border-color:#78728e; background:var(--theme-tint); }
    & .theme-switch:hover { background:#393347; }
    & .theme-switch:focus-visible, & :focus-visible { outline-color:var(--focus); }
    & .theme-glyph { background:linear-gradient(90deg, transparent 50%, currentColor 50%); }
    & .eyebrow { color:var(--theme-link); }
    & .eyebrow::before { background:var(--theme-link); }
    & .hero .reject { color:#b6b0c8!important; }
    & .lede { color:#d4d1df!important; }
    & body[data-branch] .hero::after {
      background:linear-gradient(90deg,#15151c 0 36%,rgb(21 21 28 / .94) 44%,rgb(21 21 28 / .22) 66%,transparent 79%),linear-gradient(0deg,#15151c,transparent 23%);
    }
    & body[data-branch="family"] .hero::before { background-image:radial-gradient(ellipse at 63% 46%,#3e365f,#211f34 72%)!important; }
    & .hero-family [stroke="#5b4fb0"] { stroke:#afa0ff; }
    & .hero-family [fill="#5b4fb0"] { fill:#d0c6ff; }
    & .hero-family [stroke="#276948"] { stroke:#83dbb9; }
    & .hero-family [stroke="#984617"] { stroke:#ffb28b; }
    & .hero-family .hero-family-transfer { stroke:#f3edff; }
    & :is(.process-row,.route-strip,.pipeline) { background:var(--theme-band); }
    & .process-row > .process-diagram { background:var(--surface-panel)!important; border-color:var(--border-default)!important; }
    & body[data-branch] .process-diagram :is(.visual-caption,.visual-key,.micro) { color:var(--text-secondary); border-color:var(--border-default); }
    & .process-diagram :is(.viz-node,.lane,.lane button,.evidence-inputs button,.evidence-output,.matrix-row>*) {
      color:var(--grid-ink); background:var(--surface-muted); border-color:#6a6679;
    }
    & .process-diagram .matrix-row .done { color:var(--status-accepted); }
    & .process-diagram .matrix-row .review { color:var(--status-question); }
    & .process-diagram .matrix-row .open { color:var(--theme-link); }
    & .process-diagram [data-viz-detail].is-active { color:white; background:var(--grid-accent)!important; }
    & .process-diagram .visual-key i { background:var(--theme-link); }
    & :is(.compact-grid>*+*,.decision-grid .outputs,.brief,.resource-card,.guide-contents,.guide-section pre,.cookie-panel) {
      background:var(--surface-panel); color:var(--grid-ink); border-color:var(--border-default);
    }
    & .decision-grid > .boundary { background:var(--theme-band); border-color:var(--border-default); }
    & .decision-grid :is(.fit,.boundary,.outputs) { border-color:var(--border-default); }
    & :is(.decision-grid p,.outputs ul,.practice-art figcaption,.resource-note,.resource-breadcrumbs,.prompt-status,.policy-date,.policy-content caption) { color:var(--text-secondary); }
    & .decision-grid .fit::before { color:var(--status-accepted); }
    & .illustrated-footer { background:linear-gradient(115deg,#1d1c28 5%,#2b293c 56%,#38354c); border-color:var(--border-default); }
    & .illustrated-footer__key { color:var(--grid-ink); }
    & :is(.footer-brief,.prompt-toolbar button) { color:#211d36; background:#d1c8ff; }
    & :is(.resource-callout,.prompt-toolbar,.policy-callout) { color:var(--grid-ink); background:var(--theme-tint); }
    & :is(.resource-callout,.policy-callout,.guide-contents) { border-left-color:var(--theme-link); }
    & .guide-contents { border-top-color:var(--theme-link); }
    & :is(.resource-callout a,.resource-card a,.resource-link,.guide-section a,.service-number,.cookie-panel a,.button--quiet) { color:var(--theme-link); }
    & .resource-card .micro { color:var(--text-secondary); }
    & .resource-shell .button { background:var(--grid-accent); color:white; }
    & :is(.resource-grid,.resource-card,.guide-section,.prompt-toolbar,.guide-section pre,.service-block,.policy-index,.policy-content section,.policy-content th,.policy-content td,.policy-intro,.practice-art,.claim-rule,.family-flow p,.brief__output,.options,.options label,.visual-head) { border-color:var(--border-default); }
    & .policy-summary { border-color:var(--border-default); background:var(--border-default); }
    & .policy-index a:hover { color:var(--theme-link); }
    & .cookie-panel { border-top-color:var(--theme-link); }
  }
  @media (max-width:800px) {
    html[data-theme="dark"][data-skin="gridline"] body[data-branch] .hero::after {
      background:linear-gradient(180deg,#15151c,rgb(21 21 28 / .12) 30%,transparent 75%);
    }
  }
}
