.qtrend-widget{
  padding: 2.25rem 0;
}

.qtrend-card{
  position: relative;
  background: var(--bs-surface);
  border: 1px solid var(--bs-border-color);
  border-radius: 1rem;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.qtrend-card::before{
  content: "";
  position: absolute;
  inset: -40% -20% auto auto;
  width: 320px;
  height: 200px;
  background: radial-gradient(closest-side, rgba(14,165,233,.18), transparent 70%);
  pointer-events: none;
}

.qtrend-head{
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.15rem;
}

.qtrend-title h2{
  margin: 0;
  font-size: 1.35rem;
  color: var(--bs-heading);
}

.qtrend-kicker{
  margin: 0 0 .25rem;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--bs-muted);
}

.qtrend-sub{
  margin: .35rem 0 0;
  color: var(--bs-muted);
  font-size: .9rem;
}

.qtrend-controls{
  display: flex;
  flex-direction: column;
  gap: .5rem;
  align-items: flex-end;
}

.qtrend-tabs,
.qtrend-periods{
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  justify-content: flex-end;
}

.qtrend-tab,
.qtrend-period{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .35rem .75rem;
  gap: .4rem;
  position: relative;
  border-radius: 999px;
  border: 1px solid var(--bs-border-color);
  background: var(--bs-surface-2);
  color: var(--bs-muted);
  font-size: .82rem;
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.qtrend-icon{
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
}

.qtrend-label{
  line-height: 1;
}

.qtrend-tab.is-active,
.qtrend-period.is-active{
  background: var(--bs-primary);
  border-color: var(--bs-primary);
  color: #ffffff;
  box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}

.qtrend-list{
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: .6rem;
}

.qtrend-item{
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "rank main action";
  align-items: center;
  gap: .75rem;
  padding: .65rem .8rem;
  border-radius: .85rem;
  border: 1px solid var(--bs-border-color);
  background: var(--bs-surface-2);
  transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
}

.qtrend-item:hover{
  border-color: rgba(14,165,233,.6);
  box-shadow: 0 6px 16px rgba(15,23,42,.12);
  transform: translateY(-1px);
}

.qtrend-rank{
  grid-area: rank;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #0b1220;
  background: linear-gradient(135deg, rgba(14,165,233,.18), rgba(37,99,235,.2));
}

.qtrend-main{
  grid-area: main;
  min-width: 0;
}

.qtrend-title-link{
  display: inline-block;
  font-weight: 600;
  color: var(--bs-heading);
  text-decoration: none;
}

.qtrend-title-link:hover{
  color: var(--bs-primary-600);
  text-decoration: underline;
}

.qtrend-meta{
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-top: .35rem;
  font-size: .82rem;
}

.qtrend-chip{
  padding: .1rem .55rem;
  border-radius: 999px;
  background: rgba(37,99,235,.12);
  color: #1d4ed8;
  font-weight: 500;
}

.qtrend-views{
  color: var(--bs-muted);
}

.qtrend-delta{
  font-weight: 600;
  color: var(--bs-muted);
}

.qtrend-delta.is-up{
  color: #16a34a;
}

.qtrend-delta.is-down{
  color: #dc2626;
}

.qtrend-action{
  grid-area: action;
}

.qtrend-open{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .35rem .75rem;
  border-radius: .6rem;
  border: 1px solid var(--bs-border-color);
  background: #ffffff;
  color: var(--bs-heading);
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
  gap: .35rem;
  transition: box-shadow .15s ease, transform .12s ease, border-color .15s ease;
}

.qtrend-open-icon{
  width: 1rem;
  height: 1rem;
}

.qtrend-open:hover{
  border-color: rgba(14,165,233,.6);
  box-shadow: 0 4px 12px rgba(15,23,42,.12);
  transform: translateY(-1px);
}

.qtrend-open:active{
  transform: translateY(0);
  box-shadow: none;
}

.qtrend-empty{
  margin: 1rem 0 0;
  color: var(--bs-muted);
}

html[data-theme="dark"] .qtrend-card::before{
  background: radial-gradient(closest-side, rgba(56,189,248,.18), transparent 70%);
}

html[data-theme="dark"] .qtrend-rank{
  color: #e2e8f0;
}

html[data-theme="dark"] .qtrend-open{
  background: #0f172a;
  color: #e2e8f0;
}

@media (max-width: 900px){
  .qtrend-controls{
    align-items: flex-end;
  }
}

@media (max-width: 760px){
  .qtrend-action{
    justify-self: end;
  }

  .qtrend-tab,
  .qtrend-period{
    padding: .45rem;
    width: 2.25rem;
    height: 2.25rem;
    justify-content: center;
  }

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

  .qtrend-tab::after,
  .qtrend-period::after{
    content: attr(data-label);
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: #0b1220;
    color: #ffffff;
    padding: .35rem .5rem;
    border-radius: .4rem;
    font-size: .72rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease;
    box-shadow: 0 8px 20px rgba(15,23,42,.2);
    z-index: 2;
  }

  .qtrend-tab:hover::after,
  .qtrend-period:hover::after,
  .qtrend-tab:focus-visible::after,
  .qtrend-period:focus-visible::after{
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@media (max-width: 600px){
  .qtrend-delta{
    display: none;
  }

  .qtrend-chip{
    display: none;
  }

  .qtrend-meta{
    justify-content: flex-end;
  }
}

@media (max-width: 480px){
  .qtrend-card{
    padding: 1rem;
  }

  .qtrend-title h2{
    font-size: 1.15rem;
  }

  .qtrend-sub{
    font-size: .82rem;
  }

  .qtrend-item{
    padding: .55rem .65rem;
    gap: .6rem;
  }

  .qtrend-rank{
    width: 1.9rem;
    height: 1.9rem;
    font-size: .8rem;
  }

  .qtrend-title-link{
    font-size: .95rem;
  }

  .qtrend-meta{
    font-size: .78rem;
  }

  .qtrend-open{
    padding: .35rem;
    font-size: .78rem;
    width: 2.05rem;
    height: 2.05rem;
    justify-content: center;
  }

  .qtrend-open-label{
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }

  .qtrend-tab,
  .qtrend-period{
    width: 2.05rem;
    height: 2.05rem;
  }
}

@media (max-width: 420px){
  .qtrend-title h2{
    font-size: 1.05rem;
  }
}
