/* ==========================================================================
   COZONE Web — Global Search Popover (Edition R1 · 极简深灰)
   Clean dark matte elevation, whisper-quiet health telemetry, zero neon/glow.
   ========================================================================== */

.cz-search-backdrop {
  position: fixed;
  inset: 0;
  z-index: 890;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.16s ease;
}

.cz-search-backdrop.is-open {
  opacity: 1;
}

.cz-search-popover,
.cz-search-popover *,
.cz-search-popover *::before,
.cz-search-popover *::after {
  box-sizing: border-box;
}

.cz-search-popover {
  position: fixed;
  z-index: 900;
  width: 480px;
  max-width: calc(100% - 32px);
  max-height: 580px;
  background: #1C1C20;
  background: rgba(28, 28, 32, 0.94);
  -webkit-backdrop-filter: saturate(140%) blur(20px);
  backdrop-filter: saturate(140%) blur(20px);
  border: 1px solid #2A2A30;
  border-radius: 10px;
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.52),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  color: var(--text, #F4F4F6);
  font-family: var(--font-sans, "PingFang SC", "Microsoft YaHei UI", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  -webkit-font-smoothing: antialiased;
}

.cz-search-popover.is-open {
  opacity: 1;
  transform: translateY(0);
}

.cz-search-popover[hidden],
.cz-search-backdrop[hidden] {
  display: none;
}

/* Mobile full-width slide-down sheet (< 768px, strict 0px horizontal overflow) */
.cz-search-popover.is-mobile {
  left: 0;
  right: 0;
  width: auto;
  max-width: 100%;
  border-left: none;
  border-right: none;
  border-radius: 0 0 14px 14px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.56);
  transform: translateY(-10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.cz-search-popover.is-mobile.is-open {
  transform: translateY(0);
}

.cz-sp-body {
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 10px 0 12px;
  scrollbar-width: thin;
  scrollbar-color: #323238 transparent;
}

.cz-sp-body::-webkit-scrollbar {
  width: 6px;
}

.cz-sp-body::-webkit-scrollbar-track {
  background: transparent;
}

.cz-sp-body::-webkit-scrollbar-thumb {
  background: #323238;
  border-radius: 3px;
}

/* Mobile sheet header */
.cz-sp-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px calc(14px + env(safe-area-inset-right, 0px)) 10px calc(14px + env(safe-area-inset-left, 0px));
  margin-bottom: 4px;
  border-bottom: 1px solid #242429;
  min-width: 0;
}

.cz-sp-sheet-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary, #8E8E93);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.cz-sp-close-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary, #8E8E93);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.cz-sp-close-btn:hover {
  background: #26262B;
  color: var(--text, #F4F4F6);
}

/* Section layout */
.cz-sp-section {
  padding: 4px 12px;
  min-width: 0;
}

.cz-sp-sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 6px 5px;
  min-width: 0;
}

.cz-sp-sec-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary, #8E8E93);
  letter-spacing: 0.02em;
}

.cz-sp-sec-count {
  font-size: 11px;
  color: var(--text-muted, #636368);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* Quiet aggregate probe_summary telemetry bar */
.cz-sp-probe-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px 7px;
  font-size: 11px;
  line-height: 15px;
  color: var(--text-muted, #76767D);
  font-variant-numeric: tabular-nums;
  min-width: 0;
}

.cz-sp-probe-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Whisper-quiet 6px semantic health dot (zero glow) */
.cz-sp-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--health-idle, #636366);
}

.cz-sp-dot.is-healthy {
  background: var(--health-ok, #30D158);
}

.cz-sp-dot.is-degraded {
  background: var(--health-warn, #FFD60A);
}

.cz-sp-dot.is-cooldown {
  background: var(--health-bad, #FF453A);
}

.cz-sp-dot.is-untested {
  background: var(--health-idle, #636366);
}

.cz-sp-divider {
  height: 1px;
  background: #242429;
  margin: 8px 16px;
}

.cz-sp-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* Empty / focus hint */
.cz-sp-empty {
  padding: 18px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cz-sp-empty-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text, #F4F4F6);
}

.cz-sp-empty-sub {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary, #8E8E93);
}

.cz-sp-hints {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 11px;
  color: var(--text-muted, #636368);
}

.cz-sp-hint-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.cz-sp-kbd {
  font-family: var(--font-mono, "SF Mono", "Cascadia Mono", "Consolas", monospace);
  font-size: 10px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 4px;
  background: #242429;
  border: 1px solid #323238;
  color: var(--text-secondary, #8E8E93);
}

.cz-sp-status {
  padding: 10px 6px;
  font-size: 12px;
  color: var(--text-muted, #636368);
}

/* Cinema hits (Section 1: 在线播放) */
.cz-sp-cinema-row {
  width: 100%;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  cursor: pointer;
  transition: background-color 0.12s ease, box-shadow 0.12s ease;
}

.cz-sp-cinema-row:hover,
.cz-sp-cinema-row:focus-visible,
.cz-sp-cinema-row.is-active {
  background: #26262B;
  outline: none;
}

.cz-sp-cinema-row.is-active {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.cz-sp-thumb {
  width: 34px;
  height: 46px;
  border-radius: 4px;
  background: #242429;
  border: 1px solid #2E2E35;
  overflow: hidden;
  flex-shrink: 0;
}

.cz-sp-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cz-sp-cinema-info {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cz-sp-cinema-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 18px;
  color: var(--text, #F4F4F6);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cz-sp-cinema-meta {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-secondary, #8E8E93);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cz-sp-chevron {
  color: var(--text-muted, #636368);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  transition: color 0.12s ease, transform 0.12s ease;
}

.cz-sp-cinema-row:hover .cz-sp-chevron,
.cz-sp-cinema-row.is-active .cz-sp-chevron {
  color: var(--text-secondary, #8E8E93);
  transform: translateX(1px);
}

/* Netdisk, Magnet & Sniff rows (Section 2: 网盘与磁力聚合) */
.cz-sp-res-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 7px;
  min-height: 36px;
  min-width: 0;
  transition: background-color 0.12s ease, opacity 0.12s ease, box-shadow 0.12s ease;
}

.cz-sp-res-row:hover,
.cz-sp-res-row.is-active {
  background: #25252B;
}

.cz-sp-res-row.is-active {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* Dead share row: muted 0.55 opacity, sorted below valid shares */
.cz-sp-res-row.is-dead {
  opacity: 0.55;
}

.cz-sp-res-row.is-dead:hover,
.cz-sp-res-row.is-dead.is-active {
  opacity: 0.78;
}

/* Strictly muted monochrome label — zero rainbow badges */
.cz-sp-tag {
  flex-shrink: 0;
  min-width: 38px;
  height: 20px;
  padding: 0 6px;
  border-radius: 4px;
  background: #242429;
  border: 1px solid #2E2E35;
  color: #A0A0A8;
  font-size: 11px;
  font-weight: 500;
  line-height: 18px;
  text-align: center;
  letter-spacing: 0.01em;
}

.cz-sp-res-main {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.cz-sp-res-title {
  font-size: 13px;
  line-height: 18px;
  color: var(--text, #F4F4F6);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cz-sp-res-sub {
  font-size: 11px;
  line-height: 15px;
  color: var(--text-muted, #636368);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cz-sp-res-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  max-width: 100%;
}

/* Netdisk share keep-alive verification indicator */
.cz-sp-alive {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-size: 11px;
  line-height: 16px;
  white-space: nowrap;
}

.cz-sp-alive.is-alive {
  color: var(--text-secondary, #A0A0A8);
  padding: 1px 2px;
}

.cz-sp-alive.is-dead {
  height: 19px;
  padding: 0 5px;
  border-radius: 4px;
  background: #222227;
  border: 1px solid #2E2E35;
  color: var(--text-muted, #787880);
  font-size: 10px;
  line-height: 17px;
}

.cz-sp-mono {
  font-family: var(--font-mono, "SF Mono", "Cascadia Mono", "Consolas", monospace);
}

.cz-sp-code {
  flex-shrink: 0;
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono, "SF Mono", "Cascadia Mono", "Consolas", monospace);
  font-size: 11px;
  color: var(--text-secondary, #8E8E93);
  padding: 2px 6px;
  border-radius: 4px;
  background: #18181B;
  border: 1px solid #27272D;
  font-variant-numeric: tabular-nums;
}

.cz-sp-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.cz-sp-btn-copy {
  flex-shrink: 0;
  height: 24px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid #323238;
  background: transparent;
  color: #D4D4D8;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.cz-sp-btn-copy:hover,
.cz-sp-btn-copy:focus-visible,
.cz-sp-res-row.is-active .cz-sp-btn-copy:not(.cz-sp-btn-play-sm) {
  background: #2C2C32;
  border-color: #42424A;
  color: #FFFFFF;
  outline: none;
}

.cz-sp-btn-copy.is-copied {
  border-color: #3F3F46;
  background: #26262B;
  color: var(--text-secondary, #8E8E93);
}

.cz-sp-btn-play-sm {
  background: var(--cta-bg, #FFFFFF);
  border-color: var(--cta-bg, #FFFFFF);
  color: var(--cta-fg, #141416);
  font-weight: 600;
}

.cz-sp-btn-play-sm:hover,
.cz-sp-btn-play-sm:focus-visible {
  background: #E4E4E7;
  border-color: #E4E4E7;
  color: #141416;
}

.cz-sp-more-btn {
  margin-top: 4px;
  width: 100%;
  height: 30px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary, #8E8E93);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.cz-sp-more-btn:hover,
.cz-sp-more-btn:focus-visible,
.cz-sp-more-btn.is-active {
  background: #25252B;
  color: var(--text, #F4F4F6);
  outline: none;
}

/* Direct URL card & Sniff origin */
.cz-sp-direct-card {
  padding: 10px 6px 6px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.cz-sp-url-preview,
.cz-sp-sniff-origin {
  font-family: var(--font-mono, "SF Mono", "Cascadia Mono", "Consolas", monospace);
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary, #8E8E93);
  background: #161619;
  border: 1px solid #26262C;
  border-radius: 6px;
  padding: 8px 10px;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.cz-sp-sniff-origin {
  margin: 0 6px 8px;
  font-size: 11px;
  padding: 6px 9px;
}

.cz-sp-direct-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 2px;
}

.cz-sp-btn-primary {
  height: 32px;
  padding: 0 14px;
  border: none;
  border-radius: 7px;
  background: var(--cta-bg, #FFFFFF);
  color: var(--cta-fg, #141416);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background-color 0.12s ease, box-shadow 0.12s ease;
}

.cz-sp-btn-primary:hover,
.cz-sp-btn-primary:focus-visible,
.cz-sp-btn-primary.is-active {
  background: #E4E4E7;
  outline: none;
}

.cz-sp-btn-ghost {
  height: 32px;
  padding: 0 12px;
  border: 1px solid #323238;
  border-radius: 7px;
  background: transparent;
  color: var(--text, #F4F4F6);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.cz-sp-btn-ghost:hover,
.cz-sp-btn-ghost:focus-visible,
.cz-sp-btn-ghost.is-active {
  background: #26262B;
  border-color: #484852;
  outline: none;
}

.cz-sp-icon {
  width: 14px;
  height: 14px;
  display: block;
  flex-shrink: 0;
}

/* Quiet monochrome skeletons */
.cz-sp-skeleton-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 6px;
}

.cz-sp-skeleton-cinema {
  height: 46px;
  border-radius: 6px;
  background: #232328;
  animation: cz-sp-pulse 1.5s ease-in-out infinite;
}

.cz-sp-skeleton-row {
  height: 30px;
  border-radius: 6px;
  background: #232328;
  animation: cz-sp-pulse 1.5s ease-in-out infinite;
}

@keyframes cz-sp-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.85; }
}

/* Optional Light Theme support (Settings toggle only; Dark remains default) */
[data-theme="light"] .cz-search-popover {
  background: #FFFFFF;
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(24, 24, 27, 0.12);
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.14),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  color: #18181B;
}

[data-theme="light"] .cz-sp-divider {
  background: #E4E4E7;
}

[data-theme="light"] .cz-sp-sheet-head {
  border-color: #E4E4E7;
  background: transparent;
}

[data-theme="light"] .cz-sp-cinema-row:hover,
[data-theme="light"] .cz-sp-cinema-row.is-active,
[data-theme="light"] .cz-sp-res-row:hover,
[data-theme="light"] .cz-sp-res-row.is-active,
[data-theme="light"] .cz-sp-more-btn:hover,
[data-theme="light"] .cz-sp-more-btn.is-active,
[data-theme="light"] .cz-sp-close-btn:hover {
  background: #F0F0F3;
}

[data-theme="light"] .cz-sp-cinema-row.is-active,
[data-theme="light"] .cz-sp-res-row.is-active {
  box-shadow: inset 0 0 0 1px rgba(24, 24, 27, 0.08);
}

[data-theme="light"] .cz-sp-tag,
[data-theme="light"] .cz-sp-code,
[data-theme="light"] .cz-sp-kbd,
[data-theme="light"] .cz-sp-alive.is-dead,
[data-theme="light"] .cz-sp-url-preview,
[data-theme="light"] .cz-sp-sniff-origin,
[data-theme="light"] .cz-sp-thumb,
[data-theme="light"] .cz-sp-skeleton-cinema,
[data-theme="light"] .cz-sp-skeleton-row {
  background: #F4F4F5;
  border-color: #E4E4E7;
  color: #52525B;
}

[data-theme="light"] .cz-sp-alive.is-alive,
[data-theme="light"] .cz-sp-probe-summary {
  color: #52525B;
}

[data-theme="light"] .cz-sp-dot.is-healthy {
  background: var(--health-ok, #248A3D);
}

[data-theme="light"] .cz-sp-btn-copy,
[data-theme="light"] .cz-sp-btn-ghost {
  border-color: #D4D4D8;
  color: #27272A;
}

[data-theme="light"] .cz-sp-btn-copy:hover,
[data-theme="light"] .cz-sp-btn-ghost:hover,
[data-theme="light"] .cz-sp-res-row.is-active .cz-sp-btn-copy:not(.cz-sp-btn-play-sm) {
  background: #E4E4E7;
  border-color: #A1A1AA;
  color: #09090B;
}

[data-theme="light"] .cz-sp-btn-primary,
[data-theme="light"] .cz-sp-btn-play-sm {
  background: #18181B;
  border-color: #18181B;
  color: #FFFFFF;
}

/* Mobile compact 2-row netdisk grid so titles breathe with 0px overflow on 390px */
@media (max-width: 767px) {
  .cz-sp-body {
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .cz-sp-section {
    padding: 4px calc(10px + env(safe-area-inset-right, 0px)) 4px calc(10px + env(safe-area-inset-left, 0px));
  }

  .cz-sp-res-row {
    padding: 8px 6px;
    gap: 8px;
  }

  .cz-sp-netdisk-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    column-gap: 8px;
    row-gap: 4px;
    align-items: center;
  }

  .cz-sp-netdisk-row > .cz-sp-tag {
    grid-column: 1;
    grid-row: 1;
  }

  .cz-sp-netdisk-row > .cz-sp-res-main {
    grid-column: 2;
    grid-row: 1;
  }

  .cz-sp-netdisk-row > .cz-sp-btn-copy {
    grid-column: 3;
    grid-row: 1 / span 2;
    align-self: center;
  }

  .cz-sp-netdisk-row > .cz-sp-res-meta {
    grid-column: 2;
    grid-row: 2;
    flex-wrap: wrap;
    gap: 6px;
  }

  .cz-sp-cinema-row {
    padding: 8px 6px;
  }

  .cz-sp-btn-copy {
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
  }

  .cz-sp-hints {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cz-search-backdrop,
  .cz-search-popover,
  .cz-search-popover.is-mobile,
  .cz-sp-cinema-row,
  .cz-sp-res-row,
  .cz-sp-btn-copy,
  .cz-sp-btn-primary,
  .cz-sp-btn-ghost,
  .cz-sp-chevron {
    transition: none;
  }

  .cz-sp-skeleton-cinema,
  .cz-sp-skeleton-row {
    animation: none;
    opacity: 0.6;
  }
}
