/* "Recent searches": the sidebar button, the rail, the drawer, the /history page and the Clear-all
   dialog. Its own file because the React main page (client/) loads it too, without site.css: the
   server adds the drawer to that page (withHistoryDrawer in server/site/layout.js). Tokens come from
   whichever page it is on; the two React lacks have their site.css value as a fallback. */
/* hidden always wins inside the panel and the recents box, whatever display a part sets. */
.hpanel [hidden], .hrecents[hidden] { display: none !important; }
/* The sidebar button: an icon alone (its name read aloud and shown on hover), like a chat app's. */
.hbtn {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px;
  border-radius: 12px; color: var(--ink-2); text-decoration: none;
}
.hbtn:hover { background: var(--brand-soft); color: var(--ink); }
/* The screen's own top-left corner, not the content column's. */
.home-corner { display: flex; justify-content: flex-start; width: 100%; padding: 12px 12px 0; }

/* The rail: wide screens only, while the drawer is closed (it replaces the lone button there). */
.hrail { display: none; }
@media (min-width: 1100px) {
  :root { --hrail-w: 60px; }
  body.has-rail { padding-left: var(--hrail-w); }
  .has-rail .hbtn, .has-rail .home-corner { display: none; }
  .hrail {
    position: fixed; inset: 0 auto 0 0; z-index: 6; width: var(--hrail-w);
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 0;
    background: var(--surface); border-right: 1px solid var(--line);
  }
  /* Under the open sidebar it is covered; hidden once the slide is over, so Tab skips it. */
  .hrail { transition: visibility 0s; }
  html.hdock .hrail { visibility: hidden; transition: visibility 0s var(--hslide-ms); }
}
.hrail-btn {
  position: relative; display: grid; place-items: center; width: 44px; height: 44px;
  border-radius: 12px; color: var(--ink-2); text-decoration: none;
}
.hrail-btn:hover, .hrail-btn:focus-visible { background: var(--brand-soft); color: var(--ink); }
.hrail-btn:first-child { margin-bottom: 8px; }
/* Its name, in a dark tip to the right, on hover or keyboard focus. */
.hrail-btn::after {
  content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  padding: 6px 10px; border-radius: 8px; background: var(--ink); color: var(--surface);
  font-size: 13px; font-weight: 700; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s;
}
.hrail-btn:hover::after, .hrail-btn:focus-visible::after { opacity: 1; }

/* The drawer slides in from the left, like a chat app's history, and back out when closed. */
:root { --hslide-ms: .3s; --hslide-ease: cubic-bezier(.32, .72, 0, 1); }
.hdrawer {
  position: fixed; inset: 0 auto 0 0; margin: 0; padding: 0; border: 0;
  width: min(480px, 100vw); max-width: 100vw; height: 100vh; height: 100dvh; max-height: none;
  background: var(--surface); color: var(--ink); border-radius: 0 20px 20px 0;
  box-shadow: 16px 0 48px rgba(31, 42, 39, .18);
}
.hdrawer::backdrop { background: rgba(31, 42, 39, .32); }
@media (max-width: 639px) { .hdrawer { border-radius: 0; } }
/* Wide screens: docked beside the page (html.hdock, set in <head> and by site.js, moves the page
   over; .docked styles the drawer, and stays on it while it slides out). No dimming.
   1100px matches DOCK_WIDE in site.js and the <head> script (withHistoryDrawer, historyDockScript). */
@media (min-width: 1100px) {
  :root { --hdock-w: clamp(400px, 36vw, 480px); }
  html.hdock body { padding-left: var(--hdock-w); }
  .hdrawer.docked { z-index: 7; width: var(--hdock-w); border-radius: 0; box-shadow: none; border-right: 1px solid var(--line); }
}
/* Opened or closed by a click (site.js adds the class): it slides, its dimming fades, and a docked
   one carries the page with it. On page load it is simply there, part of the page. */
@media (prefers-reduced-motion: no-preference) {
  body.has-rail { transition: padding-left var(--hslide-ms) var(--hslide-ease); }
  .hdrawer.hslide-in { animation: hdrawer-in var(--hslide-ms) var(--hslide-ease); }
  .hdrawer.hslide-out { animation: hdrawer-out var(--hslide-ms) var(--hslide-ease) forwards; }
  .hdrawer.hslide-in::backdrop { animation: hfade-in var(--hslide-ms) ease-out; }
  .hdrawer.hslide-out::backdrop { animation: hfade-out var(--hslide-ms) ease-in forwards; }
  @keyframes hdrawer-in { from { transform: translateX(-100%); } }
  @keyframes hdrawer-out { to { transform: translateX(-100%); } }
  @keyframes hfade-in { from { opacity: 0; } }
  @keyframes hfade-out { to { opacity: 0; } }
}
.hpanel { display: flex; flex-direction: column; position: relative; }
.hdrawer .hpanel { height: 100%; }
.hpanel-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px 8px; }
.hpanel-title { flex: 1; font-family: var(--font-display); font-size: 25px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.hcount { font-size: 13px; font-weight: 700; color: var(--ink-2); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 1px 9px; }
.hclose { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--bg); font-size: 24px; line-height: 1; color: var(--ink-2); }
.hclose:hover { color: var(--ink); }
.hpanel-tools { padding: 0 20px; }
.hfilter {
  width: 100%; height: 44px; margin: 4px 0 8px; padding: 0 16px;
  border: 1.5px solid var(--line); border-radius: 22px; background: var(--surface); font-size: 16px;
}
.hfilter:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.hchips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.hchips::-webkit-scrollbar { display: none; }
.hchip {
  flex: none; min-height: 32px; padding: 0 12px; border-radius: 16px; font-size: 13px; font-weight: 700;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink-2);
}
.hchip:hover { border-color: var(--brand); }
.hchip[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.hpanel-body { flex: 1; overflow-y: auto; padding: 0 12px 12px; }
.hpaused { margin: 4px 8px 4px; padding: 10px 12px; border-radius: 12px; background: var(--brand-soft); color: var(--ink); font-size: 14px; font-weight: 600; }
.hgroup {
  position: sticky; top: 0; z-index: 1; margin: 0; padding: 12px 8px 4px;
  background: var(--surface); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
}
.hlist { list-style: none; margin: 0; padding: 0; }
.hrow { position: relative; border-radius: 14px; touch-action: pan-y; }
.hrow.swiping { background: var(--danger, #A33A2B); }
.hrow.swiping::after {
  content: '🗑️ Delete'; position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  color: #FFF; font-weight: 800; font-size: 14px;
}
.hrow-in { position: relative; z-index: 1; display: flex; align-items: flex-start; gap: 6px; padding: 10px 8px; border-radius: 14px; background: var(--surface); }
.hrow-in:hover, .hrow-in:focus-within { background: var(--bg); }
.hlink { flex: 1; min-width: 0; display: flex; gap: 12px; align-items: flex-start; color: inherit; text-decoration: none; }
.htile { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; background: var(--brand-soft); }
.hmain { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.hq { font-weight: 700; font-size: 16px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hlink:hover .hq { color: var(--brand); text-decoration: underline; }
.hq mark { background: var(--brand-soft); color: inherit; border-radius: 3px; padding: 0 1px; box-shadow: inset 0 -2px 0 var(--brand-edge, #BFD8CD); }
.hprev { margin-top: 1px; font-size: 14px; line-height: 1.4; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 5px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.hagree { padding: 1px 8px; border-radius: 8px; background: var(--brand-soft); color: var(--ink); }
.hagree-disagree { background: var(--error-bg); color: var(--error); }
.hfast { color: var(--brand); }
.hacts { flex: none; display: flex; gap: 2px; }
.hact { width: 34px; height: 34px; border: 0; border-radius: 50%; background: none; display: grid; place-items: center; font-size: 16px; line-height: 1; color: var(--ink-3); }
.hact:hover { background: var(--surface); box-shadow: 0 1px 4px rgba(31, 42, 39, .14); }
.hdel { font-size: 20px; padding-bottom: 2px; }
.hdel:hover { color: var(--danger, #A33A2B); }
@media (hover: none) { .hact { width: 44px; height: 44px; } }
.hpin { filter: grayscale(1); opacity: .55; }
.hpin[aria-pressed='true'] { filter: none; opacity: 1; }
/* With a mouse, a row's buttons show on hover; a pinned row keeps its pin showing. */
@media (hover: hover) {
  .hrow-in .hact { opacity: 0; }
  .hrow-in:hover .hact, .hrow-in:focus-within .hact, .hpin[aria-pressed='true'] { opacity: 1; }
  .hrow-in:hover .hpin:not([aria-pressed='true']), .hrow-in:focus-within .hpin:not([aria-pressed='true']) { opacity: .55; }
}
.hempty { margin: 18px 8px 0; color: var(--ink-2); }
.herror { color: var(--danger, #A33A2B); font-weight: 600; }
.hnote { margin: 20px 8px 0; font-size: 12.5px; color: var(--ink-3); }
.hnote a { color: inherit; }
.htoast {
  position: absolute; left: 16px; right: 16px; bottom: 76px; z-index: 3;
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px;
  background: var(--ink); color: var(--surface); font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
.htoast span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.htoast-undo { flex: none; min-height: 36px; padding: 0 12px; border: 0; border-radius: 10px; background: var(--surface); color: var(--ink); font-weight: 800; }
.hpanel-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.hpill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px;
  border-radius: 20px; border: 1.5px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 700; color: var(--ink-2);
}
.hpill:hover { border-color: var(--brand); color: var(--ink); }
.hpill.on { background: var(--brand-soft); border-color: var(--brand-edge, #BFD8CD); color: var(--ink); }
/* The /history page: the same panel, laid out in the page. */
.history .hpanel-head, .history .hpanel-tools, .history .hpanel-foot { padding-left: 0; padding-right: 0; }
.history .hpanel-body { padding-left: 0; padding-right: 0; }
.history .hpanel-head { padding-top: 24px; }
.history .hgroup { position: static; }
.history .hpanel-foot { margin-top: 16px; }
.history .htoast { position: fixed; left: 50%; right: auto; bottom: 24px; transform: translateX(-50%); width: min(420px, calc(100vw - 32px)); }

/* Recent searches, dropped down from a search box (.sbox is their positioning box). */
.hrecents {
  position: absolute; left: -2px; right: -2px; top: calc(100% + 6px); z-index: 20;
  padding: 6px; border-radius: 18px; background: var(--surface); text-align: left;
  border: 1.5px solid var(--line); box-shadow: 0 18px 40px rgba(31, 42, 39, .16);
}
.hrecents-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px 4px; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.hrecents-all { font-size: 13px; letter-spacing: 0; text-transform: none; font-weight: 700; }
.hrecents-list { list-style: none; margin: 0; padding: 0; }
.hrecent { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 10px; border-radius: 12px; color: var(--ink); font-weight: 600; text-decoration: none; }
.hrecent:hover, .hrecent:focus-visible { background: var(--bg); }
.hrecent .hq { font-size: 15px; font-weight: 600; }
.hrecent-icon { flex: none; width: 22px; text-align: center; }
/* A phone's top-bar box is narrow: its list spans the screen under the bar. */
@media (max-width: 639px) {
  .topbar .sbox { position: static; }
  .topbar .hrecents { left: 8px; right: 8px; top: calc(100% + 4px); }
}

.modal {
  width: min(360px, calc(100% - 32px)); border: 0; border-radius: 14px; padding: 24px;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 20px 50px rgba(31, 42, 39, .25);
}
.modal::backdrop { background: rgba(31, 42, 39, .5); }
.modal h2 { font-size: 18px; margin: 0 0 8px; }
.modal p { margin: 0; color: var(--ink-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal-actions .btn { min-height: 44px; }

/* The dialog's buttons (the same as site.css .btn, which the React page doesn't load). */
.modal-actions .btn {
  display: inline-flex; align-items: center; justify-content: center; padding: 0 20px; border-radius: 10px;
  font-size: 16px; font-weight: 600; text-decoration: none; border: 1.5px solid transparent;
}
.modal-actions .btn-2 { background: var(--surface); border-color: var(--brand); color: var(--brand); }
.modal-actions .btn-danger { background: var(--danger, #A33A2B); color: #FFF; }
