/* Trace search palette, result trail and keyboard sheet (palette.js). Same legibility floor as
   trace.css: body >= 14px, support >= 12px, 7:1 body / 4.5:1 support on the opaque surfaces here,
   no opacity on text. */

/* ---------- the bar above the lenses ---------- */
.search-bar { flex: none; margin: 12px 12px 4px; }
.search-open, .search-trail {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px;
  background: #0a141e; border: 1px solid #35506a; border-radius: 10px; color: var(--ink-2);
}
.search-open { padding: 0 6px 0 12px; cursor: text; font-size: 14px; text-align: left; }
.search-open:hover { border-color: #5b8cc4; color: var(--ink); }
.search-open .search-hint { flex: 1; min-width: 0; }
.search-bar kbd, .pal kbd {
  font: 12px/1 var(--mono); color: var(--ink); background: #1a2532; border: 1px solid #3a4d63;
  border-radius: 5px; padding: 3px 6px; min-width: 22px; text-align: center; display: inline-block;
}
.pal-icon { font-size: 18px; line-height: 1; color: #9fc4e8; flex: none; }
.keys-open {
  flex: none; width: 28px; height: 28px; border-radius: 7px; border: 1px solid #3a4d63; background: #13202c;
  color: var(--ink); font: 700 13px/1 var(--sans); cursor: pointer;
}
.keys-open:hover { border-color: #5b8cc4; }
.search-trail { padding: 0 4px 0 0; border-color: #5b8cc4; background: #0d1c2b; }
.search-trail button { background: none; border: 0; color: var(--ink); cursor: pointer; }
.trail-q { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 9px 4px 9px 12px; text-align: left; font-size: 14px; }
.trail-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trail-pos { flex: none; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.trail-step, .trail-x { flex: none; width: 30px; height: 30px; border-radius: 7px; font-size: 18px; line-height: 1; }
.trail-step:hover:not(:disabled), .trail-x:hover { background: #1b3048; }
.trail-step:disabled { color: #7d8896; cursor: default; }

/* ---------- the palette ---------- */
.pal-layer { position: fixed; inset: 0; z-index: 60; display: flex; justify-content: center; align-items: flex-start; padding: 9vh 16px 16px; }
.pal-scrim { position: absolute; inset: 0; background: rgba(3, 6, 10, 0.62); }
.pal {
  position: relative; width: min(760px, 100%); max-height: min(78vh, 760px); display: flex; flex-direction: column;
  background: #0d141d; border: 1px solid #3a526a; border-radius: 14px; box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  color: var(--ink); font: 14px/1.45 var(--sans); overflow: hidden;
}
.pal-top { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid #243345; }
.pal-top .pal-icon { font-size: 22px; }
.pal-input {
  flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--ink);
  font: 17px/1.4 var(--sans); padding: 4px 0;
}
.pal-input::placeholder { color: #98a4b3; }
.pal-scopes { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px; border-bottom: 1px solid #243345; }
.pal-scope {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid #33465b; background: #111b27; color: var(--ink-2);
  border-radius: 999px; padding: 4px 11px; font-size: 13px; cursor: pointer;
}
.pal-scope:hover { color: var(--ink); border-color: #4d6a88; }
.pal-scope[aria-selected=true] { background: #1d3552; border-color: #6d9fd6; color: #fff; }
.pal-count { font: 12px var(--mono); color: #c9d6e4; }
.pal-list { overflow-y: auto; overscroll-behavior: contain; padding: 4px 0 8px; min-height: 120px; scrollbar-width: thin; scrollbar-color: #3b5267 transparent; }
.pal-section {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 12px 16px 5px; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #aeb9c7;
}
.pal-note { font-weight: 500; letter-spacing: 0; text-transform: none; color: #aeb9c7; font-size: 12.5px; }
.pal-row {
  display: flex; align-items: flex-start; gap: 11px; padding: 8px 14px 8px 13px; margin: 0 6px; border-radius: 9px;
  border-left: 3px solid transparent; cursor: pointer;
}
.pal-row[aria-selected=true] { background: #182838; border-left-color: #6d9fd6; }
.pal-chip { flex: none; width: 10px; height: 10px; border-radius: 3px; margin-top: 6px; background: #55657a; }
.pal-command .pal-chip, .pal-more .pal-chip { background: none; border: 1px solid #5d6f86; }
.pal-main { flex: 1; min-width: 0; }
.pal-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.pal-title b { flex: none; max-width: 60%; font-weight: 650; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-target, .pal-ask { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #dbe2ea; }
.pal-target { font: 13px/1.5 var(--mono); }
.pal-ask { font-size: 14px; }
.pal-ask:empty::before { content: "…"; color: #98a4b3; }
.pal-block .pal-title b, .pal-largest .pal-title b, .pal-text .pal-title b { max-width: 100%; }
.pal-snip {
  font: 13px/1.55 var(--mono); color: #dbe2ea; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.pal-meta { font-size: 12.5px; color: #aeb9c7; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-size { flex: none; font: 12.5px var(--mono); color: #dbe2ea; margin-top: 2px; font-variant-numeric: tabular-nums; }
.pal-key { flex: none; }
.pal-more .pal-title b { font-weight: 600; color: var(--link); }
.pal mark { background: #ffe27a; color: #111; border-radius: 3px; padding: 0 1px; }
.pal-empty { margin: 0; padding: 28px 18px; color: var(--ink-2); text-align: center; }
.pal-foot {
  display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 9px 14px; border-top: 1px solid #243345;
  font-size: 12.5px; color: #aeb9c7; background: #0a1017;
}
.pal-foot kbd { padding: 2px 5px; font-size: 11.5px; }

/* ---------- keyboard sheet ---------- */
.keys-sheet { width: min(680px, 100%); outline: none; }
.keys-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid #243345; }
.keys-head h2 { margin: 0; font-size: 18px; }
.keys-body { overflow-y: auto; padding: 6px 18px 18px; display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 4px 28px; }
.keys-body h3 { margin: 12px 0 6px; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: #aeb9c7; }
.keys-body dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; align-items: baseline; }
.keys-body dt { white-space: nowrap; }
.keys-body dd { margin: 0; color: var(--ink); font-size: 14px; }

/* The words searched for, in the side panel after a jump (CSS Custom Highlight API). */
::highlight(trace-find) { background-color: #ffe27a; color: #111; }

@media (max-width: 980px) {
  .search-bar { margin: 0 16px 6px; }
  .search-open, .search-trail { min-height: 36px; background: #0d1c29; }
  .search-open kbd { display: none; }
  .pal-layer { padding: 8px; }
  .pal { max-height: calc(100vh - 16px); }
  .pal-foot { display: none; }
  .pal-title { flex-direction: column; align-items: stretch; gap: 0; }
  .pal-title b { max-width: 100%; }
}
