/* ============================================================
   Torrent Indexer 2.0 — KDE Breeze Dark (Prism Launcher style)
   Flat, blocky, square. No gradients. No rounded fluff.
   ============================================================ */

:root {
  --bg-window:   #232629;  /* content area */
  --bg-panel:    #31363b;  /* bars / sidebar  */
  --bg-raised:   #3b4045;  /* hover */
  --bg-sunken:   #1b1e20;  /* line edits */
  --bg-altrow:   #2a2e32;
  --border:      #4d4d4d;
  --border-dark: #1b1e20;
  --text:        #eff0f1;
  --text-dim:    #a7aaac;
  --text-off:    #6e7175;
  --blue:        #3daee9;  /* Breeze highlight */
  --blue-deep:   #1d99f3;
  --green:       #27ae60;
  --red:         #da4453;
  --orange:      #f67400;
  --yellow:      #fdbc4b;
  --purple:      #9b59b6;
  --teal:        #16a085;
  --sel-text:    #232629;  /* dark text on blue selection, like Prism */
  --font: 'Noto Sans', 'Segoe UI', Ubuntu, Cantarell, -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  font-size: 12.5px;
  color: var(--text);
  background: var(--bg-window);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select { font-family: inherit; }
svg { display: block; }
[hidden] { display: none !important; }

::-focus-visible { outline: 1px solid var(--blue); outline-offset: 1px; }

/* scrollbars — square & dark */
* { scrollbar-width: thin; scrollbar-color: #43494e var(--bg-window); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-window); }
::-webkit-scrollbar-thumb { background: #43494e; border: 2px solid var(--bg-window); }
::-webkit-scrollbar-thumb:hover { background: #545b61; }

/* ------------------------------------------------ title bar */
.titlebar {
  height: 30px;
  background: var(--bg-panel);
  display: flex;
  align-items: center;
  position: relative;
  flex: none;
  user-select: none;
}
.titlebar-title {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 7px;
  font-size: 12px;
  color: var(--text);
  pointer-events: none;
}
.titlebar-title svg { width: 14px; height: 14px; }
.win-controls { margin-left: auto; display: flex; height: 100%; }
.win-controls button {
  width: 42px; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
}
.win-controls button:hover { background: var(--bg-raised); color: var(--text); }
.win-controls button.close:hover { background: var(--red); color: #fcfcfc; }
.win-controls svg { width: 12px; height: 12px; }

/* ------------------------------------------------ toolbar */
.toolbar {
  height: 44px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-dark);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  flex: none;
  z-index: 60;
}
.tb-btn {
  display: flex; align-items: center; gap: 7px;
  height: 32px;
  padding: 0 9px;
  border-radius: 2px;
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
}
.tb-btn:hover { background: var(--bg-raised); }
.tb-btn:active { background: #43494e; }
.tb-btn.ghosted { color: var(--text-off); pointer-events: none; }
.tb-btn svg.tb-ico { width: 16px; height: 16px; flex: none; }
.tb-btn .chev { width: 9px; height: 9px; opacity: .7; }
.tb-btn .badge {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 10.5px;
  padding: 0 5px;
  line-height: 15px;
  border-radius: 2px;
}
.tb-sep { width: 1px; height: 22px; background: var(--border); margin: 0 6px; flex: none; }
.tb-spacer { flex: 1; }

/* search line edit */
.searchwrap {
  position: relative;
  flex: 1;
  max-width: 620px;
  margin: 0 8px;
  min-width: 160px;
}
.searchwrap .search-ico {
  position: absolute; left: 9px; top: 50%;
  transform: translateY(-50%);
  width: 13px; height: 13px;
  color: var(--text-off);
  pointer-events: none;
}
#q {
  width: 100%;
  height: 28px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text);
  font-size: 12.5px;
  padding: 0 26px 0 30px;
}
#q::placeholder { color: var(--text-off); }
#q:focus { outline: none; border-color: var(--blue); }
.q-clear {
  position: absolute; right: 4px; top: 50%;
  transform: translateY(-50%);
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-off);
  border-radius: 2px;
}
.q-clear:hover { color: var(--text); background: var(--bg-raised); }
.q-clear svg { width: 10px; height: 10px; }

/* autocomplete dropdown */
.ac {
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  box-shadow: 0 4px 0 rgba(0,0,0,.25);
  z-index: 120;
  max-height: 264px;
  overflow-y: auto;
}
.ac-item {
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ac-item:hover { background: var(--bg-raised); }
.ac-item.active { background: var(--blue); color: var(--sel-text); }
.ac-hint {
  padding: 5px 10px;
  font-size: 10.5px;
  color: var(--text-off);
  border-top: 1px solid var(--border-dark);
}

/* popovers */
.pop {
  position: fixed;
  top: 76px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  box-shadow: 0 6px 0 rgba(0,0,0,.28);
  padding: 12px 14px;
  z-index: 110;
  width: 264px;
  font-size: 12px;
}
.pop h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-dim); margin-bottom: 9px; font-weight: 700;
}
.pop-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 7px 0; }
.pop-row label { color: var(--text); }
.pop .checks { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 4px 0; }
.pop .checks label { display: flex; align-items: center; gap: 5px; font-size: 12px; cursor: pointer; }
.pop input[type="checkbox"] { accent-color: var(--blue); width: 13px; height: 13px; }
.pop select {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--text);
  height: 26px;
  padding: 0 6px;
  border-radius: 2px;
  font-size: 12px;
}
.pop kbd {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 2px;
  padding: 0 5px;
  font-size: 10.5px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--text-dim);
}
.pop .help-row { display: flex; justify-content: space-between; padding: 4px 0; color: var(--text-dim); }

/* ------------------------------------------------ main split */
.main { flex: 1; display: flex; min-height: 0; }

.content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-window);
  padding: 8px 16px 28px;
  min-width: 0;
}

/* grouped browse grid (the launcher look) */
.group-head {
  display: flex; align-items: center; gap: 9px;
  padding: 14px 2px 9px;
  cursor: pointer;
  user-select: none;
}
.group-head .g-chev { width: 11px; height: 11px; color: var(--text-dim); transition: transform .12s; }
.group-head.collapsed .g-chev { transform: rotate(-90deg); }
.group-head .g-title { font-size: 12.5px; font-weight: 700; }
.group-head .g-count { font-size: 11px; color: var(--text-off); }
.group-head .g-line { flex: 1; height: 1px; background: var(--border); }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 2px;
}
.group-body.collapsed { display: none; }

.tile {
  padding: 9px 6px 8px;
  border-radius: 2px;
  text-align: center;
  cursor: pointer;
  min-width: 0;
}
.tile:hover { background: var(--bg-raised); }
.tile-ico {
  width: 56px; height: 56px;
  margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
}
.tile-ico svg { width: 28px; height: 28px; color: #fcfcfc; }
.tile-label {
  margin-top: 7px;
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: break-word;
}
.tile.selected .tile-label {
  background: var(--blue);
  color: var(--sel-text);
}
.tile.selected { background: rgba(61,174,233,.14); }

/* ------------------------------------------------ search results */
.res-head {
  position: sticky;
  top: 0;
  background: var(--bg-window);
  z-index: 5;
  padding: 10px 2px 8px;
}
.res-title { font-size: 14px; font-weight: 700; }
.res-sub { font-size: 11px; color: var(--text-dim); margin-top: 3px; }
.chips { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  padding: 2px 7px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  font-size: 10.5px;
  letter-spacing: .03em;
  color: var(--blue);
  border-radius: 2px;
}
.provs { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.prov {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  padding: 2px 8px;
  font-size: 11px;
  color: var(--text-dim);
  border-radius: 2px;
}
.prov .dot { width: 7px; height: 7px; background: var(--text-off); flex: none; }
.prov.pending .dot { background: var(--yellow); animation: blink 1s steps(2) infinite; }
.prov.ok .dot { background: var(--green); }
.prov.zero .dot { background: var(--text-off); }
.prov.err .dot { background: var(--red); }
.prov .n { color: var(--text); }
@keyframes blink { 50% { opacity: .25; } }

table.tbl {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
  margin-top: 10px;
}
.tbl thead th {
  background: var(--bg-panel);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  padding: 6px 8px;
  border: 1px solid var(--border-dark);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.tbl thead th:hover { color: var(--text); }
.tbl thead th.sorted { color: var(--blue); }
.tbl tbody tr { background: var(--bg-window); cursor: pointer; }
.tbl tbody tr:nth-child(even) { background: var(--bg-altrow); }
.tbl tbody tr:hover { background: var(--bg-raised); }
.tbl tbody tr.selected,
.tbl tbody tr.selected:nth-child(even) { background: var(--blue); }
.tbl tbody tr.selected td { color: var(--sel-text) !important; border-color: rgba(0,0,0,.15); }
.tbl tbody tr.selected .mark { color: var(--sel-text); }
.tbl td {
  padding: 5px 8px;
  border-bottom: 1px solid #1f2225;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tbl .td-title { overflow: hidden; text-overflow: ellipsis; }
.cat-sq {
  width: 16px; height: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  vertical-align: middle;
  border-radius: 1px;
}
.cat-sq svg { width: 9px; height: 9px; color: #fcfcfc; }
.t-num { text-align: right; font-variant-numeric: tabular-nums; }
td.seed { color: var(--green); font-weight: 700; }
td.leech { color: var(--orange); }
.src-tag { font-size: 10.5px; color: var(--text-dim); }
.mark { background: transparent; color: var(--blue); font-weight: 700; }
tr.selected .src-tag { color: var(--sel-text); }
.scorebar {
  display: inline-block;
  width: 44px; height: 5px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  vertical-align: middle;
}
.scorebar i { display: block; height: 100%; background: var(--blue); }
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-off);
  font-size: 12.5px;
  line-height: 1.8;
}
.empty b { color: var(--text-dim); }

/* ------------------------------------------------ right sidebar */
.sidebar {
  width: 288px;
  flex: none;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-dark);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sb-hero { padding: 22px 18px 10px; text-align: center; }
.sb-icon {
  width: 88px; height: 88px;
  margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
}
.sb-icon svg { width: 44px; height: 44px; color: #fcfcfc; }
.sb-name {
  margin-top: 13px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.sb-sub { margin-top: 5px; font-size: 11px; color: var(--text-dim); }
.sb-btns { padding: 12px 14px 4px; display: flex; flex-direction: column; gap: 6px; }
.sb-split { display: flex; }
.sb-btn {
  flex: 1;
  height: 30px;
  background: var(--bg-raised);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 12px;
  color: var(--text);
  border: 1px solid var(--border-dark);
}
.sb-btn:hover { background: #43494e; }
.sb-btn svg { width: 13px; height: 13px; }
.sb-btn.primary { background: var(--blue-deep); border-color: var(--blue-deep); color: #fcfcfc; font-weight: 700; }
.sb-btn.primary:hover { background: #3daee9; }
.sb-split .sb-btn + .sb-btn { flex: none; width: 30px; border-left: none; }
.sb-split .sb-btn + .sb-btn .chev { width: 9px; height: 9px; }
.sb-sep { height: 1px; background: var(--border-dark); margin: 10px 0; }
.sb-acts { padding: 0 14px; }
.act-row {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 7px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  user-select: none;
}
.act-row:hover { background: var(--bg-raised); }
.act-row.disabled { color: var(--text-off); pointer-events: none; }
.act-ico { width: 16px; height: 16px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: 1px; }
.act-ico svg { width: 10px; height: 10px; color: #fcfcfc; }
.act-row .chev { margin-left: auto; width: 9px; height: 9px; opacity: .6; }
.sb-info { padding: 2px 18px 20px; }
.info-row { display: flex; justify-content: space-between; gap: 12px; padding: 3.5px 0; font-size: 11.5px; }
.info-row .k { color: var(--text-dim); flex: none; }
.info-row .v { text-align: right; overflow-wrap: anywhere; }
.info-row .v.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 10.5px; }
.sb-empty { padding: 46px 24px; text-align: center; color: var(--text-off); font-size: 12px; line-height: 1.9; }
.sb-empty svg { width: 40px; height: 40px; margin: 0 auto 14px; color: #43494e; }
.why {
  margin: 2px 18px 0;
  padding: 8px 10px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue);
  font-size: 10.5px;
  line-height: 1.7;
  color: var(--text-dim);
}

/* ------------------------------------------------ news bar */
.newsbar {
  height: 30px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-dark);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  flex: none;
  font-size: 11.5px;
}
.newsbar svg { width: 14px; height: 14px; color: var(--green); flex: none; }
.news-text { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.news-text b { color: var(--text); font-weight: 700; }
.news-more { color: var(--blue); cursor: pointer; flex: none; }
.news-more:hover { text-decoration: underline; }

/* ------------------------------------------------ status bar */
.statusbar {
  height: 26px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 11px;
  color: var(--text);
  flex: none;
  user-select: none;
}
.statusbar .seg { display: flex; align-items: center; gap: 9px; min-width: 0; }
.statusbar .seg > span { white-space: nowrap; }
.statusbar .dot-sep { color: var(--text-off); }
.statusbar .ok-ico { color: var(--green); }
.statusbar svg { width: 11px; height: 11px; }

/* ------------------------------------------------ toasts */
#toasts {
  position: fixed;
  right: 14px;
  bottom: 64px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue);
  padding: 9px 14px;
  font-size: 12px;
  min-width: 220px;
  max-width: 340px;
  box-shadow: 0 5px 0 rgba(0,0,0,.3);
  animation: toast-in .14s steps(3);
}
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ------------------------------------------------ responsive */
.details-toggle { display: none; }
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    right: 0; top: 74px; bottom: 56px;
    z-index: 130;
    transform: translateX(100%);
    transition: transform .15s steps(3);
    box-shadow: -6px 0 0 rgba(0,0,0,.25);
  }
  .sidebar.open { transform: translateX(0); }
  .details-toggle { display: flex; }
}
@media (max-width: 760px) {
  .tb-label { display: none; }
  .tb-btn { padding: 0 7px; }
  .titlebar-title .tb-label { display: inline; }
}
@media (max-width: 560px) {
  .tb-sep { display: none; }
  .tb-btn { padding: 0 5px; gap: 4px; }
  .searchwrap { margin: 0 3px; min-width: 80px; }
  #btn-providers .badge { display: none; }
  #btn-providers .tb-label, #btn-help .tb-label { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
  .content { padding: 6px 8px 24px; }
  .sidebar { width: 262px; }
  /* statusbar: keep left + indexed count, drop the rest */
  .statusbar { padding: 0 8px; font-size: 10.5px; }
  .statusbar .seg { min-width: 0; overflow: hidden; }
  .statusbar .seg > span { white-space: nowrap; }
  #status-time, #status-provs, .statusbar .dot-sep, .statusbar .ok-ico { display: none; }
}
