/* ── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Roboto", sans-serif;
  background: #fff;
  color: #222;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 21vh;
  padding-bottom: 2rem;
  padding-left: 2rem;
  padding-right: 2rem;
}


/* ── Homepage header bar ─────────────────────────────── */
.hp-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #ddd;
  height: 62px;
}
.hp-header-left {
  flex: 1;
  min-width: 0;
}
.hp-header-center {
  flex: 0 0 740px;
  padding-left: 5px;
}
.hp-header-right {
  flex: 1;
  min-width: 0;
}
.hp-logo-icon {
  width: 24px;
  height: 24px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}
.dir-title { font-family: Roboto, sans-serif; font-size: 24px; font-weight: 700; margin: 0; }
.hp-logo {
  line-height: 1.2;
  color: #4285F4;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.hp-logo:hover { text-decoration: none; }
.hp-mobile-logo { display: none !important; }

/* ── Search box area ──────────────────────────────────── */
.search-wrap {
  width: 100%;
  max-width: 740px;
  position: relative;
}
#searchArea {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}
h1 {
  width: calc(100% - 70px); /* reserve the .btn-cluster's width so centered text lines up with the search pill, not the full row */
  text-align: center;
  font-family: "Google Sans", "Roboto", sans-serif;
  font-size: clamp(3.3rem, 12vw, 6rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-bottom: 1.2rem;
  color: #4285F4;
  cursor: pointer;
  user-select: none;
}
.search-row {
  flex: 1;
  display: flex;
  gap: 0;
  background: #fff;
  border: 1px solid #ebebeb;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
  transition: box-shadow 0.2s;
}
.search-row:focus-within {
  box-shadow: 0 2px 12px rgba(0,0,0,0.14);
  border-color: #cccccc;
}
.search-row.suggest-open {
  border-bottom-left-radius: 0;
}
.testing-msg {
  margin-top: 6px;
  padding-left: 50px;
  font-size: 0.8rem;
  color: #888;
  text-align: left;
}
.testing-msg strong {
  color: #555;
}
#q {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  padding: 15px 20px;
  font-family: "Google Sans", "Roboto", sans-serif;
  font-size: 18px;
  background: transparent;
  color: #202124;
  caret-color: #202124;
}
#topicTag {
  display: none;
  align-items: center;
  padding: 0 8px 0 16px;
  font-size: 1rem;
  font-weight: 400;
  gap: 6px;
  white-space: nowrap;
  border-right: 1px solid #e0e0e0;
  cursor: default;
}
#topicTag { cursor: pointer; }
#topicTag:hover { filter: brightness(0.93); }
#searchBtn {
  border: none;
  background: #4285F4;
  color: #fff;
  padding: 15px 24px;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s;
}
#searchBtn:hover { background: #3367d6; }
#clearInputBtn {
  display: none;
  align-self: center;
  border: none;
  background: #f0f0f0;
  color: #888;
  font-weight: 500;
  font-size: 1.1rem;
  padding: 10px 15px;
  margin: 0 6px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
}
#clearInputBtn:hover { background: #e0e0e0; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
#quoteBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  font-family: monospace;
  font-weight: 500;
  font-size: 1rem;
  flex-shrink: 0;
}

/* ── Expand button cluster ───────────────────────────── */
.btn-cluster {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
#expandBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  font-size: 1.1rem;
  flex-shrink: 0;
}
#expandBtn.active {
  background: #e8edf8;
  border-color: #c5d0ea;
  color: #4285F4;
}
.expand-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  transition: max-height 0.22s ease, opacity 0.18s ease;
  z-index: 50;
}
.expand-panel.open {
  max-height: 200px;
  opacity: 1;
  pointer-events: auto;
}
.expand-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid #eee;
  background: #f0f0f0;
  color: #888;
  font-size: 1rem;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.expand-item:hover { background: #e0e0e0; }

/* ── Autocomplete dropdown ────────────────────────────── */
.suggestions {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-top: none;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  display: none;
  z-index: 10;
  max-height: 260px;
  overflow-y: auto;
  font-family: "Google Sans", "Roboto", sans-serif;
}
.suggestions.open { display: block; }
.suggestions div {
  padding: 10px 20px;
  cursor: pointer;
  font-size: 18px;
  border-bottom: 1px solid #f0f0f0;
}
.suggestions div:last-child { border-bottom: none; }
.suggestions div:hover,
.suggestions div.active { background: #f0f4ff; }
.suggestions .prefix { font-weight: 500; }
.suggestions div.history-item { padding-left: 10px; display: flex; align-items: center; }
.suggestions .history-clock { filter: grayscale(1); opacity: 0.5; margin-right: 30px; }

/* ── Site filter row ─────────────────────────────────── */
.site-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-left: 2px;
}
.site-label {
  font-family: monospace;
  font-size: 0.85rem;
  color: #999;
  flex-shrink: 0;
  user-select: none;
}
.site-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  padding: 0 10px;
  width: 22rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.site-input-wrap:focus-within {
  border-color: #ccc;
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}
#siteInput {
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.9rem;
  padding: 6px 4px;
  width: 100%;
  color: #333;
}
#siteInput::placeholder { color: #bbb; }
.site-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: #aaa;
  font-size: 1.1rem;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
}
.site-clear:hover { color: #555; }
.site-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  z-index: 200;
  overflow: hidden;
}
.site-sug-item {
  padding: 8px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  color: #333;
  font-family: monospace;
  border-bottom: 1px solid #f4f4f4;
}
.site-sug-item:last-child { border-bottom: none; }
.site-sug-item:hover,
.site-sug-item.active { background: #f0f4ff; }

/* ── Search history list ──────────────────────────────── */
.history-section {
  width: 100%;
  max-width: 680px;
  margin-top: 2.5rem;
  display: none;
}
.history-section.visible { display: block; }
.history-section h2 {
  font-size: 0.85rem;
  font-weight: 500;
  color: #888;
  letter-spacing: 0.05em;
  margin-bottom: 0.8rem;
  padding-left: 4px;
}
.history-section h2 .heading-suffix {
  font-weight: 400;
}
.history-list {
  list-style: none;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
}
.history-list li {
  padding: 10px 16px;
  background: rgb(242, 255, 245);
  margin-bottom: 4px;
  border-radius: 8px;
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  border: 1px solid #eee;
  cursor: pointer;
  transition: background 0.1s;
}
.history-list li:hover { background: #cdeed4; }
.history-list .empty {
  color: #aaa;
  font-style: italic;
  cursor: default;
  border: none;
  background: transparent;
}
.history-list .empty:hover { background: transparent; }
.history-list li.clear-btn {
  background: #f0f0f0;
  color: #888;
  font-weight: 500;
}
.history-list li.clear-btn:hover { background: #e0e0e0; }
#domainsList li:not(.clear-btn):not(.empty) { font-family: monospace; }

/* ── Topic buttons ───────────────────────────────────── */
.topic-section {
  width: 100%;
  max-width: 680px;
  margin-top: 2.5rem;
}
.topic-section h2 {
  font-size: 0.85rem;
  font-weight: 500;
  color: #888;
  letter-spacing: 0.05em;
  margin-bottom: 0.8rem;
  padding-left: 4px;
}
.topic-section h2 .heading-suffix {
  font-weight: 400;
}
/* buildTopics() emits exactly three .topic-row children, width-balanced, so the
   line count never depends on wrapping. Rows are max-content wide and run past
   the 680px content column into the whitespace on the right; the heading and the
   first pill of each row stay left-aligned with the rest of the page. */
.topic-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.topic-row {
  display: flex;
  flex-direction: row;
  gap: 8px;
}
.welcome-msg {
  width: 100%;
  max-width: 680px;
  margin-top: 2.4rem;
  padding-left: 4px;
  color: #888;
  font-size: 0.85rem;
}
.welcome-msg .welcome-title {
  font-weight: 500;
  margin-bottom: 0.5rem;
}
.welcome-msg ul {
  list-style: disc;
  padding-left: 1.2em;
  line-height: 1.7;
}
.directory-link-wrap {
  width: 100%;
  max-width: 640px;
  margin-top: 1.2rem;
}
.directory-link {
  font-size: 0.95rem;
  font-weight: 700;
  color: #483D8B;
  text-decoration: underline;
}
.demo-link {
  background: none;
  border: none;
  padding: 0;
  color: #1a73e8;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.topic-list li {
  padding: 10px 11px;
  border-radius: 8px;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.1s;
  white-space: nowrap;
}

/* ── Page footer ───────────────────────────────────────── */
.page-footer {
  width: 100%;
  max-width: 680px;
  text-align: center;
  font-size: 0.85rem;
  color: #70757a;
  padding: 2rem 0 1rem;
  margin-top: 1rem;
  border-top: 1px solid #e8eaed;
}
.page-footer a { color: #1a73e8; text-decoration: none; margin: 0 2px; }
.page-footer a:hover { text-decoration: underline; }
.search-timing { color: #9aa0a6; font-size: 0.8rem; }

/* ── "Search results" placeholder ─────────────────────── */
.results-section {
  width: 100%;
  max-width: 680px;
  margin-top: 3rem;
  display: none;
}
.results-section.visible { display: block; }
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 4px;
  margin-bottom: 0.8rem;
}
.results-section h2 {
  font-size: 0.85rem;
  font-weight: 500;
  color: #888;
  letter-spacing: 0.05em;
  margin: 0;
}
.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  font-size: 0.9rem;
  border-radius: 6px;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.share-btn.copied { background: #4caf50; border-color: #43a047; }
.share-btn img { width: 1rem; height: 1rem; object-fit: contain; opacity: 0.5; }
.results-section .placeholder { padding: 4px 0; }
.result-status { color: #70757a; font-style: italic; padding: 8px 0; }
.result-error  { color: #d93025; padding: 8px 0; }
.search-result { padding: 8px 0; }
.search-result .site-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.search-result .site-row > div { min-width: 0; overflow: hidden; }
.search-result .site-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1.5px solid #ccc;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #999; flex-shrink: 0;
  overflow: hidden;
}
.search-result .site-icon img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.search-result .site-name { font-size: 1.1rem; color: #202124; font-weight: 400; }
.search-result .site-url  { font-size: 0.95rem; color: #4d5156; display: flex; align-items: baseline; overflow: hidden; flex-wrap: nowrap; }
.site-url-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex-shrink: 1; }
.topic-badge   { flex-shrink: 0; margin-left: 6px; padding: 1px 5px; border-radius: 3px; white-space: nowrap; }
.search-result .result-title {
  font-size: 1.55rem;
  color: #1a0dab;
  margin-bottom: 4px;
  cursor: pointer;
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-result .result-title > a { flex: 1; min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-result .result-title:hover > a { text-decoration: underline; }
.result-desc {
  font-size: 1.1rem;
  color: #4d5156;
  line-height: 1.58;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-result .result-missing { font-size: 0.85rem; color: #70757a; margin-top: 6px; }
.search-result .result-missing a { color: #1a0dab; text-decoration: none; cursor: pointer; }
.search-result .result-missing a:hover { text-decoration: underline; }

/* ── Result thumbnail (desktop only, left-gutter positioned) */
.result-body { display: block; }
.result-thumb-wrap {
  display: none;
  position: absolute;
  left: -190px;
  top: 32px;
  text-decoration: none;
}
.result-thumb {
  display: block;
  width: 160px;
  max-height: 200px;
  object-fit: cover;
  object-position: top;
  border-radius: 4px;
  border: 1px solid #e0e0e0;
  cursor: pointer;
}
.result-thumb-large {
  display: none;
  position: fixed;
  width: 800px;
  max-width: calc(100vw - 16px);
  border-radius: 4px;
  border: 1px solid #ccc;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  z-index: 50;
}
.search-result.has-thumb { position: relative; }
.search-result.has-thumb .result-thumb-wrap { display: block; }
.result-thumb-wrap:hover .result-thumb-large { display: block; }
body.disable-thumbs .result-thumb-wrap { display: none !important; }

/* ── Per-result kebab menu ──────────────────────────────── */
.result-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  background: #fff;
  box-shadow: -10px 0 8px 6px #fff;
}
.result-menu {
  position: relative;
}
.result-menu-btn,
.result-feedback-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  font-size: 0.9rem;
  border-radius: 6px;
  flex-shrink: 0;
}
.result-menu-btn.active,
.result-feedback-btn.active {
  background: #e8edf8;
  border-color: #c5d0ea;
  color: #4285F4;
}
.result-feedback {
  position: relative;
}
.result-feedback:has(.result-feedback-panel.open) {
  background: #fff;
  border-radius: 6px;
}
.search-result .result-title:has(.result-feedback-panel.open) {
  background: #fff;
  border-radius: 6px;
  position: relative;
  z-index: 48;
}
.result-feedback-panel {
  position: absolute;
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  transition: max-height 0.22s ease, opacity 0.18s ease;
  z-index: 50;
  background: #fff;
  border-radius: 6px;
  padding: 0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.result-feedback-panel.open {
  padding: 6px 4px;
}
.result-feedback-panel--up {
  bottom: calc(100% + 4px);
}
.result-feedback-panel--down {
  top: calc(100% + 4px);
}
.result-feedback-panel.open {
  max-height: 200px;
  opacity: 1;
  pointer-events: auto;
}

/* ── Yellow-thumbs variant: panel slides from behind the button ─ */
/* Toggle A/B: add/remove "result-feedback-yellow-thumbs" on the  */
/* container div in page.html. JS stays on .result-feedback.       */
.result-feedback.result-feedback-yellow-thumbs .result-feedback-panel {
  align-items: flex-start;
}
.result-feedback.result-feedback-yellow-thumbs .result-feedback-panel--up {
  bottom: 0;
}
.result-feedback.result-feedback-yellow-thumbs .result-feedback-panel .result-menu-item {
  font-size: 0.9rem;
  padding-left: 0.5rem;
}
.result-menu-panel {
  position: absolute;
  top: 0;
  left: calc(100% + 4px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  transition: max-height 0.22s ease, opacity 0.18s ease;
  z-index: 50;
}
.result-menu-panel.open {
  max-height: 200px;
  opacity: 1;
  pointer-events: auto;
}
.result-menu-item {
  display: flex;
  align-items: center;
  padding: 0 12px;
  height: 1.8rem;
  font-size: 0.9rem;
  border-radius: 6px;
  white-space: nowrap;
  text-decoration: none;
}
.result-feedback-panel .result-menu-item {
  padding-left: 4px;
}
.rfb-m { display: none; }
.result-menu-item--disabled {
  cursor: default;
  pointer-events: none;
}

/* ── Settings cogwheel & panel ─────────────────────────── */
.settings-gear {
  position: fixed;
  top: 10px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  cursor: pointer;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: background 0.15s;
}
.settings-gear:hover { background: #f0f0f0; }

.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 430px;
  height: 100%;
  background: #fff;
  box-shadow: -2px 0 16px rgba(0,0,0,0.15);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 10001;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.settings-panel.open { transform: translateX(0); }
.settings-panel-hdr {
  display: block;
  width: 100%;
  cursor: pointer;
  margin-bottom: 1.5rem;
}
.settings-panel h2 {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 0;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  font-size: 0.95rem;
  color: #333;
  border-bottom: 1px solid #f0f0f0;
}
.algo-selector { display:flex; gap:1rem; }
.algo-selector label { display:flex; align-items:center; gap:4px; cursor:pointer; font-size:0.95rem; }
.settings-gap {
  padding: 12px 0;
  min-height: 22px;
}
.settings-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.settings-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.settings-switch .slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  transition: 0.2s;
  border-radius: 22px;
  cursor: pointer;
}
.settings-switch .slider::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  transition: 0.2s;
  border-radius: 50%;
}
.settings-switch input:checked + .slider { background: #4285F4; }
.settings-switch input:checked + .slider::before { transform: translateX(18px); }

.settings-spacer {
  height: 24px;
}

.settings-section-label {
  font-size: 1.1rem;
  font-weight: 500;
  padding: 14px 0 2px;
}

.settings-blurb {
  font-size: 0.85rem;
  color: #555;
  line-height: 1.6;
  padding: 6px 0 10px;
}

.settings-row--action {
  justify-content: flex-end;
  border-bottom: none;
}

.settings-acc {
  border-bottom: 1px solid #e8e8e8;
}
.settings-acc-hdr {
  padding: 14px 0;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.acc-hdr-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.acc-title {
  font-size: 1rem;
  font-weight: 500;
  color: #333;
  flex: 1;
}
.acc-chevron {
  font-size: 0.6rem;
  color: #888;
  transition: transform 0.2s;
  margin-left: 8px;
  flex-shrink: 0;
}
.settings-acc-hdr.open .acc-chevron {
  transform: rotate(180deg);
}
.settings-acc-hdr > .settings-blurb {
  flex-basis: 100%;
  margin: 2px 0 0;
}
.settings-acc-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.settings-acc-body.open {
  max-height: 800px;
}

#deleteHistoryBtn {
  font-weight: 400;
}

#restoreDefaultsBtn {
  font-weight: 400;
  align-self: flex-start;
  margin-top: 8px;
  color: #483D8B;
}

.btn-close {
  background: #f9f7ff;
  color: #333;
  border: 1px solid #c4b5fd60;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
  transition: background 0.15s;
}
.btn-close:hover { background: #f3effe; }
#settingsClose { margin-top: 24px; }

/* Language chiclets (settings sidebar - 8 quick options) */
.lang-chiclets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 12px 0 8px;
}
.lang-chip {
  background: var(--grp-bg, #f9f7ff);
  color: #333;
  border: 1px solid var(--grp-border, #c4b5fd60);
  border-radius: 8px;
  padding: 7px 4px;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.lang-chip:hover { background: #ede9ff; border-color: #c4b5fd; }
.lang-chip.selected {
  background: #483D8B;
  color: #fff;
  border-color: #483D8B;
}
.lang-all-row {
  display: flex;
  justify-content: flex-start;
  padding: 4px 0 12px;
}
.lang-all-btn {
  background: none;
  border: none;
  color: #483D8B;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.lang-all-btn:hover { color: #6c5ce7; }

/* Language full-screen page */
.lang-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 9000;
  flex-direction: column;
  overflow: hidden;
}
.lang-overlay.open { display: flex; }
.lang-overlay-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px 16px;
  border-bottom: 1px solid #e8e8e8;
  flex-shrink: 0;
}
.lang-overlay-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: #222;
}
.lang-overlay-close {
  background: #f9f7ff;
  border: 1px solid #c4b5fd60;
  color: #483D8B;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 8px;
  transition: background 0.15s;
}
.lang-overlay-close:hover { background: #ede9ff; }
.lang-overlay-blurb {
  font-size: 0.9rem;
  color: #666;
  padding: 14px 32px 4px;
  flex-shrink: 0;
}
.lang-overlay-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 32px 24px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  align-content: start;
}
.lang-group {
  background: var(--grp-bg);
  border: 1px solid var(--grp-border);
  border-radius: 10px;
  padding: 16px;
}
.lang-group-hdr {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--grp-hdr);
  margin: 0 0 12px;
}
.lang-group-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.lang-group-chips .lang-chip {
  flex: 0 0 auto;
  padding: 6px 14px;
}
.lang-overlay-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  border-top: 1px solid #e8e8e8;
  flex-shrink: 0;
}

/* Standard grey button */
.btn-gray {
  background: #f0f0f0;
  color: #888;
  border: 1px solid #eee;
  cursor: pointer;
  transition: background 0.15s, opacity 0.18s ease;
}
.btn-gray:hover { background: #e0e0e0; }

/* Standard app button */
.btn-std {
  background: #f9f7ff;
  color: #483D8B;
  border: 1px solid #c4b5fd60;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
  transition: background 0.15s;
}
.btn-std:hover { background: #f3effe; }

/* icon buttons and menu items override btn-std defaults */
.result-menu-btn,
.result-feedback-btn,
.share-btn {
  padding: 0;
  font-weight: 400;
  transition: background 0.15s, opacity 0.18s ease;
}
.result-menu-btn.fb-active {
  opacity: 0.1;
  pointer-events: none;
}
.result-feedback-spacer {
  position: absolute;
  top: 0;
  left: 100%;
  height: 1.8rem;
  width: 3rem;
  z-index: 10;
  pointer-events: none;
}
.result-feedback:has(.result-feedback-panel.open) .result-feedback-spacer {
  pointer-events: auto;
}
.result-menu-item {
  padding: 0 12px;
  font-weight: 400;
}

.settings-version {
  margin-top: auto;
  padding-top: 12px;
  font-size: 0.72rem;
  color: #999;
  text-align: right;
}

/* ── Toast notification ─────────────────────────────── */
#toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: #333;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 600;
  white-space: nowrap;
}
#toast.show { opacity: 1; }

/* ── Custom tooltip ─────────────────────────────────── */
#tooltip {
  position: fixed;
  z-index: 500;
  background: #111;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.5;
  pointer-events: none;
  display: none;
  max-width: 260px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.dir-promo {
  position: fixed;
  left: calc(50vw - 369px - 7rem);
  top: 20px;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  color: #1a73e8;
  text-decoration: none;
  white-space: nowrap;
  z-index: 5;
  letter-spacing: 0.02em;
}
.dir-promo:hover { text-decoration: underline; color: #1558b0; }

/* ── tablet (601px–1024px) ──────────────────────────────────────────────── */
@media (min-width: 601px) and (max-width: 1024px) {
  .dir-promo { left: 20px; top: 20px; }
}

/* ── mobile (max-width: 600px) ─────────────────────────────────────────── */
@media (max-width: 600px) {
  .hp-header {
    position: relative;
    align-self: stretch;
    margin-top: -3vh;
    margin-left: -1rem;
    margin-right: -1rem;
  }
  .hp-logo {
    font-size: 13px;
    font-weight: 700;
    color: #4285F4;
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.1;
    text-decoration: none;
  }
  .hp-header-center { flex: 1; display: flex; align-items: center; justify-content: center; }
  .hp-mobile-logo {
    display: block !important;
    font-size: clamp(2.4rem, 10vw, 3.2rem);
    width: auto;
    white-space: nowrap;
    margin: 0;
    line-height: 1;
    letter-spacing: -0.02em;
    text-align: center;
    position: relative;
    left: -5px;
  }
  .search-wrap h1 { display: none; }
  .search-wrap { padding-top: 30px; }
  .dir-promo { position: fixed; left: 7px; top: 0; font-size: 15px; text-align: center; }
  body {
    padding-top: 3vh;
    padding-left: 1rem;
    padding-right: 1rem;
    padding-bottom: calc(5rem + 100px);
  }
  h1 { white-space: nowrap; font-size: clamp(2.4rem, 10vw, 3.2rem); width: 100%; }
  .suggestions .history-clock { margin-right: 15px; }
  #tooltip { display: none !important; }
  #searchArea { margin-bottom: 10px; }
  .btn-cluster { display: none; }
  .site-input-wrap { width: 100%; max-width: 22rem; }
  .suggestions { right: 0 !important; z-index: 10; }
  #q { font-size: 16px; padding: 13px 14px; }
  #searchBtn { padding: 13px 16px; font-size: 1rem; }
  .history-section, .results-section { max-width: 100%; }
  .search-result .result-title { font-size: 1.35rem; }
  .result-desc  { font-size: 1rem; }
  .topic-section {
    width: 100vw;
    max-width: 100vw;
    margin-left: -1rem;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .topic-section::-webkit-scrollbar { display: none; }
  .topic-section h2 { padding-left: 1rem; }
  .welcome-msg { padding-left: 1rem; padding-right: 1rem; }
  .topic-list {
    display: grid;
    grid-template-rows: repeat(3, auto);
    grid-auto-flow: column;
    width: max-content;
    padding: 0 1rem 0.5rem;
  }
  /* Keep the pills as direct grid items so the mobile 3-row scroller is
     unaffected by the .topic-row wrappers the desktop layout needs. */
  .topic-row { display: contents; }
  .topic-list li { justify-content: center; }
  .settings-panel { width: 90%; }
  .settings-gear { position: absolute; }
  .result-menu-btn,
  .result-feedback-btn {
    width: 2.3rem;
    height: 2.3rem;
    font-size: 1.2rem;
  }
  .result-menu-panel {
    left: auto;
    right: calc(100% + 4px);
  }
  .result-menu-item {
    height: 2.7rem;
    padding: 0 18px;
    font-size: 1.275rem;
  }
  .result-feedback-panel {
    left: auto;
    right: 0;
    min-width: 18.7rem;
    max-width: 80vw;
  }
  .result-feedback-panel .result-menu-item {
    font-size: 1.275rem;
    white-space: normal;
    height: auto;
    min-height: 2.7rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    justify-content: flex-end;
    align-items: flex-start;
    text-align: right;
  }
  .rfb-d { display: none; }
  .rfb-m { display: inline; }
  .result-thumb-wrap { display: none !important; }
  .search-result.has-thumb { position: static; }

  /* tour: invite card must not overflow narrow screens */
  .tour-invite { min-width: 0; max-width: calc(100vw - 2rem); }
  .tour-invite p { white-space: normal; }

  /* tour: all popovers fill the available width on mobile */
  .gs-tour-popover.driver-popover { max-width: calc(100vw - 2rem); min-width: min(22rem, calc(100vw - 2rem)); }
  .gs-tour-popover-narrow.driver-popover { max-width: calc(100vw - 2rem); min-width: min(20rem, calc(100vw - 2rem)); }
  .gs-tour-popover .driver-popover-footer-btn { white-space: nowrap; font-size: 0.85rem; padding: 0.4rem 0.8rem; }
  .gs-tour-popover .driver-popover-footer { padding-bottom: 5px; }
}

/* ── Screenshot lightbox ────────────────────────────────── */
#thumbLightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.82);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-frame {
  position: relative;
  background: #fff;
  padding: 16px;
  border-radius: 6px;
  box-shadow: 0 8px 48px rgba(0,0,0,0.6);
}
.lightbox-img {
  display: block;
  max-width: calc(90vw - 32px);
  max-height: calc(90vh - 32px);
}
.lightbox-close {
  position: absolute;
  top: -15px;
  right: -15px;
  width: 32px;
  height: 32px;
  background: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  color: #444;
}

/* ── Guided tour (driver.js) ──────────────────────────── */
.tour-invite {
  position: fixed;
  z-index: 9999;
  background: #fff;
  border: 1px solid #ebebeb;
  border-radius: 1rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 1rem 1.2rem;
  text-align: center;
  min-width: 20rem;
  font-family: "Google Sans", "Roboto", sans-serif;
}
.tour-invite p { margin-bottom: 0.8rem; font-size: 1rem; color: #202124; white-space: nowrap; }
.tour-invite-actions { display: flex; gap: 0.6rem; justify-content: center; }
.tour-invite-close {
  all: unset;
  position: absolute;
  top: 0;
  right: 0;
  width: 32px;
  height: 28px;
  font-size: 18px;
  font-weight: 500;
  text-align: center;
  color: #888;
  cursor: pointer;
  transition: color 0.2s;
}
.tour-invite-close:hover { color: #333; }

.tour-invite-firstrun {
  background: #fde047;
  border-color: #000;
  color: #000;
}
.tour-invite-firstrun p { color: #000; }
.tour-invite-firstrun .tour-invite-close { color: #000; }
.tour-invite-firstrun .tour-invite-close:hover { color: #333; }
.tour-invite-firstrun .tour-btn-primary { background: #000; color: #fde047; }
.tour-invite-firstrun .tour-btn-primary:hover { background: #222; }

.tour-btn {
  border: none;
  border-radius: 1.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.tour-btn-primary { background: #4285F4; color: #fff; }
.tour-btn-primary:hover { background: #3367d6; }
.tour-btn-ghost { background: #f0f0f0; color: #555; }
.tour-btn-ghost:hover { background: #e0e0e0; }

.gs-privacy-highlight {
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px #10b981;
  background: rgba(16, 185, 129, 0.06);
  margin: 0 -12px;
  padding: 0 12px;
  transition: box-shadow 0.3s, background 0.3s;
}

.gs-tour-popover.driver-popover {
  border-radius: 1rem;
  font-family: "Google Sans", "Roboto", sans-serif;
  max-width: 26rem;
  background: #fff;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
}
.gs-tour-popover-narrow.driver-popover {
  max-width: 23rem;
}
.gs-tour-popover .driver-popover-title { color: #4285F4; }
.gs-tour-popover .driver-popover-footer-btn {
  border: none;
  border-radius: 1.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}
.gs-tour-popover .driver-popover-next-btn,
.gs-tour-popover .driver-popover-done-btn {
  background: #4285F4;
  color: #fff;
}
.gs-tour-popover .driver-popover-next-btn:hover,
.gs-tour-popover .driver-popover-done-btn:hover {
  background: #3367d6;
}
.gs-tour-popover .driver-popover-prev-btn {
  background: #f0f0f0;
  color: #555;
}
.gs-tour-popover .driver-popover-prev-btn:hover {
  background: #e0e0e0;
}
.gs-tour-popover .driver-popover-close-btn {
  color: #888;
}
.gs-tour-popover .driver-popover-close-btn:hover {
  color: #333;
}
.lightbox-close:hover { background: #f0f0f0; }

.gs-ok-btn {
  background: #4285F4 !important;
  color: #fff !important;
}
.gs-ok-btn:hover {
  background: #3367d6 !important;
}

/* ── Cookie consent bar (GDPR / ePrivacy) ───────────────── */
.cc-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1200;
  background: #fff;
  border-top: 1px solid #e8eaed;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
  transform: translateY(100%);
  visibility: hidden;
  transition: transform 0.3s ease, visibility 0s 0.3s;
}
.cc-bar.cc-open { transform: translateY(0); visibility: visible; transition: transform 0.3s ease, visibility 0s; }
.cc-inner {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.4rem 1.5rem 1.1rem;
  max-height: 80vh;
  overflow-y: auto;
}
.cc-title {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: #202124;
}
.cc-text {
  margin: 0 0 1.1rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #5f6368;
}
.cc-text-tight { margin-bottom: 0.8rem; }

.cc-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.4rem;
}
.cc-btn {
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  min-width: 8rem;
  justify-content: center;
}
.cc-btn-alt { margin-right: auto; border-radius: 8px; }
.cc-btn-primary {
  background: #483D8B;
  color: #fff;
  border-color: #483D8B;
}
.cc-btn-primary:hover { background: #3b3175; }

/* Category rows in the Customize view */
.cc-cat {
  border-top: 1px solid #f1f3f4;
  padding: 0.7rem 0;
}
.cc-cat-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.cc-cat-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #202124;
}
.cc-cat-always {
  font-size: 0.8rem;
  font-weight: 700;
  color: #9aa0a6;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cc-cat-desc {
  margin: 0.3rem 0 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #5f6368;
  max-width: 48rem;
}

/* Legal links line */
.cc-legal {
  margin-top: 1rem;
  padding-top: 0.8rem;
  border-top: 1px solid #f1f3f4;
  font-size: 0.8rem;
  color: #9aa0a6;
  text-align: center;
}
.cc-legal a { color: #1a73e8; text-decoration: none; margin: 0 2px; }
.cc-legal a:hover { text-decoration: underline; }

@media (max-width: 600px) {
  .cc-inner { padding: 1.1rem 1rem 0.9rem; max-height: 85vh; }
  .cc-title { font-size: 1rem; }
  .cc-text { font-size: 0.85rem; }
  .cc-actions { gap: 0.5rem; }
  .cc-btn { flex: 1 1 100%; min-width: 0; }
  .cc-btn-alt { margin-right: 0; order: 3; }
}
