/* Toolbar */
.tg-toolbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: rgba(248,250,252,.92);
  backdrop-filter: saturate(1.4) blur(6px);
  border-bottom: 1px solid #e2e8f0;
  overflow: visible;            /* ensure nothing is clipped here */
}
.tg-toolbar-inner { padding: .75rem 0; }

/* Selected chips */
.selected-chips { color: #000; display:flex; gap:.5rem; flex-wrap:wrap; text-decoration: none;}
.chip {
  display:inline-flex; align-items:center; gap:.4rem;
  padding:.35rem .6rem; border:1px solid #e2e8f0; border-radius:999px;
  background:#f8fafc; font-weight:600; text-decoration: none; color: #000;
}

.chip .x:hover{ opacity:1; text-decoration: none;}

/* Result card tag pills (click to filter) */
.tag-pill { cursor:pointer; user-select:none; }
.tag-pill.active {
  background: #e9f5ff !important;
  border-color: #373a3cff !important;
}
.tag-pill .count { opacity:.6; margin-left:.25rem; }

.dropdown-toggle { font-weight: 600; } /* keep your typographic choice */

/* Clear All vertical centering */
.btn-outline-danger.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
  padding-top: .25rem;
  padding-bottom: .25rem;
}

.btn { box-shadow: 0 6px 18px rgba(15,23,42,.06); }

.entry-card {
  margin-bottom: 12px;
  border-radius: 8px;
}

/* ---- Search form layout ---- */
/* Make the form a column (title above input, centered) */
#searchForm{
  display: flex;               /* (already in your HTML, here for completeness) */
  flex-direction: column;      /* title above input */
  align-items: center;         /* center horizontally */
}

/* Wrapper constrains width + anchors suggestion menu */
.search-wrap {
  position: relative;
  width: 100%;
  max-width: 640px;            /* unified cap for input + suggestions */
  margin: 0 auto;              /* center */
}

/* The input simply fills the inner wrapper */
.search-pill{
  width: 100%;
  border-radius: 999px;
  padding-left: 2.25rem;    /* leave space for icon */
  padding-right: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* Icon is now positioned relative to .search-inner (always correct) */
.search-icon{
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  pointer-events: none;
  color: #64748b;
}

.search-pill {
  width: 100%;
  border-radius: 999px;
  padding-left: 2.25rem;    /* space for icon */
  padding-right: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);

  font-size: 1.1rem;     /* increase text size (default ~1rem) */
  font-weight: 600;      /* semi-bold */
  line-height: 1.4;      /* a bit more breathing room */

}

/* New inner wrapper: the thing that actually defines the input’s width */
.search-inner{
  position: relative;
  width: min(600px, 90%);   /* mobile/tablet default */
  margin: 0 auto;           /* center */
}

/* Make the search field full-width on phones in PORTRAIT */
@media (max-width: 576px) and (orientation: portrait) {
  .search-pill {
    width: 100%;
    max-width: 100%;
  }
}

/* Mobile-landscape “page doesn’t stretch” fix */
@media (orientation: landscape) and (max-width: 900px){
  .container{ max-width: 100% !important; }
}

/* Desktop: shrink neatly */
@media (min-width: 992px){
  .search-inner{ width: 400px; }   /* pick your width */
}

/* Respect iOS safe areas (Dynamic Island / notch) */
@supports (padding: max(0px)) {
  .container {
    padding-left: max(var(--bs-gutter-x, 1rem), env(safe-area-inset-left));
    padding-right: max(var(--bs-gutter-x, 1rem), env(safe-area-inset-right));
  }
}
@media (orientation: landscape) {
  .container {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}

/* ---- Fake dropdown rail (chip-style tag groups) ---- */
.chip-rail {
  display: flex;
  flex-wrap: nowrap;           /* single row */
  gap: 8px;
  overflow-x: auto;            /* horizontal scroll */
  overflow-y: visible;         /* allow menus to extend downward */
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.chip-rail::-webkit-scrollbar { display: none; }
.chip-rail { scrollbar-width: none; }

.chip-dropdown {
  position: relative;          /* anchor when not portaled */
  display: inline-block;
  flex: 0 0 auto;              /* keep width; do not shrink */
}

.chip-toggle {
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
}

/* Menu (used both in-place and when portaled to body) */
.chip-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 280px;
  max-width: 75vw;
  max-height: 360px;
  overflow: auto;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: .5rem;
  box-shadow: 0 12px 24px rgba(15,23,42,.18);
  display: none;               /* hidden by default */
  z-index: 1080;
}
/* When portaled to <body>, switch to fixed positioning so it ignores clipping parents */
.chip-menu[data-portal="true"] {
  position: fixed;
  top: 0; left: 0;             /* will be set inline by JS */
  display: block;
  z-index: 2000;               /* above everything in the toolbar */
}
/* Visible state when not portaled (kept for completeness) */
.chip-menu.show { display: block; }

/* Items inside menu */
.chip-item {
  padding: .5rem .75rem;
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
}
.chip-item:hover { background:#f8fafc; }
.chip-item.active { background:#eef6ff; }

.chip-item .label { white-space: normal; line-height: 1.3; }
.chip-item .count { margin-left: .5rem; opacity: .7; }

/* iOS scroll tweak */
@supports (-webkit-touch-callout: none) {
  .chip-rail { -webkit-overflow-scrolling: touch; }
}

/* Suggestions menu should follow the inner wrapper’s width */
.suggest-menu{
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;              /* match .search-inner width */
  max-width: none;          /* no extra cap needed now */
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15,23,42,.10);
  padding: 6px;
  z-index: 1500;
}

.suggest-item{
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .6rem;
  border-radius: 8px;
  cursor: pointer;
}
.suggest-item.is-active { background: #f1f5f9; }
.suggest-item:hover,
.suggest-item.is-active{ background: #f8fafc; }
.suggest-empty{
  padding: .45rem .6rem;
  color: #64748b;
}

/* ---- Typewriter caret + measuring mirror ---- */
.typewriter { position: relative; }

.type-caret, .tw-mirror { left: 0; } 

.type-caret{
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 1.2em;               /* roughly text line-height */
  background: #0f172a;         /* match your text color */
  opacity: .9;
  pointer-events: none;
  animation: tw-blink 1s steps(1,end) infinite;
  /* left is set from JS */
}

@keyframes tw-blink {
  0%, 50% { opacity: .0; }
  51%,100% { opacity: .9; }
}

/* Hidden mirror used to measure text width */
.tw-mirror{
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  visibility: hidden;
  white-space: pre;
  font: inherit;
  letter-spacing: inherit;
  box-sizing: border-box;
}

/* keep bullets aligned and breathable */
  #pros-cons-heading + .row ul li div > div { line-height: 1.35; }
  .bg-success-subtle { background-color: #e6f4ea !important; }
  .bg-danger-subtle  { background-color: #fde7e9 !important; }