/* Telegram Panel — WWW. Mobile-first, ciemny motyw (złoto/bursztyn jak wersja okienkowa). */
:root {
  --bg: #121110;
  --surface: #1c1a18;
  --surface2: #26231f;
  --surface3: #302c27;
  --border: #3a352e;
  --text: #f1ead9;
  --muted: #a89f8c;
  --accent: #d4a24c;
  --accent-2: #e6b865;
  --accent-ink: #1a1509;
  --ok: #58b36a;
  --ok-bg: #1f3524;
  --err: #e0625a;
  --err-bg: #3d1f1d;
  --warn: #e3a93f;
  --warn-bg: #3b2e17;
  --info-bg: #26313d;
  --radius: 14px;
  --tabbar-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "DejaVu Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-2); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--safe-t) + 10px) 16px 10px;
  background: rgba(18, 17, 16, 0.92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-row { display: flex; align-items: center; gap: 10px; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.brand small { color: var(--muted); font-weight: 500; font-size: 13px; margin-left: 6px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-top: 8px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
  padding: 6px 11px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface2); font-size: 13px; cursor: pointer; user-select: none;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.chip.on { border-color: rgba(88, 179, 106, .5); background: var(--ok-bg); }
.chip.on .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.chip.warn { border-color: rgba(227, 169, 63, .5); background: var(--warn-bg); }
.chip.static { cursor: default; }
.busy { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--accent-2); }
.spinner {
  width: 14px; height: 14px; border-radius: 50%; flex: 0 0 auto;
  border: 2px solid rgba(212, 162, 76, .25); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 3px; background: var(--surface3); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; }

main {
  padding: 14px 14px calc(var(--tabbar-h) + var(--safe-b) + 20px);
  max-width: 1100px; margin: 0 auto;
}
.view-title { display: flex; align-items: center; gap: 10px; margin: 4px 2px 12px; }
.view-title h1 { font-size: 22px; margin: 0; flex: 1; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(24, 22, 20, 0.95);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11px; background: none; border: 0; cursor: pointer; padding: 0;
}
.tab svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.tab.active { color: var(--accent-2); }
.side { display: none; }

@media (min-width: 900px) {
  .tabbar { display: none; }
  .side {
    display: flex; flex-direction: column; gap: 4px;
    position: fixed; top: 0; bottom: 0; left: 0; width: 220px; z-index: 25;
    padding: 18px 12px; background: var(--surface); border-right: 1px solid var(--border);
  }
  .side .brand { padding: 6px 10px 16px; }
  .side button {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
    background: none; border: 0; color: var(--muted); cursor: pointer; text-align: left;
  }
  .side button svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; }
  .side button.active { background: var(--surface2); color: var(--text); }
  .side button:hover { color: var(--text); }
  .topbar, main { margin-left: 220px; }
  .topbar .brand { display: none; }
  main { padding-bottom: 40px; }
}

/* ---------- cards / lists ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.card h2 { font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.card h2 .grow { font-size: 15px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(3, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 2px; }
.stat.bad .value { color: var(--err); }
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 10px; padding: 11px 2px;
  border-bottom: 1px solid var(--border); min-width: 0;
}
.row:last-child { border-bottom: 0; }
.row.tap { cursor: pointer; }
.row.tap:active { background: var(--surface2); }
.row .title { font-weight: 600; }
.row .sub { color: var(--muted); font-size: 12.5px; }
.row .chev { color: var(--muted); flex: 0 0 auto; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.bar { height: 6px; border-radius: 6px; background: var(--err-bg); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--ok); }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px;
  background: var(--surface3); color: var(--muted); white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: #9fe0ab; }
.badge.err { background: var(--err-bg); color: #f3a39d; }
.badge.warn { background: var(--warn-bg); color: #f0cc85; }
.badge.info { background: var(--info-bg); color: #a9c6e6; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  padding: 5px 10px; border-radius: 999px; font-size: 12.5px; border: 1px solid var(--border);
  background: var(--surface2);
}
.pill.ok { background: var(--ok-bg); border-color: rgba(88, 179, 106, .4); }
.pill.err { background: var(--err-bg); border-color: rgba(224, 98, 90, .4); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface2); cursor: pointer; font-weight: 600; font-size: 14.5px; white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--err-bg); border-color: rgba(224, 98, 90, .5); color: #f7b7b1; }
.btn.ok { background: var(--ok-bg); border-color: rgba(88, 179, 106, .5); color: #b8ecc2; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btns.stretch > .btn { flex: 1 1 140px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface2);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: 0 0 auto;
}
.icon-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface2); font-size: 16px; /* 16px = brak zoomu w iOS */
  outline: none; -webkit-appearance: none; appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px;
  background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px;
}
textarea { min-height: 180px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 12px; padding: 10px 0; cursor: pointer; }
.check input { display: none; }
.check .box {
  width: 44px; height: 26px; border-radius: 999px; background: var(--surface3); position: relative;
  flex: 0 0 auto; transition: background .2s;
}
.check .box::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #cfc6b3; transition: transform .2s;
}
.check input:checked + .box { background: var(--accent); }
.check input:checked + .box::after { transform: translateX(18px); background: #fff; }
.tick { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--border); cursor: pointer; }
.tick input { width: 22px; height: 22px; accent-color: var(--accent); flex: 0 0 auto; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search] { flex: 1; }
.seg {
  display: flex; background: var(--surface2); border: 1px solid var(--border); border-radius: 12px;
  padding: 3px; margin-bottom: 12px; overflow-x: auto; scrollbar-width: none;
}
.seg button {
  flex: 1 0 auto; min-height: 36px; border: 0; background: none; border-radius: 9px; padding: 0 12px;
  color: var(--muted); font-weight: 600; font-size: 13.5px; cursor: pointer;
}
.seg button.active { background: var(--surface3); color: var(--text); }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filters .full { grid-column: 1 / -1; }
@media (min-width: 900px) { .filters { grid-template-columns: repeat(4, 1fr); } .filters .full { grid-column: auto; } }
pre.term {
  margin: 0; background: #0c0b0a; border: 1px solid var(--border); border-radius: 12px; padding: 10px;
  max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font: 12px/1.45 ui-monospace, Menlo, Consolas, "DejaVu Sans Mono", monospace; color: #d7d0bf;
}
details.card > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform .2s; }
details.card:not([open]) > summary::after { transform: rotate(-90deg); }
details.card[open] > summary { margin-bottom: 10px; }

/* ---------- matrix grid (desktop) ---------- */
.grid-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--border); border-radius: 12px; }
table.grid { border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
table.grid th, table.grid td { padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.grid thead th { position: sticky; top: 0; background: var(--surface2); z-index: 2; }
table.grid th.first, table.grid td.first {
  position: sticky; left: 0; background: var(--surface); z-index: 1; max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; text-align: left;
}
table.grid thead th.first { z-index: 3; }
table.grid td.cell { text-align: center; cursor: pointer; font-weight: 700; }
table.grid td.y { background: rgba(88, 179, 106, .22); color: #9fe0ab; }
table.grid td.n { background: rgba(224, 98, 90, .16); color: #f3a39d; }
table.grid td.sel { background: rgba(212, 162, 76, .45); color: #fff; }

/* ---------- sheet / toast ---------- */
.backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 40;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.backdrop.show { opacity: 1; pointer-events: auto; }

/* ---------- prawy panel (czat z agentem / logi / katalog) ---------- */
.drawer-btn {
  position: fixed; right: 12px; bottom: calc(var(--tabbar-h, 64px) + var(--safe-b, 0px) + 14px);
  z-index: 35; width: 48px; height: 48px; border-radius: 50%;
  background: var(--surface2, #26241f); color: var(--fg, #eee); border: 1px solid var(--border);
  font-size: 22px; line-height: 1; cursor: pointer; box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
}
.drawer-btn:active { transform: scale(.94); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 55;
  width: min(430px, 100vw);
  background: var(--surface); border-left: 1px solid var(--border);
  padding: calc(10px + var(--safe-t, 0px)) 12px calc(14px + var(--safe-b, 0px));
  transform: translateX(105%); visibility: hidden;
  transition: transform .25s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .25s;
  display: flex; flex-direction: column; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.drawer.show { transform: translateX(0); visibility: visible; transition: transform .25s cubic-bezier(.2, .8, .2, 1), visibility 0s; }
.drawer .list { display: flex; flex-direction: column; gap: 8px; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-height: 88vh; overflow: auto; -webkit-overflow-scrolling: touch;
  background: var(--surface); border-top-left-radius: 20px; border-top-right-radius: 20px;
  border: 1px solid var(--border); padding: 8px 16px calc(18px + var(--safe-b));
  transform: translateY(105%); visibility: hidden;
  transition: transform .25s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .25s;
}
.sheet.show { transform: translateY(0); visibility: visible; transition: transform .25s cubic-bezier(.2, .8, .2, 1), visibility 0s; }
.sheet .grab { width: 40px; height: 5px; border-radius: 5px; background: var(--surface3); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.sheet-head h3 { margin: 0; font-size: 18px; flex: 1; overflow-wrap: anywhere; }
@media (min-width: 900px) {
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%; width: 560px; max-height: 84vh;
    border-radius: 18px; transform: translate(-50%, -46%) scale(.98); opacity: 0; pointer-events: none;
    transition: transform .2s, opacity .2s;
  }
  .sheet.show { transform: translate(-50%, -50%); opacity: 1; pointer-events: auto; }
  .sheet .grab { display: none; }
}
.toasts {
  position: fixed; left: 12px; right: 12px; z-index: 60;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
@media (min-width: 900px) { .toasts { bottom: 20px; left: 240px; } }
.toast {
  pointer-events: auto; max-width: 520px; width: 100%; padding: 12px 14px; border-radius: 12px;
  background: var(--surface3); border: 1px solid var(--border); box-shadow: 0 8px 30px rgba(0, 0, 0, .45);
  animation: pop .2s ease-out; font-size: 14px;
}
.toast.ok { background: var(--ok-bg); border-color: rgba(88, 179, 106, .45); }
.toast.error { background: var(--err-bg); border-color: rgba(224, 98, 90, .5); }
.toast.warning { background: var(--warn-bg); border-color: rgba(227, 169, 63, .5); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ---------- login ---------- */
.login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login .card { width: 100%; max-width: 380px; padding: 22px; }
.login h1 { margin: 0 0 4px; font-size: 22px; }
.logo {
  width: 56px; height: 56px; border-radius: 16px; margin-bottom: 14px;
  background: linear-gradient(135deg, #e6b865, #b07a25); display: flex; align-items: center; justify-content: center;
}
.logo svg { width: 30px; height: 30px; fill: #1a1509; }
.qr-box {
  background: #fff; border-radius: 16px; padding: 12px; width: min(300px, 100%); aspect-ratio: 1;
  margin: 8px auto 12px; display: flex; align-items: center; justify-content: center;
}
.qr-box img { width: 100%; height: 100%; image-rendering: pixelated; }
.qr-box.empty { background: var(--surface2); color: var(--muted); font-size: 13px; text-align: center; }
.countdown { font-variant-numeric: tabular-nums; }

/* ---------- sprawdzanie linków: tagi, ocena, oznaczenia list ---------- */
.tagrow { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; align-items: center; }
.tagchip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; min-height: 26px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface2); color: var(--text); font-size: 12px; cursor: pointer;
}
.tagchip b { font-weight: 600; color: var(--muted); font-size: 11px; }
.tagchip.on { border-color: rgba(88, 179, 106, .6); background: var(--ok-bg); }
.tagchip.zero { opacity: .45; }
.tagchip.custom { cursor: default; border-color: rgba(212, 162, 76, .5); }
.tagchip .x { border: 0; background: none; color: inherit; font-size: 16px; line-height: 1; padding: 0 0 0 2px; cursor: pointer; min-width: 22px; min-height: 22px; }
.tagadd { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.tagadd input { flex: 1; min-height: 38px; }
.icon-btn.mark-ok { background: var(--ok-bg); border-color: rgba(88, 179, 106, .6); color: #9fe0ab; }
.icon-btn.mark-err { background: var(--err-bg); border-color: rgba(224, 98, 90, .6); color: #f3a39d; }
.proxyline { font-size: 12.5px; margin: 6px 0 8px; padding: 6px 10px; border-radius: 9px; background: var(--surface2); overflow-wrap: anywhere; }
.proxyline.ok { background: var(--ok-bg); color: #b8ecc2; }
.proxyline.warn { background: var(--warn-bg); color: #f0cc85; }
.proxyline.err { background: var(--err-bg); color: #f7b7b1; }
.chip b { font-weight: 700; margin-left: 2px; }
button.chip { color: var(--text); font-family: inherit; }
.tagchip.off { border-color: rgba(224, 98, 90, .6); background: var(--err-bg); text-decoration: line-through; }
.tagchip.warnchip { border-color: rgba(227, 169, 63, .6); background: var(--warn-bg); }
details.taggroup { border-top: 1px solid var(--border); padding: 6px 0; }
details.taggroup > summary { cursor: pointer; font-size: 13.5px; color: var(--muted); padding: 4px 0; list-style: none; }
details.taggroup > summary::-webkit-details-marker { display: none; }
details.taggroup[open] > summary { color: var(--text); }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.stats { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.stats th, table.stats td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; white-space: nowrap; }
table.stats td:first-child { white-space: normal; min-width: 160px; overflow-wrap: anywhere; }
table.stats tr.off { opacity: .5; }

/* ---------- czat z asystentem ---------- */
.rowsel { width: 22px; height: 22px; accent-color: var(--accent); flex: 0 0 auto; align-self: flex-start; margin-top: 4px; }
.selbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
#chat-root .chat-fab {
  position: fixed; right: 14px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); z-index: 35;
  display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 15px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45); cursor: pointer;
}
#chat-root .chat-fab.hidden { display: none; }
#chat-root .chat-scrim { display: none; position: fixed; inset: 0; z-index: 44; background: transparent; }
#chat-root .chat-scrim.open { display: block; }
#chat-root .chat-panel {
  position: fixed; right: 0; bottom: 0; z-index: 45; width: min(85vw, 380px); height: min(72vh, 640px);
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-right: 0; border-bottom: 0;
  border-radius: 16px 0 0 0; box-shadow: -6px 0 24px rgba(0, 0, 0, .5);
  visibility: hidden; transform: translateX(105%); transition: transform .2s ease, visibility .2s;
}
#chat-root .chat-panel.open { visibility: visible; transform: none; }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; -webkit-overflow-scrolling: touch; }
.cmsg { max-width: 92%; padding: 8px 11px; border-radius: 14px; font-size: 14.5px; line-height: 1.4; overflow-wrap: anywhere; white-space: pre-wrap; }
.cmsg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.cmsg.bot { align-self: flex-start; background: var(--surface2); border-bottom-left-radius: 4px; }
.cmsg.typing { opacity: .6; font-style: italic; }
.cmsg.sys { align-self: center; background: none; color: var(--muted); font-size: 12.5px; text-align: center; }
.cmsg.sys.err { color: #f3a39d; }
.caction { align-self: stretch; border: 1px solid var(--accent); border-radius: 12px; padding: 10px; background: var(--surface2); font-size: 14px; }
.caction.done { border-color: rgba(88, 179, 106, .6); }
.caction.rejected { border-color: var(--border); opacity: .75; }
.caction.failed { border-color: rgba(224, 98, 90, .6); }
.chat-input { display: flex; gap: 8px; padding: 8px; border-top: 1px solid var(--border); padding-bottom: calc(8px + var(--safe-b)); align-items: flex-end; }
.chat-input textarea { min-height: 42px; max-height: 110px; resize: none; font-family: inherit; font-size: 16px; }
@media (min-width: 900px) {
  #chat-root .chat-fab { bottom: 20px; right: 20px; }
  #chat-root .chat-scrim { display: none !important; }
  #chat-root .chat-panel { top: 0; height: auto; width: 380px; border-radius: 0; border-top: 0; }
}

/* ---------- panel: zakładki Czat / Na żywo, wpisy zdarzeń ---------- */
#chat-root .chat-fabs { position: fixed; right: 14px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); z-index: 35; display: flex; gap: 8px; }
#chat-root .chat-fabs.hidden { display: none; }
#chat-root .chat-fabs .chat-fab { position: static; }
#chat-root .live-fab { background: var(--surface3); color: var(--text); border-color: var(--border); }
#chat-root .live-fab.working { background: var(--ok-bg); border-color: rgba(88, 179, 106, .7); color: #b8ecc2; animation: livepulse 1.6s ease-in-out infinite; }
@keyframes livepulse { 50% { box-shadow: 0 0 0 6px rgba(88, 179, 106, .18); } }
.chat-tabs { display: flex; gap: 4px; }
.chat-tab { min-height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface2); color: var(--muted); font-weight: 600; font-size: 13.5px; cursor: pointer; }
.chat-tab.active { background: var(--surface3); color: var(--text); border-color: var(--accent); }
.chat-pane, .live-pane { display: none; flex: 1; min-height: 0; flex-direction: column; }
.chat-panel[data-tab="chat"] .chat-pane, .chat-panel[data-tab="live"] .live-pane { display: flex; }
.chat-tools { display: flex; justify-content: flex-end; padding: 6px 10px 0; }
.live-counters { padding: 8px 12px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.live-tools { display: flex; gap: 6px; padding: 8px 10px; flex-wrap: wrap; align-items: center; }
.live-tools select { min-height: 34px; padding: 4px 28px 4px 10px; font-size: 14px; width: auto; flex: 1 1 130px; }
.live-list { gap: 6px; }
.lev { border-left: 3px solid var(--border); padding: 6px 9px; background: var(--surface2); border-radius: 8px; font-size: 13.5px; }
.lev.ok { border-left-color: var(--ok); } .lev.err { border-left-color: var(--err); background: var(--err-bg); } .lev.info { border-left-color: var(--muted); }
.lev-top { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.lev-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.lev-name { font-weight: 600; } .lev-detail { overflow-wrap: anywhere; color: var(--text); } .lev-meta { font-size: 12px; color: var(--muted); }
details.evrow { border-left: 3px solid var(--border); padding: 6px 10px; border-bottom: 1px solid var(--border); }
details.evrow.ok { border-left-color: var(--ok); } details.evrow.err { border-left-color: var(--err); } 
details.evrow > summary { cursor: pointer; list-style: none; } details.evrow > summary::-webkit-details-marker { display: none; }
.evbody { padding: 6px 0; display: flex; flex-direction: column; gap: 6px; }
@media (min-width: 900px) { #chat-root .chat-fabs { bottom: 20px; right: 20px; } }
