/* Visual search: the header band (query card, drop box, modes, "Describe it", controls, status line), the
   waterfall of result tiles, the waiting / no-region cards, the match inspector and the sidebar's recent
   searches. Values from docs/design-board/Search.dc.html and PhoneSearch.dc.html. Owner: the search builder. */

/* The search view brings its own header (the query card): no view title, no phone meta row. */
#main:has(> #searchView:not([hidden])) > .vhead,
#main:has(> #searchView:not([hidden])) > .prow { display: none; }

/* ---------- header band ---------- */
.s-head { display: flex; flex-direction: column; gap: 14px; margin: 0 calc(-1 * var(--pad)); padding: 18px var(--pad) 16px;
  background: var(--bg-head); border-bottom: 1px solid var(--line); }
.s-qrow { display: flex; flex-wrap: wrap; align-items: stretch; gap: 14px; }

.s-query { flex: 1 1 340px; min-width: 0; display: flex; align-items: center; gap: 14px; }
.s-qthumb { position: relative; flex: none; width: 72px; height: 72px; border-radius: 12px; }
.s-qthumb.has-img { background: #fff; box-shadow: 0 0 0 1px var(--line-2); }
.s-qimg, .s-qmask { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: cover; border-radius: inherit; }
.s-qmask { image-rendering: pixelated; pointer-events: none; }
.s-qph { position: absolute; inset: 0; display: grid; place-items: center; border-radius: inherit; background: var(--accent-soft); color: var(--accent-icon); }
.s-qthumb.is-text .s-qph { background: var(--panel); color: var(--faint); box-shadow: inset 0 0 0 1px var(--line-2); }
.s-qthumb.has-img .s-qph { display: none; }
.s-qbusy { position: absolute; inset: 0; display: grid; place-items: center; border-radius: inherit; background: rgba(0, 0, 0, .45); }
.s-qbadge { position: absolute; right: -6px; bottom: -6px; width: 22px; height: 22px; display: none; place-items: center; border-radius: 50%;
  background: var(--accent-strong); border: 2px solid var(--bg-head); color: #fff; pointer-events: none; }
.s-qbadge .ic { width: 11px; height: 11px; stroke-width: 2; }
.s-qthumb.has-img .s-qbadge { display: grid; }
.s-qclear { position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; display: grid; place-items: center; padding: 0; border-radius: 50%;
  border: 2px solid var(--bg-head); background: var(--raised-2); color: var(--text); cursor: pointer; opacity: 0; transition: opacity .15s; }
.s-query:hover .s-qclear, .s-qclear:focus-visible { opacity: 1; }
@media (hover: none) { .s-qclear { opacity: 1; } }
.s-qtext { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.s-qlabel { color: var(--faint); font-size: 12px; }
.s-qname { font-size: 18px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-qfacts { color: var(--muted); font-size: 12px; }
.s-qshort, .s-qpick { display: none; }

.s-drop { flex: 0 1 230px; min-height: 72px; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 16px;
  border: 1.5px dashed var(--line-3); border-radius: 12px; background: transparent; color: var(--muted); cursor: pointer; transition: border-color .15s, color .15s; }
.s-drop:hover, .s-drop:focus-visible { border-color: var(--accent); color: var(--text-2); }
.s-drop-tx { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; font-size: 11.5px; text-align: left; }
.s-drop-t { color: var(--text); font-size: 13px; font-weight: 600; }

.s-row2 { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.s-modes { display: flex; padding: 3px; gap: 2px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; }
.s-modes button { height: 30px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-weight: 500; white-space: nowrap; cursor: pointer; }
.s-modes button:hover { color: var(--text); }
.s-modes button.na:not(.on) { color: var(--dim); }
.s-modes button.on { background: var(--accent-strong); color: #fff; font-weight: 600; }
.s-prompt { color: var(--accent-text); }
.s-modes button.on .s-prompt { color: var(--accent-ink); }
.s-modes .s-refine { display: none; }
.s-text { flex: 1 1 240px; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; background: var(--panel);
  border: 1px solid var(--line-2); border-radius: 10px; color: var(--faint); cursor: text; }
.s-text:focus-within { border-color: var(--accent); }
.s-text input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; outline: 0; background: transparent; color: var(--text); }
.s-text input::placeholder { color: var(--faint); }

.s-ctls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 22px; }
.s-ctl { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.s-ctl strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.s-ctl input { width: 130px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.s-ctl + .s-ctl input { width: 120px; }
.s-ctl input:disabled { opacity: .35; cursor: default; }
.s-sbtn { height: 32px; display: flex; align-items: center; gap: 6px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 8px;
  background: transparent; color: var(--text-2); font-size: 12px; cursor: pointer; white-space: nowrap; }
.s-sbtn:hover, .s-sbtn[aria-expanded=true] { background: var(--raised); }
.s-sbtn .k { color: var(--faint); }
.s-switch { display: flex; align-items: center; gap: 8px; padding: 0; border: 0; background: transparent; color: var(--text-2); font-size: 12px; cursor: pointer; }
.s-track { position: relative; width: 30px; height: 18px; flex: none; border-radius: 999px; background: var(--line-3); transition: background .15s ease; }
.s-knob { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #c9cad0; transition: left .15s ease, background .15s ease; }
.s-switch[aria-checked=true] .s-track { background: var(--accent-strong); }
.s-switch[aria-checked=true] .s-knob { left: 14px; background: #fff; }
.s-status { min-height: 17px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.s-status:empty { display: none; }

/* ---------- results ---------- */
.s-body { position: relative; padding-top: 20px; }
.s-grid { transition: opacity .2s; }
.s-grid.busy { opacity: .55; }

.s-res { display: flex; flex-direction: column; gap: 7px; color: inherit; text-decoration: none; border-radius: 10px; transition: translate .16s ease; }
.s-res:hover { translate: 0 -2px; }
.s-res:focus-visible { outline: none; }
.s-frame { position: relative; flex: 1; min-height: 0; display: block; border-radius: 10px; overflow: hidden; background: var(--ph);
  outline: 2px solid transparent; outline-offset: 2px; transition: box-shadow .16s ease, outline-color .12s; }
.s-frame.ld { background: #fff; }
.s-res:hover .s-frame { box-shadow: 0 10px 26px rgba(0, 0, 0, .5); }
.s-res.sel .s-frame, .s-res:focus-visible .s-frame { outline-color: var(--accent); }
.s-th { width: 100%; height: 100%; display: block; object-fit: cover; opacity: 0; transition: opacity .2s; }
.s-th.ld { opacity: 1; }
.s-mask { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; pointer-events: none; }
.s-pill { position: absolute; top: 8px; left: 8px; padding: 3px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums;
  white-space: nowrap; color: #fff; background: rgba(17, 17, 19, .78); box-shadow: 0 2px 8px rgba(0, 0, 0, .25); pointer-events: none; }
.s-res.hi .s-pill { background: var(--accent-strong); }
/* several selected, or picking with "Select": a check (or an empty circle) at the top right */
.s-grid.multi .s-res.sel .s-frame::after, .s-grid.picking .s-frame::after { content: ""; position: absolute; top: 8px; right: 8px; width: 22px; height: 22px;
  border-radius: 50%; box-shadow: 0 2px 8px rgba(0, 0, 0, .4); pointer-events: none; }
.s-grid.picking .s-res:not(.sel) .s-frame::after { border: 2px solid #fff; background: rgba(0, 0, 0, .25); box-sizing: border-box; }
.s-grid.multi .s-res.sel .s-frame::after, .s-grid.picking .s-res.sel .s-frame::after {
  background: var(--accent-strong) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5l3 3 6-7'/%3E%3C/svg%3E") center / 12px no-repeat; }
.s-cap { flex: none; height: 32px; padding: 0 2px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.s-grid:not(.paths) .s-cap { display: none; }
/* right-to-left with an ellipsis: the folder is trimmed from the left, its deepest folders stay visible */
.s-dir { color: var(--faint); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; }
.s-name { color: var(--text-2); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- states: waiting, no region, errors, start ---------- */
.s-card { max-width: 440px; margin: 60px auto; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px; text-align: center;
  background: var(--sheet); border: 1px solid #2f3036; border-radius: 16px; }
.s-card .s-card-ic { width: 34px; height: 34px; color: var(--faint); stroke-width: 1.3; }
.s-card .s-card-ic.accent { color: var(--accent-icon); }
.s-card.err .s-card-ic { color: var(--danger); }
.s-card-t { font-size: 16px; font-weight: 650; }
.s-card-x { color: var(--muted); overflow-wrap: anywhere; }
.s-card .btn { margin-top: 6px; }
.s-wait { position: relative; }
.s-card.s-float { position: absolute; left: 50%; top: 90px; width: 380px; max-width: 90%; margin: 0; transform: translateX(-50%); padding: 22px;
  background: var(--sheet); box-shadow: 0 24px 60px rgba(0, 0, 0, .5); }
.s-spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent); animation: spin .9s linear infinite; }
.s-secs { color: var(--accent-text); font-variant-numeric: tabular-nums; min-height: 18px; }
.s-skel { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: start; }
.s-sk { border-radius: 10px; background: var(--panel); animation: pulse 1.6s ease-in-out infinite; }
.s-none { padding: 60px 0; text-align: center; color: var(--muted); }
.s-intro { max-width: 520px; }
.s-modes-help { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 8px 0 0; text-align: left; font-size: 12.5px; }
.s-modes-help dt { color: var(--text); font-weight: 600; white-space: nowrap; }
.s-modes-help dd { margin: 0; color: var(--muted); }
.s-engine { display: none; }

/* ---------- match inspector ---------- */
.m-preview { display: flex; align-items: center; justify-content: center; height: 220px; padding: 10px; border-radius: 14px; background: #fff; cursor: zoom-in; }
.m-pic { position: relative; display: inline-flex; max-width: 100%; max-height: 100%; }
.m-pic > img:first-child { display: block; max-width: 100%; max-height: 200px; object-fit: contain; opacity: 0; transition: opacity .2s; }
.m-pic > img.ld { opacity: 1; }
.m-mask { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; pointer-events: none; }
.m-score { display: flex; align-items: center; gap: 14px; }
.m-pct { font-size: 40px; font-weight: 750; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; color: #fff; }
.m-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.m-sub { color: var(--muted); font-size: 12px; }
.m-bar { height: 6px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.m-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.m-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.m-card { display: flex; flex-direction: column; gap: 2px; padding: 9px 11px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; min-width: 0; }
.m-card .k { color: var(--faint); font-size: 11.5px; }
.m-card .v { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.m-card .c { color: var(--faint); font: 11px/1.4 var(--mono); }
.m-details { display: flex; flex-direction: column; gap: 6px; }
.m-name { font-size: 14px; font-weight: 650; word-break: break-all; }
.m-path { position: relative; padding: 8px 36px 8px 10px; background: var(--sunk); border: 1px solid var(--line); border-radius: 8px;
  color: var(--muted); font: 11px/1.5 var(--mono); word-break: break-all; }
.m-copy { position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); cursor: pointer; }
.m-copy:hover { background: var(--raised); color: var(--text); }
.m-meta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.m-meta:empty { display: none; }
.m-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ins-btn.on { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.ins-sec.m-phone, .m-phone-act { display: none; }
@media (min-width: 768px) {
  .m-grid2 .ins-btn { height: 38px; gap: 6px; padding: 0 4px; font-size: 12.5px; }
  .m-grid2 .ic { width: 14px; height: 14px; }
}

/* ---------- sidebar: recent searches ---------- */
.s-rrow { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; padding: 6px 8px; border: 0; border-radius: 8px; background: transparent;
  color: var(--text-2); text-align: left; cursor: pointer; }
.s-rrow:hover { background: var(--hover); }
.s-rrow.on { background: var(--panel); color: var(--text); }
.s-rpic { width: 32px; height: 32px; flex: none; border-radius: 6px; object-fit: cover; background: #fff; }
.s-rtext { display: grid; place-items: center; background: var(--raised); color: var(--faint); }
.s-rtx { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.s-rname { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-rsub { color: var(--faint); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- phones (PhoneSearch.dc.html) ---------- */
@media (max-width: 767px) {
  .s-head { margin: 0; padding: 4px 0 6px; gap: 12px; background: none; border: 0; }
  .s-drop, .s-qlabel, .s-qfacts, .s-qbadge, .s-status { display: none !important; }
  .s-query { flex: 1 1 auto; gap: 12px; padding: 10px; background: var(--sheet); border: 1px solid var(--line-2); border-radius: 14px; }
  .s-qthumb { width: 52px; height: 52px; border-radius: 10px; }
  .s-qclear { border-color: var(--sheet); }
  .s-qname { font-size: 13px; font-weight: 600; letter-spacing: 0; }
  .s-qshort { display: block; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .s-qpick { display: grid; place-items: center; flex: none; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 10px; background: var(--raised); color: var(--text); cursor: pointer; }
  .s-row2 { gap: 10px; }
  .s-modes { flex: 1 1 100%; flex-wrap: nowrap; gap: 8px; margin: 0 calc(-1 * var(--pad)); padding: 0 var(--pad); overflow-x: auto; background: none; border: 0; border-radius: 0;
    scrollbar-width: none; }
  .s-modes::-webkit-scrollbar { display: none; }
  .s-modes button { flex: none; height: 36px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 999px; color: var(--text-2); font-size: 12.5px; }
  .s-modes button.on { border-color: var(--accent-strong); }
  .s-modes .s-refine { display: inline-flex; align-items: center; gap: 6px; }
  .s-modes .s-refine[aria-expanded=true] { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
  .s-head:not(.refine-open) .s-text, .s-head:not(.refine-open) .s-ctls { display: none; }
  .s-text { flex: 1 1 100%; height: 44px; border-radius: 12px; }
  .s-ctls { gap: 12px 18px; }
  .s-ctl { flex: 1 1 100%; }
  .s-ctl input, .s-ctl + .s-ctl input { flex: 1; width: auto; min-width: 0; }
  .s-sbtn { height: 36px; }
  .s-body { padding-top: 8px; }
  .s-res, .s-frame { border-radius: 12px; }
  .s-pill { top: 7px; left: 7px; }
  .s-skel { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .s-card { margin: 32px auto; }
  .s-card.s-float { top: 40px; }
  .s-modes-help { grid-template-columns: 1fr; gap: 2px; }
  .s-modes-help dd { margin-bottom: 6px; }
  /* the engine state sits in the top bar, where the name search button is in folders */
  .s-engine { position: fixed; z-index: 31; top: calc(18px + env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: flex; align-items: center; gap: 6px;
    padding: 6px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: rgba(139, 140, 147, .14); color: var(--muted); }
  .s-engine[hidden] { display: none; }
  .s-engine .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
  .s-engine[data-state=awake] { background: rgba(34, 197, 94, .12); color: #86efac; }
  .s-engine[data-state=awake] .dot { background: var(--ok); }
  .s-engine[data-state=waking] { background: rgba(245, 158, 11, .14); color: #fcd34d; }
  .s-engine[data-state=waking] .dot { background: var(--warn); animation: pulse 1.4s ease-in-out infinite; }
  .s-engine[data-state=error] { background: rgba(239, 125, 114, .14); color: #f5c0ba; }

  .ins-sec.m-desk, .m-desk-act { display: none; }
  .ins-sec.m-phone { display: flex; }
  .m-phone-act { display: flex; }
  .m-ph { display: flex; align-items: center; gap: 12px; }
  .m-ph-img { width: 76px; height: 76px; flex: none; border-radius: 12px; object-fit: cover; background: #fff; }
  .m-ph-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
  .m-ph-score { display: flex; align-items: baseline; gap: 8px; color: var(--muted); font-size: 12px; }
  .m-ph-pct { color: var(--text); font-size: 26px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
  .m-ph-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-ph-dir { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; }
  .m-ph-sig { color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
  .s-rrow { min-height: 44px; }
}
@media (hover: none) {
  .s-res:hover { translate: none; }
  .s-res:hover .s-frame { box-shadow: none; }
}
