/* Rootweave shared-shell tokens (Architecture v9 §11.1).
 *
 * Tailwind 4 expresses its theme as CSS custom properties; these are that
 * theme, authored by hand so a page renders from this file alone (the
 * host's sign-in page loads nothing else). The Atlas skin in
 * output.css (built from ../../input.css: Tailwind utilities, DaisyUI
 * components, the Atlas faces and the three-pane shell grid) reads these
 * same `--sh-*` tokens rather than declaring a second palette.
 *
 * Colours are the Atlas paper/ink ramp from knowmaps/crates/knowmaps/input.css
 * converted to hex, so tests/theme.rs can hold every pairing to WCAG AA.
 * Both brands share one geometry and type scale and differ only in the accent
 * ramp, so switching brand can never move a control.
 */

/* Cascade order. Everything below sits in the `sh` layer, above Tailwind's
 * preflight (base) and below DaisyUI components and utilities, so a template
 * can refine an `sh-*` element with a utility class. Declared here, first,
 * because tokens.css loads before output.css. */
@layer properties, theme, base, sh, components, utilities;

@layer sh {

/* Theme (daily-UI decision §8). Every colour token is light-dark(light, dark)
 * and resolves against color-scheme: `light dark` follows the system's
 * prefers-color-scheme with no script, and a device override
 * (data-theme="light" | "dark", set from the sh_theme cookie) pins one.
 * Atlas names: surface = paper, surface-raised = paper2, surface-sunken =
 * sunk, border = line, control-border = ink3, text = ink, text-muted = ink2. */
:root {
  color-scheme: light dark;
  --sh-space-1: 0.25rem;
  --sh-space-2: 0.5rem;
  --sh-space-3: 0.75rem;
  --sh-space-4: 1rem;
  --sh-space-6: 1.5rem;
  --sh-space-8: 2rem;

  --sh-radius-sm: 0.375rem;
  --sh-radius-md: 0.625rem;
  --sh-radius-lg: 0.875rem;

  /* Typography (daily-UI decision §8, U4.2). One stack for the whole shell;
   * monospace is for code only. These are the system stacks; output.css
   * prepends the self-hosted Atlas faces (Hanken Grotesk, JetBrains Mono).
   * The prose body is 17 px / 1.6 and headings step 28 / 22 / 18 px. */
  --sh-font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sh-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --sh-text-sm: 0.875rem;
  --sh-text-base: 1rem;
  --sh-text-lg: 1.125rem;
  --sh-text-xl: 1.5rem;
  --sh-text-body: 1.0625rem;
  --sh-leading-body: 1.6;
  --sh-text-h1: 1.75rem;
  --sh-text-h2: 1.375rem;
  --sh-text-h3: 1.125rem;
  --sh-leading-heading: 1.25;

  --sh-facet-width: 16rem;
  --sh-measure: 68ch;

  --sh-surface: light-dark(#f9f5ed, #201b15);
  --sh-surface-raised: light-dark(#fdfaf3, #2a241e);
  --sh-surface-sunken: light-dark(#f5f0e6, #1e150e);
  --sh-border: light-dark(#e2dbd1, #37322b);
  /* Interactive boundaries (inputs, quiet buttons) need 3:1 non-text
   * contrast (WCAG 1.4.11); decorative borders keep the softer --sh-border. */
  --sh-control-border: light-dark(#827a72, #979187);
  --sh-text: light-dark(#29211a, #f5f1e8);
  --sh-text-muted: light-dark(#594f47, #b6b0a6);
  --sh-danger: light-dark(#a4243b, #ef8497);
  --sh-ok: light-dark(#1d6f42, #6cc08b);
  --sh-highlight: light-dark(#fff0a3, #5a4700);
  /* Floating layers (receipt toast, palette): a lift and a scrim. */
  --sh-shadow-color: light-dark(rgb(0 0 0 / 0.18), rgb(0 0 0 / 0.55));
  --sh-shadow: 0 4px 16px var(--sh-shadow-color);
  --sh-scrim: light-dark(rgb(0 0 0 / 0.4), rgb(0 0 0 / 0.6));
}

/* An engine without light-dark() would drop every colour token; it keeps
 * the light palette instead. */
@supports not (color: light-dark(#000000, #ffffff)) {
  :root {
    --sh-surface: #f9f5ed;
    --sh-surface-raised: #fdfaf3;
    --sh-surface-sunken: #f5f0e6;
    --sh-border: #e2dbd1;
    --sh-control-border: #827a72;
    --sh-text: #29211a;
    --sh-text-muted: #594f47;
    --sh-danger: #a4243b;
    --sh-ok: #1d6f42;
    --sh-highlight: #fff0a3;
    --sh-shadow-color: rgb(0 0 0 / 0.18);
    --sh-scrim: rgb(0 0 0 / 0.4);
  }

  [data-brand="knowmaps"] {
    --sh-accent: #2f5d8c;
    --sh-accent-contrast: #ffffff;
  }

  [data-brand="askai"] {
    --sh-accent: #5a3f8c;
    --sh-accent-contrast: #ffffff;
  }
}

[data-theme="light"] {
  color-scheme: light;
}

[data-theme="dark"] {
  color-scheme: dark;
}

[data-brand="knowmaps"] {
  --sh-accent: light-dark(#2f5d8c, #7aa8d6);
  --sh-accent-contrast: light-dark(#ffffff, #0c0e12);
}

[data-brand="askai"] {
  --sh-accent: light-dark(#5a3f8c, #b09ada);
  --sh-accent-contrast: light-dark(#ffffff, #0c0e12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body.sh-body {
  margin: 0;
  background: var(--sh-surface);
  color: var(--sh-text);
  font-family: var(--sh-font-sans);
  font-size: var(--sh-text-base);
  line-height: 1.5;
}

/* User agents give controls their own font (a textarea is monospace); they
 * take the shell's stack instead. */
button,
input,
select,
textarea {
  font: inherit;
}

code,
kbd,
samp,
pre {
  font-family: var(--sh-font-mono);
}

code,
kbd,
samp {
  font-size: 0.9em;
}

/* Prose: the Focus reader and editor. */
.sh-prose {
  font-size: var(--sh-text-body);
  line-height: var(--sh-leading-body);
  max-width: var(--sh-measure);
}

.sh-prose h1,
.sh-prose h2,
.sh-prose h3 {
  line-height: var(--sh-leading-heading);
  margin: 1.5em 0 0.5em;
}

.sh-prose h1 {
  font-size: var(--sh-text-h1);
}

.sh-prose h2 {
  font-size: var(--sh-text-h2);
}

.sh-prose h3 {
  font-size: var(--sh-text-h3);
}

.sh-prose > :first-child {
  margin-top: 0;
}

.sh-prose p,
.sh-prose ul,
.sh-prose ol,
.sh-prose pre,
.sh-prose blockquote {
  margin: 0 0 1em;
}

.sh-prose ul,
.sh-prose ol {
  padding-left: 1.5em;
}

.sh-prose li + li {
  margin-top: 0.25em;
}

.sh-prose [data-task-list] {
  list-style: none;
  padding-left: 0;
}

.sh-prose [data-task-item] {
  display: flex;
  align-items: baseline;
  gap: var(--sh-space-2);
}

.sh-prose [data-task-item] > p {
  margin: 0;
}

.sh-prose [data-task-item][data-checked="true"] > p {
  color: var(--sh-text-muted);
  text-decoration: line-through;
}

/* The read view's checkbox is a one-button form (§4.11 CAS, JS-off). */
.sh-task__toggle {
  flex: none;
  margin: 0;
}

.sh-task__box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25em;
  height: 1.25em;
  padding: 0;
  border: 1px solid var(--sh-text-muted);
  border-radius: var(--sh-radius-sm);
  background: var(--sh-surface);
  color: var(--sh-accent-contrast);
  font-size: var(--sh-text-sm);
  line-height: 1;
  cursor: pointer;
}

.sh-task__box[aria-checked="true"] {
  border-color: var(--sh-accent);
  background: var(--sh-accent);
}

.sh-prose blockquote {
  padding-left: var(--sh-space-3);
  border-left: 3px solid var(--sh-border);
  color: var(--sh-text-muted);
}

/* In the Wordgard editor a task item is a list item carrying data-checked
   (NOTE-5 patch 0001); its box is drawn, and toggled from the read view. */
.sh-editor li[data-checked] {
  display: flex;
  align-items: baseline;
  gap: var(--sh-space-2);
  list-style: none;
}

.sh-editor li[data-checked] > p {
  margin: 0;
}

.sh-editor li[data-checked]::before {
  content: "☐";
  flex: none;
  margin-left: -1.5em;
}

.sh-editor li[data-checked="true"]::before {
  content: "☑";
}

.sh-prose pre {
  padding: var(--sh-space-3);
  border-radius: var(--sh-radius-sm);
  background: var(--sh-surface-sunken);
  font-size: var(--sh-text-sm);
  line-height: 1.5;
  overflow-x: auto;
}

.sh-prose pre code {
  font-size: inherit;
}

.sh-skip-link {
  position: absolute;
  left: -9999px;
}

.sh-skip-link:focus {
  left: var(--sh-space-2);
  top: var(--sh-space-2);
  z-index: 10;
  padding: var(--sh-space-2);
  background: var(--sh-accent);
  color: var(--sh-accent-contrast);
  border-radius: var(--sh-radius-sm);
}

a {
  color: var(--sh-accent);
}

/* Every keyboard operative wears the one ring (WCAG 2.4.7): the facet
   rail's <summary> disclosures and checkboxes as much as links/buttons,
   and selects, text areas and anything given a tabindex (U2). */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--sh-accent);
  outline-offset: 2px;
}

.sh-heading {
  font-size: var(--sh-text-h1);
  line-height: var(--sh-leading-heading);
  margin: 0 0 var(--sh-space-4);
}

.sh-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sh-space-2);
}

.sh-list__empty {
  color: var(--sh-text-muted);
}

.sh-card + .sh-card {
  margin-top: var(--sh-space-4);
}

/* One task per row: title, state, and the CAS submit stay on one line so a
   long list reads as a list rather than a stack of forms. In a narrow card
   the row wraps rather than squeezing the title until the columns collide. */
.sh-form.sh-task {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sh-space-3);
  flex-direction: row;
  flex-wrap: wrap;
}

.sh-task__state {
  color: var(--sh-text-muted);
  font-size: var(--sh-text-sm);
  margin-left: auto;
}

/* The title takes the slack; the meta and the control keep their own width. */
.sh-task > span:first-of-type {
  flex: 1 1 8rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.sh-task > .sh-card__meta,
.sh-task__state,
.sh-task .sh-button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.sh-card {
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-radius-md);
  background: var(--sh-surface-raised);
  padding: var(--sh-space-4);
}

.sh-card__title {
  font-size: var(--sh-text-lg);
  margin: 0 0 var(--sh-space-2);
}

.sh-card__meta {
  color: var(--sh-text-muted);
  font-size: var(--sh-text-sm);
}

/* Search (daily-UI U2.1). A rail link `/` follows; the page is plain
 * HTML: a GET form, hits grouped by note, the provider's histogram. */
.sh-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sh-space-6);
}

@media (min-width: 64rem) {
  .sh-search {
    grid-template-columns: minmax(0, 1fr) var(--sh-facet-width);
  }
}

.sh-search__form {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
}

.sh-search__form .sh-form__control {
  flex: 1 1 16rem;
}

.sh-hits {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sh-space-2);
}

.sh-hit__link {
  display: block;
  padding: var(--sh-space-2) var(--sh-space-3);
  border-radius: var(--sh-radius-sm);
  color: var(--sh-text);
  text-decoration: none;
}

.sh-hit__link:hover,
.sh-hit__link:focus-visible {
  background: var(--sh-surface-sunken);
}

.sh-hit__snippet {
  margin: 0 0 var(--sh-space-1);
  overflow-wrap: anywhere;
}

.sh-hit__mark {
  background: var(--sh-highlight);
  color: var(--sh-text);
  border-radius: var(--sh-radius-sm);
}

.sh-histogram {
  list-style: none;
  margin: 0 0 var(--sh-space-4);
  padding: 0;
}

.sh-histogram__row {
  display: flex;
  justify-content: space-between;
  gap: var(--sh-space-2);
  font-size: var(--sh-text-sm);
}

.sh-histogram__bar {
  display: block;
  width: 100%;
  height: 0.375rem;
  margin: var(--sh-space-1) 0 var(--sh-space-2);
  accent-color: var(--sh-accent);
}

/* A hit's `#<block-ulid>` lands on its block: JS-off, CSS only. */
.sh-prose [data-block-id]:target {
  background: var(--sh-highlight);
  color: var(--sh-text);
  outline: 2px solid var(--sh-accent);
  outline-offset: 2px;
  border-radius: var(--sh-radius-sm);
  scroll-margin-top: var(--sh-space-8);
}

.sh-form {
  display: flex;
  flex-direction: column;
  gap: var(--sh-space-3);
}

.sh-form__row {
  display: flex;
  flex-direction: column;
  gap: var(--sh-space-1);
}

.sh-form__control {
  padding: var(--sh-space-2);
  border: 1px solid var(--sh-control-border);
  border-radius: var(--sh-radius-sm);
  background: var(--sh-surface);
  color: var(--sh-text);
}

.sh-button {
  /* Anchors wear this class too (Edit, Cancel), so it must lay out as a
     block-level control instead of inline text that collides with a
     neighbouring button. */
  display: inline-block;
  padding: var(--sh-space-2) var(--sh-space-4);
  border: 1px solid var(--sh-accent);
  border-radius: var(--sh-radius-sm);
  background: var(--sh-accent);
  color: var(--sh-accent-contrast);
  font: inherit;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

a.sh-button {
  color: var(--sh-accent-contrast);
  margin-top: var(--sh-space-3);
}

a.sh-button--quiet {
  color: var(--sh-text);
}

.sh-button--quiet {
  background: transparent;
  color: var(--sh-text);
  border-color: var(--sh-control-border);
}

.sh-score-rail__title {
  margin: 0;
  font-size: var(--sh-text-sm);
  color: var(--sh-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Focus stacks four rails; without a gap they read as one list. */
.sh-score-rail + .sh-score-rail {
  margin-top: var(--sh-space-4);
}
.sh-score-rail {
  display: flex;
  flex-direction: column;
  gap: var(--sh-space-2);
  border-left: 1px solid var(--sh-border);
  padding-left: var(--sh-space-4);
}

.sh-score-rail__row {
  display: flex;
  justify-content: space-between;
  gap: var(--sh-space-4);
  font-size: var(--sh-text-sm);
}

/* The facet rail (§6.11) lives in the Atlas sidebar. <details> collapses
   it, and each dimension, without scripting. Width follows the sidebar. */
.sh-facet-rail {
  margin-top: var(--sh-space-4);
  padding-top: var(--sh-space-3);
  border-top: 1px solid var(--sh-border);
  width: auto;
}

.sh-facet-rail__summary {
  font-weight: 600;
  cursor: pointer;
}

.sh-facet-rail__presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sh-space-2);
  margin-block: var(--sh-space-3);
}

.sh-facet-rail__presets [aria-current="true"] {
  font-weight: 600;
  text-decoration: underline;
}

.sh-facet-bar__group + .sh-facet-bar__group {
  margin-top: var(--sh-space-3);
}

.sh-facet-bar__legend {
  font-weight: 600;
  font-size: var(--sh-text-sm);
  cursor: pointer;
}

.sh-facet-bar__values {
  border: 0;
  margin: 0;
  padding: var(--sh-space-2) 0 0;
  display: grid;
  gap: var(--sh-space-1);
}

.sh-facet-value,
.sh-facet-door {
  display: flex;
  align-items: baseline;
  gap: var(--sh-space-2);
  font-size: var(--sh-text-sm);
  min-width: 0;
}

.sh-facet-value__name {
  overflow-wrap: anywhere;
  min-width: 0;
}

.sh-facet-count {
  margin-left: auto;
  color: var(--sh-text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* A door (FAC-15): no results under these filters, results behind it. */
.sh-facet-door {
  color: var(--sh-text-muted);
  border: 1px dashed var(--sh-border);
  border-radius: var(--sh-radius-md);
  padding: var(--sh-space-1) var(--sh-space-2);
  flex-wrap: wrap;
}

.sh-facet-door .sh-facet-count {
  margin-left: 0;
  white-space: normal;
}

.sh-facet-bar__empty {
  margin: 0;
  font-size: var(--sh-text-sm);
  color: var(--sh-text-muted);
}

.sh-facet-bar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sh-space-2);
  margin-top: var(--sh-space-4);
}

.sh-dialog-sheet {
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-radius-lg);
  background: var(--sh-surface);
  padding: var(--sh-space-6);
}

.sh-toast-receipt {
  border: 1px solid var(--sh-border);
  border-left: 4px solid var(--sh-ok);
  border-radius: var(--sh-radius-sm);
  background: var(--sh-surface-raised);
  padding: var(--sh-space-3);
}

.sh-toast-receipt--conflict {
  border-left-color: var(--sh-danger);
}

.sh-conflict-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sh-space-3);
  margin-block-end: var(--sh-space-4);
}

.sh-conflict-banner > p {
  margin: 0;
  min-width: 0;
  /* The message names the head, one long unbreakable id. */
  overflow-wrap: anywhere;
}

.sh-error {
  display: grid;
  gap: var(--sh-space-4);
  max-width: var(--sh-measure);
  border: 1px solid var(--sh-border);
  border-left: 4px solid var(--sh-danger);
  border-radius: var(--sh-radius-sm);
  background: var(--sh-surface-raised);
  padding: var(--sh-space-4);
}

.sh-error__message,
.sh-error__back {
  margin: 0;
}

.sh-grid-widgets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: var(--sh-space-4);
}

.sh-split {
  display: grid;
  grid-template-columns: var(--sh-facet-width) minmax(0, 1fr);
  gap: var(--sh-space-6);
  align-items: start;
}

/* The Library landing (daily-UI decision §2–§3). Below 1024 px the list and
   Focus are two modes of one pane, picked by the List/Note switch's
   `data-landing-mode` (the switch is what a row's swap redraws, so the mode
   flips with no page load); at >= 1024 px (64rem, below) they sit side by
   side. */
.sh-landing {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sh-space-6);
  align-items: start;
}

.sh-landing__modes[data-landing-mode="list"] ~ .sh-landing .sh-landing__focus,
.sh-landing__modes[data-landing-mode="focus"] ~ .sh-landing .sh-landing__list {
  display: none;
}

.sh-landing__modes {
  display: flex;
  gap: var(--sh-space-2);
  margin-bottom: var(--sh-space-4);
}

.sh-landing__modes .sh-button {
  margin-top: 0;
}

.sh-landing__rows {
  gap: 0;
}

.sh-landing__item {
  display: flex;
  flex-direction: column;
  gap: var(--sh-space-1);
  padding: var(--sh-space-2) var(--sh-space-3);
  border-radius: var(--sh-radius-sm);
}

/* The note in Focus is the marked row. The keys move focus, so the row they
   select wears the focus ring rather than a second identical highlight. */
.sh-landing__item:has(> [aria-current="true"]) {
  background: var(--sh-surface-sunken);
}

.sh-landing__row {
  color: var(--sh-text);
  font-weight: 600;
  text-decoration: none;
}

.sh-landing__row:hover {
  text-decoration: underline;
}

.sh-landing__title {
  font-size: var(--sh-text-h2);
  line-height: var(--sh-leading-heading);
  margin: 0 0 var(--sh-space-4);
}

.sh-landing__title a {
  color: var(--sh-text);
}

/* Stage and rule ids on a placeholder page (decision 2026-09-25 §1). */
.sh-placeholder__facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--sh-space-1) var(--sh-space-4);
  margin: var(--sh-space-4) 0;
}

.sh-placeholder__facts dt {
  font-weight: 600;
}

.sh-placeholder__facts dd {
  margin: 0;
}

@media (max-width: 48rem) {
  .sh-split {
    grid-template-columns: minmax(0, 1fr);
  }

  .sh-facet-rail {
    width: auto;
  }
}

/* Settings theme toggle: one form per choice, laid out as a row. */
.sh-theme-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sh-space-2);
}

/* >= 1024 px (owner decision 2026-09-29, the Atlas breakpoint): the Library
   list and Focus sit side by side, so both modes show at once and the
   List/Note switch has nothing left to switch. */
@media (min-width: 64rem) {
  .sh-landing {
    grid-template-columns: minmax(18rem, 26rem) minmax(0, 1fr);
  }

  .sh-landing__modes[data-landing-mode] ~ .sh-landing .sh-landing__list,
  .sh-landing__modes[data-landing-mode] ~ .sh-landing .sh-landing__focus {
    display: block;
  }

  .sh-landing__focus {
    border-left: 1px solid var(--sh-border);
    padding-left: var(--sh-space-6);
  }

  .sh-landing__modes {
    display: none;
  }
}

.sh-kbd {
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-radius-sm);
  background: var(--sh-surface-sunken);
  color: var(--sh-text);
  padding: 0 var(--sh-space-1);
  font-size: var(--sh-text-sm);
}

/* The scope every view is read in (decision §7); Contexts choose it. */
.sh-scope {
  margin: 0 0 var(--sh-space-2);
  color: var(--sh-text-muted);
  font-size: var(--sh-text-sm);
}

/* Receipt toasts: in the page flow with scripting off, floating above it
   with scripting on (keynav.js adds the dismiss control and timer). */
.sh-toast-receipt[data-toast] {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sh-space-3);
  margin-block-end: var(--sh-space-4);
}

.sh-toast-receipt__message {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* `.sh-button` sets a display, which would otherwise override `hidden` on
   the JS-revealed controls (palette trigger, dismiss, key switch). */
.sh-button[hidden] {
  display: none;
}

@media (scripting: enabled) {
  .sh-toast-receipt[data-toast] {
    position: fixed;
    z-index: 10;
    inset-block-end: var(--sh-space-4);
    inset-inline-end: var(--sh-space-4);
    max-width: min(28rem, calc(100vw - 2 * var(--sh-space-4)));
    margin: 0;
    box-shadow: var(--sh-shadow);
  }
}

/* The command palette (U1.4): a modal <dialog> built by keynav.js. */
.sh-palette {
  width: min(36rem, calc(100vw - 2 * var(--sh-space-4)));
  margin: 12vh auto auto;
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-radius-md);
  background: var(--sh-surface);
  color: var(--sh-text);
  padding: var(--sh-space-3);
}

.sh-palette::backdrop {
  background: var(--sh-scrim);
}

.sh-palette__input {
  width: 100%;
  box-sizing: border-box;
}

.sh-palette__list {
  list-style: none;
  margin: var(--sh-space-2) 0 0;
  padding: 0;
  max-height: 50vh;
  overflow-y: auto;
}

.sh-palette__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sh-space-3);
  padding: var(--sh-space-2) var(--sh-space-3);
  border-radius: var(--sh-radius-sm);
}

.sh-palette__option {
  cursor: pointer;
}

.sh-palette__option[aria-selected="true"] {
  background: var(--sh-accent);
  color: var(--sh-accent-contrast);
}

.sh-palette__empty {
  margin: var(--sh-space-2) 0 0;
  padding: var(--sh-space-2) var(--sh-space-3);
  color: var(--sh-text-muted);
}

.sh-palette__empty[hidden] {
  display: none;
}

.sh-palette__status {
  margin: var(--sh-space-2) 0 0;
  color: var(--sh-danger);
}

.sh-palette__status:empty {
  display: none;
}

/* Password step-up ([SEC-13]). Closed until stepup.js calls showModal. A
   raised sheet over the scrim: the title, one line of why, the field, the
   error when there is one, then Cancel and Confirm on one row at the end. */
.sh-stepup {
  /* Preflight zeroes every margin; the UA centres a modal dialog with
     `margin: auto`, so the sheet says it again or it sits in the corner. */
  margin: auto;
  width: min(26rem, calc(100vw - 2 * var(--sh-space-4)));
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-radius-lg);
  background: var(--sh-surface-raised);
  color: var(--sh-text);
  padding: var(--sh-space-5, 1.25rem) var(--sh-space-5, 1.25rem) var(--sh-space-4);
  box-shadow: 0 1.5rem 3.5rem -1rem var(--sh-shadow-color);
}

.sh-stepup::backdrop {
  background: var(--sh-scrim);
}

.sh-stepup > .sh-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--sh-space-3) var(--sh-space-2);
  margin: 0;
}

.sh-stepup > .sh-form > :not(.sh-button) {
  grid-column: 1 / -1;
  margin: 0;
}

.sh-stepup > .sh-form > .sh-button {
  margin: var(--sh-space-2) 0 0;
}

.sh-stepup > .sh-form > .sh-button:first-of-type {
  grid-column: 2;
}

.sh-stepup .sh-heading {
  font-size: 1.25rem;
  line-height: 1.25;
}

.sh-stepup [data-stepup-password-error] {
  color: var(--sh-danger);
}

.sh-stepup [data-stepup-password-error]:empty {
  display: none;
}


/* A0 web vault H4-H7: badges, coverage, revisions, organizing, capture tabs. */
.sh-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sh-space-2);
  margin-block: var(--sh-space-2);
}

.sh-badge {
  display: inline-block;
  padding: 0 var(--sh-space-2);
  border: 1px solid var(--sh-border);
  border-radius: var(--sh-radius-sm);
  font-size: var(--sh-text-sm);
  color: var(--sh-text);
  background: var(--sh-surface-raised);
}

/* Provenance and coverage: what is known, never a health signal. */
.sh-badge--epistemic {
  border-color: var(--sh-control-border);
}

/* Next-action status; at most two are shown. */
.sh-badge--operational {
  background: var(--sh-surface-sunken);
}

.sh-badge--queued {
  border-style: dashed;
  border-color: var(--sh-control-border);
}

.sh-badge--refused {
  border-color: var(--sh-danger);
  color: var(--sh-danger);
}

.sh-badges__details {
  flex-basis: 100%;
  font-size: var(--sh-text-sm);
  color: var(--sh-text-muted);
}

.sh-badges__facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--sh-space-1) var(--sh-space-3);
  margin: var(--sh-space-2) 0 0;
}

.sh-coverage {
  font-size: var(--sh-text-sm);
  color: var(--sh-text-muted);
  margin-block: var(--sh-space-2);
}

.sh-revision-label {
  font-size: var(--sh-text-sm);
  color: var(--sh-text-muted);
}

.sh-revision-label--historic {
  color: var(--sh-danger);
}

.sh-organize {
  margin-block-end: var(--sh-space-4);
}

.sh-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sh-space-1);
  list-style: none;
  margin: 0 0 var(--sh-space-2);
  padding: 0;
}

.sh-form--inline {
  display: inline;
}

.sh-tabs {
  display: flex;
  gap: var(--sh-space-3);
  margin-block-end: var(--sh-space-4);
  border-bottom: 1px solid var(--sh-border);
}

.sh-tabs__tab {
  padding: var(--sh-space-2) 0;
  color: var(--sh-text);
}

/* /new capture kinds (H3): the tabs are plain anchors, so the sections are
   switched with :target and no script. Note is the default; targeting Link
   or File hides Note so the page never stacks three forms. */
#new-link:not(:target),
#new-file:not(:target) {
  display: none;
}

body:has(#new-link:target) #new-note,
body:has(#new-file:target) #new-note {
  display: none;
}

.sh-context__filter {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--sh-space-1) var(--sh-space-3);
}

} /* @layer sh */
