/*
 * tools-workbench.css — components for Klipa's interactive workbench tools
 * (M3U analyzer, M3U editor, and future tool pages). Loads on top of
 * styles.css + tools.css and reuses the same design tokens, so dark mode
 * follows automatically via :root[data-theme="dark"].
 *
 * Naming: .wb-* (workbench). Additive by design — nothing here overrides
 * existing site classes.
 */

/* ──────────────────────────────────────────────────────────
 * Wide shell for workbench pages
 * ────────────────────────────────────────────────────────── */

.article-main.wb-main {
  max-width: 74rem;
}

/* Explicit-display components must still honor the hidden attribute
   (display:flex would otherwise override the UA's display:none). */
.wb-main [hidden] {
  display: none !important;
}

.wb-alert[hidden],
.wb-success[hidden],
.wb-bulkbar[hidden],
.wb-progress[hidden],
.wb-drawer[hidden],
.wb-drawer-backdrop[hidden],
.wb-popover[hidden] {
  display: none !important;
}

/* ──────────────────────────────────────────────────────────
 * Tool header: title, lede, trust pills, header actions
 * ────────────────────────────────────────────────────────── */

.wb-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.5rem;
}

.wb-header .article-title {
  margin: 0;
}

.wb-header-lede {
  margin: 0.6rem 0 0;
  max-width: 46rem;
  color: var(--text-soft);
  font-size: 1.08rem;
  line-height: 1.55;
}

.wb-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.wb-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.32rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.wb-pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(46, 196, 182, 0.15);
}

.wb-pill.is-net .wb-pill-dot { background: var(--gold); box-shadow: 0 0 0 3px rgba(242, 169, 60, 0.15); }

.wb-header-actions {
  display: flex;
  gap: 0.5rem;
}

/* ──────────────────────────────────────────────────────────
 * Buttons — disciplined set: primary / ghost / danger / icon
 * ────────────────────────────────────────────────────────── */

.wb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.6rem;
  padding: 0.45rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease,
    transform 80ms ease, box-shadow 120ms ease;
}

.wb-btn:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--card-tint);
}

.wb-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.wb-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.wb-btn-primary {
  border-color: transparent;
  background: var(--grad-cta);
  color: #fff;
}

.wb-btn-primary:hover:not(:disabled) {
  background: var(--grad-cta);
  border-color: transparent;
  filter: brightness(1.08);
}

.wb-btn-danger {
  color: var(--coral);
}

.wb-btn-danger:hover:not(:disabled) {
  border-color: var(--coral);
  background: rgba(244, 122, 90, 0.08);
}

.wb-btn-sm {
  min-height: 2.1rem;
  padding: 0.25rem 0.7rem;
  font-size: 0.84rem;
}

.wb-btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
}

.wb-btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--card-tint);
}

.wb-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  min-width: 2.6rem;
  height: 2.6rem;
  padding: 0;
}

.wb-iconbtn svg {
  width: 18px;
  height: 18px;
}

/* XMLTV viewer and matcher: dense split panes without turning the page into
   a heavy SPA. Lists are bounded by the controllers and remain keyboard-safe. */
.wb-epg-grid {
  display: grid;
  grid-template-columns: minmax(15rem, 0.34fr) minmax(0, 1fr);
  min-height: 32rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--panel);
}

.wb-epg-sidebar {
  border-right: 1px solid var(--line);
  background: var(--bg);
}

.wb-epg-sidebar-head,
.wb-epg-main-head {
  padding: 0.8rem;
  border-bottom: 1px solid var(--line);
}

.wb-epg-list {
  max-height: 32rem;
  overflow: auto;
}

.wb-epg-channel {
  display: block;
  width: 100%;
  padding: 0.72rem 0.8rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.wb-epg-channel:hover,
.wb-epg-channel[aria-current="true"] {
  background: var(--card-tint);
}

.wb-epg-channel strong,
.wb-epg-channel small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wb-epg-channel small {
  margin-top: 0.2rem;
  color: var(--text-muted);
  font-family: var(--mono, monospace);
  font-size: 0.72rem;
}

.wb-epg-main {
  min-width: 0;
}

.wb-schedule {
  max-height: 32rem;
  padding: 0.8rem;
  overflow: auto;
}

.wb-programme {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  gap: 0.8rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}

.wb-programme-time {
  color: var(--text-muted);
  font-family: var(--mono, monospace);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.wb-programme h3 {
  margin: 0;
  font-size: 0.95rem;
}

.wb-programme p {
  margin: 0.35rem 0 0;
  color: var(--text-soft);
  font-size: 0.84rem;
  line-height: 1.5;
}

.wb-dual-input {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.wb-dual-input .wb-inputcard {
  margin: 0;
}

.wb-match-table .wb-table td {
  vertical-align: middle;
}

.wb-confidence {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.wb-confidence small,
.wb-match-table td small {
  display: block;
  max-width: 19rem;
  margin-top: 0.2rem;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wb-status-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.48rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.76rem;
  font-weight: 650;
  white-space: nowrap;
}

.wb-status-chip.is-ok { color: var(--teal); }
.wb-status-chip.is-warn { color: var(--gold); }
.wb-status-chip.is-bad { color: var(--coral); }

.wb-metric-small {
  max-width: 14rem;
  font-size: clamp(1rem, 2vw, 1.35rem) !important;
  line-height: 1.25;
}

.wb-map-results {
  display: grid;
  gap: 0.35rem;
  max-height: 19rem;
  margin-top: 0.8rem;
  overflow: auto;
}

.wb-map-option {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.wb-map-option:hover,
.wb-map-option:focus-visible {
  border-color: var(--primary);
}

@media (max-width: 760px) {
  .wb-epg-grid,
  .wb-dual-input {
    grid-template-columns: 1fr;
  }

  .wb-epg-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .wb-epg-list {
    max-height: 14rem;
  }

  .wb-programme {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }
}

/* ──────────────────────────────────────────────────────────
 * Input card: tabs (File / Paste / URL), dropzone, paste area
 * ────────────────────────────────────────────────────────── */

.wb-inputcard {
  margin: 1.6rem 0 2rem;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.wb-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  padding: 0.25rem;
  width: max-content;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.wb-tab {
  padding: 0.42rem 0.95rem;
  border: 0;
  border-radius: calc(var(--radius) - 3px);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.wb-tab[aria-selected="true"] {
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.wb-panel[hidden] {
  display: none;
}

.wb-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 172px;
  padding: 1.4rem 1rem;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--bg);
  text-align: center;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, transform 140ms ease;
}

.wb-drop:hover,
.wb-drop:focus-visible {
  border-color: var(--primary);
}

.wb-drop.is-drag {
  border-color: var(--primary);
  background: rgba(124, 94, 240, 0.07);
  transform: scale(1.005);
}

.wb-drop.is-error {
  border-color: var(--coral);
  background: rgba(244, 122, 90, 0.06);
}

.wb-drop-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(124, 94, 240, 0.1);
  color: var(--primary);
}

.wb-drop-icon svg {
  width: 22px;
  height: 22px;
}

.wb-drop-title {
  color: var(--text);
  font-weight: 700;
  font-size: 1.02rem;
}

.wb-drop-sub {
  color: var(--text-muted);
  font-size: 0.86rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

.wb-drop-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.wb-drop-hint {
  color: var(--muted-2);
  font-size: 0.8rem;
}

.wb-paste {
  width: 100%;
  min-height: 172px;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.86rem;
  line-height: 1.5;
  resize: vertical;
}

.wb-paste:focus {
  outline: none;
  border-color: var(--primary);
}

.wb-urlrow {
  display: flex;
  gap: 0.6rem;
}

.wb-urlrow .tool-input {
  flex: 1;
  min-width: 0;
}

/* ──────────────────────────────────────────────────────────
 * Inline error / status banners (never toasts for critical info)
 * ────────────────────────────────────────────────────────── */

.wb-alert {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin: 0.8rem 0 0;
  padding: 0.75rem 0.95rem;
  border: 1px solid rgba(244, 122, 90, 0.45);
  border-radius: var(--radius);
  background: rgba(244, 122, 90, 0.07);
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.45;
}

.wb-alert svg {
  flex: none;
  width: 17px;
  height: 17px;
  margin-top: 0.12rem;
  color: var(--coral);
}

.wb-alert.is-info {
  border-color: rgba(91, 124, 245, 0.4);
  background: rgba(91, 124, 245, 0.07);
}

.wb-alert.is-info svg { color: var(--accent); }

.wb-alert a { color: var(--text); font-weight: 600; }

/* ──────────────────────────────────────────────────────────
 * Progress (parsing/analyzing large playlists)
 * ────────────────────────────────────────────────────────── */

.wb-progress {
  margin: 0.8rem 0;
}

.wb-progress-label {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.wb-progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--card-tint);
  overflow: hidden;
}

.wb-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--grad-brand);
  transition: width 160ms ease;
}

/* ──────────────────────────────────────────────────────────
 * Metrics row + health score
 * ────────────────────────────────────────────────────────── */

.wb-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.8rem;
  margin: 1.6rem 0 1rem;
}

.wb-metric {
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
}

.wb-metric-value {
  display: block;
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 1.9rem;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.wb-metric-label {
  display: block;
  margin-top: 0.3rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.wb-metric.is-bad .wb-metric-value { color: var(--coral); }
.wb-metric.is-warn .wb-metric-value { color: var(--gold); }
.wb-metric.is-good .wb-metric-value { color: var(--teal); }

.wb-score {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.35rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background:
    radial-gradient(120px 90px at 85% 15%, rgba(124, 94, 240, 0.14), transparent 70%),
    var(--panel);
}

.wb-score-value {
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 1.9rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.wb-score-value small {
  color: var(--muted-2);
  font-size: 1rem;
}

.wb-score-note {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.wb-score-note button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-soft);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ──────────────────────────────────────────────────────────
 * Issues list — every row is actionable
 * ────────────────────────────────────────────────────────── */

.wb-section {
  margin: 2rem 0;
}

.wb-section-title {
  margin: 0 0 0.8rem;
  color: var(--text);
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.005em;
}

.wb-issues {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.wb-issue {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
}

.wb-issue-sev {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.wb-issue-sev.high { background: var(--coral); box-shadow: 0 0 0 3px rgba(244, 122, 90, 0.16); }
.wb-issue-sev.medium { background: var(--gold); box-shadow: 0 0 0 3px rgba(242, 169, 60, 0.16); }
.wb-issue-sev.low { background: var(--muted-2); box-shadow: 0 0 0 3px rgba(138, 135, 168, 0.16); }

.wb-issue-body {
  flex: 1 1 260px;
  min-width: 0;
}

.wb-issue-title {
  color: var(--text);
  font-weight: 650;
  font-size: 0.96rem;
}

.wb-issue-detail {
  margin-top: 0.15rem;
  color: var(--text-muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.wb-issue-tag {
  flex: none;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.wb-issue-actions {
  display: flex;
  gap: 0.4rem;
  margin-left: auto;
}

/* ──────────────────────────────────────────────────────────
 * Data tables (analysis report + editor grid)
 * ────────────────────────────────────────────────────────── */

.wb-tablewrap {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
  overflow: hidden;
}

.wb-tablescroll {
  overflow: auto;
  max-height: 520px;
}

.wb-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

.wb-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.wb-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line);
  color: var(--text-soft);
  vertical-align: middle;
  min-width: 0;
}

.wb-table tbody tr:hover td {
  background: var(--card-tint);
}

.wb-table tbody tr.is-selected td {
  background: rgba(124, 94, 240, 0.08);
}

.wb-table .num {
  text-align: right;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.wb-cellname {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 550;
}

.wb-cellmono {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.82rem;
}

.wb-cellgroup {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td.wb-status { white-space: nowrap; font-size: 0.82rem; }

.wb-statusdot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: baseline;
}

.wb-statusdot.ok { background: var(--teal); }
.wb-statusdot.warn { background: var(--gold); }
.wb-statusdot.bad { background: var(--coral); }

.wb-emptyrow td {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
}

/* Table toolbar (search + filters above the table) */

.wb-tabletools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.wb-search {
  position: relative;
  flex: 1 1 220px;
  min-width: 170px;
}

.wb-search input {
  width: 100%;
  padding: 0.55rem 0.85rem 0.55rem 2.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.wb-search input:focus {
  outline: none;
  border-color: var(--primary);
}

.wb-search svg {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  color: var(--muted-2);
  pointer-events: none;
}

.wb-select {
  max-width: 240px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
}

.wb-select:focus {
  outline: none;
  border-color: var(--primary);
}

.wb-tablefoot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.6rem 0.8rem;
  border-top: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* Two-column split for groups + domains summaries */

.wb-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ──────────────────────────────────────────────────────────
 * Technical trust footer
 * ────────────────────────────────────────────────────────── */

.wb-trust {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  margin-top: 0.7rem;
  color: var(--muted-2);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.78rem;
}

/* ──────────────────────────────────────────────────────────
 * Success banner + next-step row
 * ────────────────────────────────────────────────────────── */

.wb-success {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid rgba(46, 196, 182, 0.4);
  border-radius: var(--r-md);
  background: rgba(46, 196, 182, 0.07);
}

.wb-success-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: var(--teal);
  color: #062f2a;
}

.wb-success-check svg { width: 16px; height: 16px; }

.wb-success-title {
  color: var(--text);
  font-weight: 700;
}

.wb-success-detail {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.wb-next {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
}

/* ──────────────────────────────────────────────────────────
 * Editor toolbar + bulk bar
 * ────────────────────────────────────────────────────────── */

.wb-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.wb-toolbar-sep {
  width: 1px;
  height: 1.6rem;
  background: var(--line);
  margin: 0 0.15rem;
}

.wb-bulkbar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.8rem;
  border-top: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 -8px 24px -18px rgba(83, 76, 158, 0.5);
}

.wb-bulkbar-count {
  color: var(--text);
  font-weight: 700;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.wb-chiprow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  align-items: center;
}

.wb-chip {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.wb-chip strong {
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.wb-dirty {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
}

/* ──────────────────────────────────────────────────────────
 * Inspector drawer (channel details) — right side on desktop,
 * bottom sheet on small screens.
 * ────────────────────────────────────────────────────────── */

.wb-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(20, 16, 44, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.wb-drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.wb-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  display: flex;
  flex-direction: column;
  width: min(420px, 94vw);
  border-left: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  transform: translateX(102%);
  transition: transform 220ms cubic-bezier(0.3, 0.9, 0.4, 1);
}

.wb-drawer.is-open {
  transform: translateX(0);
}

.wb-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

.wb-drawer-title {
  color: var(--text);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wb-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem;
}

.wb-drawer-foot {
  display: flex;
  gap: 0.5rem;
  padding: 0.9rem 1.1rem;
  border-top: 1px solid var(--line);
}

.wb-field {
  margin-bottom: 0.85rem;
}

.wb-field label {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.wb-field input,
.wb-field select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.88rem;
}

.wb-field input:focus,
.wb-field select:focus {
  outline: none;
  border-color: var(--primary);
}

.wb-field .wb-field-hint {
  margin-top: 0.25rem;
  color: var(--muted-2);
  font-size: 0.78rem;
}

.wb-rawlist {
  margin: 0.4rem 0 0;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ──────────────────────────────────────────────────────────
 * Popover (dedupe strategy, score explanation)
 * ────────────────────────────────────────────────────────── */

.wb-popover {
  position: absolute;
  z-index: 30;
  width: min(320px, 92vw);
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
  box-shadow: var(--shadow-md);
}

.wb-popover[hidden] {
  display: none;
}

.wb-popover h4 {
  margin: 0 0 0.4rem;
  color: var(--text);
  font-size: 0.95rem;
}

.wb-popover p {
  margin: 0 0 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.wb-radio {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.45rem 0.5rem;
  border-radius: var(--radius);
  cursor: pointer;
}

.wb-radio:hover {
  background: var(--card-tint);
}

.wb-radio input {
  margin-top: 0.2rem;
}

.wb-radio-title {
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 650;
}

.wb-radio-desc {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ──────────────────────────────────────────────────────────
 * Checkbox
 * ────────────────────────────────────────────────────────── */

.wb-check {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ──────────────────────────────────────────────────────────
 * A11y helpers
 * ────────────────────────────────────────────────────────── */

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

/* ──────────────────────────────────────────────────────────
 * Empty state (teaches the next action)
 * ────────────────────────────────────────────────────────── */

.wb-empty {
  padding: 2.2rem 1rem;
  text-align: center;
}

.wb-empty-title {
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
}

.wb-empty-desc {
  max-width: 26rem;
  margin: 0.35rem auto 0.9rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ──────────────────────────────────────────────────────────
 * FAQ (reuse .article-faq) + docs styling helpers
 * ────────────────────────────────────────────────────────── */

.wb-docs {
  max-width: 46rem;
}

.wb-docs h2 {
  margin: 2.4rem 0 0.7rem;
  color: var(--text);
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  scroll-margin-top: calc(var(--topbar-h) + 1rem);
}

.wb-docs h3 {
  margin: 1.6rem 0 0.4rem;
  color: var(--text);
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 1.12rem;
  font-weight: 600;
}

.wb-docs p {
  margin: 0 0 1rem;
  color: var(--text-soft);
  font-size: 1rem;
  line-height: 1.65;
}

.wb-docs ul,
.wb-docs ol {
  margin: 0 0 1rem;
  padding-left: 1.4rem;
  color: var(--text-soft);
  font-size: 1rem;
  line-height: 1.65;
}

.wb-docs li { margin: 0.25rem 0; }

.wb-docs a {
  color: var(--primary-deep);
  border-bottom: 1px solid rgba(124, 94, 240, 0.35);
}

.wb-docs a:hover { color: var(--primary); }

.wb-docs code {
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: var(--card-tint);
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.88em;
}

/* ──────────────────────────────────────────────────────────
 * Mobile
 * ────────────────────────────────────────────────────────── */

@media (max-width: 860px) {
  .wb-split {
    grid-template-columns: 1fr;
  }

  .wb-issue-actions {
    margin-left: 0;
    width: 100%;
  }
}

@media (max-width: 700px) {
  /* Data tables become stacked cards: label everything explicitly. */
  .wb-tablewrap[data-mobile="cards"] .wb-table thead {
    display: none;
  }

  .wb-tablewrap[data-mobile="cards"] .wb-table,
  .wb-tablewrap[data-mobile="cards"] .wb-table tbody,
  .wb-tablewrap[data-mobile="cards"] .wb-table tr,
  .wb-tablewrap[data-mobile="cards"] .wb-table td {
    display: block;
    width: 100%;
    border: 0;
  }

  .wb-tablewrap[data-mobile="cards"] .wb-table tr {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--line);
  }

  .wb-tablewrap[data-mobile="cards"] .wb-table td {
    padding: 0.14rem 0;
  }

  .wb-tablewrap[data-mobile="cards"] td.wb-cellname {
    max-width: none;
    white-space: normal;
    font-size: 0.98rem;
  }

  .wb-tablewrap[data-mobile="cards"] td.wb-cellmono {
    max-width: none;
    white-space: normal;
    word-break: break-all;
  }

  .wb-tablewrap[data-mobile="cards"] td[data-label]::before {
    content: attr(data-label);
    display: inline-block;
    margin-right: 0.45rem;
    color: var(--muted-2);
    font-size: 0.7rem;
    font-weight: 650;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  .wb-tablewrap[data-mobile="cards"] td.wb-cellselect {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .wb-tablewrap[data-mobile="cards"] tr {
    position: relative;
  }

  .wb-tablewrap[data-mobile="cards"] tr.is-selected {
    border-left: 3px solid var(--primary);
  }

  .wb-tablescroll {
    max-height: none;
    overflow: visible;
  }

  /* Drawer becomes a bottom sheet. */
  .wb-drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 86vh;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    transform: translateY(103%);
  }

  .wb-drawer.is-open {
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .wb-drawer,
  .wb-drawer-backdrop,
  .wb-drop,
  .wb-progress-fill {
    transition-duration: 0.001ms !important;
  }
}

/* ------------------------------------------------------------------
   M3U8 tester specifics: duration strip, flags, mono URIs, tag chips.
   ------------------------------------------------------------------ */

.wb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.wb-tag-chip {
  font-family: var(--mono, "JetBrains Mono", monospace);
  font-size: 0.78rem;
}

.wb-tag-chip b {
  color: var(--text-muted);
  font-weight: 600;
}

.wb-uri {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono, "JetBrains Mono", monospace);
  font-size: 0.8rem;
  direction: rtl;
  text-align: left;
}

.wb-dim {
  color: var(--text-muted);
}

.wb-flag {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
}

.wb-dur-over {
  color: var(--coral);
  font-weight: 700;
}

.wb-strip {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 72px;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--card-tint);
}

.wb-strip-bar {
  flex: 1 1 0;
  min-width: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--teal, var(--accent));
  opacity: 0.75;
}

.wb-strip-bar.is-over {
  background: var(--coral);
  opacity: 0.9;
}

/* ------------------------------------------------------------
   M3U splitter (/tools/m3u-split/)
   ------------------------------------------------------------ */
.sp-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 24px;
  align-items: center;
  margin: 0 0 18px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
}
.sp-controls legend { padding: 0 8px; }
.sp-option {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}
.sp-option input { accent-color: var(--primary); width: 16px; height: 16px; }
.sp-n { display: inline-flex; gap: 10px; align-items: center; }
.sp-n input {
  width: 90px;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
}
.sp-parts { list-style: none; margin: 14px 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sp-part {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}
.sp-part-name { font-family: ui-monospace, monospace; font-size: 13px; color: var(--ink); overflow-wrap: anywhere; }
.sp-part-count { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
[data-theme="dark"] .sp-controls, [data-theme="dark"] .sp-part { background: var(--card); }
