:root {
  --bg: #0f1115; --panel: #171a21; --border: #262b36;
  --text: #e6e9ef; --dim: #8b93a5; --accent: #4f8ef7;
  --ok: #3fb96a; --warn: #e0a63c; --bad: #e05c5c;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f6f7f9; --panel: #ffffff; --border: #e2e5ea; --text: #1c2230; --dim: #667085; }
}
* { box-sizing: border-box; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, system-ui, sans-serif; }

header {
  display: flex; align-items: center; gap: 24px; padding: 14px 20px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 5;
}
header h1 { font-size: 17px; }
nav { display: flex; gap: 14px; flex: 1; }
nav a { color: var(--dim); text-decoration: none; padding: 4px 2px; }
nav a.active { color: var(--text); border-bottom: 2px solid var(--accent); }
#worker-dot { font-size: 13px; color: var(--dim); }
#worker-dot.ok { color: var(--ok); } #worker-dot.warn { color: var(--warn); } #worker-dot.bad { color: var(--bad); }

main { max-width: 860px; margin: 0 auto; padding: 20px; }
.loading, .empty, .error { color: var(--dim); padding: 40px 0; text-align: center; }
.error { color: var(--bad); }

.feed { display: flex; flex-direction: column; gap: 14px; }
.card {
  display: flex; gap: 14px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; transition: opacity .25s, transform .25s;
}
.card.gone { opacity: 0; transform: translateX(30px); }
.thumb { position: relative; flex: 0 0 200px; align-self: flex-start; }
.thumb img { width: 200px; border-radius: 6px; display: block; background: #000; aspect-ratio: 16/9; object-fit: cover; }
.thumb .dur { position: absolute; right: 5px; bottom: 5px; background: #000c; color: #fff; font-size: 11px; padding: 1px 5px; border-radius: 4px; }
.body { flex: 1; min-width: 0; }
.body h3 { font-size: 15px; margin-bottom: 2px; }
.meta { color: var(--dim); font-size: 12.5px; margin-bottom: 8px; }

.gist { border-left: 3px solid var(--accent); padding-left: 10px; margin-bottom: 10px; }
.gist-pending { color: var(--dim); font-style: italic; margin-bottom: 10px; }
.gist-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--border); color: var(--dim); }
.tag.type { color: var(--accent); }
.tag.worth-yes { background: #1d3a28; color: var(--ok); }
.tag.worth-maybe { background: #3a331d; color: var(--warn); }
.tag.worth-skip { background: #3a1d1d; color: var(--bad); }
.gist-summary { font-weight: 550; }
.gist-chain { color: var(--dim); font-size: 13.5px; margin: 4px 0; }
.gist-chain strong { color: var(--text); }
.gist-chain .arr { color: var(--accent); margin: 0 5px; }
.gist-payoff { font-size: 13.5px; }
.ideas { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.idea { display: inline-flex; align-items: center; gap: 2px; background: var(--border); border-radius: 12px; padding: 1px 4px 1px 9px; font-size: 12px; }
.idea a { color: var(--accent); text-decoration: none; }
.idea .promote { border: none; background: none; padding: 0 5px; font-size: 13px; color: var(--dim); cursor: pointer; }
.idea .promote:hover { color: var(--ok); }
.score { color: var(--accent); font-weight: 600; }

.detail .back { color: var(--dim); text-decoration: none; display: inline-block; margin-bottom: 14px; }
.detail-head { display: flex; gap: 16px; margin-bottom: 14px; }
.detail-head .thumb { flex: 0 0 260px; }
.detail-head .thumb img { width: 260px; }
.detail-head h2 { font-size: 18px; margin-bottom: 4px; }
.detail-link { color: inherit; text-decoration: none; }
.detail-link:hover { color: var(--accent); }
.status-pill { border: 1px solid var(--border); border-radius: 10px; padding: 0 8px; font-size: 12px; }
.btn-link { color: var(--accent); text-decoration: none; font-size: 13.5px; padding: 5px 8px; }
.desc { margin: 12px 0; color: var(--dim); }
.desc pre { white-space: pre-wrap; font: inherit; font-size: 13px; margin-top: 8px; }
.comments { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 14px; }
.comments h3 { font-size: 14px; margin-bottom: 10px; }
.comments .hint { font-weight: 400; }
#comment-list { list-style: none; margin-bottom: 12px; }
#comment-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.cmeta { color: var(--dim); font-size: 11.5px; }
.cdel { border: none; background: none; color: var(--bad); cursor: pointer; font-size: 11.5px; padding: 0 4px; }
#comment-form { display: flex; gap: 8px; align-items: flex-start; }
#comment-form textarea { flex: 1; resize: vertical; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 7px; padding: 8px 10px; font: inherit; font-size: 13.5px; }

.discover #add-search { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.discover #add-search input { flex: 1; min-width: 240px; }
.search-section { margin-top: 26px; }
.search-section h2 { font-size: 15px; display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.search-section .sdel { padding: 1px 8px; font-size: 12px; margin-left: auto; }
.feed.compact .card { padding: 10px; }
.feed.compact .thumb { flex-basis: 150px; }
.feed.compact .thumb img { width: 150px; }

.src-icon { color: var(--dim); width: 18px; display: inline-block; }
.channels section.sub h2 { text-transform: none; letter-spacing: 0; padding-left: 14px; }
.channels section.sub ul { padding-left: 14px; }
#add-playlist { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
#add-playlist input { flex: 1; min-width: 220px; }

@media (max-width: 640px) {
  header { gap: 12px; padding: 10px 12px; flex-wrap: wrap; }
  header h1 { font-size: 15px; }
  nav { gap: 10px; font-size: 14px; }
  main { padding: 12px; }
  .card { flex-direction: column; }
  .thumb, .feed.compact .thumb { flex-basis: auto; width: 100%; }
  .thumb img, .feed.compact .thumb img { width: 100%; }
  .detail-head { flex-direction: column; }
  .detail-head .thumb img { width: 100%; }
  #add-channel, #add-playlist, .discover #add-search { flex-direction: column; align-items: stretch; }
}

.actions { display: flex; gap: 8px; }
button {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 7px; padding: 5px 14px; cursor: pointer; font-size: 13.5px;
}
button:hover { border-color: var(--accent); }
button.on { color: var(--warn); }
#more { display: block; margin: 18px auto; }

.channels section { margin-top: 22px; }
.channels h2 { font-size: 14px; color: var(--dim); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.channels ul { list-style: none; }
.channels li { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border); }
.ch-handle { color: var(--dim); font-size: 13px; flex: 1; }
.rm { padding: 1px 8px; font-size: 12px; }
#add-channel { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#add-channel input { flex: 1; min-width: 220px; }
.hint { color: var(--dim); font-size: 12px; }

input, select {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 7px; padding: 7px 10px; font-size: 14px;
}
.settings { display: flex; flex-direction: column; gap: 14px; max-width: 480px; }
.settings label { display: flex; flex-direction: column; gap: 4px; color: var(--dim); font-size: 13px; }
.settings button { align-self: flex-start; }
#settings-status, #worker-status { color: var(--dim); font-size: 13px; }
