.library-search {
  position: relative;
  z-index: 5;
  margin: 24px 0 18px;
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--blue) 30%, var(--line));
  border-radius: 17px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--blue) 9%, transparent), transparent 58%),
    color-mix(in srgb, var(--bg-elevated) 76%, transparent);
  box-shadow: 0 10px 28px rgba(0,0,0,0.08);
}

.hero:has(.library-search) { z-index: 2; }
.library-search [hidden] { display: none !important; }

.search-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.search-title {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0.02em;
}

.search-heading .search-title {
  margin: 0;
}

.search-close {
  display: none;
  padding: 6px 2px 6px 12px;
  border: 0;
  color: var(--blue);
  background: transparent;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.search-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(142px, 0.36fr);
  gap: 8px;
}

.search-query,
.search-filter {
  position: relative;
  min-width: 0;
}

.search-query {
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  width: 20px;
  height: 20px;
  color: var(--muted-2);
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
  pointer-events: none;
}

.search-query input,
.search-filter select {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  font: inherit;
  font-size: 0.94rem;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.search-query input {
  padding: 11px 42px 11px 43px;
  font-weight: 550;
}

.search-query input::placeholder { color: var(--muted-2); opacity: 1; }
.search-query input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.search-filter select {
  appearance: none;
  -webkit-appearance: none;
  padding: 11px 38px 11px 13px;
  cursor: pointer;
}

.search-query input:hover,
.search-filter select:hover {
  border-color: var(--line-strong);
  background: color-mix(in srgb, var(--bg) 96%, transparent);
}

.search-query input:focus,
.search-filter select:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--blue) 72%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 17%, transparent);
  background: var(--bg);
}

.search-chevron {
  position: absolute;
  right: 12px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: var(--muted-2);
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  width: 34px;
  height: 34px;
  padding: 7px;
  border: 0;
  border-radius: 9px;
  color: var(--muted-2);
  background: transparent;
  cursor: pointer;
  transform: translateY(-50%);
}

.search-clear:hover { color: var(--text); background: var(--bg-card-strong, var(--bg-card)); }
.search-clear svg { display: block; width: 100%; height: 100%; stroke: currentColor; stroke-linecap: round; stroke-width: 1.8; }

.search-status {
  min-height: 1.35em;
  margin: 9px 2px 0;
  color: var(--muted-2);
  font-size: 0.78rem;
  line-height: 1.4;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: grid;
  gap: 3px;
  max-height: min(440px, 62vh);
  padding: 7px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 15px;
  background: color-mix(in srgb, var(--bg-elevated) 96%, transparent);
  box-shadow: 0 20px 52px rgba(0,0,0,0.28);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.search-result {
  display: grid;
  gap: 2px;
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  transition: background 130ms ease;
}

.search-result:hover,
.search-result:focus-visible {
  background: color-mix(in srgb, var(--blue) 12%, var(--bg-card));
  text-decoration: none;
}

.search-result strong,
.search-result span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.search-result strong { font-size: 0.91rem; line-height: 1.4; }
.search-result span { color: var(--muted); font-size: 0.82rem; line-height: 1.4; }
.search-empty { margin: 0; padding: 13px 12px; color: var(--muted); font-size: 0.88rem; }

.search-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hero-simple {
  grid-template-columns: minmax(0, 1fr);
}

.hero-simple h1 {
  max-width: none;
}

.library-search[data-simple-search] .search-controls {
  grid-template-columns: minmax(0, 1fr);
}

.library-overview .section-heading {
  margin-bottom: 18px;
}

.place-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.place-filters button {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 650;
  cursor: pointer;
}

.place-filters button:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.place-filters button[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--blue) 65%, var(--line));
  color: var(--text);
  background: color-mix(in srgb, var(--blue) 14%, transparent);
}

.place-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: color-mix(in srgb, var(--bg-elevated) 62%, transparent);
}

.place-card {
  display: grid;
  grid-template-columns: minmax(190px, 0.34fr) minmax(0, 1fr);
  min-width: 0;
  padding: 0 18px;
  border-top: 1px solid var(--line);
}

.place-card:first-child {
  border-top: 0;
}

.place-card[hidden] {
  display: none;
}

/* Live filtering (library-filter.js) hides rows in place. Grid/flex elements
   need an explicit override to beat their display value. */
.guide-topic[hidden],
.guide-topic-links a[hidden],
[data-filter-section][hidden],
[data-filter-empty][hidden] {
  display: none !important;
}

.filter-empty {
  max-width: var(--reading, 72ch);
  margin: 6px auto 0;
  padding: 44px 16px;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
}

.filter-empty strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 1rem;
}

.place-card-heading {
  display: grid;
  grid-column: 1;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 14px 18px 14px 0;
}

.place-flag {
  display: block;
  width: 40px;
  height: 30px;
  border: 1px solid color-mix(in srgb, var(--line-strong) 74%, transparent);
  border-radius: 5px;
  object-fit: cover;
  box-shadow: 0 2px 5px rgba(0,0,0,0.09);
}

.place-card-heading h3 {
  min-width: 0;
  margin: 0 0 2px;
  color: var(--text);
  font-size: 0.95rem;
  letter-spacing: -0.015em;
}

.place-card-heading span {
  display: block;
  color: var(--muted-2);
  font-size: 0.72rem;
}

.place-card > a,
.guide-topic-links a {
  position: relative;
  display: block;
  min-width: 0;
  padding: 14px 32px 14px 18px;
  border-left: 1px solid var(--line);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.place-card > a {
  grid-column: 2;
}

.place-card > a::after,
.guide-topic-links a::after {
  content: "\203A";
  position: absolute;
  top: 50%;
  right: 8px;
  color: var(--muted-2);
  transform: translateY(-50%);
}

.place-card > a:hover,
.guide-topic-links a:hover {
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 7%, transparent);
  text-decoration: none;
}

.place-card > a ~ a {
  border-top: 1px solid var(--line);
}

.place-empty {
  margin: 0;
  padding: 18px 0 4px;
  color: var(--muted);
}

.general-guide-list {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: color-mix(in srgb, var(--bg-elevated) 62%, transparent);
}

.guide-topic {
  display: grid;
  grid-template-columns: minmax(190px, 0.28fr) minmax(0, 1fr);
  border-top: 1px solid var(--line);
}

.guide-topic:first-child {
  border-top: 0;
}

.guide-topic-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 17px 18px;
}

.guide-topic-heading > span {
  color: var(--blue);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.guide-topic-heading h3 {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.35;
}

.guide-topic-links {
  min-width: 0;
  border-left: 1px solid var(--line);
}

.guide-topic-links a {
  border-left: 0;
  border-top: 1px solid var(--line);
}

.guide-topic-links a:first-child {
  border-top: 0;
}

.guide-topic-links strong,
.guide-topic-links span {
  display: block;
}

.guide-topic-links strong {
  padding-right: 8px;
  font-size: 0.92rem;
  line-height: 1.4;
}

.guide-topic-links span {
  margin-top: 3px;
  padding-right: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.library-disclaimer {
  max-width: 76ch;
  margin: 24px auto 0;
  color: var(--muted-2);
  font-size: 0.85rem;
  text-align: center;
}

.library-disclaimer strong {
  color: var(--muted);
}

@media (max-width: 760px) {
  .place-card,
  .guide-topic {
    grid-template-columns: minmax(0, 1fr);
  }

  .place-card-heading {
    grid-column: 1;
    padding-right: 0;
  }

  .place-card > a {
    grid-column: 1;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .guide-topic-heading {
    padding-bottom: 13px;
  }

  .guide-topic-links {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 640px) {
  html.search-overlay-open { overflow: hidden; }

  .library-search { margin-top: 20px; padding: 13px; }
  .search-controls { grid-template-columns: 1fr; }
  .search-query input,
  .search-filter select { min-height: 48px; }

  .library-search.search-mobile-active {
    position: fixed;
    z-index: 1000;
    top: var(--search-viewport-top, 0px);
    left: 0;
    width: 100%;
    height: var(--search-viewport-height, 100dvh);
    max-width: none;
    margin: 0;
    padding: max(14px, env(safe-area-inset-top)) 14px max(10px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: var(--bg);
    box-shadow: none;
    box-sizing: border-box;
  }

  .search-mobile-active .search-heading { flex: none; }
  .search-mobile-active .search-title { font-size: 0.9rem; }
  .search-mobile-active .search-close { display: block; }
  .search-mobile-active .search-controls,
  .search-mobile-active .search-status { flex: none; }
  .search-mobile-active .search-query input { font-size: 16px; }

  .search-mobile-active .search-results {
    position: static;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    margin: 10px -4px 0;
    padding: 5px 4px 0;
    overflow-y: auto;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    overscroll-behavior: contain;
  }

  .search-mobile-active .search-result {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
  }

  .search-mobile-active .search-result span {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .place-filters { gap: 6px; }
  .place-filters button { min-height: 36px; padding: 7px 11px; font-size: 0.8rem; }
  .place-card { padding: 0 14px; }
  .place-card-heading { padding-top: 13px; padding-bottom: 13px; }
  .place-card > a { padding: 12px 28px 12px 0; }
  .guide-topic-heading { padding: 15px 14px 12px; }
  .guide-topic-links a { padding: 12px 30px 12px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .search-query input,
  .search-filter select,
  .search-result { transition: none; }
}

/* ============================================================
   Library hubs (Help Center + Travel Rules) — card-grid layout
   Ported from the redesign mockups, driven by library-filter.js.
   ============================================================ */

.hub-hero {
  max-width: 840px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}
.hub-hero::before { display: none; }
.hub-hero .hero-copy { padding: 4px 0 0; }
.hub-hero .eyebrow { justify-content: center; }
.hub-hero h1 { max-width: none; margin-inline: auto; }
.hub-hero .subtitle { max-width: 58ch; margin-inline: auto; }

.hub-hero .library-search-inline {
  max-width: 560px;
  margin: 26px auto 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
}
.hub-hero .library-search-inline .search-controls { grid-template-columns: minmax(0, 1fr); }

.hub-content {
  max-width: 840px;
  margin: 6px auto 0;
}

.hub-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 0 0 30px;
}
.hub-chips button {
  min-height: 38px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}
.hub-chips button:hover { border-color: var(--line-strong); color: var(--text); }
.hub-chips button[aria-pressed="true"] {
  border-color: var(--blue);
  color: #fff;
  background: var(--action-pill-gradient);
}

.hub-section { margin-bottom: 34px; }
.hub-section[hidden] { display: none !important; }

.hub-label {
  margin: 0 0 13px;
  color: var(--muted-2);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.hub-count { font-variant-numeric: tabular-nums; }

.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

/* Guide card — Help topics and Travel Rules general guides */
.hub-card {
  display: block;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-card);
  color: inherit;
  text-decoration: none;
  transition: border-color 140ms ease, background 140ms ease;
}
.hub-card:hover {
  border-color: var(--line-strong);
  background: color-mix(in srgb, var(--bg-elevated) 82%, var(--bg-card));
}
.hub-card .q {
  margin: 0 0 5px;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -0.01em;
}
.hub-card .d {
  margin: 0;
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.5;
}
.hub-card[hidden] { display: none !important; }

/* Place card — flag + name + type + article links */
.hub-place {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-card);
}
.hub-place[hidden] { display: none !important; }
.hub-place-head {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 4px;
}
.hub-flag {
  flex-shrink: 0;
  width: 28px;
  height: 19px;
  border-radius: 4px;
  object-fit: cover;
  border: 0.5px solid rgba(0, 0, 0, 0.25);
  background: var(--bg-elevated);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16);
}
.hub-place-name {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.hub-place-type {
  color: var(--muted-2);
  font-size: 0.72rem;
}
.hub-article {
  display: block;
  padding: 9px 0;
  color: var(--blue);
  font-size: 0.855rem;
  line-height: 1.4;
  text-decoration: none;
}
.hub-article + .hub-article { border-top: 1px solid var(--line); }
.hub-article:hover { color: color-mix(in srgb, var(--blue) 68%, var(--text)); }

/* Numbered general-guide groups (01 / 02 / 03) */
.hub-guides-group { margin-bottom: 24px; }
.hub-guides-group[hidden] { display: none !important; }
.hub-guides-head {
  display: flex;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 12px;
}
.hub-num {
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}
.hub-guides-name {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
}

.hub-disclaimer {
  max-width: 76ch;
  margin: 28px auto 0;
  color: var(--muted-2);
  font-size: 0.85rem;
  line-height: 1.5;
  text-align: center;
}
.hub-disclaimer strong { color: var(--muted); }

@media (max-width: 600px) {
  .hub-chips { gap: 6px; }
  .hub-chips button { min-height: 36px; padding: 7px 12px; font-size: 0.8rem; }
  .hub-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .hub-chips button,
  .hub-card { transition: none; }
}
