/* The Xenon menu (js/menu/xenon-menu.js): the same rows in its own window (menu.html) and as pages
   of Settings on the dashboard (js/menu/xenon-menu-panel.js). It is Settings' rail and page, because
   the menu's window opens Settings and the Store in place and nothing may jump on the way: a section is
   a title over one well, a row is a name on the left and its control on the right. It looks
   the same under every skin: the rules that meet a skin's list carry #xm-root, the id both
   hosts give the root. Colour is left to state: what is chosen is neutral, a switch that is
   on shows the theme's accent, the one main action is the Store's green. */

/* A page of Settings (#settings-place): Settings has the rail, the title and the scroll, and
   the section is one block across its columns, no wider than its own window would draw it
   (on the Edge the screens and their tabs would drift a screen apart). */
#settings-overlay .settings-place { grid-column: 1 / -1; max-width: 1200px; }
#settings-overlay .settings-group.settings-place::before { content: none; }
.settings-place > .xm { display: block; height: auto; }
.settings-place .xm-main { display: block; padding: 0; overflow: visible; scrollbar-gutter: auto; }
.xm-frame:focus { outline: none; }
.xm-frame {
  --text: var(--cst-text);
  --muted-text: var(--cst-muted);
  --dim-text: var(--cst-muted);
  --text-dim: var(--cst-muted);
  --line: var(--cst-sep);
  --divider: var(--cst-sep);
  --control-bg: var(--cst-well);
  --hover-bg: var(--cst-on);
  --surface: var(--cst-solid);
  --radius-control: 10px;
  --focus-ring: 0 0 0 2px var(--cst-key);
  position: relative;
  width: min(1080px, 100%); height: min(720px, 100%);
  color: var(--cst-text);
  background: var(--cst-page);
  -webkit-backdrop-filter: blur(40px);
  backdrop-filter: blur(40px);
  border: 1px solid var(--cst-sep);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}
:root[data-appearance="light"] .xm-frame { color-scheme: light; }
body.low-power-gpu .xm-frame { -webkit-backdrop-filter: none; backdrop-filter: none; }
@media (prefers-reduced-transparency: reduce) {
  .xm-frame { -webkit-backdrop-filter: none; backdrop-filter: none; }
}
/* In its own window the window is the frame, and there is nothing behind it to frost. */
.xm-page .xm-frame {
  width: 100%; height: 100vh;
  background: var(--cst-solid);
  -webkit-backdrop-filter: none; backdrop-filter: none;
  border: 0; border-radius: 0; box-shadow: none;
}

.xm {
  display: grid; grid-template-columns: 256px minmax(0, 1fr);
  height: 100%; min-height: 0;
  color: var(--cst-text); font-size: 15px;
}
.xm.is-busy { cursor: progress; }
/* No weight of its own: every key below sets its own size and colour. */
:where(.xm) button { font: inherit; color: inherit; }
#xm-root button:focus-visible, #xm-root input:focus-visible { outline: none; box-shadow: var(--focus-ring); }
/* A controller moves the focus by script, which browsers do not always ring: show it while the pad drives. */
#xm-root.xm-pad button:focus, #xm-root.xm-pad input:focus { outline: none; box-shadow: var(--focus-ring); }
/* A switch's input is invisible: the ring goes on its track. */
#xm-root .xm-switch input:focus-visible + .ui-toggle-track, #xm-root.xm-pad .xm-switch input:focus + .ui-toggle-track { box-shadow: var(--focus-ring); }
.xm-ic {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
/* Bit and the Scintilla are made of pixels: a stroke would melt them into a blob. */
.xm-ic.xm-mark { stroke: none; }
.xm-ic.xm-fill { fill: currentColor; stroke: none; }
/* Its 15-cell grid stays crisp only at a whole number of pixels per cell, at 100% and 150% alike. */
.xm .xm-ic.xspark { width: 30px; height: 30px; margin: -5px; }
.xm .xm-tile .xm-ic.xspark { margin: -3px; }
/* Bit's 12 cells: 24 px is a whole number of pixels per cell at 100%, 150% and 200%. */
.xm .xm-ic.xm-mark-bit { width: 24px; height: 24px; margin: -2px; }
.xm .xm-tile .xm-ic.xm-mark-bit { margin: 0; }

/* ── The rail ── */
.xm-nav {
  display: flex; flex-direction: column; gap: 14px; min-height: 0;
  padding: 22px 14px 14px;
  background: var(--cst-rail);
}
.xm-brand { flex: none; display: flex; flex-direction: column; gap: 2px; padding-left: 10px; }
.xm-brand-name { font-size: 26px; font-weight: 700; line-height: 1.2; }
.xm-findbox { position: relative; flex: none; display: block; }
.xm-findbox > .xm-ic {
  position: absolute; left: 12px; top: 50%; width: 18px; height: 18px;
  transform: translateY(-50%); color: var(--cst-muted); pointer-events: none;
}
.xm-nav-list { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; }
.xm-nav-btn, .xm-settings, .xm-bit {
  appearance: none; flex: none; display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 42px; padding: 6px 10px; line-height: 1.2; text-align: left;
  color: var(--cst-muted); background: none; border: 0; border-radius: 10px; cursor: pointer;
  font-size: 15px; font-weight: 600;
}
.xm-nav .xm-ic { width: 19px; height: 19px; }
/* The pixel marks keep their size and take up as much room as the other icons. */
.xm-nav .xm-ic.xspark { width: 30px; height: 30px; margin-inline-end: -6px; }
.xm-nav .xm-ic.xm-mark-bit { width: 24px; height: 24px; margin-inline-end: -3px; }
.xm-nav-btn:hover, .xm-settings:hover, .xm-bit:hover { color: var(--cst-text); background: var(--cst-well); }
.xm-nav-btn[aria-current="true"] { color: var(--cst-text); background: var(--cst-on); }
/* Inside the row: a scrolling list clips whatever leaves its box. */
#xm-root :is(.xm-nav-btn, .xm-settings, .xm-bit):focus-visible,
#xm-root.xm-pad :is(.xm-nav-btn, .xm-settings, .xm-bit):focus { outline: 2px solid var(--cst-key); outline-offset: -2px; box-shadow: none; }
.xm-nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.xm-nav-value { flex: none; margin-left: auto; color: var(--cst-text); font-variant-numeric: tabular-nums; }
.xm-nav-value.is-update { color: var(--cst-danger); }
/* A group of pages, as Settings names it in its rail. */
.xm-nav-head { flex: none; padding: 14px 10px 4px; color: var(--cst-muted); font-size: 13px; font-weight: 600; }
.xm-nav-foot { flex: none; display: flex; flex-direction: column; gap: 2px; padding-top: 8px; border-top: 1px solid var(--cst-sep); }

/* ── One section ── */
/* A maximized window keeps Settings' column, in the middle. */
.xm-main {
  min-width: 0; min-height: 0; overflow-y: auto; scrollbar-gutter: stable;
  display: grid; grid-template-columns: minmax(0, 960px); justify-content: center; align-content: start;
  padding: 22px 32px 40px;
}
.xm-head { display: flex; align-items: flex-start; gap: var(--space-4); margin-bottom: 28px; }
.xm-head .xm-words { flex: 1; }
.xm-title { margin: 0; font-size: 26px; font-weight: 700; line-height: 40px; }
.xm-head .xm-sub { margin: 0; font-size: 15px; }
/* Kept in sight when the section was scrolled down. */
.xm-result:not([hidden]) {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: var(--space-3);
  margin: 0 0 var(--space-4); padding: var(--space-3);
  background: var(--cst-solid); border-radius: 10px; box-shadow: 0 0 0 1px var(--cst-sep);
}
.xm-result[data-type="error"]:not([hidden]), .xm-result[data-type="warning"]:not([hidden]) { box-shadow: 0 0 0 1px var(--color-warn); }
.xm-result-img { flex: none; width: 112px; height: 63px; object-fit: cover; border-radius: 4px; background: var(--cst-well); }
.xm-result-words { flex: 1; min-width: 0; }
.xm-result-words p { margin: 0; overflow-wrap: anywhere; }
.xm-result-kicker, .xm-result-message { color: var(--cst-muted); font-size: 13.5px; font-weight: 500; }
.xm-result-title { font-weight: 600; }
.xm-result-actions { flex: none; display: flex; gap: var(--space-2); }
.xm-result-act {
  appearance: none; min-height: 44px; padding: 0 14px; font-size: 14.5px; font-weight: 600;
  color: var(--cst-text); background: var(--cst-well); border: 0; border-radius: 10px; cursor: pointer;
}
.xm-result-act:hover { background: var(--cst-on); }
.xm-result-act.is-primary, .xm-result-act.is-primary:hover { color: var(--cst-key-ink); background: var(--cst-key); }

.xm-error { margin: 0 0 var(--space-4); color: var(--color-warn); font-weight: 600; }
.xm-error[hidden] { display: none; }
.xm-body { min-width: 0; display: flex; flex-direction: column; gap: 28px; }
.xm-empty { margin: 0; color: var(--cst-muted); }
/* What a search matched (js/fuzzy-find.js renderHighlighted), as in Settings' own search. */
.xm-row mark { padding: 0 1px; color: inherit; background: color-mix(in srgb, var(--accent) 22%, transparent); border-radius: 3px; }

/* Quick actions */
/* Three columns at most: wider, the last tile sat alone on its own row. */
.xm-tiles {
  display: grid; gap: var(--space-3);
  grid-template-columns: repeat(auto-fill, minmax(max(190px, calc((100% - 2 * var(--space-3)) / 3)), 1fr));
}
.xm-tile {
  appearance: none; cursor: pointer; text-align: left;
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-content: center; column-gap: var(--space-3);
  min-height: 60px; padding: var(--space-2) var(--space-3);
  background: var(--cst-well); border: 0; border-radius: 10px;
}
.xm-tile:hover:enabled { background: var(--cst-on); }
.xm-tile:disabled { cursor: default; }
.xm-tile:disabled .xm-ic, .xm-tile:disabled .xm-tile-label { color: var(--cst-muted); }
.xm-tile .xm-ic { grid-row: span 3; align-self: start; width: 24px; height: 24px; color: var(--cst-text); }
.xm-tile-label { font-size: 15px; font-weight: 600; overflow-wrap: break-word; }
.xm-tile-sub { grid-column: 2; font-size: 13.5px; font-weight: 500; line-height: 1.3; color: var(--cst-muted); overflow-wrap: break-word; }
.xm-tile-key { grid-column: 2; margin-top: 2px; font-size: 13.5px; font-weight: 500; color: var(--cst-muted); }

/* A group's name, close to what it names. */
.xm-heading { margin: 0 0 -18px; padding: 0 2px; font-size: 17px; font-weight: 700; color: var(--cst-text); }
/* A page, under "Your widgets": its name first, which one is in use beside it. */
.xm-heading--page { font-size: 15px; font-weight: 600; }
.xm-heading-note { margin-inline-start: var(--space-2); font-size: 13.5px; font-weight: 500; color: var(--cst-muted); }

/* Rows */
.xm-list { display: flex; flex-direction: column; background: var(--cst-well); border-radius: 10px; }
.xm-row {
  display: flex; align-items: center; gap: 24px;
  min-height: 56px; padding: 10px 16px;
}
/* A hairline 16 px in from the well's edges, as in Settings. An image: a row's hover colour leaves it. */
.xm-row + .xm-row {
  background-image: linear-gradient(var(--cst-sep), var(--cst-sep));
  background-position: 16px 0; background-size: calc(100% - 32px) 1px; background-repeat: no-repeat;
}
.xm-row--stack { flex-wrap: wrap; row-gap: var(--space-2); padding-block: var(--space-3); }
.xm-row--stack > .xm-words { flex-basis: 100%; }
.xm-row--wrap { flex-wrap: wrap; row-gap: var(--space-2); padding-block: var(--space-3); }
.xm-row--wrap > .xm-search { flex-basis: 100%; }
.xm-words { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.xm-label { font-size: 15px; font-weight: 600; }
.xm-sub { color: var(--cst-muted); font-size: 13.5px; font-weight: 500; line-height: 1.4; }
.xm-value { color: var(--cst-muted); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; min-width: 0; }
.xm-tone-on .xm-value, .xm-tone-on .xm-note { color: var(--accent-ink, var(--accent)); }
.xm-tone-warn .xm-value, .xm-tone-warn .xm-note { color: var(--color-warn); }
/* Settings' keys, 44 px tall: this menu is also used with a finger. */
#xm-root .ui-btn { min-height: 44px; padding: 0 14px; border: 0; border-radius: 10px; box-shadow: none; font-size: 14.5px; font-weight: 600; line-height: 1.2; }
#xm-root .ui-btn--secondary { color: var(--cst-text); background: var(--cst-well); }
#xm-root .ui-btn--secondary:hover:not(:disabled) { background: var(--cst-on); }
#xm-root .ui-btn--primary { color: var(--cst-key-ink); background: var(--cst-key); }
.xm-act { flex: none; }
#xm-root .xm-act[aria-expanded="true"] { background: var(--cst-on); }
.xm-acts { display: flex; flex-wrap: wrap; gap: var(--space-2); flex: none; max-width: 100%; }
#xm-root .xm-switch { flex: none; width: 44px; height: 26px; border: 0; }
/* The 44x26 switch takes presses from a 48x48 square around it. */
#xm-root .xm-switch input { inset: -11px -2px; width: auto; height: auto; }
#xm-root .xm-switch .ui-toggle-track { border: 0; border-radius: 13px; background: rgba(255, 255, 255, 0.18); }
:root[data-appearance="light"] #xm-root .xm-switch input:not(:checked) + .ui-toggle-track { background: rgba(20, 24, 44, 0.16); }
#xm-root .xm-switch .ui-toggle-track::after { top: 3px; left: 3px; width: 20px; height: 20px; border: 0; border-radius: 50%; background: #fff; box-shadow: none; }
#xm-root .xm-switch input:checked + .ui-toggle-track { background: var(--accent); }
#xm-root .xm-switch input:checked + .ui-toggle-track::after { transform: translateX(18px); background: var(--on-accent, #fff); }
