/* DV57 GLASS command palette. Stage 3 of 4 adds the scope chip, the toasts and the Smoke (dark) glass.
   The glass itself is WebGL (js/glass.js); everything here is layout, type and the
   CSS frosted fallback used when WebGL is unavailable (html.no-gl) or before the first glass frame. The page never
   reads the OS colour scheme: Frost (light glass) is the default, Smoke is chosen from the palette and stored. */

:root {
  --ink: #161b28;
  --ink-2: #2f3647;
  --ink-3: #4f5868;
  --hl: #0b6a78;
  --on-wall: #f4f1ff;
  --pal-w: 640px;
  --pal-wide: 920px;
  --pal-top: clamp(76px, 21vh, 210px);
  --pad: 12px;
  --field-h: 58px;
  --row-h: 54px;
  --r-panel: 26px;
  --r-field: 17px;
  --r-row: 16px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  color: var(--ink);
  background: #2a2c4a;
}
:root[data-theme="smoke"] { --ink: #f5f6fb; --ink-2: #dfe2ec; --ink-3: #b9bfcf; --hl: #8ff0ff; }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { background: #2a2c4a; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
kbd { font: 500 12px/1 Inter, system-ui, sans-serif; }
.sr, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { position: fixed; z-index: 50; left: 12px; top: 12px; padding: 12px 16px; border-radius: 12px; background: #fff; color: #111; }

.ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.mi { display: inline-block; width: 22px; height: 22px; flex: none; background: currentColor; -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }

/* ---------- desktop */
.wall { position: fixed; inset: 0; overflow: hidden; }
.wall-img { width: 100%; height: 100%; object-fit: cover; object-position: var(--wall-x, 50%) 50%; display: block; }
.glass { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.no-gl .glass { display: none; }

.top { position: fixed; z-index: 2; left: 0; right: 0; top: 0; height: 64px; padding: 0 22px; display: flex; align-items: center; justify-content: space-between;
  color: var(--on-wall); text-shadow: 0 1px 10px rgba(20, 12, 50, .35); pointer-events: none; }
.brand { pointer-events: auto; display: inline-flex; align-items: center; gap: 10px; min-height: 44px; color: inherit; text-decoration: none;
  font-weight: 600; font-size: 15px; letter-spacing: .14em; text-transform: uppercase; border-radius: 12px; padding: 0 6px; margin-left: -6px; }
.brand-mark { width: 26px; height: 26px; filter: drop-shadow(0 2px 8px rgba(40, 20, 90, .35)); }
.clock { margin: 0; display: flex; gap: 10px; font: 500 14px/1 Inter, sans-serif; font-variant-numeric: tabular-nums; opacity: .92; }

.trigger { position: fixed; z-index: 3; top: 12px; left: 50%; width: 300px; height: 44px; margin-left: -150px; border-radius: 22px;
  display: flex; align-items: center; gap: 10px; padding: 0 8px 0 16px; color: var(--ink-2); transition: opacity .18s var(--ease); }
.trigger .ic { width: 18px; height: 18px; }
.trigger-label { flex: 1; text-align: left; font-size: 14px; font-weight: 500; letter-spacing: .02em; }
.trigger-kbd { padding: 6px 8px; border-radius: 9px; background: rgba(255, 255, 255, .34); color: var(--ink-2); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .45); }
[data-theme="smoke"] .trigger-kbd { background: rgba(255, 255, 255, .12); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2); }
.is-open .trigger, .is-moving .trigger { opacity: 0; pointer-events: none; }
.trigger:focus-visible { outline: 2px solid rgba(255, 255, 255, .85); outline-offset: 4px; }

.hints { position: fixed; z-index: 2; left: 0; right: 0; bottom: 22px; margin: 0; display: flex; justify-content: center; gap: 18px;
  font-size: 12.5px; font-weight: 500; color: var(--on-wall); opacity: 0; transition: opacity .3s var(--ease); text-shadow: 0 1px 8px rgba(20, 12, 50, .45); pointer-events: none; }
.hints span { display: inline-flex; align-items: center; gap: 6px; }
.hints kbd { min-width: 22px; height: 22px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 7px; background: rgba(255, 255, 255, .16); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28); }
.is-open .hints { opacity: .85; }
.credit { position: fixed; z-index: 2; right: 14px; bottom: 10px; margin: 0; font-size: 11px; color: var(--on-wall); opacity: .55; pointer-events: none; }

/* ---------- palette */
.pal { position: fixed; inset: 0; z-index: 4; visibility: hidden; pointer-events: none; }
.is-open .pal, .is-moving .pal { visibility: visible; }
.is-open .pal { pointer-events: auto; }
.pal-panel { position: absolute; top: var(--pal-top); left: 0; right: 0; margin: 0 auto; width: min(var(--pal-w), calc(100vw - 32px)); padding: var(--pad);
  border-radius: var(--r-panel); transition: width 0s; }
.is-wide .pal-panel { width: min(var(--pal-wide), calc(100vw - 32px)); }
.pal-panel > * { transition: opacity .2s var(--ease); }
.pal.is-shown .pal-panel > * { transition: opacity .26s var(--ease) .15s; }
.pal:not(.is-shown) .pal-panel > * { opacity: 0; transition-duration: .1s; }

.pal-field { position: relative; display: flex; align-items: center; gap: 10px; height: var(--field-h); padding: 0 8px 0 20px; border-radius: var(--r-field); }
.pal-search-ic { display: none; width: 20px; height: 20px; color: var(--ink-3); }
.pal-input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: var(--ink); font: 400 18px/1.2 Inter, sans-serif; letter-spacing: .01em; caret-color: var(--ink); padding: 0; }
.pal-input::placeholder { color: var(--ink-3); text-transform: uppercase; letter-spacing: .075em; font-size: 16.5px; opacity: 1; }
.pal-input::-webkit-search-cancel-button { display: none; }
.pal-field:focus-within { box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .62), 0 0 18px rgba(170, 245, 255, .28); }
[data-theme="smoke"] .pal-field:focus-within { box-shadow: 0 0 0 1.5px rgba(200, 245, 255, .45), 0 0 18px rgba(140, 230, 255, .18); }
.pal-scope { display: inline-flex; align-items: center; gap: 2px; height: 32px; padding: 0 2px 0 12px; border-radius: 11px; flex: none;
  background: rgba(255, 255, 255, .42); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .6); font-size: 14px; font-weight: 600; color: var(--ink-2); }
[data-theme="smoke"] .pal-scope { background: rgba(255, 255, 255, .14); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); }
.pal-scope[hidden] { display: none; }
.pal-scope-x { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; }
.pal-scope-x svg, .pal-close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.pal-close { flex: none; min-width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; color: var(--ink-3); }
.pal-close svg { display: none; }
.pal-close kbd { padding: 6px 8px; border-radius: 8px; background: rgba(255, 255, 255, .3); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .45); color: var(--ink-3); }
[data-theme="smoke"] .pal-close kbd { background: rgba(255, 255, 255, .1); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2); }
.pal-close:focus-visible, .pal-scope-x:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }

.pal-body { position: relative; margin-top: 8px; }
.pal-list { position: relative; z-index: 1; max-height: calc(100vh - var(--pal-top) - var(--field-h) - 2 * var(--pad) - 96px); max-height: calc(100dvh - var(--pal-top) - var(--field-h) - 2 * var(--pad) - 96px);
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; border-radius: var(--r-row); }
.pal-list::-webkit-scrollbar { display: none; }
.pal-cols { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.is-wide .pal-cols { grid-template-columns: 1fr 1fr; }
.pal-col { min-width: 0; }
.pal-gh { height: 32px; padding: 10px 16px 0; font-size: 12.5px; font-weight: 600; letter-spacing: .02em; color: var(--ink-3); }
.pal-group + .pal-group { margin-top: 4px; }
.is-root .pal-gh { display: none; }

.opt { position: relative; display: flex; align-items: center; gap: 14px; height: var(--row-h); padding: 0 16px; border-radius: var(--r-row); cursor: pointer;
  color: var(--ink); user-select: none; -webkit-tap-highlight-color: transparent; }
.opt .mi { color: var(--ink-2); }
.opt .tile { width: 26px; height: 26px; flex: none; margin: 0 -2px; filter: drop-shadow(0 2px 4px rgba(20, 20, 60, .22)); }
.opt-label { flex: 1; min-width: 0; font-size: 17px; font-weight: 500; letter-spacing: -.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opt-label mark { background: none; color: var(--hl); font-weight: 600; }
.opt-meta { flex: none; font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.opt-keys { display: inline-flex; gap: 3px; }
.opt-keys kbd { min-width: 22px; height: 22px; padding: 0 5px; display: inline-grid; place-items: center; border-radius: 6px; background: rgba(255, 255, 255, .28); color: var(--ink-2); font-size: 11.5px; }
[data-theme="smoke"] .opt-keys kbd { background: rgba(255, 255, 255, .1); }
.opt-on { font-size: 11.5px; font-weight: 600; padding: 4px 8px; border-radius: 99px; background: rgba(11, 106, 120, .14); color: var(--hl); }
/* the ↵ hint: one pseudo-element on the selected row (no extra SVG per row) */
.opt::after { content: ""; width: 18px; height: 18px; flex: none; opacity: 0; transform: translateX(-4px); transition: opacity .15s, transform .2s var(--ease); background: var(--ink-2);
  -webkit-mask: var(--enter) center / contain no-repeat; mask: var(--enter) center / contain no-repeat; }
.opt[aria-selected="true"]::after { opacity: .8; transform: none; }
:root { --enter: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 5.6v6.2a2.4 2.4 0 0 1-2.4 2.4H5.6M9.6 10.2l-4 4 4 4'/%3E%3C/svg%3E"); }
.is-wide .opt-meta { display: none; }
.pal-empty { margin: 0; padding: 18px 16px 20px; font-size: 15px; color: var(--ink-2); }
.pal-empty[hidden] { display: none; }

/* DOM capsule: only for the CSS fallback (WebGL draws the real one) */
.cap { display: none; }

/* ---------- toasts */
.toasts { position: fixed; z-index: 6; left: 0; right: 0; bottom: 64px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { display: inline-flex; align-items: center; gap: 10px; padding: 11px 18px 11px 12px; border-radius: 18px; font-size: 14.5px; font-weight: 500; color: var(--ink);
  background: rgba(255, 255, 255, .44); -webkit-backdrop-filter: blur(22px) saturate(170%); backdrop-filter: blur(22px) saturate(170%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .62), inset 0 1px 0 rgba(255, 255, 255, .8), 0 14px 34px rgba(20, 14, 60, .28);
  animation: toastin .42s var(--ease) both; }
[data-theme="smoke"] .toast { background: rgba(20, 22, 34, .5); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18), 0 14px 34px rgba(0, 0, 0, .35); }
.toast .mi, .toast .tile { width: 22px; height: 22px; }
.toast.is-out { animation: toastout .3s var(--ease) both; }
@keyframes toastin { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes toastout { to { opacity: 0; transform: translateY(6px) scale(.97); } }

/* ---------- CSS frosted fallback (no WebGL, or before the first glass frame) */
html:not(.gl-on) .trigger, html:not(.gl-on) .pal-panel, html:not(.gl-on) .cap {
  -webkit-backdrop-filter: blur(26px) saturate(165%) brightness(1.08); backdrop-filter: blur(26px) saturate(165%) brightness(1.08); }
html:not(.gl-on) .trigger, html:not(.gl-on) .pal-panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, .36));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .6), inset 0 1px 0 rgba(255, 255, 255, .9), inset 0 -1px 0 rgba(150, 240, 255, .7), 0 20px 50px rgba(20, 12, 60, .3); }
html:not(.gl-on) .pal-field { background: rgba(255, 255, 255, .3); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .55), inset 0 1px 0 rgba(255, 255, 255, .8); }
html:not(.gl-on)[data-theme="smoke"] .trigger, html:not(.gl-on)[data-theme="smoke"] .pal-panel { background: linear-gradient(180deg, rgba(24, 26, 40, .6), rgba(16, 18, 30, .66)); }
html:not(.gl-on)[data-theme="smoke"] .pal-field { background: rgba(255, 255, 255, .08); }
html:not(.gl-on) .cap { display: block; position: absolute; z-index: 0; left: 0; top: 0; border-radius: var(--r-row); pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, .62), rgba(255, 255, 255, .4));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .8), inset 0 2px 0 rgba(255, 255, 255, .95), inset -10px 0 18px -10px rgba(255, 120, 220, .55), inset 10px 0 18px -10px rgba(120, 240, 255, .55), 0 0 16px rgba(190, 250, 255, .5);
  transition: transform .26s var(--ease), width .26s var(--ease), height .26s var(--ease), opacity .2s; }
html:not(.gl-on)[data-theme="smoke"] .cap { background: linear-gradient(180deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, .12)); }
@media (prefers-reduced-transparency: reduce) {
  html:not(.gl-on) .pal-panel, html:not(.gl-on) .trigger { background: rgba(236, 238, 246, .94); }
  html:not(.gl-on)[data-theme="smoke"] .pal-panel { background: rgba(22, 24, 36, .95); }
}

/* ---------- phone: a full-width top sheet, the field and the results as two glass bodies */
@media (max-width: 699px), (max-height: 480px) {
  :root { --pad: 0px; --field-h: 52px; --row-h: 52px; --r-panel: 22px; --pal-top: calc(env(safe-area-inset-top, 0px) + 10px); }
  .top { height: 56px; padding: 0 16px; top: auto; bottom: 0; }
  .brand { font-size: 13px; }
  .clock { font-size: 13px; }
  .trigger { top: var(--pal-top); left: 10px; right: 10px; width: auto; margin: 0; height: var(--field-h); border-radius: 18px; }
  .trigger-kbd { display: none; }
  .pal-panel { left: 10px; right: 10px; width: auto; margin: 0; padding: 0; }
  .is-wide .pal-panel { width: auto; }
  .pal-field { padding: 0 4px 0 14px; border-radius: 18px; }
  .pal-search-ic { display: block; }
  .pal-input { font-size: 17px; }
  .pal-input::placeholder { font-size: 15px; letter-spacing: .06em; }
  .pal-close kbd { display: none; }
  .pal-close svg { display: block; width: 18px; height: 18px; }
  .pal-body { margin-top: 10px; padding: 6px; border-radius: var(--r-panel); }
  .pal-list { max-height: calc(100dvh - var(--pal-top) - var(--field-h) - 96px); }
  .is-root .pal-gh { display: block; }
  .pal-gh { padding: 8px 12px 0; height: 28px; }
  .opt { padding: 0 12px; gap: 12px; }
  .opt-label { font-size: 16px; }
  .hints { display: none; }
  .credit { bottom: auto; top: calc(100dvh - 72px); right: 16px; display: none; }
  html:not(.gl-on) .pal-panel { background: none; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  html:not(.gl-on) .pal-field, html:not(.gl-on) .pal-body { -webkit-backdrop-filter: blur(26px) saturate(165%) brightness(1.08); backdrop-filter: blur(26px) saturate(165%) brightness(1.08);
    background: linear-gradient(180deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, .36)); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .6), 0 16px 40px rgba(20, 12, 60, .28); }
  html:not(.gl-on)[data-theme="smoke"] .pal-field, html:not(.gl-on)[data-theme="smoke"] .pal-body { background: linear-gradient(180deg, rgba(24, 26, 40, .6), rgba(16, 18, 30, .66)); }
}
@media (max-height: 480px) { .pal-list { max-height: calc(100dvh - var(--pal-top) - var(--field-h) - 30px); } .top { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0s !important; transition-duration: 1ms !important; }
}
.motion-off *, .motion-off *::before, .motion-off *::after { animation-duration: 1ms !important; animation-delay: 0s !important; transition-duration: 1ms !important; }

/* big monitors: keep the board's proportion (the palette is ~45 % of the screen width) */
@media (min-width: 1800px) and (min-height: 1000px) {
  :root { --pal-w: 800px; --pal-wide: 1120px; --field-h: 70px; --row-h: 64px; --pad: 14px; --r-panel: 30px; --r-field: 20px; --r-row: 19px; }
  .pal-input { font-size: 21px; } .pal-input::placeholder { font-size: 19px; }
  .opt-label { font-size: 20px; } .opt .mi { width: 25px; height: 25px; } .opt .tile { width: 30px; height: 30px; }
  .opt { padding: 0 20px; gap: 16px; } .pal-gh { font-size: 14px; padding-left: 20px; }
}
