:root {
  --bg: #f4f5f8; --card: #fff; --fg: #181b24; --muted: #667085; --line: #e3e6ee; --soft: #eef0f6;
  --accent: #d97706; --accent-fg: #fff; --hot: #dc2626; --warm: #d97706; --cool: #64748b; --hl: #fff4d6;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1118; --card: #161a24; --fg: #e8eaf0; --muted: #8b93a7; --line: #262c3a; --soft: #1d2230;
    --accent: #f5a524; --accent-fg: #1a1203; --hot: #f87171; --warm: #f5a524; --cool: #8b93a7; --hl: #3a2f10;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .25);
  }
}
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
a { color: inherit; }
.muted { color: var(--muted); } .small { font-size: 13px; } .err { color: var(--hot); min-height: 1.4em; margin: 0; }

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 10px 20px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.logo { font-weight: 700; font-size: 20px; letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: pulse 2.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 9px transparent; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }
.pill { font-size: 13px; padding: 3px 10px; border-radius: 99px; background: var(--soft); color: var(--muted); }
.pill.ok { color: var(--fg); } .pill.warn { background: color-mix(in srgb, var(--hot) 16%, transparent); color: var(--hot); }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tab { border: 0; background: none; color: var(--muted); padding: 7px 12px; border-radius: 8px; font: inherit; cursor: pointer; }
.tab:hover { background: var(--soft); } .tab.on { background: var(--soft); color: var(--fg); font-weight: 600; }
.logout { font-size: 13px; color: var(--muted); text-decoration: none; } .logout:hover { color: var(--fg); }

main { max-width: 1080px; margin: 0 auto; padding: 18px 20px 80px; display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 16px; }
.controls { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.actions { margin: 2px 0 4px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.hist { margin-left: auto; }
input, select, button { font: inherit; color: inherit; }
input[type=date], input[type=password], input[type=search], select { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; }
input[type=search] { flex: 1; min-width: 200px; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 9px; padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { background: var(--soft); } .btn.small { padding: 4px 10px; font-size: 13px; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); } .btn:disabled { opacity: .5; cursor: default; }
.preset { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 5px 13px; cursor: pointer; font-size: 14px; }
.preset:hover { background: var(--soft); } .preset.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }

.chart-wrap { position: relative; }
.chart { height: 110px; }
.chart svg { width: 100%; height: 100%; display: block; }
.chart rect.bar { fill: var(--accent); opacity: .75; cursor: pointer; transition: opacity .1s; }
.chart rect.bar:hover { opacity: 1; }
.chart text { fill: var(--muted); font-size: 10px; }
.chart .empty { display: grid; place-items: center; height: 100%; color: var(--muted); }

.chips { gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 3px 10px 3px 4px; cursor: pointer; font-size: 13px; }
.chip img, .av { width: 20px; height: 20px; border-radius: 50%; background: var(--soft); object-fit: cover; flex: none; }
.chip i { font-style: normal; color: var(--muted); }
.chip.off { opacity: .45; } .chip:hover { background: var(--soft); }

.progress { display: flex; align-items: center; gap: 12px; margin: 6px 0; }
.bar { flex: 1; height: 6px; border-radius: 4px; background: var(--soft); overflow: hidden; max-width: 320px; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }

.note { padding: 12px 14px; border-radius: 10px; background: var(--soft); color: var(--muted); }
.runmeta { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin: 6px 0 10px; }

.topic { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); margin-bottom: 12px; overflow: hidden; }
.t-head { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; padding: 14px 16px; cursor: pointer; align-items: start; }
.t-head:hover { background: color-mix(in srgb, var(--soft) 50%, transparent); }
.score { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: 20px; color: #fff; background: var(--cool); }
.score.hot { background: var(--hot); } .score.warm { background: var(--warm); color: #1a1203; } .score.na { font-size: 13px; }
.t-title { font-weight: 650; font-size: 17px; line-height: 1.3; margin: 0 0 3px; }
.t-sum { margin: 0 0 8px; color: var(--fg); opacity: .88; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 13px; color: var(--muted); }
.tag { background: var(--soft); border-radius: 6px; padding: 1px 7px; }
.mood { font-size: 13px; }
.caret { color: var(--muted); transition: transform .15s; align-self: center; } .topic.open .caret { transform: rotate(90deg); }
.t-body { display: none; border-top: 1px solid var(--line); padding: 8px 16px 14px; }
.topic.open .t-body { display: block; }
.win { padding: 12px 0; border-bottom: 1px dashed var(--line); } .win:last-child { border-bottom: 0; }
.w-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.w-head b { font-weight: 650; }
.w-sum { margin: 4px 0 8px; font-size: 14px; color: var(--muted); }
.quotes { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.quote { text-align: left; border: 0; border-left: 3px solid var(--accent); background: var(--soft); border-radius: 0 8px 8px 0; padding: 5px 10px; cursor: pointer; font-size: 14px; word-break: break-word; }
.quote:hover { filter: brightness(.96); } .quote .u { font-weight: 650; margin-right: 6px; }
.w-act { display: flex; gap: 8px; flex-wrap: wrap; }
.other { margin-top: 18px; } .other summary { cursor: pointer; color: var(--muted); }

.msg-row { display: grid; grid-template-columns: 76px 1fr; gap: 8px; padding: 3px 4px; border-radius: 6px; font-size: 14px; word-break: break-word; }
.msg-row:hover { background: var(--soft); }
.msg-row.hl { background: var(--hl); outline: 1px solid var(--accent); }
.msg-row.ev .t::after { content: " ★"; color: var(--accent); }
.msg-row .t { white-space: nowrap; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; padding-top: 2px; }
.msg-row .u { font-weight: 650; }
.msg-row .b { font-size: 11px; margin-left: 4px; padding: 0 5px; border-radius: 4px; background: var(--soft); color: var(--muted); font-weight: 500; }
.reply { display: block; font-size: 12px; color: var(--muted); margin-bottom: 1px; cursor: pointer; border-left: 2px solid var(--line); padding-left: 6px; }
.emote { height: 24px; vertical-align: middle; margin: 0 1px; }
.srch-ch { font-size: 12px; color: var(--muted); }
.result-row { display: block; width: 100%; text-align: left; border: 0; background: none; border-bottom: 1px solid var(--line); padding: 8px 4px; cursor: pointer; }
.result-row:hover { background: var(--soft); }

.chan { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center; padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.chan .av { width: 36px; height: 36px; }
.chan .live { color: var(--hot); font-weight: 600; font-size: 12px; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--card); border-left: 1px solid var(--line); box-shadow: -12px 0 40px rgba(0, 0, 0, .25); transform: translateX(105%); transition: transform .22s ease; z-index: 40; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
@media (prefers-reduced-motion: reduce) { .drawer { transition: none; } }
.drawer-head { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px 8px; }
.d-title { font-weight: 700; font-size: 17px; }
.icon { border: 0; background: var(--soft); border-radius: 8px; width: 32px; height: 32px; cursor: pointer; }
.drawer-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 0 16px 10px; border-bottom: 1px solid var(--line); }
.check { font-size: 13px; color: var(--muted); display: flex; gap: 5px; align-items: center; }
.drawer-body { overflow: auto; padding: 10px 12px 40px; flex: 1; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 30; }

.login { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card { width: min(360px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.login-card p { margin: 0; }

@media (max-width: 640px) {
  .top { padding: 8px 12px; } main { padding: 12px 12px 80px; }
  .t-head { grid-template-columns: 40px 1fr; } .score { width: 40px; height: 40px; font-size: 17px; } .caret { display: none; }
  .tabs { margin-left: 0; width: 100%; } .hist { margin-left: 0; }
}

.sec { margin: 4px 0 8px; font-size: 16px; }
#pane-channels { display: flex; flex-direction: column; gap: 12px; }
.rates p { margin: 0 0 10px; }
.rate-bin { display: grid; grid-template-columns: 135px 1fr 110px minmax(150px, auto); gap: 10px; align-items: center; padding: 4px 0; font-size: 14px; }
.rate-bin.thin { opacity: .55; }
.rb-bar { height: 10px; border-radius: 5px; background: var(--soft); overflow: hidden; }
.rb-bar i { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.rb-v { font-variant-numeric: tabular-nums; font-weight: 600; }
.rate-table { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 6px; }
.rt-row { display: grid; grid-template-columns: 24px 1fr 90px 90px 100px; gap: 10px; align-items: center; padding: 5px 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.rt-row .av { width: 22px; height: 22px; } .rt-head { color: var(--muted); font-size: 12px; }
.rt-row span:nth-child(n+3) { text-align: right; }
@media (max-width: 640px) { .rate-bin { grid-template-columns: 90px 1fr 90px; } .rb-s { display: none; } .rt-row { grid-template-columns: 24px 1fr 70px 70px 80px; } }

.chan.clickable { cursor: pointer; } .chan.clickable:hover { background: var(--soft); }

/* zakładka Kanały: długie nazwy się zawijają / skracają, awatary zawsze małe */
body { overflow-x: hidden; }
main > * { min-width: 0; }
.chip { max-width: 100%; overflow-wrap: anywhere; text-align: left; }
.chan > div { min-width: 0; overflow-wrap: anywhere; }
.chan > div:last-child { white-space: nowrap; }
.rt-row > span:nth-child(2) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.rt-row .av, .chan .av { flex: none; }
.field.inline input { min-width: 0; }
.chip i { white-space: nowrap; flex: none; }
@media (max-width: 640px) {
  .rt-row { grid-template-columns: 22px minmax(70px, 1fr) 46px 46px 52px; gap: 6px; font-size: 13px; }
  .rt-head { font-size: 11px; }
}
