/* The command palette (palette.mjs): ⌘K / Ctrl+K. It's drawn with the app's own colour tokens, so it fits the
   classic look in light and dark; the futuristic theme (html[data-theme="future"]) turns it into deep-space
   glass with a thin blue edge. The highlighted row is always SoudCoh Blue. Classes are prefixed pal-. */
.pal-root {
  --pal-bg: var(--float, rgba(255, 255, 255, .94));
  --pal-line: var(--line, #D3E0F3);
  --pal-sep: var(--line, #D3E0F3);
  --pal-ink: var(--ink, #00163D);
  --pal-muted: var(--muted, #45597A);
  --pal-faint: var(--faint, #6B7A93);
  --pal-tile: var(--accent-soft, rgba(0, 109, 255, .10));
  --pal-tile-line: transparent;
  --pal-icon: var(--accent, #006DFF);
  --pal-head: var(--accent-text, #0058d6);
  --pal-hl: inherit;
  --pal-hl-line: var(--accent-line, rgba(0, 109, 255, .35));
  --pal-tag: var(--panel-2, #F3F7FE);
  --pal-active: #1a7bff;
  --pal-active-2: #006DFF;
  --pal-active-glow: 0 8px 22px -12px rgba(0, 109, 255, .75);
  --pal-scrim: var(--scrim, rgba(0, 22, 61, .32));
  --pal-shadow: 0 2px 6px rgba(0, 22, 61, .06), 0 30px 80px -16px rgba(0, 22, 61, .36);
  --pal-kbd: var(--panel-2, #F3F7FE);
  --pal-kbd-line: var(--line, #D3E0F3);
  --pal-screen: var(--screen, #0E1014);
  --pal-ok: var(--ok, #138a4b);
  --pal-warn: var(--warn, #a86400);
  --pal-danger: var(--danger, #d23a3a);
  --pal-edge: transparent;
  position: fixed; inset: 0; z-index: 85; /* over Talk to Pixel (80) and its small bar, under the toast (90) */
  font-family: "SC Inter", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.35; color: var(--pal-ink);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
.pal-root[hidden] { display: none; }

/* Deep space: dark glass over whatever is behind (the 3D universe shows through), a faint blue light from
   above and one thin glowing edge. */
html[data-theme="future"] .pal-root {
  --pal-bg: radial-gradient(120% 80% at 50% -30%, rgba(0, 109, 255, .20), rgba(0, 109, 255, 0) 62%), rgba(6, 10, 22, .80);
  --pal-line: rgba(138, 184, 255, .17);
  --pal-sep: rgba(138, 184, 255, .10);
  --pal-ink: #EEF4FF;
  --pal-muted: rgba(208, 222, 244, .64);
  --pal-faint: rgba(178, 198, 230, .46);
  --pal-tile: linear-gradient(180deg, rgba(92, 157, 255, .13), rgba(92, 157, 255, .05));
  --pal-tile-line: rgba(138, 184, 255, .16);
  --pal-icon: #8AB8FF;
  --pal-head: rgba(138, 184, 255, .74);
  --pal-hl: #8AB8FF;
  --pal-hl-line: transparent;
  --pal-tag: rgba(138, 184, 255, .08);
  --pal-active: #1a7bff;
  --pal-active-2: #0062f0;
  --pal-active-glow: 0 10px 30px -12px rgba(0, 109, 255, .95), 0 0 0 1px rgba(138, 184, 255, .35) inset;
  --pal-scrim: radial-gradient(90% 70% at 50% 18%, rgba(0, 38, 110, .30), rgba(0, 2, 10, .66));
  --pal-shadow: 0 0 0 1px rgba(0, 0, 0, .55), 0 34px 100px -14px rgba(0, 0, 0, .9), 0 0 90px -24px rgba(0, 109, 255, .55), inset 0 1px 0 rgba(255, 255, 255, .06);
  --pal-kbd: rgba(138, 184, 255, .07);
  --pal-kbd-line: rgba(138, 184, 255, .2);
  --pal-screen: #05070b;
  --pal-ok: #3ddc84;
  --pal-warn: #f5a524;
  --pal-danger: #ff5b5b;
  --pal-edge: rgba(92, 157, 255, .95);
  color-scheme: dark;
}

.pal-scrim { position: absolute; inset: 0; background: var(--pal-scrim); touch-action: none; animation: pal-fade .18s ease; }
.pal {
  position: absolute; left: 0; right: 0; top: max(11vh, 56px); margin: 0 auto;
  width: min(680px, calc(100vw - 48px)); max-height: min(620px, calc(100dvh - max(11vh, 56px) - 40px));
  display: flex; flex-direction: column; overflow: hidden; isolation: isolate;
  background: var(--pal-bg); color: var(--pal-ink);
  border: 1px solid var(--pal-line); border-radius: 18px; box-shadow: var(--pal-shadow);
  backdrop-filter: blur(30px) saturate(170%); -webkit-backdrop-filter: blur(30px) saturate(170%);
  animation: pal-in .2s cubic-bezier(.2, .9, .3, 1);
}
/* The thin glowing edge (future theme): along the top on a computer, along the bottom of the phone's sheet. */
.pal::before {
  content: ""; position: absolute; z-index: 2; left: 14%; right: 14%; top: 0; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--pal-edge), transparent);
}
.pal-out .pal { animation: pal-off .14s ease forwards; }
.pal-out .pal-scrim { animation: pal-unfade .14s ease forwards; }
@keyframes pal-in { from { opacity: 0; transform: translateY(-10px) scale(.985); } }
@keyframes pal-off { to { opacity: 0; transform: translateY(-4px) scale(.99); } }
@keyframes pal-fade { from { opacity: 0; } }
@keyframes pal-unfade { to { opacity: 0; } }
.pal-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }

/* ---------- the search box ---------- */
.pal-head { position: relative; display: flex; align-items: center; gap: 10px; min-height: 62px; padding: 0 12px 0 18px; border-bottom: 1px solid var(--pal-sep); }
.pal-head > svg.i { width: 20px; height: 20px; flex: none; color: var(--pal-faint); }
.pal-input {
  flex: 1; min-width: 0; height: 60px; padding: 0; border: 0; outline: 0; background: none; border-radius: 0;
  font-family: inherit; font-size: 18px; font-weight: 500; line-height: 1.2; letter-spacing: -.012em; color: var(--pal-ink); caret-color: var(--pal-active);
  -webkit-appearance: none; appearance: none;
}
.pal-input::placeholder { color: var(--pal-faint); opacity: 1; }
/* The box is the whole header: no focus ring of its own (the future look rings every focused control). */
.pal-input:focus, .pal-input:focus-visible { outline: 0; box-shadow: none; animation: none; }
.pal-crumb {
  flex: none; display: inline-flex; align-items: center; gap: 2px; max-width: 42%; height: 30px; padding: 0 3px 0 11px;
  border-radius: 99px; background: var(--pal-tile); border: 1px solid var(--pal-tile-line); color: var(--pal-ink);
  font-size: 13.5px; font-weight: 650;
}
.pal-crumb[hidden] { display: none; }
.pal-crumb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-crumb-x, .pal-clear {
  flex: none; display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%;
  background: none; color: var(--pal-faint); cursor: pointer;
}
.pal-crumb-x svg.i, .pal-clear svg.i { width: 15px; height: 15px; }
.pal-crumb-x:hover, .pal-clear:hover { color: var(--pal-ink); background: var(--pal-tag); }
.pal-clear[hidden] { display: none; }
.pal-esc {
  flex: none; height: 24px; padding: 0 8px; border-radius: 7px; border: 1px solid var(--pal-kbd-line); background: var(--pal-kbd);
  color: var(--pal-muted); font-family: inherit; font-size: 11.5px; font-weight: 600; line-height: 1; letter-spacing: .02em; cursor: pointer;
}
.pal-esc:hover { color: var(--pal-ink); }
.pal-cancel { display: none; flex: none; height: 44px; padding: 0 4px 0 8px; border: 0; background: none; color: var(--pal-active-2); font-family: inherit; font-size: 16px; font-weight: 600; cursor: pointer; }
html[data-theme="future"] .pal-cancel { color: #8AB8FF; }
.pal-head button:focus-visible, .pal-opt:focus-visible { outline: 2px solid var(--pal-active); outline-offset: 2px; }

/* ---------- results ---------- */
.pal-list { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 4px 0 10px; scrollbar-width: thin; scrollbar-color: var(--pal-line) transparent; }
.pal-group + .pal-group, .pal-note + .pal-group { margin-top: 2px; }
.pal-gh { padding: 14px 22px 6px; font-size: 11px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; color: var(--pal-head); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-group-ai { margin-top: 8px; padding-top: 4px; border-top: 1px solid var(--pal-sep); }
.pal-note { margin: 14px 22px 2px; color: var(--pal-muted); font-size: 13.5px; }

.pal-opt {
  position: relative; display: flex; align-items: center; gap: 13px; min-height: 52px; margin: 0 8px; padding: 7px 12px 7px 9px;
  border-radius: 12px; color: var(--pal-ink); cursor: pointer; user-select: none; -webkit-user-select: none;
}
.pal-opt.on {
  background: linear-gradient(180deg, var(--pal-active), var(--pal-active-2)); color: #fff;
  box-shadow: var(--pal-active-glow), inset 0 1px 0 rgba(255, 255, 255, .2);
}
.pal-lead {
  flex: none; position: relative; display: grid; place-items: center; width: 48px; height: 32px; border-radius: 9px;
  background: var(--pal-tile); color: var(--pal-icon); box-shadow: inset 0 0 0 1px var(--pal-tile-line);
}
.pal-lead svg.i { width: 18px; height: 18px; stroke-width: 1.8; }
.pal-opt.on .pal-lead { background: rgba(255, 255, 255, .16); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22); }
.pal-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pal-title { font-size: 14.5px; font-weight: 600; letter-spacing: -.006em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-sub { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 12.5px; color: var(--pal-muted); white-space: nowrap; overflow: hidden; }
.pal-subt { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pal-tag {
  flex: none; padding: 0 6px; border-radius: 5px; line-height: 17px; font-size: 11.5px; font-weight: 600;
  color: var(--pal-ink); background: var(--pal-tag); box-shadow: inset 0 0 0 1px var(--pal-line);
}
.pal-opt.on .pal-sub { color: rgba(255, 255, 255, .8); }
.pal-opt.on .pal-tag { color: #fff; background: rgba(255, 255, 255, .14); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .3); }
/* Matched letters: bold with a soft blue underline (the classic look keeps its one blue for the highlighted
   row); in deep space they also light up blue. */
.pal-opt mark {
  background: none; color: var(--pal-hl); font-weight: 700;
  text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; text-decoration-color: var(--pal-hl-line);
}
.pal-sub mark { font-weight: 650; }
.pal-opt.on mark { color: #fff; text-decoration-thickness: 1.5px; text-decoration-color: rgba(255, 255, 255, .62); }
.pal-q { font-weight: 700; }

.pal-meta { flex: none; display: flex; align-items: center; gap: 8px; color: var(--pal-faint); font-size: 12px; }
.pal-kind { font-weight: 600; letter-spacing: .01em; }
.pal-go svg.i { display: block; width: 16px; height: 16px; color: var(--pal-faint); }
.pal-opt.on .pal-meta, .pal-opt.on .pal-go svg.i { color: rgba(255, 255, 255, .85); }
.pal-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px 0 8px; border-radius: 99px;
  font-size: 11.5px; font-weight: 600; color: var(--pal-muted); box-shadow: inset 0 0 0 1px var(--pal-line); white-space: nowrap;
}
.pal-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--pal-ok); box-shadow: 0 0 0 3px rgba(61, 220, 132, .16); }
.pal-pill.off .pal-dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--pal-faint); }
.pal-pill.warn .pal-dot { background: var(--pal-warn); box-shadow: 0 0 0 3px rgba(245, 165, 36, .18); }
.pal-pill.danger .pal-dot { background: var(--pal-danger); box-shadow: 0 0 0 3px rgba(255, 91, 91, .18); }
.pal-opt.on .pal-pill { color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .34); }
.pal-opt.on .pal-pill .pal-dot { box-shadow: 0 0 0 2px rgba(255, 255, 255, .5); }
.pal-opt.on .pal-pill.off .pal-dot { box-shadow: inset 0 0 0 1.5px #fff; }

/* A TV's real picture, or a wall's pictures laid out as the TVs hang. */
.pal-lead-shot { background: none; box-shadow: none; }
.pal-opt.on .pal-lead-shot { background: none; box-shadow: none; }
.pal-shot {
  display: grid; overflow: hidden; border-radius: 4px; background: #000;
  box-shadow: 0 0 0 1px rgba(138, 184, 255, .22), 0 3px 10px -3px rgba(0, 0, 0, .55);
}
.pal-shot.multi { gap: 1px; padding: 1px; border-radius: 5px; }
.pal-opt.on .pal-shot { box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .7), 0 4px 12px -4px rgba(0, 20, 80, .6); }
.pal-cell { position: relative; overflow: hidden; background: var(--pal-screen); border-radius: 1px; }
.pal-cell img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* Standby: a dark screen with the small red light. No signal: grey static. */
.pal-cell.standby::after { content: ""; position: absolute; right: 2px; bottom: 2px; width: 3px; height: 3px; border-radius: 50%; background: #ff3b3b; box-shadow: 0 0 3px #ff3b3b; }
.pal-cell.nosig { background: repeating-linear-gradient(135deg, #1a1f29 0 2px, #10141b 2px 4px); }

/* Pixel's rows: the assistant's glowing orb. */
.pal-lead-ai { background: none; box-shadow: none; }
.pal-opt.on .pal-lead-ai { background: none; box-shadow: none; }
.pal-orb {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: #fff;
  background: radial-gradient(circle at 34% 28%, #cfe1ff 0, #5C9DFF 22%, #006DFF 52%, #00163D 100%);
  box-shadow: 0 0 16px -2px rgba(0, 109, 255, .8), inset 0 0 0 1px rgba(255, 255, 255, .28);
}
.pal-orb svg.i { width: 15px; height: 15px; stroke-width: 2.1; }
.pal-opt.on .pal-orb { box-shadow: 0 0 0 2px rgba(255, 255, 255, .55), 0 0 18px rgba(138, 184, 255, .9); }
/* Pixel itself on its rows (purple like everywhere else), with what the row does as a small blue badge. */
.pal-pixel { position: relative; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: radial-gradient(circle at 50% 60%, rgba(124, 77, 255, .5), #1a0f45 70%); box-shadow: inset 0 0 0 1px rgba(180, 150, 255, .35), 0 0 14px -4px rgba(124, 77, 255, .9); }
.pal-pixel > svg.i { width: 24px; height: 24px; }
.pal-pixel-badge { position: absolute; right: -5px; bottom: -5px; display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; color: #fff;
  background: #006DFF; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .85); }
.pal-pixel-badge svg.i { width: 10px; height: 10px; stroke-width: 2.6; }
.pal-opt.on .pal-pixel { box-shadow: inset 0 0 0 1px rgba(220, 205, 255, .6), 0 0 0 2px rgba(255, 255, 255, .5), 0 0 18px rgba(124, 77, 255, .95); }

/* ---------- key hints ---------- */
.pal-foot { display: flex; align-items: center; gap: 16px; padding: 9px 16px 10px 18px; border-top: 1px solid var(--pal-sep); font-size: 12px; color: var(--pal-faint); white-space: nowrap; }
.pal-grow { flex: 1; }
.pal-keys { display: inline-flex; align-items: center; gap: 4px; }
.pal-root kbd {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 6px;
  background: var(--pal-kbd); box-shadow: inset 0 0 0 1px var(--pal-kbd-line), 0 1px 0 var(--pal-kbd-line);
  color: var(--pal-muted); font: 600 11px/1 "SC Inter", -apple-system, BlinkMacSystemFont, sans-serif;
}
.pal-keys kbd + kbd { margin-left: -1px; }
.pal-opt.on kbd { background: rgba(255, 255, 255, .16); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .3); color: #fff; }
@media (max-width: 760px) { .pal-foot .pal-keys:nth-child(3) { display: none; } }

/* ---------- phone: a full-width sheet from the top, above the keyboard ---------- */
@media (max-width: 640px) {
  .pal {
    top: 0; width: auto; margin: 0; max-height: calc(var(--pal-vh, 100dvh) - 48px);
    padding-top: env(safe-area-inset-top); border-width: 0 0 1px; border-radius: 0 0 22px 22px;
    animation-name: pal-drop; animation-duration: .24s;
  }
  .pal::before { top: auto; bottom: 0; }
  .pal-out .pal { animation-name: pal-lift; }
  @keyframes pal-drop { from { transform: translateY(-28px); opacity: 0; } }
  @keyframes pal-lift { to { transform: translateY(-16px); opacity: 0; } }
  .pal-head { min-height: 56px; padding: 0 10px 0 16px; gap: 9px; }
  .pal-input { height: 56px; font-size: 17px; }
  .pal-esc, .pal-foot, .pal-fine { display: none; }
  .pal-cancel { display: inline-flex; align-items: center; }
  .pal-crumb { max-width: 46%; }
  .pal-list { padding-bottom: 12px; }
  .pal-gh { padding: 14px 18px 6px; }
  .pal-opt { min-height: 56px; margin: 0 6px; padding: 7px 10px 7px 8px; gap: 12px; }
  .pal-title { font-size: 15px; }
  .pal-sub { font-size: 13px; }
}
@media (hover: none) { .pal-fine { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .pal, .pal-scrim, .pal-out .pal, .pal-out .pal-scrim { animation: none !important; }
}
