
/* A widget's choices: names in one column, what they set in the next. */
.xm-tune { --xm-tune-name: 150px; flex-basis: 100%; min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.xm-tune .xm-row { min-height: 44px; padding: 0; }
.xm-tune .xm-row + .xm-row { background-image: none; }
.xm-tune .xm-row--stack { flex-wrap: nowrap; }
.xm-tune .xm-row--stack > .xm-words { flex: 0 0 var(--xm-tune-name); }
/* Where it goes, how it looks, what it shows: three short groups, not one long stack. */
.xm-tunehead { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--cst-muted); }
.xm-tunehead:not(:first-child) { margin-top: var(--space-2); padding-top: var(--space-3); border-top: 1px solid var(--cst-sep); }

/* A placed widget: the picture it has in the Add list, so it is known at a glance. */
.xm-row--widget > .xm-addthumb { flex: none; width: 72px; font-size: 1.4em; }
.xm-row--off > .xm-addthumb { opacity: 0.45; }
.xm-row--off > .xm-words > .xm-label { color: var(--cst-muted); }

/* Readings to pick: a line of keys per group, a tick on what is shown. */
.xm-checks { display: flex; flex-direction: column; gap: var(--space-2); }
.xm-hint { min-height: 1.4em; margin: 0; }
.xm-chipline { display: flex; align-items: flex-start; gap: var(--space-4); }
.xm-chipline-name { flex: 0 0 var(--xm-tune-name); padding-top: 12px; font-size: 13.5px; font-weight: 600; color: var(--cst-muted); }
.xm-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); min-width: 0; }
.xm-chip { padding-inline: var(--space-3); }
:is(.xm-chip, .xm-choices--multi > .xm-choice)[aria-pressed="true"]::before { content: "\2713"; margin-right: 6px; }

/* Naming a page: the field and its two buttons share a line where they fit. */
.xm-row--stack > .xm-page-name { flex: 1 1 200px; width: auto; min-width: 0; }
.xm-act .xm-mark-bit { margin-block: -2px; margin-inline: -4px 6px; vertical-align: middle; }

/* One answer of several: Settings' segmented control. Several at once are keys of their own. */
.xm-choices { display: flex; flex-wrap: wrap; gap: 2px; width: fit-content; max-width: 100%; padding: 2px; background: var(--cst-well); border-radius: 10px; }
.xm-choices--multi { gap: var(--space-2); padding: 0; background: none; }

/* The live preview of a scene: the page drawn at 1280x720 and scaled down, so a
   scene keeps the composition it has on a real screen. */
.xm-scene-view {
  position: relative; width: 320px; max-width: 100%; aspect-ratio: 16 / 9; overflow: hidden;
  background: var(--cst-well); border-radius: 10px;
}
.xm-scene-frame {
  position: absolute; top: 0; left: 0; width: 1280px; height: 720px; border: 0;
  transform: scale(.25); transform-origin: top left; pointer-events: none; visibility: hidden;
}
.xm-scene-frame.is-ready { visibility: visible; }
.xm-choice, .xm-addchoice {
  appearance: none; cursor: pointer; min-height: 44px; padding: 0 14px;
  color: var(--cst-muted); background: var(--cst-well); border: 0; border-radius: 10px;
  font-size: 14px; font-weight: 600;
}
.xm-addchoice { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: var(--space-2); color: var(--cst-text); text-align: left; }
.xm-choice:hover, .xm-addchoice:hover { color: var(--cst-text); background: var(--cst-on); }
.xm-choice[aria-pressed="true"] { color: var(--cst-text); background: var(--cst-on); }
.xm-choices:not(.xm-choices--multi) > .xm-choice { min-height: 40px; border-radius: 8px; background: none; }
.xm-choices:not(.xm-choices--multi) > .xm-choice:hover { background: var(--cst-well); }
.xm-choices:not(.xm-choices--multi) > .xm-choice[aria-pressed="true"] { background: var(--cst-on); }
.xm-app { display: inline-flex; align-items: center; gap: var(--space-2); }
.xm-app-icon { flex: none; width: 24px; height: 24px; object-fit: contain; }
.xm-place-says:has(.xm-app-icon) { display: flex; align-items: center; gap: var(--space-2); }

/* Three ways to use Xenon: cards on the page, not cards in a row of a list. */
.xm-row--modes { padding: 0; }
.xm-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); width: 100%; }
.xm-mode {
  appearance: none; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 4px; min-height: 88px; padding: var(--space-4);
  background: var(--cst-well); border: 0; border-radius: 10px;
}
.xm-mode:hover, .xm-mode[aria-pressed="true"] { background: var(--cst-on); }
.xm-mode-name { font-size: 15px; font-weight: 600; }
.xm-mode[aria-pressed="true"] .xm-mode-name::after { content: "\2713"; margin-inline-start: 6px; }

.xm-combo {
  appearance: none; cursor: pointer; flex: none; min-width: 150px; min-height: 44px; padding: 0 14px;
  font-size: 14.5px; font-variant-numeric: tabular-nums; font-weight: 600;
  color: var(--cst-text); background: var(--cst-well); border: 0; border-radius: 10px;
}
.xm-combo:hover { background: var(--cst-on); }
.xm-combo.is-recording { color: var(--accent-ink, var(--accent)); }

#xm-root .xm-search {
  width: 100%; min-height: 44px; padding: 0 var(--space-3);
  font: inherit; font-size: 14.5px; font-weight: 500; color: var(--cst-text); background: var(--cst-well);
  border: 0; border-radius: 10px; box-shadow: none;
}
#xm-root .xm-search:focus { outline: 1.5px solid var(--cst-muted); outline-offset: -1.5px; box-shadow: none; }
#xm-root .xm-search::placeholder { color: var(--cst-muted); opacity: 1; }
/* Neutral, as in Settings: it takes the focus every time the window opens, and a green ring
   there would read as the page's main thing. */
#xm-root .xm-find { flex: none; height: 40px; min-height: 40px; padding: 0 12px 0 38px; font-size: 15px; }
#xm-root .xm-find:focus { outline: 1.5px solid var(--cst-muted); outline-offset: -1.5px; }
.xm-addcats { flex-basis: 100%; }
.xm-addlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: var(--space-2); width: 100%; }
.xm-addthumb {
  display: grid; place-items: center; aspect-ratio: 3 / 2; overflow: hidden;
  color: var(--cst-muted); background: var(--cst-solid); border-radius: 6px;
  font-size: 2.4em; font-weight: 600;
}
.xm-addthumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.xm-addname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xm-addtag { font-size: 0.8em; color: var(--cst-gold); }
.xm-addsub { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }

/* A mouse needs these bars in a narrow window; the system's wide ones look foreign here. */
.xm-nav, .xm-nav-list, .xm-main { scrollbar-width: thin; scrollbar-color: var(--cst-sep) transparent; }

/* ── Phone width: sections in a row on top, one column below ── */
@media (max-width: 720px) {
  .xm-result:not([hidden]) { flex-wrap: wrap; }
  .xm { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .xm-nav {
    flex-direction: row; align-items: center; gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    overflow-x: auto;
    scrollbar-width: none;   /* the current section scrolls into view, the cut label shows there is more */
  }
  .xm-brand { display: none; }
  .xm-findbox { width: 170px; }
  .xm-nav-list { flex: none; flex-direction: row; overflow: visible; }
  .xm-nav-head { display: none; }
  .xm-nav-btn, .xm-settings, .xm-bit { width: auto; min-height: 44px; white-space: nowrap; }
  .xm-nav-foot { flex-direction: row; padding-top: 0; border-top: 0; }
  .xm-main { padding: var(--space-4); }
  .xm-head { position: relative; margin-bottom: var(--space-5); }
  .xm-title { font-size: 22px; line-height: 1.3; }
  .xm-tiles { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
  .xm-modes { grid-template-columns: minmax(0, 1fr); }
  .xm-row { flex-wrap: wrap; }
  .xm-row--two { padding-block: var(--space-3); }
  .xm-row--two > .xm-words { flex-basis: 100%; }
  .xm-row--widget > .xm-words { flex-basis: calc(100% - 72px - var(--space-4)); }
  .xm-tune .xm-row--stack { flex-wrap: wrap; gap: var(--space-2); }
  .xm-tune .xm-row--stack > .xm-words { flex-basis: 100%; }
  .xm-chipline { flex-direction: column; gap: var(--space-2); }
  .xm-chipline-name { flex: none; padding-top: 0; }
  .xm-hint { min-height: 2.8em; }
  .xm-addlist { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .xm-combo { min-width: 0; }
  .xm-value { text-align: left; }
}

/* A finger on a handheld's small screen: 48 px targets instead of 44. */
@media (pointer: coarse) {
  .xm-nav-btn, .xm-settings, .xm-bit, .xm-choice, .xm-addchoice, .xm-combo { min-height: 48px; }
  #xm-root .ui-btn, #xm-root .xm-search { min-height: 48px; }
  .xm-choices:not(.xm-choices--multi) > .xm-choice { min-height: 44px; }
}

/* ── The "Main screen" tile (js/alerts/screen-tile.js) ── */
.screen-tile-mount {
  display: flex; flex-direction: column; gap: var(--space-3);
  height: 100%; min-height: 0; padding: var(--space-4);
  color: var(--text);
}
.scr-head { display: flex; align-items: center; flex: none; }
.scr-title { font-weight: 700; font-size: 15px; }
.scr-body { display: flex; flex-direction: column; gap: var(--space-4); flex: 1; min-height: 0; overflow-y: auto; }
.scr-error { margin: 0; color: var(--color-warn); font-size: 13px; font-weight: 600; }
.scr-error[hidden] { display: none; }
.scr-empty { margin: 0; color: var(--text-dim); font-size: 13px; }
.scr-group { display: flex; flex-direction: column; gap: var(--space-2); }
.scr-group-head { display: flex; align-items: baseline; gap: var(--space-2); min-width: 0; }
.scr-group-title { font-weight: 650; font-size: 13px; }
.scr-group-sub { color: var(--text-dim); font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scr-quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: var(--space-2); }
.scr-quick-btn {
  appearance: none; cursor: pointer; font: inherit; color: inherit;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: var(--space-2);
  min-height: 72px; padding: var(--space-3);
  background: var(--control-bg); border: 1px solid var(--line); border-radius: var(--radius-control);
}
.scr-quick-btn:hover { background: var(--hover-bg); border-color: var(--accent); }
.scr-quick-btn:focus-visible, .screen-tile-mount .ui-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.scr-quick-btn .xm-ic { color: var(--accent-ink, var(--accent)); }
.scr-quick-label { font-size: 13px; font-weight: 600; text-align: left; overflow-wrap: break-word; hyphens: auto; }
.scr-list { display: flex; flex-direction: column; }
.scr-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); min-height: 32px; padding: 6px 0; }
.scr-row + .scr-row { border-top: 1px solid var(--line); }
.scr-name { font-size: 13px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scr-value { font-size: 13px; color: var(--text-dim); text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scr-tone-on .scr-value { color: var(--accent-ink, var(--accent)); }
.scr-tone-warn .scr-value { color: var(--color-warn); }
.scr-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.scr-actions .ui-btn, .scr-all { min-height: 44px; }
.scr-all { flex: none; width: 100%; }
