:root {
  --card-radius: 10px;
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.12);
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  /* 卡片最小宽度约为原先的 2 倍（原先约 6.75rem） */
  --grid-min: 13.5rem;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: linear-gradient(165deg, #f8fafc 0%, #eef2ff 45%, #f1f5f9 100%);
  min-height: 100vh;
}

.navbar-brand {
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* 与下方结果区同宽：占满 main.container 内容宽度，无外框单独收窄 */
.search-shell {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
}

.search-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: relative;
  overflow: visible;
  box-sizing: border-box;
  padding: 2.15rem 1.35rem 1.6rem;
  background: linear-gradient(
    165deg,
    #ffffff 0%,
    rgba(248, 250, 252, 0.97) 42%,
    rgba(238, 242, 255, 0.65) 100%
  );
  border-radius: 20px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.9) inset,
    0 1px 3px rgba(15, 23, 42, 0.05),
    0 14px 40px rgba(15, 23, 42, 0.07),
    0 28px 80px -20px rgba(79, 70, 229, 0.18);
}

.search-panel::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: min(11rem, 50%);
  height: 4px;
  border-radius: 0 0 8px 8px;
  background: linear-gradient(90deg, #a5b4fc, #6366f1 40%, #4f46e5 60%, #a5b4fc);
  pointer-events: none;
}

@media (min-width: 768px) {
  .search-panel {
    padding: 2.5rem 2rem 1.85rem;
  }
}

.search-panel-inner {
  position: relative;
  box-sizing: border-box;
  width: 100%;
}

.search-panel-loading {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 1.15rem;
  height: 1.15rem;
  color: var(--accent) !important;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 2;
}

.search-panel-loading.htmx-request {
  opacity: 0.9;
}

/* 覆盖 Bootstrap Reboot 等对 form 的样式，保证胶囊条为 flex 且占满一行 */
form#search-form.search-pill,
form.search-pill {
  display: flex !important;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.45rem;
  width: 100% !important;
  max-width: 100%;
  margin: 0 !important;
  box-sizing: border-box;
  min-height: 54px;
  padding: 6px 8px 6px 20px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.06),
    0 8px 24px rgba(15, 23, 42, 0.06),
    0 0 0 1px rgba(255, 255, 255, 0.9) inset,
    inset 0 1px 0 rgba(255, 255, 255, 1);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

form.search-pill:hover {
  border-color: #c7d2fe;
  box-shadow:
    0 2px 6px rgba(15, 23, 42, 0.07),
    0 12px 32px rgba(79, 70, 229, 0.1),
    0 0 0 1px rgba(129, 140, 248, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 1);
}

form.search-pill:focus-within {
  border-color: #818cf8;
  box-shadow:
    0 0 0 4px var(--accent-soft),
    0 6px 20px rgba(79, 70, 229, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 1);
  outline: none;
}

.search-pill-select {
  flex: 0 0 auto;
  width: auto;
  min-width: 3.25rem;
  max-width: 5rem;
  padding: 0.35rem 1.35rem 0.35rem 0.1rem;
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  background-color: transparent;
  border: none;
  border-right: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
}

.search-pill-select:focus {
  outline: none;
  box-shadow: none;
}

.search-pill-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.45rem 0.65rem;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--text);
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.search-pill-input::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

.search-pill-input:focus {
  outline: none !important;
  box-shadow: none !important;
}

.search-pill-submit {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  color: #fff;
  background: linear-gradient(155deg, #a5d8ff 0%, #93c5fd 18%, #818cf8 52%, #4f46e5 100%);
  border: none;
  border-radius: 50%;
  box-shadow:
    0 2px 6px rgba(79, 70, 229, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

.search-pill-submit:hover {
  filter: brightness(1.06) saturate(1.05);
  box-shadow:
    0 4px 14px rgba(79, 70, 229, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.search-pill-submit:active {
  transform: scale(0.94);
}

.search-pill-submit:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.search-stats-line {
  box-sizing: border-box;
  width: 100%;
  margin-top: 0.5rem;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text);
}

.search-stats-line.border-top {
  border-top-color: rgba(148, 163, 184, 0.22) !important;
}

.search-stats-total {
  font-weight: 700;
  color: #dc2626;
}

.search-stats-picked {
  font-weight: 700;
  color: #16a34a;
}

.search-stats-time {
  font-weight: 700;
  color: #2563eb;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.2rem var(--accent-soft);
}

.btn-primary {
  --bs-btn-bg: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: #4338ca;
  --bs-btn-hover-border-color: #4338ca;
}

.results-section {
  transition: opacity 0.2s ease;
}

.results-section.htmx-swapping {
  opacity: 0.55;
}

.pager-loading {
  width: 1.05rem;
  height: 1.05rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.pager-loading.htmx-request {
  opacity: 0.9;
}

/* 让 hx-disabled-elt 用在 <a> 上也能像按钮一样不可点 */
a[disabled],
a.disabled {
  pointer-events: none;
  opacity: 0.55;
}

.site-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--grid-min), 1fr));
  gap: 0.65rem;
}

@media (min-width: 1200px) {
  .site-cards-grid {
    gap: 0.75rem;
  }
}

.site-card-wrap {
  position: relative;
}

.site-card-wrap:hover {
  z-index: 15;
}

.site-card-wrap:hover .site-card {
  overflow: visible;
}

.site-card {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: var(--card-radius);
  background: var(--surface);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  height: 100%;
  overflow: hidden;
}

.site-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.09);
  border-color: rgba(79, 70, 229, 0.3);
}

/* 横向卡片：压低高度约为原先纵向堆叠的一半观感 */
.site-card .site-card-inner {
  padding: 0.4rem 0.55rem;
  min-height: 0;
}

.logo-wrap {
  width: 2rem;
  height: 2rem;
  min-width: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #f8fafc, #f1f5f9);
  border-radius: 7px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  overflow: hidden;
}

.logo-wrap img {
  max-width: 80%;
  max-height: 80%;
  object-fit: contain;
}

.logo-placeholder {
  font-size: 0.85rem;
  line-height: 1;
  color: #cbd5e1;
}

.card-title-text {
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-bottom: 0.1rem;
}

.domain-text {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--accent);
  word-break: break-all;
}

.desc-text {
  font-size: 0.65rem;
  line-height: 1.3;
  color: var(--muted);
  margin-top: 0.15rem;
  /* 浮在 stretched-link 的 ::after 之上，悬停才能收到指针事件 */
  position: relative;
  z-index: 2;
}

.desc-has-full:hover {
  cursor: help;
}

.desc-line.desc-line-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.desc-full-hover {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 5;
  min-width: min(100%, 12rem);
  max-width: min(24rem, calc(100vw - 2rem));
  padding: 0.5rem 0.65rem;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 8px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.9) inset,
    0 10px 28px rgba(15, 23, 42, 0.12);
}

.desc-text:hover .desc-full-hover {
  display: block;
}

.line-clamp-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.badge-mode {
  font-weight: 500;
  font-size: 0.7rem;
  padding: 0.35em 0.55em;
}

.footer-note {
  font-size: 0.8rem;
  color: var(--muted);
}

.empty-state {
  padding: 2rem 1.25rem;
  border-radius: 16px;
  background: var(--surface);
  border: 1px dashed rgba(148, 163, 184, 0.5);
}

.min-w-0 {
  min-width: 0;
}
