/* Valya workbench — the search field and palette (plan §03). Same palette
   as workbench.css (the digest's colours); nothing behind hover, the selected
   row is the one the keyboard reaches. One column and a full-width field on a
   phone; the dialog sits at the top of a 1366×768 screen with room for three
   groups of eight. */

/* the top-bar field ------------------------------------------------------- */
.search {
  display: flex; align-items: center; gap: 6px;
  min-width: 260px; flex: 1 1 260px; max-width: 460px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px;
  color: var(--muted);
}
.search:focus-within { border-color: var(--accent); background: var(--card); color: var(--ink); }
.search input[type="search"] {
  flex: 1 1 auto; min-width: 0; border: 0; background: transparent; font: inherit; color: var(--ink);
  outline: none; padding: 4px 0;
}
.search input::-webkit-search-decoration { -webkit-appearance: none; }
.search-hint {
  font: 11px/1 var(--font); color: var(--muted); border: 1px solid var(--line); border-radius: 3px;
  padding: 3px 5px; background: var(--card); white-space: nowrap;
}
@media (max-width: 1000px) {
  .search { order: 10; flex-basis: 100%; max-width: none; margin-bottom: 8px; }
  .search-hint { display: none; }
}

/* the palette ------------------------------------------------------------- */
.palette {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(35, 32, 29, .35);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 16px 16px;
}
.palette[hidden] { display: none; }
body.palette-open { overflow: hidden; }
.palette-box {
  width: 100%; max-width: 720px; max-height: 84vh;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 16px 48px rgba(35, 32, 29, .25);
  display: flex; flex-direction: column; overflow: hidden;
}
.palette-form {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  border-bottom: 1px solid var(--line); color: var(--muted); margin: 0;
}
.palette-form .ico { width: 1.2em; height: 1.2em; }
.palette-form input[type="search"] {
  flex: 1 1 auto; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 16px;
  color: var(--ink); outline: none; padding: 4px 0;
}
.palette-form input::-webkit-search-decoration { -webkit-appearance: none; }
.palette-past { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; margin: 0; cursor: pointer; }
.palette-close {
  background: transparent; border: 0; padding: 0; cursor: pointer; color: var(--muted); font: inherit;
}
.palette-close kbd {
  font: 11px/1 var(--font); border: 1px solid var(--line); border-radius: 3px; padding: 3px 5px; background: var(--bg);
}
.palette-close:focus-visible, .palette-past input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.palette-results { overflow-y: auto; flex: 1 1 auto; padding: 4px 0 8px; }
.pal-group { padding: 6px 0 2px; }
.pal-group-head {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  padding: 8px 14px 4px;
}
.pal-empty, .pal-error { padding: 4px 14px 8px; margin: 0; }
.pal-error { color: var(--red); font-weight: 600; }

.pal-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 8px 14px; text-decoration: none; color: var(--ink);
  background: transparent; border: 0; border-left: 3px solid transparent; font: inherit; text-align: left; cursor: pointer;
}
.pal-row.selected, .pal-row:hover { background: var(--soft); border-left-color: var(--accent); }
.pal-main { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.pal-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-hit { background: transparent; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; font-weight: 700; }
.pal-chips { display: inline-flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; flex: none; max-width: 48%; }
.pal-territory { color: var(--muted); }
.pal-more .pal-title { color: var(--accent); font-weight: 400; }
.pal-add .ico { color: var(--accent); width: 1.2em; height: 1.2em; }
.pal-add .pal-main { flex: 1 1 auto; }
.pal-recent .pal-title { font-weight: 400; }

.palette-status, .palette-help {
  margin: 0; padding: 6px 14px; border-top: 1px solid var(--line);
}
.palette-status:empty { display: none; }
.palette-help { border-top: 0; padding-top: 0; }

@media (max-width: 1000px) {
  .palette { padding: 0; align-items: stretch; }
  .palette-box { max-width: none; max-height: none; border-radius: 0; border: 0; }
  .pal-row { flex-direction: column; align-items: flex-start; gap: 4px; }
  .pal-chips { justify-content: flex-start; max-width: none; }
  .palette-help { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .palette-box { animation: pal-in 120ms ease-out; }
  @keyframes pal-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
}

@media print {
  .search, .palette { display: none !important; }
}
