:root {
  --bg: #0d0e10;
  --panel: #131518;
  --line: #22252a;
  --text: #d6d9de;
  --dim: #80868f;
  --faint: #4c515a;
  --strong: #f1f2f4;
  --live: #ff3b3b;
  --link: #8ab4f8;
  --error: #ff8a80;
  --hl: rgba(217, 165, 32, 0.10);
  --hlbar: #d9a520;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --chat-w: 360px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

[hidden] { display: none !important; }

/* ── górny pasek ── */
.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  min-width: 0;
}
.brand {
  font-weight: 650;
  color: var(--strong);
  text-decoration: none;
  letter-spacing: 0.01em;
}
.pill {
  font: 600 11px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 5px 7px;
  border-radius: 3px;
  background: #1c1f23;
  color: var(--dim);
}
.pill.live { background: var(--live); color: #fff; }
.plat { font: 12px var(--mono); color: var(--dim); }
.plat[data-p="twitch"]  { color: #a970ff; }
.plat[data-p="kick"]    { color: #53fc18; }
.plat[data-p="youtube"] { color: #ff4e45; }
.plat[data-p="trovo"]   { color: #19d66b; }
.title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.viewers { font: 12px var(--mono); color: var(--dim); }
.tools { display: flex; align-items: center; gap: 6px; }
.links a {
  font: 12px var(--mono);
  color: var(--dim);
  text-decoration: none;
  margin-right: 8px;
}
.links a:hover { color: var(--text); }

button {
  font: 12px var(--mono);
  color: var(--dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 4px 8px;
  cursor: pointer;
}
button:hover { color: var(--text); border-color: var(--faint); }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }

/* ── układ ── */
.layout { flex: 1; display: flex; min-height: 0; }

.stage { flex: 1; position: relative; min-width: 0; background: #000; }
.player, .player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.offline {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background: var(--bg);
}
.offline-inner { max-width: 560px; }
.offline-tag {
  margin: 0 0 14px;
  font: 600 12px var(--mono);
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--faint);
}
.offline-msg {
  margin: 0 0 14px;
  font-size: 20px;
  line-height: 1.4;
  color: var(--strong);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.offline-msg:empty { display: none; }
.offline-last { margin: 0 0 14px; color: var(--dim); font-size: 13px; }
.offline-links a { font: 13px var(--mono); color: var(--link); margin: 0 8px; text-decoration: none; }
.offline-links a:hover { text-decoration: underline; }

/* ── czat ── */
.chat {
  width: var(--chat-w);
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  background: var(--panel);
  border-left: 1px solid var(--line);
}
.topic {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  font: 12.5px/1.45 var(--mono);
  color: var(--dim);
  overflow-wrap: anywhere;
}
.topic::before { content: "temat: "; color: var(--faint); }

.log {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  font: 13px/1.5 var(--mono);
  overflow-wrap: anywhere;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.line { padding: 1px 10px; }
.line .ts { color: var(--faint); }
.line .nick { font-weight: 600; cursor: pointer; }
.line .nick:hover { text-decoration: underline; }
.line .br { color: var(--faint); }
.line.system { color: var(--dim); }
.line.system .mark { color: var(--faint); }
.line.info { color: var(--dim); }
.line.error { color: var(--error); }
.line.action .body { font-style: italic; }
.line.hl { background: var(--hl); box-shadow: inset 2px 0 var(--hlbar); }
.log a { color: var(--link); text-decoration: underline; text-decoration-color: rgba(138, 180, 248, 0.35); }
.log a:hover { text-decoration-color: currentColor; }

.more {
  position: absolute;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%);
  background: var(--bg);
  color: var(--text);
}

.users {
  max-height: 40%;
  overflow-y: auto;
  padding: 6px 10px;
  border-top: 1px solid var(--line);
  font: 12.5px/1.6 var(--mono);
  columns: 2;
}
.users div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }

.input {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--line);
}
.input input {
  flex: 1;
  min-width: 0;
  padding: 7px 8px;
  font: 13px var(--mono);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
}
.input input::placeholder { color: var(--faint); }
.nickbtn { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.count { min-width: 34px; }

/* ── tryby ── */
body.cinema .chat { display: none; }
body.popout .bar,
body.popout .stage { display: none; }
body.popout .chat { width: 100%; border-left: 0; }

@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .stage { flex: none; width: 100%; aspect-ratio: 16 / 9; }
  .chat { width: auto; flex: 1; border-left: 0; border-top: 1px solid var(--line); }
  .links, .viewers, .plat, #popout, #reload { display: none !important; }
  .bar { gap: 8px; padding: 0 10px; }
  .brand { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .tools { flex: none; }
  .offline-msg { font-size: 16px; }
  body.cinema .stage { flex: 1; aspect-ratio: auto; }
}

.captcha { padding: 8px 8px 0; border-top: 1px solid var(--line); }
.line.keyline {
  margin: 2px 10px;
  padding: 4px 8px;
  border: 1px dashed var(--faint);
  border-radius: 3px;
  color: var(--strong);
  user-select: all;
}
