/* Secondary investigation apps share the desktop Fluent palette. */
:is(.diary11-window, .research-window, .case-tools-window, .forensics11-window) {
  color: var(--fluent-text);
  background: var(--fluent-base);
  border-color: var(--fluent-line);
  font: 13px/1.5 var(--fluent-font);
  color-scheme: light;
  --secondary-success: #0f6b4b;
  --secondary-caution: #895700;
}
body[data-enigmal-theme="night"] :is(.diary11-window, .research-window, .case-tools-window, .forensics11-window) {
  color-scheme: dark;
  --secondary-success: #8ec5ad;
  --secondary-caution: #d5ae75;
}
/* Managed chrome uses forced legacy colors, so scoped importance is required. */
:is(.diary11-window, .research-window, .case-tools-window, .forensics11-window) .win11-window-titlebar {
  color: var(--fluent-text) !important;
  background: var(--fluent-base) !important;
}
:is(.diary11-window, .research-window, .case-tools-window, .forensics11-window) .win11-window-app-id strong,
:is(.diary11-window, .research-window, .case-tools-window, .forensics11-window) .win11-window-caption-controls button {
  color: var(--fluent-text) !important;
}
:is(.diary11-window, .research-window, .case-tools-window, .forensics11-window) .win11-window-caption-controls button:hover:not(.is-close),
:is(.diary11-window, .research-window, .case-tools-window, .forensics11-window) .win11-window-caption-controls button:active:not(.is-close) {
  background: var(--fluent-subtle) !important;
}
:is(.diary11-window, .research-window, .case-tools-window, .forensics11-window) .win11-window-caption-controls button.is-close:hover {
  color: #fff !important;
  background: #c42b1c !important;
}
:is(.diary11-window, .research-window, .case-tools-window, .forensics11-window) :is(button, input, select, textarea) {
  font-family: var(--fluent-font);
  font-size: 13px;
}
:is(.diary11-window, .research-window, .case-tools-window, .forensics11-window) button {
  min-height: 32px;
  border: 1px solid var(--fluent-line);
  border-radius: 4px;
  color: var(--fluent-text);
  background: var(--fluent-layer);
  font-weight: 400;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}
:is(.diary11-window, .research-window, .case-tools-window, .forensics11-window) button:hover:not(:disabled) {
  background: var(--fluent-subtle);
  border-color: color-mix(in srgb, var(--fluent-text) 24%, transparent);
}
:is(.diary11-window, .research-window, .case-tools-window, .forensics11-window) button:active:not(:disabled) {
  opacity: .8;
}
:is(.diary11-window, .research-window, .case-tools-window, .forensics11-window) button:disabled {
  opacity: .5;
  cursor: default;
}
:is(.diary11-window, .research-window, .case-tools-window, .forensics11-window) :is(input:not([type="checkbox"]):not([type="range"]), select, textarea) {
  color: var(--fluent-text);
  background: var(--fluent-layer);
  border: 1px solid var(--fluent-line);
  border-bottom-color: var(--fluent-muted);
  border-radius: 4px;
}
:is(.diary11-window, .research-window, .case-tools-window, .forensics11-window) :is(input, textarea)::placeholder {
  color: var(--fluent-muted);
  opacity: 1;
}
:is(.diary11-window, .research-window, .case-tools-window, .forensics11-window) :is(button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--fluent-accent);
  outline-offset: 2px;
}
:is(.diary11-window, .research-window, .case-tools-window, .forensics11-window) input {
  accent-color: var(--fluent-accent);
}
:is(.diary11-window, .research-window, .case-tools-window, .forensics11-window) :is(h2, h3) {
  font-family: var(--fluent-font);
  color: var(--fluent-text);
  font-weight: 600;
  letter-spacing: 0;
}

/* Quiet navigation, distinct selected state, and primary record commands. */
.diary11-window :is(.diary11-section, .diary11-entry),
.research-window .research-layout nav button,
.case-tools-window :is(.case-tools-tabs, .case-tools-body > aside) button,
.forensics11-window .forensics11-tabs button {
  position: relative;
  border-color: transparent;
  background: transparent;
}
.diary11-window :is(.diary11-section.is-active, .diary11-entry.is-selected),
.research-window .research-layout nav button[aria-pressed="true"],
.case-tools-window .case-tools-tabs button[aria-pressed="true"],
.case-tools-window .case-tools-body > aside button[aria-current="true"],
.forensics11-window .forensics11-tabs button[aria-selected="true"] {
  color: var(--fluent-text);
  background: var(--fluent-subtle);
  border: 1px solid var(--fluent-line);
  box-shadow: inset 3px 0 var(--fluent-accent);
}
.case-tools-window .case-tools-tabs button[aria-pressed="true"],
.forensics11-window .forensics11-tabs button[aria-selected="true"] {
  box-shadow: inset 0 -3px var(--fluent-accent);
}
.diary11-window [data-journal-save-note],
.research-window button[type="submit"],
.case-tools-window button[type="submit"],
.forensics11-window .forensics11-submit {
  color: var(--fluent-on-accent);
  background: var(--fluent-accent);
  border-color: transparent;
  padding: 7px 14px;
  font-weight: 600;
}
.diary11-window [data-journal-save-note]:hover,
.research-window button[type="submit"]:hover,
.case-tools-window button[type="submit"]:hover,
.forensics11-window .forensics11-submit:hover {
  color: var(--fluent-on-accent);
  background: var(--fluent-accent);
  filter: brightness(.95);
}

/* Journal retains its document hierarchy while respecting both themes. */
.diary11-window {
  grid-template-rows: 32px minmax(0, 1fr);
  --diary-ink: var(--fluent-text);
  --diary-muted: var(--fluent-muted);
  --diary-line: var(--fluent-line);
  --diary-accent: var(--fluent-accent);
}
.diary11-window .diary11-titlebar {
  color: var(--fluent-text);
  background: var(--fluent-base);
  border-color: var(--fluent-line);
}
.diary11-window .diary11-shell { background: var(--fluent-base); height: 100%; }
.diary11-window :is(.diary11-section, .diary11-entry, .diary11-entry strong, .diary11-case strong) { color: var(--fluent-text); }
.diary11-window .diary11-section b {
  color: var(--fluent-accent);
  background: var(--fluent-subtle);
}
.diary11-window :is(.diary11-case > span, .diary11-attachment > span:first-child) {
  color: var(--fluent-accent);
  background: var(--fluent-subtle);
  border-color: var(--fluent-line);
}
.diary11-window .diary11-section-icon { color: var(--fluent-muted); }
.diary11-window :is(.diary11-sidebar, .diary11-notes) { background: var(--fluent-base); }
.diary11-window :is(.diary11-entry-column, .diary11-reading) { background: var(--fluent-layer); }
.diary11-window .diary11-reading { padding: 26px; }
.diary11-window .diary11-paper {
  border-color: var(--fluent-line);
  border-radius: 6px;
  background: var(--fluent-layer);
  box-shadow: none;
}
.diary11-window .diary11-paper::before { background: var(--fluent-line); }
.diary11-window .diary11-paper p {
  color: var(--fluent-text);
  font: 14px/1.8 var(--fluent-font);
}
.diary11-window .diary11-article h2 { font-size: 24px; line-height: 1.3; }
.diary11-window :is(.diary11-attachment, .diary11-derived-list button) {
  color: var(--fluent-text);
  background: var(--fluent-layer);
}
.diary11-window :is(.diary11-kicker, .diary11-section.is-active .diary11-section-icon, .diary11-titlebar .os-icon, .diary11-note-link strong) { color: var(--fluent-accent); }
.diary11-window :is(.diary11-entry small, .diary11-empty, .diary11-case small, .diary11-notes header small, .diary11-record-id, .diary11-source-strip, .diary11-attachments > header, .diary11-attachment small, .diary11-muted, .diary11-notes > label, .diary11-note-actions span, .diary11-note-link, .diary11-derived-list > strong, .diary11-derived-list small, .diary11-feedback, .diary11-sidebar footer, .diary11-entry-column > header small, .diary11-entry-column > header span) {
  color: var(--fluent-muted);
  font-size: 11px;
}
.diary11-window :is(.diary11-sidebar footer strong, .diary11-hypothesis) { color: var(--fluent-text); }
.diary11-window .diary11-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  min-width: 0;
  background: var(--fluent-layer);
  border-color: var(--fluent-line);
}
.diary11-window .diary11-sidebar .diary11-search input {
  width: 100%;
  min-width: 0;
  height: 18px;
  min-height: 18px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  line-height: 18px;
}
.diary11-window .diary11-notes > .diary11-hypothesis {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  color: var(--fluent-text);
  font: 400 12px/1.45 var(--fluent-font);
  text-align: left;
}
.diary11-window .diary11-hypothesis span {
  min-width: 0;
  margin: 0;
  color: inherit;
  font-size: 12px;
  font-weight: 400;
}
.diary11-window .diary11-hypothesis input[type="checkbox"] {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
  box-shadow: none;
}
.diary11-window .diary11-notes textarea { font: 13px/1.65 var(--fluent-font); }
.diary11-window .diary11-notes header button { width: 32px; height: 32px; }
.diary11-window .diary11-note-actions button.is-danger {
  color: var(--fluent-text);
  background: var(--fluent-layer);
  border-color: var(--fluent-line);
}
.diary11-window :is(.diary11-source-strip > span, .diary11-feedback[data-kind="success"]) { color: var(--secondary-success); }
.diary11-window :is(.diary11-source-strip > span.is-caution, .diary11-contamination, .diary11-contamination strong, .diary11-feedback[data-kind="warning"]) { color: var(--secondary-caution); }
.diary11-window .diary11-contamination { border-left-color: var(--secondary-caution); }

/* Research and case tools use light command bars above scrollable content. */
.research-window .research-layout nav,
.case-tools-window .case-tools-body > aside { background: var(--fluent-base); }
.research-window .research-layout main,
.case-tools-window .case-tools-body > main { background: var(--fluent-layer); }
.research-window :is(.research-sources article, fieldset),
.case-tools-window :is(form, fieldset) {
  background: var(--fluent-base);
  border-color: var(--fluent-line);
  border-radius: 6px;
}
.research-window .research-sources button,
.research-window [data-research-transform] { padding: 6px 12px; }
.research-window .research-source-text,
.case-tools-window pre {
  color: var(--fluent-text);
  background: var(--fluent-subtle);
  border: 1px solid var(--fluent-line);
  border-radius: 6px;
  padding: 16px;
  font: 12px/1.7 Consolas, ui-monospace, monospace;
  overflow-wrap: anywhere;
}
.research-window :is(.research-sources small, [data-research-feedback]),
.case-tools-window :is(small, dt, [data-case-feedback]) { color: var(--fluent-muted); opacity: 1; }
.research-window .research-layout main h2 { margin-top: 0; font-size: 24px; }
.case-tools-window .case-tools-tabs { background: var(--fluent-base); border-color: var(--fluent-line); }
.case-tools-window .case-tools-body :is(form, fieldset) { box-sizing: border-box; }

/* Forensics content never depends on the original hard-coded light palette. */
.forensics11-window .forensics11-shell { color: var(--fluent-text); background: var(--fluent-base); }
.forensics11-window .forensics11-tabs { background: var(--fluent-base); border-color: var(--fluent-line); }
.forensics11-window .forensics11-workbench {
  background: var(--fluent-layer);
  border-color: var(--fluent-line);
  border-radius: 8px;
  box-shadow: none;
}
.forensics11-window .forensics11-source-select { border-color: var(--fluent-line); }
.forensics11-window .forensics11-controls { background: var(--fluent-base); border-radius: 6px; }
.forensics11-window :is(.forensics11-controls label, .forensics11-workbench > header small, .forensics11-workbench > header span, .forensics11-operation, .forensics11-empty) { color: var(--fluent-muted); font-weight: 400; }
.forensics11-window .forensics11-controls button { align-self: end; padding: 7px 12px; }
.forensics11-window :is(.forensics11-hex, .analysis-source-text) {
  color: var(--fluent-text);
  background: var(--fluent-subtle);
  border: 1px solid var(--fluent-line);
  border-radius: 6px;
  font: 12px/1.7 Consolas, ui-monospace, monospace;
}
.forensics11-window .forensics11-spectrum { background: var(--fluent-subtle); border-color: var(--fluent-line); }
.forensics11-window .forensics11-finding {
  color: var(--fluent-text);
  background: var(--fluent-base);
  border-left-color: var(--fluent-accent);
  border-radius: 4px;
}

/* Retain the existing reserved space for the diary's notes pane. */
@media (max-width: 1100px) and (min-width: 901px) {
  .diary11-window .diary11-reading { padding-right: min(36%, 350px); }
}

@media (prefers-reduced-motion: reduce) {
  :is(.diary11-window, .research-window, .case-tools-window, .forensics11-window),
  :is(.diary11-window, .research-window, .case-tools-window, .forensics11-window) * {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
.enigmal-reduced-motion :is(.diary11-window, .research-window, .case-tools-window, .forensics11-window),
.enigmal-reduced-motion :is(.diary11-window, .research-window, .case-tools-window, .forensics11-window) * {
  transition: none !important;
  animation: none !important;
  scroll-behavior: auto !important;
}
