:root {
  --paper: #f3f5f4; --surface: #ffffff; --ink: #1d2b32; --muted: #5d6c73; --line: #d6dddb;
  --accent: #17607a; --accent-ink: #ffffff; --accent-soft: #dcecf2;
  --mine: #d6eaf1; --theirs: #ffffff; --danger: #b3392f;
  --st-online: #2f9e5b; --st-away: #d99a00; --st-off: #9aa6a1;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131b1f; --surface: #1b262c; --ink: #e5edf0; --muted: #94a5ad; --line: #2c3a41;
    --accent: #4fb0d0; --accent-ink: #0b1c23; --accent-soft: #1f3a46;
    --mine: #1f4152; --theirs: #243139; --danger: #ef7d73;
    --st-online: #4cc17c; --st-away: #f0b429; --st-off: #6b7a82;
  }
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body { font: 14px/1.45 var(--font); background: var(--paper); color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

button { cursor: pointer; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 7px 12px; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); }
button.ghost { border-color: transparent; background: transparent; }
button:disabled { opacity: .55; cursor: default; }
input[type=text], input[type=password], input[type=email], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 8px 10px;
}
label { display: block; font-weight: 600; margin: 12px 0 4px; }
.err { color: var(--danger); min-height: 1.4em; margin: 8px 0 0; }
.muted { color: var(--muted); }

/* logowanie / zmiana hasła */
.center { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 28px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.brand img { max-height: 56px; max-width: 220px; object-fit: contain; }
.brand h1 { font-size: 20px; margin: 0; }
.card h2 { font-size: 16px; margin: 18px 0 0; }
.card button.primary { width: 100%; margin-top: 18px; padding: 10px; }

/* układ czatu */
.shell { height: 100%; display: grid; grid-template-columns: clamp(260px, 28vw, 320px) minmax(0, 1fr); }
.side { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--surface); min-height: 0; }
.side-top { padding: 12px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.me-row { display: flex; align-items: center; gap: 10px; }
.me-row img { max-height: 34px; max-width: 120px; object-fit: contain; }
.me-row .co { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-line { display: flex; gap: 8px; align-items: center; }
.me-line .name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-line select { width: auto; padding: 4px 6px; }
.list { overflow-y: auto; flex: 1; margin: 0; padding: 0; list-style: none; }
.item { display: flex; gap: 10px; align-items: center; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line); width: 100%; text-align: left; border-radius: 0; border-left: 0; border-right: 0; border-top: 0; background: transparent; }
.item:hover, .item[aria-current=true] { background: var(--accent-soft); }
.item .txt { flex: 1; min-width: 0; }
.item .t1 { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t2 { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 7px; font-size: 12px; font-weight: 700; min-width: 20px; text-align: center; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; background: hsl(var(--h, 200) 45% 38%); flex: none; position: relative; }
.dot { position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--surface); background: var(--st-off); }
.dot.online { background: var(--st-online); } .dot.away { background: var(--st-away); }
.side-bottom { padding: 8px 12px; border-top: 1px solid var(--line); display: flex; gap: 6px; flex-wrap: wrap; }
.side-bottom button { padding: 5px 9px; font-size: 13px; }
.empty { padding: 24px 16px; color: var(--muted); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.main-head { padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; min-height: 58px; }
.main-head .back { display: none; }
.main-head .ttl { font-weight: 700; font-size: 16px; }
.msgs { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.day { align-self: center; color: var(--muted); font-size: 12px; margin: 10px 0 4px; }
.msg { max-width: min(640px, 80%); padding: 7px 11px; border-radius: 10px; background: var(--theirs); border: 1px solid var(--line); overflow-wrap: anywhere; white-space: pre-wrap; align-self: flex-start; }
.msg.mine { background: var(--mine); border-color: transparent; align-self: flex-end; }
.msg .who { font-size: 12px; font-weight: 700; color: var(--accent); }
.msg .tm { color: var(--muted); font-size: 11.5px; margin-left: 8px; white-space: nowrap; }
.msg a { color: var(--accent); }
.typing { height: 20px; padding: 0 16px; color: var(--muted); font-size: 12.5px; }
.composer { display: flex; gap: 8px; padding: 10px 16px 14px; background: var(--paper); }
.composer textarea { resize: none; height: 44px; max-height: 140px; }
.composer button { align-self: stretch; }
.placeholder { margin: auto; text-align: center; color: var(--muted); max-width: 320px; }
.placeholder img { max-width: 220px; max-height: 120px; object-fit: contain; margin-bottom: 14px; }
.banner { background: var(--st-away); color: #1b1300; text-align: center; padding: 4px; font-size: 13px; }

/* panel admina */
.admin { height: 100%; overflow-y: auto; padding: 20px; }
.admin-in { max-width: 920px; margin: 0 auto; display: grid; gap: 20px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.panel h2 { margin: 0 0 10px; font-size: 17px; }
.bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bar h1 { font-size: 20px; margin: 0; flex: 1; }
.logo-prev { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 12px 0; }
.logo-box { width: 260px; height: 90px; border: 1px dashed var(--line); border-radius: 8px; display: grid; place-items: center; background: var(--paper); }
.logo-box.drag { border-color: var(--accent); background: var(--accent-soft); }
.logo-box img { max-width: 240px; max-height: 76px; object-fit: contain; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12.5px; color: var(--muted); }
td .row { margin: 0; }
td select { width: auto; padding: 3px 6px; }
.tag { font-size: 12px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); }
.tag.off { background: var(--line); color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); width: min(440px, 92vw); padding: 20px; }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { margin: 0 0 6px; font-size: 17px; }
dialog .pick { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; margin-top: 4px; }
dialog .pick label { font-weight: 400; margin: 4px 0; display: flex; gap: 8px; align-items: center; }
dialog .temp { font: 600 17px/1.2 Consolas, "Courier New", monospace; background: var(--paper); padding: 10px; border-radius: 6px; user-select: all; word-break: break-all; }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; }

@media (max-width: 630px) {
  .shell { grid-template-columns: 1fr; }
  .shell .main { display: none; }
  .shell.open .side { display: none; }
  .shell.open .main { display: flex; }
  .main-head .back { display: inline-block; }
  .grid2 { grid-template-columns: 1fr; }
  .msg { max-width: 90%; }
}
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

/* Stonowany interfejs komunikatora: bez ozdobnych pasów, gradientów i jaskrawych barw. */
:root, :root[data-theme="light"] {
  color-scheme: light;
  --paper: #eff2f5; --surface: #ffffff; --ink: #26323e; --muted: #6a7885;
  --line: #d9e0e6; --accent: #46657c; --accent-ink: #ffffff; --accent-soft: #e8eff4;
  --mine: #e7eef3; --theirs: #fafbfc; --danger: #ae4949;
  --st-online: #428a65; --st-away: #bc9452; --st-off: #a7b2ba;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #151b22; --surface: #202830; --ink: #e5ebef; --muted: #adb7bf;
  --line: #37444e; --accent: #90b3c7; --accent-ink: #15242f; --accent-soft: #2b3d4b;
  --mine: #293e4d; --theirs: #252f39; --danger: #e79090;
  --st-online: #66bc8c; --st-away: #e5b96c; --st-off: #7b8994;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --paper: #eff2f5; --surface: #ffffff; --ink: #26323e; --muted: #6a7885;
    --line: #d9e0e6; --accent: #46657c; --accent-ink: #ffffff; --accent-soft: #e8eff4;
    --mine: #e7eef3; --theirs: #fafbfc; --danger: #ae4949;
  }
}
body { background: var(--paper); }
.shell { grid-template-columns: clamp(280px, 28vw, 310px) minmax(0,1fr); }
.side { background: var(--surface); }
.side-top { gap: 9px; padding: 0 12px 12px; background: var(--surface); min-height: 126px; }
.me-row { margin: 0 -12px 10px; min-height: 67px; padding: 13px 12px; border-bottom: 1px solid var(--line); gap: 9px; }
.me-row .co { font-size: 16px; font-weight: 650; color: var(--ink); }
.me-row img { max-width: 55px; max-height: 44px; }
.me-line { gap: 7px; }
.me-line .name { font-size: 13px; }
.me-line select { font-size: 12px; max-width: 140px; background: var(--surface); }
.avatar { width: 36px; height: 36px; font-size: 12px; border-radius: 8px; border: 1px solid var(--line); overflow: visible; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 7px; }
.avatar .dot { width: 10px; height: 10px; }
.list { background: var(--surface); }
.item { min-height: 54px; padding: 7px 10px; gap: 8px; }
.item[aria-current=true] { border-left: 3px solid var(--accent); padding-left: 7px; }
.item .t1 { font-size: 13px; }
.item .t2 { font-size: 11px; }
.side-bottom { background: var(--surface); padding: 9px; gap: 5px; }
.side-bottom button { font-size: 12px; padding: 5px 5px; }
.main-head { min-height: 80px; padding: 14px 18px; gap: 12px; background: var(--surface); }
.main-head .avatar { width: 48px; height: 48px; }
.main-head .ttl { font-size: 16px; }
.main-head .head-text { flex: 1; min-width: 0; }
.main-head .danger { font-size: 12px; white-space: nowrap; }
.msgs { padding: 0; gap: 0; background: var(--surface); }
.day { width: 100%; text-align: center; align-self: stretch; margin: 0; padding: 6px; background: var(--paper); border-bottom: 1px solid var(--line); font-size: 11px; }
.msg, .msg.mine {
  max-width: 100%; width: 100%; align-self: stretch; border: 0; border-radius: 0;
  border-bottom: 1px solid var(--line); padding: 9px 16px 11px; white-space: normal;
  background: var(--theirs);
}
.msg.mine { background: var(--mine); }
.message-top { display: flex; align-items: center; gap: 12px; margin-bottom: 3px; }
.message-top .who { color: var(--ink); font-size: 12px; }
.message-top .tm { margin-left: auto; }
.message-top .delete-msg { opacity: .65; padding: 1px 5px; font-size: 13px; }
.message-top .delete-msg:hover { opacity: 1; }
.message-body { white-space: pre-wrap; font-size: 13px; line-height: 1.45; }
.file-chip { display: inline-block; padding: 8px 11px; border: 1px solid var(--line); background: var(--surface); border-radius: 5px; font-size: 12px; margin: 5px 0; overflow-wrap: anywhere; }
.typing { background: var(--paper); padding-top: 3px; }
.composer { padding: 9px; background: var(--surface); border-top: 1px solid var(--line); }
.composer textarea { border-radius: 5px; min-height: 48px; }
.composer .attach-btn { background: var(--paper); min-width: 42px; font-size: 20px; }
.composer button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.profile-avatar { display: flex; align-items: center; margin: 8px 0; }
.profile-avatar .avatar { height: 62px; width: 62px; }
.settings-dialog { width: min(420px, 92vw); max-height: min(88vh, 700px); overflow: hidden; padding: 16px 18px; }
.settings-dialog h2 { margin-bottom: 4px; font-size: 16px; }
.settings-dialog > .muted { margin: 0 0 8px; font-size: 12px; }
.settings-dialog form { display: grid; gap: 0; }
.settings-dialog label { margin: 8px 0 4px; font-size: 13px; }
.settings-dialog input[type=text],
.settings-dialog input[type=file],
.settings-dialog select { min-height: 38px; }
.settings-dialog .checkbox-line { display: flex; gap: 9px; align-items: center; font-weight: 400; margin: 8px 0 0; }
.settings-dialog .checkbox-line input { width: auto; }
.settings-dialog input[type=file] { max-width: 100%; font-size: 12px; }
.settings-dialog .profile-avatar { margin: 4px 0 2px; }
.settings-dialog .profile-avatar .avatar { height: 54px; width: 54px; }
.settings-dialog .settings-avatar-actions { gap: 10px; margin-bottom: 2px; }
.settings-dialog .row { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 10px; }
.settings-dialog .row > button { width: 100%; }
.settings-dialog .settings-note { margin: 4px 0 2px; font-size: 12px; }
.settings-dialog input:disabled { background: color-mix(in srgb, var(--paper) 88%, var(--surface)); color: var(--muted); cursor: not-allowed; }
.limit-input { display: flex; gap: 8px; align-items: center; }
.limit-input input { width: 85px; padding: 7px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
@media (max-width: 630px) {
  .shell { grid-template-columns: minmax(0,1fr); }
  .main-head { min-height: 72px; padding: 9px; }
  .main-head .ttl { font-size: 14px; }
  .main-head .avatar { height: 40px; width: 40px; }
  .main-head .danger { font-size: 11px; padding: 5px; }
}

/* Ekran logowania używa pełnej wysokości małego okna aplikacji Windows. */
.login-view { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-panel {
  width: min(460px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 30px; display: flex; flex-direction: column;
}
.login-header .brand { margin-bottom: 32px; }
.login-header .brand img { max-width: 115px; max-height: 58px; }
.login-header .brand h1 { font-size: 19px; line-height: 1.25; }
.login-heading h2 { margin: 0; font-size: 23px; font-weight: 650; }
.login-heading p { margin: 8px 0 24px; font-size: 13px; }
.login-form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.login-fields label { margin: 14px 0 6px; font-size: 13px; }
.login-fields input { min-height: 43px; padding: 10px 12px; }
.login-fields .err { margin-top: 10px; }
.login-actions { margin-top: auto; padding-top: 22px; }
.login-actions button.primary { width: 100%; min-height: 44px; font-size: 14px; }
.login-footer { display: grid; gap: 7px; border-top: 1px solid var(--line); margin-top: 22px; padding-top: 15px; }
.login-register { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 8px; color: var(--muted); font-size: 13px; }
.login-register .ghost, .login-server-change { color: var(--accent); padding: 5px 7px; }
.login-server-change { margin: 0 auto; font-size: 12px; }
.desktop-app .login-view { height: 100%; display: flex; align-items: stretch; padding: 14px; overflow-y: auto; }
.desktop-app .login-panel { width: 100%; max-width: none; min-height: 100%; margin: auto; flex: 1; padding: 26px 24px 20px; }
.desktop-app .login-header .brand { margin-bottom: 44px; }
.desktop-app .login-heading p { margin-bottom: 30px; }
.desktop-app .center { display: flex; align-items: stretch; padding: 14px; }
.desktop-app .center .card { flex: 1; width: 100%; max-width: none; min-height: 100%; padding: 24px; }
@media (max-height: 610px) {
  .desktop-app .login-panel { padding-top: 16px; padding-bottom: 14px; }
  .desktop-app .login-header .brand { margin-bottom: 18px; }
  .desktop-app .login-heading p { margin-bottom: 10px; }
  .desktop-app .login-fields label { margin-top: 7px; }
  .desktop-app .login-footer { margin-top: 12px; padding-top: 8px; }
}
.contact-search-wrap { padding: 7px 9px; background: var(--surface); border-bottom: 1px solid var(--line); }
.contact-search-wrap input { width: 100%; border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 4px; padding: 7px 8px; font-size: 12px; }

/* Kontakty są głównym ekranem, bez powielającej listy rozmów 1:1. */
.contacts-heading {
  margin: 0; padding: 11px 14px 8px;
  font-size: 13px; font-weight: 700; line-height: 1.25;
  color: var(--ink); background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.list-heading {
  padding: 10px 14px 8px; background: var(--paper);
  color: var(--ink); font-size: 12px; font-weight: 700;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}


/* Panel emotikonów — neutralny, dopasowany do motywu dnia i nocy. */
.composer .emoji-control { position: relative; flex: none; display: flex; align-items: stretch; }
.composer .emoji-toggle {
  width: 42px; min-width: 42px; padding: 0; border-radius: 5px;
  background: var(--paper); color: var(--ink); font: 26px/1 "Segoe UI Symbol", "Segoe UI Emoji", sans-serif;
}
.composer .emoji-toggle[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--accent); }
.emoji-panel {
  position: absolute; z-index: 30; bottom: calc(100% + 12px); left: -50px;
  width: min(340px, calc(100vw - 26px)); max-height: min(390px, 65vh);
  border: 1px solid var(--line); border-radius: 9px; overflow: hidden;
  background: var(--surface); color: var(--ink); box-shadow: 0 9px 28px rgba(0,0,0,.19);
  display: flex; flex-direction: column;
}
.emoji-heading {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 40px; padding: 6px 12px; border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.composer .emoji-close { border: 0; background: transparent; padding: 4px 8px; font-size: 14px; color: var(--muted); }
.emoji-tabs { display: flex; overflow-x: auto; gap: 2px; padding: 5px 7px; border-bottom: 1px solid var(--line); }
.composer .emoji-tab {
  flex: 1; min-width: 35px; height: 37px; padding: 3px; font: 20px/1 "Segoe UI Emoji", "Apple Color Emoji", sans-serif;
  background: transparent; border: 0; border-radius: 6px; border-bottom: 2px solid transparent;
}
.composer .emoji-tab:hover, .composer .emoji-tab.selected { background: var(--accent-soft); }
.composer .emoji-tab.selected { border-bottom-color: var(--accent); }
.emoji-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px; padding: 9px; overflow-y: auto; min-height: 75px;
}
.composer .emoji-item {
  min-width: 0; height: 40px; padding: 3px; background: transparent;
  border: 1px solid transparent; border-radius: 6px;
  font: 25px/1 "Segoe UI Emoji", "Apple Color Emoji", sans-serif;
}
.composer .emoji-item:hover, .composer .emoji-item:focus-visible { background: var(--accent-soft); border-color: var(--line); }
@media (max-width: 420px) {
  .emoji-panel { left: -50px; }
  .composer .emoji-toggle { width: 38px; min-width: 38px; }
  .emoji-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* Klasyczny, kompaktowy komunikator. Własny symbol dwóch dymków zamiast słoneczka. */
:root, :root[data-theme="light"] {
  --paper: #f0f1f1; --surface: #fff; --ink: #27313b; --muted: #65727d;
  --line: #d9dddf; --accent: #516d79; --accent-ink: #fff; --accent-soft: #edf1f3;
  --mine: #f4f6f6; --theirs: #fff; --danger: #ac4949;
  --toolbar: #354149; --toolbar-text: #f2f5f7; --warm: #d78b3b;
}
:root[data-theme="dark"] {
  --paper: #161d22; --surface: #242e35; --ink: #ecf1f3; --muted: #aebbc3;
  --line: #3a4750; --accent: #a5c5d2; --accent-ink: #1c2b35; --accent-soft: #2b3c45;
  --mine: #273c46; --theirs: #242e35; --danger: #ed9999;
  --toolbar: #121c24; --toolbar-text: #f1f5f7; --warm: #eba654;
}
.side-top { min-height: 0; padding: 0 10px 0; gap: 0; }
.me-row { padding: 10px 12px; margin: 0 -10px; min-height: 55px; }
.me-row .co { font-size: 14px; }
.me-row img { max-width: 56px; max-height: 36px; }
.me-line { padding: 9px 2px 12px; }
.me-line .name { font-size: 13px; }
.me-line select { max-width: 145px; font-size: 12px; }
.quick-nav {
  display: flex; align-items: stretch; gap: 0; margin: 0 -10px;
  background: var(--toolbar); min-height: 39px; border-bottom: 2px solid var(--warm);
}
.quick-nav button { flex: 1; min-width: 0; border: 0; border-radius: 0;
  background: transparent; color: var(--toolbar-text); font-size: 12px;
  font-weight: 550; padding: 7px 5px; display: inline-flex; align-items: center;
  justify-content: center; gap: 6px; }
.quick-nav button:last-child { flex: none; width: 41px; font-size: 17px; }
.quick-nav button:hover, .quick-nav button.quick-active { background: rgba(255,255,255,.14); }
.quick-nav button.quick-active { box-shadow: inset 0 3px 0 var(--warm); }
/* Dymek rozmowy budowany z CSS: własna identyfikacja, bez kopiowania ikon GG. */
.presence-symbol { width: 15px; height: 16px; flex: 0 0 15px; display: inline-block;
  position: relative; vertical-align: middle; --presence-color: #a4adb2; }
.presence-symbol::before { content: ''; position: absolute; left: 2px; top: 3px;
  width: 11px; height: 9px; border-radius: 5px 5px 5px 2px;
  background: var(--presence-color); box-shadow: inset 0 -1px 1px rgba(0,0,0,.15); }
.presence-symbol::after { content: ''; position: absolute; left: 3px; top: 10px;
  width: 5px; height: 4px; background: var(--presence-color);
  clip-path: polygon(0 0,100% 0,0 100%); }
.presence-symbol.online { --presence-color: #39985f; }
.presence-symbol.chatty { --presence-color: #59a9d1; }
.presence-symbol.away { --presence-color: #e0a32a; }
.presence-symbol.dnd { --presence-color: #d15a56; }
.presence-symbol.invisible, .presence-symbol.offline { --presence-color: #a5aeb4; }
.quick-nav .presence-symbol { --presence-color: #f0b560; }
.with-presence { display: flex; align-items: center; gap: 5px; }
.item { min-height: 51px; padding: 6px 10px; background: var(--surface); }
.item:hover { background: var(--accent-soft); }
.item[aria-current=true] { background: var(--accent-soft); border-left-color: var(--warm); }
.item .t1 { font-size: 12.5px; }
.item .t2 { font-size: 11.5px; }
.avatar { border-radius: 5px; width: 35px; height: 35px; }
.avatar img { border-radius: 4px; }
.contacts-heading { padding: 9px 12px 7px; font-size: 12px; color: var(--muted); }
.contact-search-wrap { padding: 7px 9px; }
.contact-search-wrap input { border-radius: 4px; font-size: 12px; background: var(--paper); }
.main-head { min-height: 64px; padding: 8px 14px; background: var(--surface); }
.main-head .avatar { width: 42px; height: 42px; }
.main-head .ttl { font-size: 14px; }
.message-top .who { color: var(--ink); }
.msg,.msg.mine { padding: 8px 12px 9px; }
.day { background: var(--paper); color: var(--muted); }
.side-bottom { background: var(--paper); padding: 7px; }
.side-bottom button { font-size: 11px; padding: 5px 7px; }
.composer { background: var(--paper); }
.composer textarea { background: var(--surface); }
.composer .emoji-toggle,.composer .attach-btn { background: var(--surface); }
.placeholder { font-size: 13px; }

/* Archiwum administratora: oddzielne od zwykłego okna czatu. */
.archive-panel { display: grid; gap: 12px; }
.archive-panel h2 { margin: 0; }
.archive-panel p { margin: 0; }
.archive-heading { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.archive-filters { display: grid; grid-template-columns: minmax(190px,2fr) minmax(130px,1fr) minmax(130px,1fr) minmax(130px,1fr) auto; gap: 8px; align-items: stretch; }
.archive-filters input, .archive-filters select { min-width: 0; width: 100%; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 5px; }
.archive-layout { display: grid; grid-template-columns: minmax(210px,31%) minmax(0,1fr); gap: 12px; min-height: 320px; }
.archive-room-list { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; max-height: 460px; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 5px; }
.archive-room { text-align: left; display: grid; gap: 3px; width: 100%; background: var(--surface); }
.archive-room strong { font-size: 12px; line-height: 1.4; }
.archive-room span { font-size: 11px; }
.archive-room .archive-participants { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.archive-room.selected { border-color: var(--accent); background: var(--accent-soft); border-left: 3px solid var(--warm); }
.archive-detail { display: flex; flex-direction: column; min-width: 0; }
.archive-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-bottom: 8px; }
.archive-tools input { flex: 1 1 155px; min-width: 0; }
.archive-tools button { white-space: nowrap; }
.archive-message-list { min-height: 190px; max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.archive-message { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.archive-message:nth-child(even) { background: var(--paper); }
.archive-message-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.archive-message-head strong { font-size: 12px; }
.archive-message-head time { margin-left: auto; font-size: 11px; color: var(--muted); }
.archive-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12.5px; }
.archive-message .file-chip { font-size: 11px; }
.archive-audit { font-size: 11px; margin-top: 8px !important; }
.archived-deleted { border-left: 3px solid var(--warm); }
.archive-note { font-size: 11px; }
@media (max-width: 830px) { .archive-filters { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 650px) { .archive-layout { grid-template-columns: 1fr; } .archive-room-list { max-height: 220px; } }
@media (max-width: 430px) { .archive-filters { grid-template-columns: 1fr; } }

.archive-filters { grid-template-columns: minmax(170px,2fr) minmax(135px,1fr) minmax(125px,1fr) minmax(115px,1fr) minmax(115px,1fr) auto; }
.archive-events { display: grid; gap: 5px; margin-top: 10px; font-size: 11px; border-top: 1px solid var(--line); padding-top: 8px; }
@media (max-width: 960px) { .archive-filters { grid-template-columns: repeat(3,minmax(0,1fr)); } }
@media (max-width: 520px) { .archive-filters { grid-template-columns: 1fr; } }

.dot.chatty { background: #59a9d1; }
.dot.dnd { background: #d15a56; }

/* Poprawki układu: elementy nagłówka i panel kontaktów nie mogą nachodzić na siebie. */
.shell { min-width: 0; }
.side, .main { min-width: 0; }
.me-row { min-width: 0; }
.me-row .co { min-width: 0; }
.me-line { display: grid; grid-template-columns: 36px minmax(0,1fr) minmax(100px,122px); min-width: 0; gap: 6px; align-items: center; }
.me-line > .presence-symbol { display: none; } /* status widoczny przy awatarze i w select */
.me-line .name { min-width: 0; }
.me-line select { min-width: 0; max-width: 100%; width: 100%; text-overflow: ellipsis; }
.quick-nav { min-width: 0; }
.quick-nav button { flex: 1 1 auto; white-space: nowrap; }
.main-head { min-width: 0; flex-wrap: wrap; row-gap: 4px; }
.main-head .head-text { flex: 1 1 160px; overflow: hidden; }
.main-head .ttl, .main-head .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main-head .room-actions { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.main-head .room-actions button { font-size: 11px; padding: 5px 8px; white-space: nowrap; }
@media (min-width: 631px) and (max-width: 820px) {
  .shell { grid-template-columns: minmax(270px, 290px) minmax(0,1fr); }
  .main-head { padding: 8px 10px; }
}
@media (max-width: 630px) {
  .me-line { grid-template-columns: 36px minmax(0,1fr) minmax(105px,135px); }
  .main-head .room-actions { margin-left: 0; }
}
/* Krótki i czytelny panel administracyjny. Wszystkie sekcje zachowują dotychczasową funkcjonalność. */
.admin { padding: 12px; }
.admin-in { max-width: 1100px; gap: 10px; }
.admin .bar { padding: 5px 4px; }
.admin .bar h1 { font-size: 18px; }
.admin-jump { display: flex; flex-wrap: wrap; gap: 6px; padding: 1px 0 4px; }
.admin-jump button { padding: 6px 10px; font-size: 12px; }
.admin-config-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; align-items: start; }
.admin-fold { border: 1px solid var(--line); border-radius: 7px; background: var(--surface); min-width: 0; overflow: hidden; }
.admin-fold > summary { cursor: pointer; padding: 11px 14px; font-size: 14px; font-weight: 650; background: var(--paper); list-style-position: inside; }
.admin-fold > summary:hover { background: var(--accent-soft); }
.admin-fold > section.panel { border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 12px 14px; }
.admin-option { display: flex; gap: 8px; align-items: flex-start; font-weight: 450; margin: 9px 0 0; }
.admin-option input { flex: none; margin-top: 3px; }
.admin-hint { font-size: 12px; margin: 5px 0 10px; }
.admin-in > .panel { padding: 12px 14px; border-radius: 7px; }
.admin-in > .panel h2 { font-size: 15px; }
.admin .panel label { margin-top: 7px; }
.admin .panel input, .admin .panel select, .admin .panel textarea { max-width: 100%; min-width: 0; }
.admin .panel p.muted { font-size: 12px; line-height: 1.4; }
.admin .panel .grid2 { gap: 0 10px; }
.admin .panel button { max-width: 100%; }
.admin .panel table { font-size: 12px; }
.admin .panel td, .admin .panel th { padding: 7px 5px; }
.admin .archive-panel { min-width: 0; }
@media (max-width: 820px) { .admin-config-grid { grid-template-columns: 1fr; } }

.admin-archive-fold > .archive-panel { border: 0; border-radius: 0; padding: 12px; }
.admin-inline-fold { border-top: 1px solid var(--line); margin-top: 10px; padding: 9px 0 0; }
.admin-inline-fold > summary { cursor: pointer; font-size: 13px; font-weight: 650; padding: 6px 2px; }
.admin-inline-fold > form { margin-top: 6px; }
/* Kompaktowy układ czterech działań w stopce panelu kontaktów. */
.side-bottom { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px; }
.side-bottom button { min-width: 0; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Panel administracyjny: niezależne kolumny, bez pustych wierszy obok rozwiniętych sekcji. */
.admin-in { max-width: 1160px; gap: 12px; }
.admin-config-grid { grid-template-columns: repeat(2, minmax(0,1fr)); align-items: start; gap: 12px; }
.admin-config-column { display: flex; flex-direction: column; min-width: 0; gap: 12px; }
.admin-fold > summary { padding: 10px 12px; }
.admin-fold > section.panel { padding: 12px; }
.admin .panel textarea { resize: vertical; }
.admin .panel .row { gap: 6px; }
.admin-in > .panel { min-width: 0; }
.admin .archive-panel { gap: 10px; }
.archive-heading { gap: 8px; }
.archive-heading .archive-delete-btn { margin-left: auto; }
.archive-tools { gap: 6px; }
.archive-room-list { max-height: 345px; }
.archive-message-list { min-height: 160px; max-height: 360px; }
.archive-layout { min-height: 250px; }
.archive-delete-btn { background: transparent; border-color: var(--danger); color: var(--danger); white-space: nowrap; }
.archive-delete-btn:hover:enabled { background: color-mix(in srgb,var(--danger) 10%,transparent); }
.archive-confirm { max-width: min(460px,94vw); line-height: 1.5; }
.archive-confirm p { margin: 12px 0; }
.archive-confirm label { font-size: 13px; }
.archive-confirm-actions { justify-content: flex-end; margin-top: 16px; }
.archive-danger-confirm { border-color: var(--danger); background: var(--danger); color: white !important; }
@media (max-width: 760px) { .admin-config-grid { grid-template-columns: 1fr; } }
@media (max-width: 690px) { .archive-heading .archive-delete-btn { margin-left: 0; } .archive-tools input { flex-basis: 100%; } }


/* Poprawione położenie ustawień i ikonowe przyciski w aplikacji desktopowej. */
.top-settings-btn {
  width: 34px; min-width: 34px; height: 34px; padding: 0; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--paper); border: 1px solid var(--line); font-size: 16px;
}
.top-settings-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.quick-nav button:only-child { width: 100%; flex: 1 1 auto; }
.me-line {
  grid-template-columns: 36px minmax(0,1fr) minmax(118px,138px) 34px;
  column-gap: 7px;
}
.me-line .name { align-self: center; }
.side-bottom { grid-template-columns: repeat(3, minmax(0,1fr)); }
.side-action {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.side-action .icon { font-size: 14px; line-height: 1; }
.side-action .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desktop-app .side-bottom { grid-template-columns: repeat(4, minmax(0,1fr)); }
.desktop-app .side-bottom .side-action { min-height: 34px; padding: 5px 0; }
.desktop-app .side-bottom .side-action .label { display: none; }
.desktop-app .side-bottom .side-action .icon { font-size: 16px; }
.desktop-app .side-bottom #pending-badge { position: absolute; margin-left: 14px; margin-top: -10px; min-width: 16px; padding: 0 5px; }
.desktop-app .side-bottom .side-action { position: relative; }
@media (max-width: 630px) {
  .me-line { grid-template-columns: 36px minmax(0,1fr) minmax(112px,132px) 34px; }
}


/* Panel administracyjny: wszystkie sekcje widoczne, logicznie pogrupowane. */
.admin-in { gap: 12px; max-width: 1180px; }
.admin-in > .bar { margin-bottom: 0; }
.admin-config-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; align-items: start; }
.admin-config-column { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.admin-config-column > .panel { min-width: 0; padding: 14px 15px; }
.admin-config-column > .panel > h2 { margin: 0 0 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); font-size: 15px; }
.admin-subsection { min-width: 0; padding: 4px 0 12px; }
.admin-subsection + .admin-subsection { border-top: 1px solid var(--line); padding-top: 14px; }
.admin-subsection h3 { font-size: 13px; font-weight: 650; margin: 0 0 10px; color: var(--ink); }
.admin-subsection label { margin-top: 7px; }
.admin-company-panel .logo-prev { display: grid; grid-template-columns: minmax(0, 220px) minmax(0,1fr); gap: 12px; align-items: center; margin: 8px 0 10px; }
.admin-company-panel .logo-box { max-width: 100%; width: 220px; height: 80px; }
.admin-company-panel .logo-box img { max-width: 90%; max-height: 65px; }
.admin-company-panel .logo-actions { min-width: 0; }
.admin-company-panel .logo-actions .row { flex-wrap: wrap; }
.admin-company-panel .logo-actions p { font-size: 11px; margin: 6px 0; }
.admin-company-panel .admin-hint { margin: 7px 0 8px; }
.admin-attachment-settings .row { justify-content: flex-start; }
.admin-add-user { padding-top: 12px; margin-top: 10px; border-top: 1px solid var(--line); }
.admin-add-user .grid2 { grid-template-columns: repeat(2,minmax(0,1fr)); }
.admin-add-user .err { margin: 0; }
.admin-in > .archive-panel { min-width: 0; }
.admin .panel input, .admin .panel select, .admin .panel textarea { width: 100%; min-width: 0; }
.admin .admin-company-panel input[type=checkbox],
.admin .admin-config-column input[type=checkbox] { width: auto; }
.admin .admin-company-panel .limit-input input { width: 78px; }
.admin .admin-company-panel .logo-prev button { width: auto; }
.admin .bar { align-items: center; }
@media (max-width: 790px) { .admin-config-grid { grid-template-columns: minmax(0,1fr); } }
@media (max-width: 540px) {
  .admin { padding: 8px; }
  .admin-config-column > .panel { padding: 12px; }
  .admin-company-panel .logo-prev { grid-template-columns: 1fr; }
  .admin-add-user .grid2 { grid-template-columns: 1fr; }
}

/* Formularz tworzenia użytkownika w jednym wierszu na szerokim ekranie. */
.admin-add-user .grid2 {
  grid-template-columns: minmax(145px,1.15fr) minmax(170px,1.35fr) minmax(130px,1fr) minmax(125px,.9fr) auto;
  gap: 8px; align-items: end;
}
.admin-add-user .grid2 > div { min-width: 0; }
.admin-add-user .grid2 > div:last-child button { white-space: nowrap; margin-top: 0 !important; min-height: 36px; }
.admin-add-user .err:empty, .admin-company-panel .err:empty, .admin-attachment-settings .err:empty { display: none; }
.admin-attachment-settings { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 14px; }
@media (max-width: 1100px) {
  .admin-add-user .grid2 { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 540px) {
  .admin-add-user .grid2 { grid-template-columns: minmax(0,1fr); }
}

.desktop-app .me-line { grid-template-columns: 36px minmax(0,1fr) minmax(118px,138px); }
.desktop-app .top-settings-btn { display: none; }

/* Kosz zamiast podpisu „Wyczyść historię”, w pasku rozmowy. */
.main-head .room-actions .history-trash-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; min-width: 36px; height: 34px; padding: 6px;
  border-radius: 6px; flex: 0 0 auto;
}
.main-head .room-actions .history-trash-btn svg { display: block; width: 18px; height: 18px; }
.main-head .room-actions .history-trash-btn:hover { background: var(--accent-soft); }
