/* ============================================================
   TS Manager — "Signal Desk"
   Bespoke dark audio-console aesthetic. Cyan-mint signal + amber live.
   Display: Bricolage Grotesque · UI: Hanken Grotesk · Data: JetBrains Mono
   ============================================================ */

/* Atrybut [hidden] musi wygrywać z komponentowym display:grid/flex — inaczej
   panele oznaczone hidden (np. „teraz gra" w Kinie) i tak się pokazują. */
[hidden] { display: none !important; }

:root {
  /* Motyw „Bento fiolet" (wg handoffu TS6 1b) — fioletowo-czarny, akcent lawendowy */
  --void: #0e0d14;           /* tło strony */
  --bg: #0e0d14;
  --bg-2: #0b0a10;           /* inset wells */
  --surface: #161320;        /* kafel / faceplate */
  --surface-2: #1a1728;
  --surface-3: #1d1930;      /* kafel wgłębiony */
  --line: rgba(255,255,255,.055); /* hairline */
  --line-2: rgba(255,255,255,.09); /* seam */

  --text: #f2f0f8;           /* primary */
  --muted: #8f89a6;          /* muted */
  --faint: #59536e;          /* nagłówki sekcji */

  --signal: #a78bfa;         /* akcent — lawenda (primary) */
  --signal-deep: #6d4fd6;    /* akcent ciemny */
  --signal-dim: rgba(167, 139, 250, 0.12);
  --signal-glow: rgba(167, 139, 250, 0.22);
  --amber: #f2cf95;          /* warning */
  --amber-glow: rgba(245, 196, 110, 0.18);
  --violet: #c9b8fc;         /* akcent jasny */
  --blue: #a99ec9;
  --red: #f06e6e;            /* danger */
  --red-glow: rgba(240, 110, 110, 0.14);

  --radius: 18px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  --font-display: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-sans: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;

  --shadow: inset 0 1px 0 rgba(255,255,255,0.03), 0 18px 40px -28px rgba(0,0,0,0.9);
  --sidebar-w: 216px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--void);
  background-image:
    radial-gradient(1100px 480px at 84% -8%, var(--signal-glow), transparent 60%),
    radial-gradient(820px 480px at -6% 110%, var(--amber-glow), transparent 55%);
  background-attachment: fixed;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}
/* faceplate grain */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: .035; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: var(--signal); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--font-mono); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; margin: 0; }
::selection { background: var(--signal); color: #14102a; }

*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: padding-box; }

/* ============================================================
   App shell
   ============================================================ */
.app { position: relative; z-index: 1; display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh;
  background: linear-gradient(180deg, #141020, #0e0d14);
  border-right: 1px solid var(--line-2);
  display: flex; flex-direction: column;
  padding: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px; }
.brand-mark {
  width: 34px; height: 28px; border-radius: 7px; flex: none;
  display: flex; align-items: flex-end; justify-content: center; gap: 2px; padding: 5px 4px;
  background: var(--bg-2); border: 1px solid var(--line-2);
}
.brand-mark i { flex: 1; background: var(--signal); border-radius: 2px; box-shadow: 0 0 8px var(--signal-glow); animation: wm 1.1s ease-in-out infinite; }
.brand-mark i:nth-child(2) { animation-delay: .18s; }
.brand-mark i:nth-child(3) { animation-delay: .36s; }
.brand-mark i:nth-child(4) { animation-delay: .1s; }
@keyframes wm { 0%, 100% { height: 30%; } 50% { height: 100%; } }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 16px; letter-spacing: 0.02em; }
.brand-name b { color: var(--signal); font-weight: 800; }
.brand-sub { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.32em; color: var(--signal); text-transform: uppercase; margin-top: 3px; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; overflow-y: auto; }
.nav-label { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.2em; color: var(--faint); text-transform: uppercase; padding: 14px 11px 7px; display: flex; align-items: center; gap: 8px; }
.nav-label::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-2), transparent); }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 13.5px; font-weight: 500;
  position: relative; transition: background .15s, color .15s; text-decoration: none;
}
.nav a i { font-size: 18px; width: 18px; text-align: center; color: var(--faint); transition: color .15s; }
.nav a:hover { background: rgba(255,255,255,0.035); color: var(--text); }
.nav a:hover i { color: var(--muted); }
.nav a.on { color: var(--text); background: linear-gradient(90deg, var(--signal-dim), transparent); box-shadow: inset 0 0 0 1px rgba(167,139,250,0.16); }
.nav a.on i { color: var(--signal); }
.nav a.on::before {
  content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px; border-radius: 0 3px 3px 0;
  background: var(--signal); box-shadow: 0 0 11px var(--signal);
}

.sidebar-foot { margin-top: auto; padding-top: 14px; }
.who { display: flex; align-items: center; gap: 10px; padding: 11px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: inset 0 2px 6px rgba(0,0,0,.5); }
.who-avatar {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 14px;
  background: linear-gradient(180deg, var(--surface-2), #17132a); color: var(--signal); border: 1px solid var(--line-2);
}
.who-name { font-size: 14px; font-weight: 600; }
.who-role { font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; color: var(--faint); text-transform: uppercase; }
.who-out-form { margin-left: auto; display: flex; }
.who-out { margin-left: auto; color: var(--faint); display: grid; place-items: center; padding: 7px; border-radius: 8px; }
button.who-out { background: none; border: 0; cursor: pointer; font: inherit; line-height: 0; }
.who-out:hover { color: var(--red); background: var(--surface); text-decoration: none; }

/* ============================================================
   Mobile bottom tab bar
   ============================================================ */
.botbar { display: none; }
.botbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: linear-gradient(180deg, #141020, #0b0a10);
  border-top: 1px solid var(--line-2);
  box-shadow: 0 -12px 30px -20px #000;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around;
}
.botbar a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-width: 54px; min-height: 52px; border-radius: 12px; flex: 1; max-width: 96px;
  color: var(--muted); text-decoration: none; font-family: var(--font-mono); font-size: 10px; letter-spacing: .04em; text-transform: uppercase;
}
.botbar a i { font-size: 21px; }
.botbar a.on { color: var(--signal); }
.botbar a.on i { color: var(--signal); }
.botbar a.on::before { content: ""; position: absolute; top: -6px; width: 22px; height: 3px; border-radius: 0 0 3px 3px; background: var(--signal); box-shadow: 0 0 10px var(--signal); }

/* ============================================================
   Topbar (console header) + live waveform
   ============================================================ */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 16px 28px;
  background: linear-gradient(180deg, rgba(9,10,12,0.94), rgba(9,10,12,0.72));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-2);
}
.topbar .tb-brand { display: none; }
.topbar h1 { font-size: 25px; }
.topbar .crumb { font-family: var(--font-mono); font-size: 11px; letter-spacing: .16em; color: var(--faint); text-transform: uppercase; margin-bottom: 4px; }

.signal-bar {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 12px;
  font-family: var(--font-mono); font-size: 12.5px; letter-spacing: .03em;
  padding: 7px 13px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--line); color: var(--muted);
  box-shadow: inset 0 2px 6px rgba(0,0,0,.5);
}
.signal-bar .addr { color: var(--text); }
.signal-bar .state { color: var(--signal); letter-spacing: .12em; font-size: 10px; }
.wave { display: none; align-items: center; gap: 2px; height: 26px; width: 150px; overflow: hidden; }
.wave span { width: 3px; background: linear-gradient(180deg, var(--signal), #1f8f78); border-radius: 2px; animation: eq 1.4s ease-in-out infinite; }
@keyframes eq { 0%,100% { height: 14%; } 50% { height: 92%; } }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--signal); }
.dot.live { box-shadow: 0 0 9px var(--signal); animation: pulse 2.3s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* ============================================================
   Content + cards (faceplate panels)
   ============================================================ */
.content { padding: 26px 32px 64px; max-width: 1600px; width: 100%; margin: 0 auto; }

.card {
  background: linear-gradient(180deg, var(--surface), #100e18);
  border: 1px solid var(--line-2); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  animation: rise .5s cubic-bezier(.2,.7,.3,1) both;
}
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 16px; font-weight: 700; }
.card-head .sub { font-family: var(--font-mono); font-size: 11px; color: var(--faint); letter-spacing: .06em; text-transform: uppercase; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

/* collapsible "Połączenie z botem" — tucked at the bottom of /music */
details.bot-conf { margin-top: 18px; }
details.bot-conf > summary { cursor: pointer; list-style: none; user-select: none; }
details.bot-conf > summary::-webkit-details-marker { display: none; }
details.bot-conf:not([open]) > summary.card-head { border-bottom: none; }
details.bot-conf .chev { color: var(--faint); transition: transform .2s ease; }
details.bot-conf[open] .chev { transform: rotate(180deg); }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.stagger > * { animation: rise .5s cubic-bezier(.2,.7,.3,1) both; }
.stagger > *:nth-child(1) { animation-delay: .04s; }
.stagger > *:nth-child(2) { animation-delay: .10s; }
.stagger > *:nth-child(3) { animation-delay: .16s; }
.stagger > *:nth-child(4) { animation-delay: .22s; }

.section-title { font-family: var(--font-mono); font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--faint); margin: 24px 2px 12px; }

/* grid helpers (dashboards) */
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* metric / gauge readouts */
.gauge { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; box-shadow: inset 0 2px 7px rgba(0,0,0,.5); }
.gauge .k { font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.gauge .v { font-family: var(--font-display); font-size: 31px; font-weight: 800; line-height: 1; margin-top: 8px; letter-spacing: -.02em; }
.gauge .v small { font-size: 14px; color: var(--faint); font-family: var(--font-mono); font-weight: 400; }
.segs { display: flex; gap: 3px; margin-top: 11px; height: 7px; }
.segs i { flex: 1; border-radius: 1px; background: #23272f; }
.segs i.f { background: var(--signal); box-shadow: 0 0 6px var(--signal-glow); }
.segs.amber i.f { background: var(--amber); box-shadow: 0 0 6px var(--amber-glow); }

/* ============================================================
   Tables
   ============================================================ */
.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl thead th {
  text-align: left; font-family: var(--font-mono); font-weight: 500;
  font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint);
  padding: 11px 18px; border-bottom: 1px solid var(--line-2); background: var(--bg-2);
}
.tbl tbody td { padding: 12px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; color: #cfd6e0; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: rgba(167,139,250,0.05); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .id, .tbl .mono { font-family: var(--font-mono); color: var(--faint); font-size: 13px; }
.tbl .name { font-weight: 600; color: var(--text); }
.actions { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.actions form { display: inline-flex; gap: 6px; align-items: center; }
.tbl-wrap { overflow-x: auto; }
/* compact inline controls inside management tables (rename / move / clone) */
.cell-form { display: inline-flex; gap: 7px; align-items: center; }
.tbl .actions input[name="name"] { max-width: 160px; }
.sel-parent { max-width: 230px; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  font-family: var(--font-mono); font-size: 13px; font-weight: 600; letter-spacing: .03em;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text);
  cursor: pointer; transition: transform .12s, background .12s, border-color .12s, box-shadow .12s, color .12s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--signal-deep); color: var(--signal); }
.btn:active { transform: scale(.98); }
.btn i { font-size: 17px; }
.btn-sm { padding: 7px 10px; font-size: 12.5px; }
.btn-primary { background: var(--signal); color: #14102a; border-color: transparent; box-shadow: 0 0 18px -2px var(--signal-glow); }
.btn-primary:hover { filter: brightness(1.08); color: #14102a; box-shadow: 0 0 24px -2px var(--signal-glow); }
.btn-danger { color: var(--red); border-color: rgba(255,96,96,0.3); background: rgba(255,96,96,0.07); }
.btn-danger:hover { background: var(--red-glow); color: var(--red); border-color: var(--red); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface); border-color: var(--line-2); }
/* icon-only square button */
.btn-icon { padding: 0; width: 36px; height: 36px; }

/* ============================================================
   Forms
   ============================================================ */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-family: var(--font-mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 7px; }

input[type=text], input[type=password], input[type=number], input[type=search], input:not([type]), select, textarea {
  font-family: var(--font-sans); font-size: 15px; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 10px 13px; width: 100%; transition: border-color .14s, box-shadow .14s, background .14s;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.4);
}
input[type=number] { font-family: var(--font-mono); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-glow); background: var(--surface); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

.inline-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }
.inline-form input[type=text], .inline-form input:not([type]) { width: auto; min-width: 180px; }
.w-num { width: 84px !important; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .08em; color: var(--muted); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 38px; height: 21px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--line-2); position: relative; transition: background .16s, border-color .16s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: var(--faint); transition: transform .16s, background .16s; }
.switch input:checked + .track { background: var(--signal-deep); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(17px); background: #14102a; }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--signal-glow); }

/* ============================================================
   Pills, tags, badges, alerts
   ============================================================ */
.tag { font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; padding: 3px 9px; border-radius: 6px; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; }
.tag.green { color: var(--signal); border-color: rgba(167,139,250,0.3); background: var(--signal-dim); }
.tag.amber { color: var(--amber); border-color: rgba(245,166,35,0.3); background: rgba(245,166,35,0.09); }
.tag.blue { color: var(--violet); border-color: rgba(155,140,255,0.3); background: rgba(155,140,255,0.1); }
.tag.dim { color: var(--faint); }

.yn-yes { color: var(--signal); font-family: var(--font-mono); }
.yn-no { color: var(--faint); }

.alert { display: flex; align-items: flex-start; gap: 11px; padding: 13px 16px; border-radius: var(--radius-sm); font-size: 14.5px; margin-bottom: 18px; border: 1px solid rgba(255,96,96,0.3); background: var(--red-glow); color: #ffb4b4; }
.alert i { font-size: 18px; flex: none; margin-top: 1px; }
.alert.ok { border-color: rgba(167,139,250,0.3); background: var(--signal-dim); color: #d8ccff; }

.empty { padding: 40px 22px; text-align: center; color: var(--faint); font-family: var(--font-mono); font-size: 13.5px; letter-spacing: .05em; }
.hint { font-size: 13.5px; color: var(--muted); margin: 0 0 16px; }
.hint code { color: var(--signal); background: var(--bg-2); padding: 1px 6px; border-radius: 5px; font-size: 13px; }

/* ============================================================
   Rooms list + live event feed (dashboard / events)
   ============================================================ */
.room { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.room:last-child { border-bottom: none; }
.room .ci { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; color: var(--void); }
.room .ci i { font-size: 17px; }
.room .info { min-width: 0; flex: 1; }
.room .cn { font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.room .cn .talk { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 8px var(--amber); animation: pulse 1s ease-in-out infinite; flex: none; }
.room .cm { font-family: var(--font-mono); font-size: 11px; color: var(--faint); margin-top: 2px; }
.stk { display: flex; flex: none; }
.stk .av { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--surface); background: linear-gradient(180deg, #1d222b, #161a20); margin-left: -8px; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--muted); }
.stk .av:first-child { margin-left: 0; }
.stk .av.spk { color: var(--amber); border-color: var(--amber); }

.feed .ev { display: grid; grid-template-columns: 13px 1fr auto; align-items: center; gap: 11px; padding: 9px 18px; }
.ev .eled { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.ev .etx { font-size: 13.5px; }
.ev .etx b { font-weight: 600; color: var(--text); }
.ev .ets { font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); }

/* /events: rozwijane wiersze ze szczegółami (dropdown) */
.feed details.ev { display: block; padding: 0; border-top: 1px solid var(--line); }
.feed details.ev:first-child { border-top: none; }
.feed details.ev > summary { display: grid; grid-template-columns: 13px 1fr auto 14px; align-items: center; gap: 11px; padding: 9px 18px; cursor: pointer; list-style: none; }
.feed details.ev > summary::-webkit-details-marker { display: none; }
.feed details.ev > summary:hover { background: rgba(255,255,255,.025); }
.feed details.ev[open] > summary { background: rgba(255,255,255,.045); }
.feed details.ev > summary .chev { color: var(--faint); font-size: 11px; text-align: center; transition: transform .2s ease; }
.feed details.ev > summary:hover .chev { color: var(--muted); }
.feed details.ev[open] > summary .chev { transform: rotate(180deg); color: var(--signal); }
.ev-detail { padding: 2px 18px 12px 42px; display: grid; gap: 5px; animation: rise .25s ease both; }
.ev-detail .kv { display: grid; grid-template-columns: 150px 1fr; gap: 10px; font-size: 12.5px; }
.ev-detail .kv .k { color: var(--faint); font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; overflow-wrap: anywhere; }
.ev-detail .kv .v { color: var(--muted); word-break: break-word; }
.ev-detail .kv.dim { grid-template-columns: 1fr; color: var(--faint); }
.ev-foot { padding: 10px 18px; border-top: 1px solid var(--line); }

/* ============================================================
   Login (pre-auth) — centered console
   ============================================================ */
.auth-wrap { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 392px;
  background: linear-gradient(180deg, var(--surface), #100e18);
  border: 1px solid var(--line-2); border-radius: 18px;
  padding: 34px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
  animation: rise .55s cubic-bezier(.2,.7,.3,1) both;
}
.auth-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 2px; background: linear-gradient(90deg, transparent, var(--signal), transparent); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-card h1 { font-size: 25px; margin-bottom: 4px; }
.auth-card .lede { color: var(--muted); font-size: 14.5px; margin-bottom: 22px; }
.auth-card .btn-primary { width: 100%; padding: 12px; margin-top: 6px; }
.auth-foot { margin-top: 22px; text-align: center; font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); display: flex; align-items: center; justify-content: center; gap: 8px; }

/* ============================================================
   Responsive — tablet & phone
   ============================================================ */
@media (max-width: 1039px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .mus-feed { grid-template-columns: 1fr; }
  /* tables -> cards */
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tbody tr, .tbl tbody td { display: block; width: 100%; }
  .tbl tbody tr { background: linear-gradient(180deg, var(--surface), #100e18); border: 1px solid var(--line-2); border-radius: 14px; margin-bottom: 11px; overflow: hidden; }
  .tbl tbody tr:hover { background: linear-gradient(180deg, var(--surface), #100e18); }
  .tbl tbody td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 15px; border-bottom: 1px solid var(--line); text-align: right; }
  .tbl tbody td:last-child { border-bottom: none; }
  .tbl tbody td::before { content: attr(data-label); font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); text-align: left; }
  .tbl tbody td[data-label=""]::before, .tbl tbody td.rowcell::before { display: none; }
  .tbl tbody td.rowcell { justify-content: flex-start; }
  .actions { justify-content: flex-end; }
}

@media (max-width: 899px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .botbar { display: flex; }
  .content { padding: 18px 16px 90px; }
  .topbar { padding: 14px 16px; }
  .topbar .tb-brand { display: flex; }
}

@media (max-width: 699px) {
  .topbar h1 { font-size: 19px; }
  .signal-bar .wave { display: none; }
  .btn-icon { width: 44px; height: 44px; }
  .actions .btn-icon { width: 40px; height: 40px; }
}

@media (min-width: 900px) {
  .signal-bar .wave { display: flex; }
}

@media (max-width: 699px) {
  .signal-bar .addr, .signal-bar .state { display: none; }
  .signal-bar { padding: 9px; }
}

/* mobile nav drawer (opened by the "Więcej" bottom-bar item) */
.nav-scrim { display: none; }
@media (max-width: 899px) {
  body.nav-open .sidebar {
    display: flex; position: fixed; top: 0; left: 0; bottom: 0; height: 100vh;
    width: 84%; max-width: 300px; z-index: 60; box-shadow: 0 0 60px rgba(0,0,0,0.65);
  }
  body.nav-open .nav-scrim {
    display: block; position: fixed; inset: 0; z-index: 59;
    background: rgba(0,0,0,0.66);
  }
  /* .app has z-index:1 (its own stacking context), which TRAPPED the drawer's
     z-index:60 below the body-level scrim (z-index:59) — drawer rendered behind
     the dim and unclickable (the old backdrop-blur just masked it). Drop .app's
     stacking context while the drawer is open so the fixed drawer escapes to the
     root layer and sits ABOVE the scrim (crisp + clickable); scrim still dims .main. */
  body.nav-open .app { z-index: auto; }
}

/* clickable client avatars (dashboard rooms) */
.av-btn { cursor: pointer; appearance: none; font: inherit; font-family: var(--font-display); font-weight: 700; transition: border-color .14s, color .14s, box-shadow .14s; }
.av-btn:hover { border-color: var(--signal); color: var(--signal); box-shadow: 0 0 11px var(--signal-glow); z-index: 1; }

/* client action modal */
.modal-scrim { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(5,6,8,0.72); backdrop-filter: blur(3px); }
.modal-scrim[hidden] { display: none; }
.modal { width: 100%; max-width: 440px; background: linear-gradient(180deg, var(--surface), #100e18); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: 0 30px 70px -30px #000; overflow: hidden; animation: rise .22s ease both; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 16px; font-weight: 700; }
.modal-x { margin-left: auto; width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.modal-x:hover { color: var(--red); border-color: var(--red); }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.cm-form { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.cm-form:last-child { border-bottom: none; padding-bottom: 0; }
.cm-form .field { margin-bottom: 10px; }
.cm-row { display: flex; gap: 10px; align-items: flex-end; }
.cm-row .field { margin-bottom: 10px; }
.cm-form .btn { width: 100%; justify-content: center; }

/* ── Music console ─────────────────────────────────────────────── */
.np {
  display: flex; gap: 16px; align-items: center;
  padding: 18px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--line-2);
}
.np-ico {
  width: 54px; height: 54px; flex: none; border-radius: 12px;
  display: grid; place-items: center; font-size: 26px;
  background: var(--signal-dim); color: var(--signal);
  border: 1px solid rgba(167,139,250,0.25);
}
.np-ico.idle { background: var(--surface-2); color: var(--faint); border-color: var(--line-2); }
.np-ico.down { background: var(--red-glow); color: var(--red); border-color: rgba(255,96,96,0.3); }
.np-body { flex: 1 1 auto; min-width: 0; }
.np-title {
  font-family: var(--font-display); font-size: 18px; font-weight: 700;
  color: var(--text); line-height: 1.25; overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.np-title.dim { color: var(--faint); font-weight: 600; }
.np-meta { margin-top: 6px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; color: var(--faint); text-transform: uppercase; }
.np-meta a { color: var(--signal); text-decoration: none; }
.np-meta a:hover { text-decoration: underline; }
.np-state {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--faint); white-space: nowrap;
}

/* progress bar */
.np-prog { margin-top: 14px; }
.np-bar {
  position: relative; height: 8px; border-radius: var(--radius-pill);
  background: var(--surface-3); overflow: hidden; cursor: pointer;
  border: 1px solid var(--line-2);
}
.np-bar-fill {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: linear-gradient(90deg, var(--signal-deep), var(--signal));
  box-shadow: 0 0 12px -2px var(--signal-glow);
  border-radius: var(--radius-pill); transition: width .25s linear;
}
.np-times { margin-top: 6px; display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 11.5px; color: var(--faint); }

/* transport row */
.transport { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.transport form { margin: 0; }
.transport .btn-icon { width: 44px; height: 44px; font-size: 19px; border-radius: 12px; }
.transport .play-toggle { width: 52px; height: 52px; font-size: 23px; }

/* volume */
.vol { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.vol > i { font-size: 18px; color: var(--faint); flex: none; }
.vol input[type=range] {
  -webkit-appearance: none; appearance: none; height: 6px; flex: 1 1 auto;
  border-radius: var(--radius-pill); background: var(--surface-3);
  border: 1px solid var(--line-2); cursor: pointer; outline: none;
}
.vol input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 16px; height: 16px;
  border-radius: 50%; background: var(--signal); border: 2px solid var(--bg);
  box-shadow: 0 0 10px -1px var(--signal-glow); cursor: pointer;
}
.vol input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: var(--signal);
  border: 2px solid var(--bg); box-shadow: 0 0 10px -1px var(--signal-glow); cursor: pointer;
}
.vol-val { font-family: var(--font-mono); font-size: 13px; color: var(--text); min-width: 3.2ch; text-align: right; flex: none; }

/* music queue list */
.queue-list { list-style: none; margin: 0; padding: 0; }
.q-row { display: flex; align-items: center; gap: 12px; padding: 10px 18px; min-height: 48px; border-bottom: 1px solid var(--line); }
.q-row:last-child { border-bottom: 0; }
.q-row:hover { background: var(--signal-dim); }
.q-pos { font-family: var(--font-mono); font-size: 12px; color: var(--signal); min-width: 2.2ch; text-align: right; flex: none; }
.q-query { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
/* metadane wiersza (kto/kiedy/serwer) — wyrównane do prawej, przed akcjami */
.q-meta { margin-left: auto; flex: none; font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .03em; color: var(--faint); white-space: nowrap; }
.q-row .tag { flex: none; }
.q-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.q-actions .btn-icon { width: 32px; height: 32px; font-size: 15px; }
.q-actions .q-act[data-act=playnow]:hover { color: var(--signal); }
.q-actions .q-act[data-act=remove]:hover { color: var(--red); }

/* youtube search results */
.yt-status { margin-top: 12px; font-family: var(--font-mono); font-size: 12.5px; letter-spacing: .05em; color: var(--faint); }
.yt-results { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.yt-result {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: inset 0 1px 4px rgba(0,0,0,.4);
}
.yt-result:hover { border-color: var(--line-2); background: var(--signal-dim); }
.yt-thumb { width: 80px; height: 45px; flex: none; border-radius: 6px; object-fit: cover; background: var(--surface-3); border: 1px solid var(--line); }
.yt-info { display: flex; flex-direction: column; gap: 3px; flex: 1 1 auto; min-width: 0; }
.yt-title { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yt-meta { font-family: var(--font-mono); font-size: 11px; color: var(--faint); letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yt-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.yt-actions .yt-act[data-act=playnow]:hover { color: var(--signal); }
@media (max-width: 640px) {
  .yt-result { flex-wrap: wrap; }
  .yt-actions { width: 100%; }
  .yt-actions .btn-sm { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── Kino (/video) ─────────────────────────────────────────────────────── */
.kino-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.kino-controls .vbar { flex: 1 1 160px; min-width: 120px; }
.vinfo { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 22px; margin-top: 4px; }
.vinfo .kv { display: flex; flex-direction: column; gap: 3px; }
.vinfo .kv .k { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.vinfo .kv .v { font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qrow { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--line); }
.qrow:last-child { border-bottom: 0; }
.qrow .qn { font-family: var(--font-mono); font-size: 12px; color: var(--faint); flex: none; }
.qrow .qurl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }

/* ── Klient online: zwijany wiersz z akcjami (mniej kontrolek naraz) ─────── */
.client-row { border-bottom: 1px solid var(--line); }
.client-row:last-child { border-bottom: 0; }
.client-row > summary { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; list-style: none; }
.client-row > summary::-webkit-details-marker { display: none; }
.client-row > summary:hover { background: var(--surface); }
.client-row .cr-nick { font-weight: 600; }
.client-row .cr-chan { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-row .cr-id { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--faint); }
.client-row .chev { color: var(--faint); transition: transform .15s; flex: none; }
.client-row[open] .chev { transform: rotate(180deg); }
.cr-actions { display: flex; flex-direction: column; gap: 8px; padding: 4px 16px 16px; }
.cr-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cr-line input, .cr-line select { flex: 1 1 180px; min-width: 140px; }
.cr-danger { margin-top: 4px; padding-top: 12px; border-top: 1px dashed rgba(255,96,96,0.22); }

/* ── Rangi: filtr + zwijane wiersze (125 grup przestaje być ścianą) ─────── */
.rank-filter { width: 220px; max-width: 46vw; font-size: 13px; padding: 7px 11px; }
.rank-row { border-bottom: 1px solid var(--line); }
.rank-row:last-child { border-bottom: 0; }
.rank-row > summary { display: flex; align-items: center; gap: 12px; padding: 11px 16px; cursor: pointer; list-style: none; }
.rank-row > summary::-webkit-details-marker { display: none; }
.rank-row > summary:hover { background: var(--surface); }
.rank-row .rk-id { font-family: var(--font-mono); font-size: 11px; color: var(--faint); min-width: 34px; }
.rank-row .rk-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .rk-perms { margin-left: auto; }
.rank-row .chev { color: var(--faint); transition: transform .15s; flex: none; }
.rank-row[open] .chev { transform: rotate(180deg); }
.rk-actions { display: flex; flex-direction: column; gap: 8px; padding: 4px 16px 16px; }
@media (max-width: 640px) { .rank-row .rk-perms span { display: none; } .rank-filter { max-width: 60vw; } }

/* ── Klasy używane w szablonach, wcześniej bez reguł (fallback inline łamał układ) ── */
/* form-grid: pola TTS / konfiguracji bota w /music. FLEX (nie grid) — pola mają
   inline flex-basis (100% / 16rem), więc textarea zajmuje pełny rząd, reszta zawija */
.form-grid { display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: flex-end; }
.form-grid .field { margin-bottom: 10px; }
/* aktywny profil serwera w /servers */
tr.row-on { background: var(--signal-dim); }
tr.row-on td { border-color: var(--signal-deep); }
.tag.tag-on { background: var(--signal-dim); color: var(--signal); border-color: var(--signal-deep); }

/* Nagłówek: gdy rozłączony (JS dodaje .off) — wygaś waveform i zatrzymaj animację */
.signal-bar.off .state { color: var(--red); }
.signal-bar.off .wave { opacity: .3; filter: grayscale(1); }
.signal-bar.off .wave span { animation-play-state: paused; }

/* ── /music: układ "źródła | kolejka" (2 kolumny na desktopie) ─────────── */
.mus-feed { display: grid; gap: 14px; grid-template-columns: 3fr 2fr; align-items: start; }
.mus-feed > #queue-card { order: -1; }        /* kolejka po LEWEJ mimo że w DOM po źródłach */
.mus-src { display: flex; flex-direction: column; min-width: 0; }
.grid > .card, .mus-feed > .card { margin-top: 0; }  /* w gridzie odstępy robi gap, nie .card+.card */
@media (max-width: 1039px) { .mus-feed { grid-template-columns: 1fr; } }

/* ── Pulpit: bento grid (wg handoffu 1b) ─────────────────────────────────── */
.dash-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }
.dash-head h1 { font: 800 24px var(--font-display); color: var(--text); }
.dash-head .clock { font: 500 11px var(--font-mono); color: var(--muted); }
.bento { display: grid; grid-template-columns: repeat(6, 1fr); grid-auto-rows: minmax(88px, auto); gap: 14px; }
.tile { border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); padding: 20px 22px; min-width: 0; }
.tile.sp3r2 { grid-column: span 3; grid-row: span 2; display: flex; flex-direction: column; }
.tile.sp2 { grid-column: span 2; padding: 16px 20px; display: flex; flex-direction: column; justify-content: center; }
.tile.sp4r2 { grid-column: span 4; grid-row: span 2; }
.tile.sp2r2 { grid-column: span 2; grid-row: span 2; display: flex; flex-direction: column; gap: 8px; }
.tile.accent { background: linear-gradient(150deg, #231b3f, #171225); border-color: rgba(167,139,250,.2); padding: 22px 24px; }
.tile-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.tile-title { font: 700 13px var(--font-sans); color: var(--violet); letter-spacing: .02em; }
.tile-title i { font-size: 14px; vertical-align: -2px; }
.pill { font: 600 9px var(--font-mono); padding: 3px 8px; border-radius: 99px; background: rgba(167,139,250,.18); color: var(--violet); letter-spacing: .08em; white-space: nowrap; }
.pill.live { display: inline-flex; align-items: center; gap: 6px; background: rgba(240,110,110,.15); color: #f39a9a; }
.pill.live::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: var(--red); }
.pill.dim { background: rgba(255,255,255,.07); color: var(--muted); }
/* music tile */
.mt-body { display: flex; gap: 16px; align-items: center; margin-top: 16px; min-width: 0; }
.mt-cover { width: 84px; height: 84px; flex: none; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 30px; color: var(--violet); background: repeating-linear-gradient(45deg, #2a2247 0 7px, #332a55 7px 14px); }
.mt-title { font: 800 19px var(--font-display); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-sub { font: 600 13px var(--font-sans); color: #a99ec9; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-meta { font: 500 11px var(--font-sans); color: var(--muted); margin-top: 6px; }
.mt-foot { margin-top: auto; padding-top: 14px; }
.mt-track { height: 5px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.mt-fill { height: 5px; border-radius: 99px; width: 0; background: linear-gradient(90deg, #a78bfa, #c9b8fc); transition: width .5s linear; }
.mt-row { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 10px; }
.mt-time { font: 500 10px var(--font-mono); color: var(--muted); }
.mt-ctrl { display: flex; gap: 6px; }
.mt-ctrl .btn-icon { width: 34px; height: 34px; }
.mt-q { font: 500 11px var(--font-sans); color: var(--muted); white-space: nowrap; }
.mt-q b { color: var(--text); }
/* kino tile */
.kt-frame { flex: 1; margin-top: 14px; border-radius: 12px; min-height: 70px; display: flex; align-items: center; justify-content: center; font: 500 9px var(--font-mono); color: var(--muted); background: repeating-linear-gradient(45deg, #1d1930 0 7px, #252040 7px 14px); }
.kt-foot { display: flex; justify-content: space-between; align-items: baseline; margin-top: 12px; gap: 10px; }
.kt-title { font: 800 16px var(--font-display); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.kt-meta { font: 500 11px var(--font-sans); color: var(--muted); white-space: nowrap; }
.kt-meta b { color: var(--text); }
/* stat tile */
.st-label { font: 600 9.5px var(--font-mono); letter-spacing: .15em; color: var(--muted); text-transform: uppercase; }
.st-row { display: flex; align-items: baseline; gap: 8px; }
.st-value { font: 800 28px var(--font-display); color: var(--text); }
.st-extra { font: 600 12px var(--font-sans); color: var(--muted); }
.st-extra.up { color: var(--signal); }
/* events tile */
.evt-head { display: flex; justify-content: space-between; margin-bottom: 10px; }
.evt-head .t { font: 700 14px var(--font-sans); color: var(--text); }
.evt-head a { font: 600 11px var(--font-sans); color: var(--violet); }
.evt-grid { display: grid; grid-template-columns: auto 1fr auto; gap: 8px 14px; align-items: center; max-height: 300px; overflow-y: auto; }
.evt-badge { font: 600 9px var(--font-mono); padding: 3px 7px; border-radius: 5px; background: rgba(167,139,250,.14); color: var(--violet); letter-spacing: .04em; }
.evt-badge.ban { background: rgba(240,110,110,.12); color: #f39a9a; }
.evt-badge.warn { background: rgba(245,196,110,.12); color: #f2cf95; }
.evt-txt { font: 500 12.5px var(--font-sans); color: #c6c1d6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.evt-txt b { color: var(--text); }
.evt-ts { font: 500 10.5px var(--font-mono); color: var(--muted); }
/* quick actions tile */
.qa-title { font: 700 14px var(--font-sans); color: var(--text); margin-bottom: 4px; }
.qa { display: block; width: 100%; padding: 10px 14px; border-radius: 10px; border: 1px solid transparent; background: var(--surface-3); font: 600 12px var(--font-sans); color: #c6c1d6; text-align: center; cursor: pointer; transition: filter .15s; }
.qa:hover { filter: brightness(1.15); text-decoration: none; }
.qa.primary { background: rgba(167,139,250,.12); border-color: rgba(167,139,250,.25); color: var(--violet); font-weight: 700; }
.qa.danger { background: rgba(240,110,110,.1); border-color: rgba(240,110,110,.22); color: #f39a9a; }
@media (max-width: 1039px) {
  .bento { grid-template-columns: 1fr; }
  .tile.sp3r2, .tile.sp2, .tile.sp4r2, .tile.sp2r2 { grid-column: span 1; grid-row: auto; }
}
