/* Torrent Search (web) — light theme is the default. */
:root {
  --bg: #f4f5f9;
  --panel: #ffffff;
  --panel2: #eceef5;
  --text: #1a1c24;
  --muted: #5b6270;
  --accent: #6c4cf5;
  --accent2: #0f9d6f;
  --danger: #d63b3b;
  --good: #178a56;
  --bad: #c84545;
  --border: #dfe3ee;
  --shadow: 0 1px 3px rgba(20, 24, 40, 0.08);
}
[data-theme="dark"] {
  --bg: #12141a;
  --panel: #1b1e27;
  --panel2: #232734;
  --text: #e8eaf2;
  --muted: #9aa1b5;
  --accent: #7c5cff;
  --accent2: #38d39f;
  --danger: #ff5d5d;
  --good: #4caf7d;
  --bad: #e05d5d;
  --border: #2c3140;
  --shadow: none;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, "Segoe UI", Roboto, sans-serif;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  box-shadow: var(--shadow);
}
.brand { font-size: 17px; letter-spacing: .3px; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 12px; }
.tabs { display: flex; gap: 6px; }
.tab {
  background: transparent; color: var(--muted);
  border: none; padding: 8px 14px; border-radius: 20px; cursor: pointer; font-size: 14px;
}
.tab.active { background: var(--accent); color: white; }
.tab:hover { color: var(--text); }
.theme-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  border-radius: 50%; width: 36px; height: 36px; cursor: pointer; font-size: 16px; line-height: 1;
}
.theme-btn:hover { border-color: var(--accent); }
/*__S2__*/
main { max-width: 1080px; margin: 0 auto; padding: 18px; }
.view { display: none; }
.view.active { display: block; }

.searchbox { display: flex; gap: 10px; margin-bottom: 12px; }
#search-input {
  flex: 1; padding: 13px 16px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font-size: 16px; outline: none;
}
#search-input:focus { border-color: var(--accent); }

.btn {
  border: none; cursor: pointer; border-radius: 10px;
  padding: 10px 18px; font-size: 14px; background: var(--panel2); color: var(--text);
}
.btn.primary { background: var(--accent); color: white; }
.btn.ghost { background: transparent; border: 1px solid var(--border); }
.btn.danger { color: var(--danger); }
.btn.mini { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.starred { background: #f4b400; color: #221c00; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .inline { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13.5px; }
select {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px;
}
.status { color: var(--muted); font-size: 13.5px; margin-left: auto; }

.sources-panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.sources-actions { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; }
#source-filter {
  flex: 1; margin-left: 8px; padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.sources-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px;
  max-height: 420px; overflow: auto;
}
.source-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px;
  cursor: pointer; font-size: 13.5px;
}
.source-row:hover { background: var(--panel2); }
.source-name { flex: 1; }
.source-engine { color: var(--muted); font-size: 11px; text-transform: uppercase; }

/* ------- result tabs + progressive scroller (mirrors the Android app) ------- */
.result-tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 10px;
  -webkit-overflow-scrolling: touch;
}
.result-tab {
  border: 1px solid var(--border); background: var(--panel); color: var(--muted);
  border-radius: 20px; padding: 7px 14px; font-size: 13.5px; cursor: pointer;
  white-space: nowrap; flex: 0 0 auto;
}
.result-tab .count {
  background: var(--accent); color: #fff; border-radius: 10px;
  padding: 0 7px; font-size: 11.5px; margin-left: 6px;
}
.result-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.result-tab.loading .count { animation: pulse 1.2s ease-in-out infinite; background: var(--muted); }
@keyframes pulse { 50% { opacity: .35; } }
.result {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.result-head { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.badge { font-size: 11.5px; padding: 3px 9px; border-radius: 20px; background: var(--panel2); color: var(--muted); }
.badge.src { color: var(--accent2); font-weight: 600; }
.result-name { font-size: 15.5px; font-weight: 600; margin-bottom: 6px; word-break: break-word; }
.result-meta { display: flex; gap: 14px; color: var(--muted); font-size: 13px; margin-bottom: 8px; flex-wrap: wrap; }
.good { color: var(--good); font-weight: 600; }
.bad { color: var(--bad); font-weight: 600; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.result-info {
  margin: 8px 0 0; padding: 8px 10px; background: var(--bg); border-radius: 8px;
  color: var(--muted); font-size: 12px; white-space: pre-wrap; word-break: break-word;
}
.loading, .empty, .error { padding: 30px; text-align: center; color: var(--muted); }
.error { color: var(--danger); }

/* toast feedback (copy / magnet handoff) */
#toast {
  position: fixed; bottom: 26px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 18px; font-size: 13.5px;
  opacity: 0; pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  z-index: 1000; box-shadow: 0 6px 20px rgba(0,0,0,.22);
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { color: var(--danger); }


.panel-head { display: flex; align-items: center; justify-content: space-between; }
h2 { margin: 6px 0 14px; font-size: 18px; }
.simple-list { list-style: none; padding: 0; }
.simple-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.muted { color: var(--muted); font-size: 12.5px; }
.check-row { display: flex; gap: 10px; align-items: center; padding: 10px 0; }
.hint { color: var(--muted); font-size: 13px; }
.footer {
  border-top: 1px solid var(--border);
  margin-top: 30px; padding: 16px 18px 26px;
  color: var(--muted); font-size: 12px; line-height: 1.6;
  text-align: center;
}
.footer p { max-width: 860px; margin: 0 auto; }



/* used by app.js (sources panel toggle, result tabs, sign-out button) */
.hidden { display: none !important; }
.logout-form { display: inline; margin: 0; }

/* category chips (multi-select) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 10px; }
.chip { border: 1px solid var(--border, #d0d4dc); background: transparent; color: inherit; border-radius: 999px;
  padding: 4px 10px; font-size: .85rem; cursor: pointer; }
.chip .count { margin-left: 6px; opacity: .65; font-size: .78rem; }
.chip.on { background: var(--accent, #6b4eff); border-color: var(--accent, #6b4eff); color: #fff; }
/* result card */
.result-meta .health { font-size: .9rem; }
.health.good { color: #1e9e57; } .health.weak { color: #d39a00; } .health.dead { color: #c0392b; } .health.unknown { color: #9aa0a6; }
.result-meta .seeds { font-weight: 600; }
.result-info { font-size: .8rem; opacity: .75; margin: 2px 0 6px; white-space: normal; overflow-wrap: anywhere; }
.result-reason { font-size: .88rem; margin: 2px 0 6px; padding: 6px 8px; border-left: 3px solid var(--accent, #6b4eff); background: rgba(107,78,255,.07); }
.badge.bucket { font-weight: 600; }
.badge.ai { background: #6b4eff; color: #fff; }
.show-more { display: block; margin: 12px auto; }

/* Ask AI */
.askbox { display: flex; gap: 8px; margin: 10px 0 4px; }
.askbox input { flex: 1; padding: 10px 12px; border: 1px dashed var(--accent, #6c4cf5); border-radius: 10px; font-size: .95rem;
  background: transparent; color: inherit; }
.ask-panel { position: relative; border: 1px solid var(--border, #dfe3ee); border-left: 4px solid var(--accent, #6c4cf5);
  border-radius: 12px; padding: 12px 14px; margin: 10px 0 14px; }
.ask-q { font-weight: 600; margin-bottom: 6px; padding-right: 30px; }
.ask-status { font-size: .9rem; margin: 4px 0; }
.ask-plan { font-size: .8rem; opacity: .75; margin-bottom: 8px; }
.ask-close { position: absolute; top: 8px; right: 8px; }
.spinner { display: inline-block; width: 10px; height: 10px; border: 2px solid var(--accent, #6c4cf5); border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* friendly status line */
.status-details { display: inline; }
.status-details summary { display: inline; cursor: pointer; text-decoration: underline dotted; }
.status-details ul { position: absolute; z-index: 5; margin: 6px 0 0; padding: 8px 12px 8px 26px; font-size: .85rem;
  background: var(--bg); border: 1px solid var(--border, #dfe3ee); border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.12); }

.loose-note { font-size: .82rem; opacity: .8; margin: 0 0 8px; }
.loose-toggle { margin-left: 4px; }
