/* ODDK Czat — interfejs v2. Niezależny od Bootstrap/CDN, zgodny z Electron.
   Nowa warstwa wizualna: istniejąca logika, formularze i archiwum pozostają bez zmian. */
:root, :root[data-theme="light"] {
  color-scheme: light;
  --paper: #f3f6fa;
  --surface: #ffffff;
  --ink: #18283b;
  --muted: #708196;
  --line: #e4eaf0;
  --accent: #376eab;
  --accent-ink: #ffffff;
  --accent-soft: #eaf2fd;
  --mine: #e8f2ff;
  --theirs: #fff;
  --danger: #cb4855;
  --warm: #94b9e9;
  --toolbar: #fff;
  --toolbar-text: #334c6b;
  --st-online: #25a86a;
  --st-away: #dda54f;
  --st-off: #a1aebb;
  --card-shadow: 0 6px 24px rgba(28,49,78,.065);
  --floating-shadow: 0 14px 40px rgba(24,47,77,.14);
  --focus-ring: 0 0 0 3px rgba(55,110,171,.16);
  --side-tint: #f9fbff;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #151f2a;
  --surface: #1e2a37;
  --ink: #ecf3fb;
  --muted: #9aabba;
  --line: #354658;
  --accent: #86b9f3;
  --accent-ink: #11263d;
  --accent-soft: #293f59;
  --mine: #294663;
  --theirs: #253543;
  --danger: #f29aa4;
  --warm: #668db8;
  --toolbar: #233243;
  --toolbar-text: #e3eefb;
  --st-online: #43cd8e;
  --st-away: #edbf6b;
  --st-off: #8192a2;
  --card-shadow: 0 8px 25px rgba(0,0,0,.14);
  --floating-shadow: 0 20px 48px rgba(0,0,0,.38);
  --focus-ring: 0 0 0 3px rgba(134,185,243,.19);
  --side-tint: #202e3b;
}
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
body { font-size: 13px; letter-spacing: .005em; background: var(--paper); }
button, input, select, textarea { transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease; }
button { border-radius: 9px; border-color: var(--line); font-weight: 550; }
button:hover:not(:disabled) { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
button.primary { border-color: transparent; background: #376eab; color: white; box-shadow: 0 3px 10px rgba(36,97,165,.12); }
button.primary:hover:not(:disabled) { background: #245e9f; border-color: transparent; }
:root[data-theme="dark"] button.primary { background: #78afe8; color: #162b40; }
:root[data-theme="dark"] button.primary:hover:not(:disabled) { background: #a1c9f4; }
input[type=text], input[type=password], input[type=email], input[type=search], select, textarea { border-radius: 9px; background: var(--surface); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
button:active:not(:disabled) { transform: translateY(1px); }

/* Dwukolumnowy komunikator: osobna lista i obszar czatu */
.shell { grid-template-columns: clamp(285px,29vw,334px) minmax(0,1fr); background: var(--paper); }
.side { border-right: 1px solid var(--line); background: var(--surface); }
.side-top { background: var(--surface); padding: 0 14px; }
.me-row {
  min-height: 74px; margin: 0 -14px 0; padding: 10px 14px;
  border-bottom: 1px solid var(--line); gap: 10px;
}
/* Większe logo w nagłówku listy kontaktów; zachowaj proporcje grafiki. */
.me-row img { max-height: 52px; max-width: 114px; width: auto; height: auto; object-fit: contain; flex: 0 1 auto; }
.me-row .co { min-width: 0; font-size: 14px; font-weight: 740; letter-spacing: -.025em; }
.me-line { padding: 12px 0 15px; gap: 8px; grid-template-columns: 38px minmax(0,1fr) minmax(106px,124px) 34px; }
.me-line .avatar { width: 38px; height: 38px; border-radius: 12px; }
.me-line .avatar img { border-radius: 11px; }
.me-line .name { font-weight: 710; color: var(--ink); font-size: 13px; }
.me-line select { height: 35px; font-size: 11px; padding: 5px 6px; border-radius: 9px; background: var(--paper); }
.top-settings-btn { width: 34px; height: 35px; min-width: 34px; border-radius: 9px; background: var(--paper); }
.top-settings-btn svg { display: block; }
.desktop-app .me-line { grid-template-columns: 38px minmax(0,1fr) minmax(108px,134px); }
.contacts-heading {
  display: flex; align-items: center; gap: 8px; padding: 18px 16px 10px;
  background: var(--surface); color: var(--ink); border-bottom: 0;
  font-size: 14px; font-weight: 760;
}
.contacts-count { display: inline-flex; align-items: center; justify-content: center; min-width: 23px; height: 21px;
  padding: 0 6px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 750; }
.contact-search-wrap { position: relative; margin: 0; padding: 0 12px 13px; border-bottom: 1px solid var(--line); background: var(--surface); }
.contact-search-wrap > svg { position: absolute; top: 11px; left: 25px; z-index: 1; pointer-events: none; color: var(--muted); }
.contact-search-wrap input, .contact-search-wrap input[type=search] {
  height: 40px; width: 100%; background: var(--paper); border: 1px solid var(--line);
  padding: 9px 12px 9px 38px; font-size: 12px; border-radius: 10px;
}
.contact-search-wrap input::placeholder { color: var(--muted); opacity: .88; }
.list { padding: 8px; background: var(--surface); }
.list li { list-style: none; }
.item {
  min-height: 66px; border: 1px solid transparent; border-radius: 11px;
  padding: 9px 10px; margin: 2px 0; align-items: center; background: transparent;
  gap: 11px; box-shadow: none;
}
.item:hover { background: var(--side-tint); border-color: var(--line); }
.item[aria-current=true] { border: 1px solid color-mix(in srgb,var(--accent) 22%,var(--line)); background: var(--accent-soft); padding: 9px 10px; }
.item .txt { min-width: 0; }
.item .t1 { font-size: 12.5px; line-height: 1.3; font-weight: 740; }
.item .t2 { margin-top: 4px; font-size: 11.5px; line-height: 1.3; }
.item .with-presence { gap: 6px; }
.item .presence-symbol { opacity: .9; }
.item .avatar, .avatar { width: 40px; height: 40px; border: 0; border-radius: 13px; font-size: 13px; }
.avatar img { border-radius: 13px; }
.avatar .dot { right: -2px; bottom: -2px; border-width: 2.5px; width: 12px; height: 12px; }
.item .badge { flex: none; }
.list-heading { border: 0; border-radius: 8px; background: var(--paper); color: var(--muted); margin: 14px 4px 8px; padding: 8px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.list .empty { padding: 28px 16px; text-align: center; font-size: 12px; }
.badge { background: #3976b9; color: #fff; box-shadow: 0 2px 5px rgba(36,97,165,.12); }

/* Stopka: 3/4 równych przycisków z własnymi SVG */
.side-bottom { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); align-items: center;
  padding: 10px 12px 12px; gap: 7px; border-top: 1px solid var(--line); background: var(--side-tint); }
.side-bottom .side-action { min-width: 0; min-height: 40px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 11px; padding: 8px 6px; white-space: nowrap; box-shadow: 0 1px 2px rgba(20,40,60,.035); }
.side-bottom .side-action:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.side-bottom .side-action svg { flex: none; width: 17px; height: 17px; }
.side-bottom .side-action .label { text-overflow: ellipsis; overflow: hidden; }
.desktop-app .side-bottom { grid-template-columns: repeat(4, minmax(0,1fr)); }
.desktop-app .side-bottom:has(.side-action:nth-child(3):last-child) { grid-template-columns: repeat(3,minmax(0,1fr)); }
.desktop-app .side-bottom .side-action { min-height: 42px; padding: 8px; }
.desktop-app .side-bottom .side-action svg { width: 19px; height: 19px; }
.desktop-app .side-bottom .side-action .label { display: none; }
.desktop-app .side-bottom #pending-badge { margin-top: -13px; margin-left: 20px; }

/* Obszar czatu */
.main { background: var(--paper); }
.main-head { min-height: 73px; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--line); gap: 12px; }
.main-head .avatar { width: 44px; height: 44px; border-radius: 14px; }
.main-head .ttl { font-size: 15px; color: var(--ink); font-weight: 760; }
.main-head .muted { font-size: 11.5px; margin-top: 2px; }
.main-head .room-actions button { border-radius: 10px; }
.main-head .room-actions .history-trash-btn { width: 36px; height: 36px; min-width: 36px; border: 1px solid var(--line); background: var(--surface); }
.main-head .room-actions .history-trash-btn:hover { background: color-mix(in srgb,var(--danger) 9%, var(--surface)); border-color: var(--danger); }
.main-head .back { background: var(--paper); border-radius: 9px; }
.msgs { flex: 1; padding: 16px 22px; gap: 7px; background: var(--paper); }
.day { align-self: center; width: fit-content; max-width: 100%; margin: 9px auto 14px; padding: 5px 12px;
  background: color-mix(in srgb,var(--surface) 85%,var(--paper)); border: 1px solid var(--line);
  border-radius: 999px; font-size: 11px; color: var(--muted); }
.msg,.msg.mine { width: fit-content; max-width: min(510px,86%); align-self: flex-start; border: 1px solid var(--line);
  border-radius: 15px 15px 15px 4px; padding: 10px 13px; background: var(--theirs);
  box-shadow: 0 2px 7px rgba(22,42,66,.035); overflow-wrap: anywhere; }
.msg.mine { align-self: flex-end; border-radius: 15px 15px 4px 15px; background: var(--mine);
  border-color: color-mix(in srgb,var(--accent) 10%,var(--line)); }
.message-top { gap: 8px; margin-bottom: 5px; }
.message-top .who { color: var(--accent); font-size: 11.5px; }
.message-top .tm { color: var(--muted); font-size: 10.5px; }
.message-top .delete-msg { border-radius: 7px; }
.message-body { line-height: 1.55; font-size: 12.8px; }
.file-chip { border-radius: 10px; background: var(--surface); }
.typing { background: var(--paper); padding: 2px 22px; min-height: 22px; height: 22px; }
.composer { background: var(--surface); border-top: 1px solid var(--line); padding: 11px 16px 13px; gap: 8px; align-items: stretch; }
.composer textarea { min-height: 44px; max-height: 140px; height: 44px; border-radius: 12px; background: var(--paper);
  border: 1px solid var(--line); padding: 11px 12px; font-size: 12.5px; line-height: 1.45; }
.composer .attach-btn,.composer .emoji-toggle { background: var(--paper); border-color: var(--line); border-radius: 11px; width: 43px; min-width: 43px; padding: 0; color: var(--muted); }
.composer .attach-btn svg,.composer .emoji-toggle svg { flex: none; display: block; }
.composer .emoji-control { align-items: stretch; }
.composer .attach-btn:hover,.composer .emoji-toggle:hover { color: var(--accent); background: var(--accent-soft); }
.composer .emoji-toggle { font-size: 12px; }
.composer .send-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 13px; border-radius: 11px; white-space: nowrap; }
.composer .send-btn svg { flex: none; }
.emoji-panel { border-radius: 14px; box-shadow: var(--floating-shadow); }
.emoji-tabs { scrollbar-width: thin; }
.emoji-grid { gap: 4px; }
.modern-placeholder { padding: 24px; max-width: 400px; }
.modern-placeholder .placeholder-icon { display: grid; place-items: center; margin: 0 auto 20px;
  width: 96px; height: 96px; border-radius: 28px; background: var(--accent-soft); color: var(--accent); }
.modern-placeholder h2 { color: var(--ink); font-size: 19px; font-weight: 760; line-height: 1.3; letter-spacing: -.025em; margin: 0 0 8px; }
.modern-placeholder p { font-size: 12.5px; line-height: 1.7; color: var(--muted); margin: 0; }
.banner { background: #fff1d6; color: #78501b; border-bottom: 1px solid #f4d7a0; }
:root[data-theme="dark"] .banner { background: #3e341e; color: #ffdc9e; border-color: #685125; }

/* Bootstrapowy styl panelu, formularzy, kart i dialogów bez zewnętrznego CSS. */
.admin { background: var(--paper); padding: 20px; }
.admin-in { max-width: 1240px; gap: 14px; }
.admin .bar { padding: 6px 3px 10px; }
.admin .bar h1 { font-size: 21px; letter-spacing: -.03em; font-weight: 780; }
.panel, .admin-config-column > .panel, .admin-in > .panel, .archive-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--card-shadow); }
.admin-in > .panel, .admin-config-column > .panel { padding: 20px; }
.admin .panel h2, .admin-config-column > .panel > h2 { font-size: 15px; padding-bottom: 12px; border-bottom: 1px solid var(--line); margin: 0 0 13px; font-weight: 760; }
.admin .panel h3 { font-weight: 750; }
.admin-config-grid,.admin-config-column { gap: 14px; }
.admin .panel input:not([type=checkbox]),.admin .panel select,.admin .panel textarea { border-radius: 9px; border-color: var(--line); min-height: 36px; }
.admin .panel input[type=checkbox] { accent-color: #4678b4; }
.admin .panel label { font-size: 12px; }
.admin .panel .row button, .admin .panel button { border-radius: 9px; }
.admin .panel table { font-size: 12px; }
.admin .panel table th { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.admin .panel table td { padding-top: 11px; padding-bottom: 11px; }
.admin .panel tbody tr:hover { background: var(--side-tint); }
.admin .logo-box { background: var(--paper); border-radius: 12px; }
.admin .archive-room-list { border-radius: 11px; }
.admin .archive-message-list { border-radius: 11px; }
.admin-subsection { padding-bottom: 16px; }
.admin-subsection + .admin-subsection { padding-top: 16px; }
.admin-add-user { margin-top: 15px; padding-top: 16px; }
.archive-room { border-radius: 8px; }
.archive-room.selected { border-left: 3px solid var(--accent); }
.archive-delete-btn { border-radius: 9px; }
.tag { border-radius: 20px; padding: 3px 9px; font-weight: 650; }
.bar button { font-size: 12px; }
dialog { max-height: 90vh; overflow-y: auto; border-radius: 17px; box-shadow: var(--floating-shadow); padding: 22px; }
dialog::backdrop { background: rgba(15,31,46,.55); backdrop-filter: blur(3px); }
dialog .row { gap: 8px; }
#toast { border-radius: 12px; box-shadow: var(--floating-shadow); background: var(--ink); color: var(--surface); font-size: 12px; }
.login-view { background: var(--paper); }
.login-panel,.card { background: var(--surface); border-radius: 18px; border-color: var(--line); box-shadow: var(--card-shadow); }
.login-panel { padding: 30px; }
.login-header .brand h1 { font-size: 20px; }
.login-heading h2 { font-size: 25px; letter-spacing: -.03em; }
.login-fields input { border-radius: 10px; }
.login-actions button.primary { border-radius: 10px; }

/* Responsywność: brak poziomego przewijania i zachowanie miejsca na czat. */
@media (min-width:631px) and (max-width:860px) {
  .shell { grid-template-columns: minmax(260px,290px) minmax(0,1fr); }
  .me-line { grid-template-columns: 36px minmax(0,1fr) minmax(100px,118px) 32px; gap: 5px; }
  .desktop-app .me-line { grid-template-columns: 36px minmax(0,1fr) minmax(105px,130px); }
  .side-top { padding-left: 10px; padding-right: 10px; }
  .me-row { margin: 0 -10px; }
  .msgs { padding: 13px 12px; }
  .msg,.msg.mine { max-width: 94%; }
  .main-head { padding: 10px; }
  .composer { padding: 10px; gap: 6px; }
  .composer .send-btn { padding: 8px 10px; }
}
@media (max-width:790px) { .admin-config-grid { grid-template-columns: minmax(0,1fr); } }
@media (max-width:630px) {
  .shell { grid-template-columns: minmax(0,1fr); }
  .side-top { padding-left: 14px; padding-right: 14px; }
  .me-row { margin: 0 -14px; }
  .me-line { grid-template-columns: 38px minmax(0,1fr) minmax(102px,134px) 34px; }
  .desktop-app .me-line { grid-template-columns: 38px minmax(0,1fr) minmax(116px,138px); }
  .main-head { padding: 10px 12px; }
  .main-head .back { display: inline-flex; }
  .main-head .head-text { flex: 1 1 100px; }
  .msgs { padding: 12px; }
  .msg,.msg.mine { max-width: 92%; }
  .composer { padding: 8px; }
  .composer .send-btn span { display: none; }
  .composer .send-btn { min-width: 42px; }
  .admin { padding: 10px; }
  .admin-in > .panel, .admin-config-column > .panel { padding: 14px; }
}
@media (max-width:400px) {
  .me-line { gap: 5px; grid-template-columns: 36px minmax(0,1fr) minmax(96px,120px) 32px; }
  .desktop-app .me-line { grid-template-columns: 36px minmax(0,1fr) minmax(108px,132px); }
  .side-bottom { gap: 5px; padding: 8px; }
  .composer .attach-btn,.composer .emoji-toggle { width: 36px; min-width: 36px; }
  .emoji-panel { left: -45px; }
}
@media (prefers-reduced-motion: reduce) { button, input, select, textarea { transition: none; } }


/* Archiwum rozmów: dopracowany układ i ikonowe przyciski akcji. */
.archive-panel { gap: 16px; }
.archive-heading { justify-content: space-between; align-items: center; }
.archive-heading h2 { display: flex; align-items: center; gap: 12px; }
.archive-heading .tag { margin-right: auto; }
.archive-filters {
  grid-template-columns: minmax(220px,2.2fr) minmax(170px,1fr) minmax(170px,1fr) minmax(140px,.9fr) minmax(140px,.9fr) auto;
  gap: 12px;
}
.archive-layout { gap: 16px; }
.archive-room-list, .archive-message-list {
  background: color-mix(in srgb, var(--surface) 94%, white 6%);
}
.archive-room-list { padding: 8px; gap: 8px; }
.archive-room {
  padding: 12px 13px; border: 1px solid var(--line); border-radius: 12px; transition: .16s ease;
}
.archive-room:hover { transform: translateY(-1px); border-color: color-mix(in srgb,var(--accent) 40%, var(--line)); box-shadow: 0 6px 16px rgba(15,23,42,.06); }
.archive-room.selected { border-left-width: 4px; box-shadow: 0 8px 20px rgba(37,99,235,.10); }
.archive-tools { gap: 10px; align-items: stretch; }
.archive-tools input { min-height: 46px; }
.archive-tools > button { min-height: 46px; }
.archive-icon-btn {
  width: 46px; min-width: 46px; height: 46px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px; font-size: 0;
}
.archive-icon-btn svg { width: 18px; height: 18px; display: block; }
.archive-heading .archive-icon-btn { margin-left: auto; }
.archive-message-list { padding: 2px; }
.archive-message { border-radius: 12px; margin: 8px; border: 1px solid transparent; }
.archive-message:nth-child(even) { background: color-mix(in srgb, var(--paper) 85%, white 15%); }
.archive-message:hover { border-color: color-mix(in srgb,var(--accent) 20%, var(--line)); }
.archive-events { background: color-mix(in srgb, var(--paper) 88%, white 12%); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.archive-note { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
.archive-empty-note { padding: 18px 14px; }
@media (max-width: 960px) {
  .archive-filters { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .archive-tools { grid-template-columns: 1fr auto auto auto; display: grid; }
  .archive-tools input { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .archive-heading { align-items: flex-start; }
  .archive-heading .tag { margin-right: 0; }
  .archive-heading .archive-icon-btn { margin-left: 0; }
  .archive-tools { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .archive-tools > button { min-width: 0; }
}


/* Ustawienia przeniesione do dolnego paska; pasek akcji ikonowy. */
.top-settings-btn { display: none !important; }
.me-line { grid-template-columns: 56px minmax(0,1fr) minmax(140px,172px); }
.side-bottom {
  grid-template-columns: repeat(4, minmax(0,1fr));
}
.side-bottom:has(.side-action:nth-child(3):last-child) { grid-template-columns: repeat(3, minmax(0,1fr)); }
.side-bottom .side-action {
  padding: 8px 0; min-height: 44px; justify-content: center;
}
.side-bottom .side-action .label { display: none; }
.side-bottom .side-action svg { width: 19px; height: 19px; }
.side-bottom #pending-badge { margin-top: -13px; margin-left: 20px; }
@media (max-width: 480px) {
  .me-line { grid-template-columns: 56px minmax(0,1fr) minmax(126px,148px); }
}


/* Status przy nagłówku „Kontakty” — również w kompaktowym oknie Windows. */
.side .side-top .me-line,
.desktop-app .side .side-top .me-line {
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  padding-bottom: 11px;
}
.side .side-top .me-line .name { min-width: 0; }
.contacts-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 12px 14px 10px;
  border-bottom: 0;
  background: var(--surface);
}
.contacts-toolbar .contacts-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  white-space: nowrap;
}
@media (max-width: 400px) {
  .contacts-toolbar { padding: 10px 11px 8px; gap: 6px; }
  .contacts-toolbar .contacts-heading { gap: 6px; font-size: 13px; }
}

/* Pasek pisania: jednakowa wysokość i idealne centrowanie ikon akcji.
   Ikony załączników i emotikonów były wcześniej rysowane w rogu przycisku. */
.composer {
  align-items: center;
}
.composer textarea {
  flex: 1 1 auto;
  min-width: 0;
  height: 48px;
  min-height: 48px;
  margin: 0;
}
.composer .attach-btn,
.composer .emoji-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 48px;
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  margin: 0;
  align-self: center;
  line-height: 1;
}
.composer .attach-btn svg,
.composer .emoji-toggle svg {
  display: block;
  width: 21px;
  height: 21px;
  margin: 0;
}
.composer .emoji-control {
  display: flex;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  align-self: center;
}
.composer .send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  min-height: 48px;
  height: 48px;
  margin: 0;
}
@media (max-width: 400px) {
  .composer .attach-btn,
  .composer .emoji-toggle,
  .composer .emoji-control {
    flex-basis: 42px;
    width: 42px;
    min-width: 42px;
    height: 46px;
    min-height: 46px;
  }
  .composer .send-btn { height: 46px; min-height: 46px; }
}


/* Spójne, ikonowe akcje profilu i zarządzania kontami. */
.settings-avatar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 12px;
}
.settings-avatar-actions .profile-avatar { margin: 0; }
.admin-icon-action {
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.admin-icon-action svg { width: 18px; height: 18px; display: block; flex: none; }
.admin-icon-action:hover { background: var(--accent-soft); border-color: var(--accent); }
.admin-icon-action.danger { color: var(--danger); }
.admin-icon-action.danger:hover { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--surface)); }
.admin-user-actions { display: flex; align-items: center; gap: 7px; flex-wrap: nowrap; }
.admin-user-actions .admin-icon-action { width: 36px; height: 36px; min-width: 36px; }
.settings-avatar-actions .avatar-delete-btn { width: 40px; height: 40px; }

/* Tytuł i etykieta archiwum mają wspólną oś pionową. */
.archive-panel .archive-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  flex-wrap: wrap;
}
.archive-heading-main { display: flex; align-items: center; gap: 12px; flex: 1 1 auto; min-width: 0; flex-wrap: wrap; }
.admin .archive-panel .archive-heading h2 {
  border-bottom: 0;
  margin: 0;
  padding: 0;
  line-height: 1.4;
  display: block;
  white-space: nowrap;
}
.archive-heading-main .tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
  vertical-align: middle;
}
.archive-heading > .archive-icon-btn { margin-left: auto; }
@media (max-width: 560px) {
  .archive-heading-main { gap: 8px; }
  .archive-heading > .archive-icon-btn { margin-left: auto; }
}


/* Usprawnienie tabeli użytkowników w panelu administratora */
.admin-users-table { table-layout: fixed; width: 100%; }
.admin-users-table th:nth-child(1) { width: 22%; }
.admin-users-table th:nth-child(2) { width: 20%; }
.admin-users-table th:nth-child(3) { width: 13%; }
.admin-users-table th:nth-child(4) { width: 13%; }
.admin-users-table th:nth-child(5) { width: 20%; }
.admin-users-table th:nth-child(6) { width: 12%; text-align: right; }
.admin-user-name-cell { vertical-align: top; }
.admin-user-meta-cell { vertical-align: top; }
.admin-user-meta-cell > div:first-child { font-weight: 600; }
.admin-user-meta-cell .muted { margin-top: 3px; overflow-wrap: anywhere; }
.admin-role-cell select { width: 100%; max-width: 170px; min-width: 130px; }
.admin-last-login-cell { white-space: nowrap; }
.admin-actions-cell { text-align: right; }
.admin-actions-cell .admin-user-actions { justify-content: flex-end; }
@media (max-width: 980px) {
  .admin-users-table { min-width: 860px; }
}


/* Akcje: wspólna oś środkowa nagłówka i ikon. */
.admin-users-table th:nth-child(6),
.admin-users-table td.admin-actions-cell { text-align: center; }
.admin-users-table .admin-actions-cell .admin-user-actions {
  justify-content: center;
  margin: 0;
}


/* Wyrównanie pionowe wartości w tabeli użytkowników */
.admin-users-table td { vertical-align: middle; }
.admin-user-name-cell,
.admin-user-meta-cell,
.admin-role-cell,
.admin-last-login-cell,
.admin-actions-cell { vertical-align: middle; }
.admin-user-name-cell > div,
.admin-user-meta-cell > div { line-height: 1.25; }
.admin-user-meta-cell .muted { margin-top: 0; }


/* Konferencje: przycisk usunięcia pokoju w kafelku (nie w nagłówku rozmowy). */
.list .group-entry {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  margin: 2px 0;
}
.list .group-entry .group-open {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}
.list .group-entry.is-deletable .group-open {
  /* Stała przestrzeń na kosz, również dla długich nazw i liczników. */
  padding-right: 61px;
}
.list .group-entry .group-delete-btn {
  position: absolute;
  z-index: 1;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--danger);
  box-shadow: none;
}
.list .group-entry .group-delete-btn svg { display: block; width: 18px; height: 18px; }
.list .group-entry .group-delete-btn:hover {
  background: color-mix(in srgb, var(--danger) 9%, var(--surface));
  border-color: var(--danger);
}
.list .group-entry .group-delete-btn:active {
  transform: translateY(calc(-50% + 1px));
}
.list .group-entry .group-delete-btn:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}
.list .group-entry .group-open .badge { margin-left: auto; }

.list .group-entry .group-open[aria-current="true"] ~ .group-delete-btn {
  background: color-mix(in srgb, var(--accent-soft) 48%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 16%, var(--line));
}


/* Kompaktowy wybór statusu — pod profilem i obok Kontakty, bez zasłaniania nazwy. */
.contacts-toolbar { position: relative; z-index: 4; }
.contacts-toolbar .contacts-heading { flex: 1 1 auto; min-width: 0; }
.status-control { position: relative; flex: 0 0 auto; }
.status-trigger {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  width: auto; max-width: 132px; min-height: 33px; padding: 5px 9px;
  background: transparent; color: var(--muted); border: 1px solid transparent;
  border-radius: 10px; white-space: nowrap; font-size: 11.5px; font-weight: 600;
  box-shadow: none;
}
.status-trigger:hover, .status-trigger[aria-expanded="true"] {
  color: var(--ink); background: var(--paper); border-color: var(--line);
}
.status-trigger .status-caption { max-width: 96px; overflow: hidden; text-overflow: ellipsis; }
.status-trigger .status-chevron { font-size: 16px; line-height: .75; color: var(--muted); }
.status-indicator {
  display: inline-block; width: 8px; height: 8px; min-width: 8px; border-radius: 50%;
  background: var(--st-off); box-shadow: 0 0 0 2px color-mix(in srgb, var(--st-off) 17%, transparent);
}
.status-indicator.online { background: var(--st-online); box-shadow: 0 0 0 2px color-mix(in srgb, var(--st-online) 17%, transparent); }
.status-indicator.chatty { background: #59a9d1; box-shadow: 0 0 0 2px #59a9d120; }
.status-indicator.away { background: var(--st-away); box-shadow: 0 0 0 2px color-mix(in srgb, var(--st-away) 17%, transparent); }
.status-indicator.dnd { background: #d15a56; box-shadow: 0 0 0 2px #d15a5620; }
.status-indicator.invisible { background: var(--st-off); box-shadow: 0 0 0 2px color-mix(in srgb, var(--st-off) 17%, transparent); }
.status-menu {
  position: absolute; right: 0; top: calc(100% + 5px); z-index: 50;
  display: flex; flex-direction: column; gap: 2px;
  width: 192px; padding: 5px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
  box-shadow: 0 9px 28px rgba(0,0,0,.16);
}
.status-menu[hidden] { display: none !important; }
.status-option {
  display: flex; align-items: center; justify-content: flex-start; gap: 10px;
  width: 100%; padding: 9px 11px; text-align: left; border: none; border-radius: 8px;
  background: transparent; font-size: 12px; color: var(--ink);
}
.status-option:hover, .status-option:focus-visible { background: var(--accent-soft); }
.status-option[aria-checked="true"] { background: var(--accent-soft); font-weight: 700; }
.status-option .status-check { margin-left: auto; opacity: 0; color: var(--accent); }
.status-option[aria-checked="true"] .status-check { opacity: 1; }
@media (max-width: 400px) {
  .status-trigger { max-width: 112px; gap: 5px; padding: 5px 6px; }
  .status-trigger .status-caption { max-width: 79px; }
}


/* Zmiana hasła: oba przyciski w jednym spójnym układzie. */
.password-card .password-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-top: 24px;
}
.password-card .password-actions > button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 46px;
  margin: 0;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 650;
  line-height: 1.35;
}
.password-card .password-actions > .password-cancel-btn {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: none;
}
.password-card .password-actions > .password-cancel-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.password-card .password-actions > .password-cancel-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}


/* Status przy nazwie konta (zamiast przy nagłówku Kontakty).
   Siatka zachowuje miejsce dla nazwy; menu otwiera się nad listą kontaktów. */
.side .side-top { position: relative; z-index: 10; }
.side .side-top .me-line,
.desktop-app .side .side-top .me-line {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) max-content;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding-bottom: 11px;
}
.side .side-top .me-line .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .side-top .status-control { justify-self: end; min-width: 0; }
.side .side-top .status-trigger { max-width: 126px; padding: 5px 6px; }
.side .side-top .status-trigger .status-caption { max-width: 89px; }
.contacts-toolbar { z-index: 1; }
.contacts-toolbar .contacts-heading { flex: 1 1 auto; }
@media (max-width: 360px) {
  .side .side-top .me-line,
  .desktop-app .side .side-top .me-line { gap: 6px; grid-template-columns: 36px minmax(0, 1fr) max-content; }
  .side .side-top .status-trigger { max-width: 110px; gap: 5px; padding: 5px 4px; }
  .side .side-top .status-trigger .status-caption { max-width: 75px; }
}

/* Rejestracja: zwarty formularz bez wymuszonego przewijania w oknie Windows.
   W bardzo niskich rozdzielczościach pozostaje dostępne przewijanie awaryjne. */
.register-view {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.register-card {
  width: min(470px, 100%);
  max-width: 470px;
  padding: 20px 26px;
}
.register-card .brand { gap: 12px; margin: 0 0 8px; }
.register-card .brand img { max-height: 43px; max-width: 135px; }
.register-card .brand h1 { font-size: 18px; line-height: 1.2; }
.register-card h2 { margin: 8px 0 0; font-size: 20px; line-height: 1.3; }
.register-card .register-intro { margin: 5px 0 11px; line-height: 1.38; font-size: 12px; }
.register-card label { font-size: 12.5px; line-height: 1.25; margin: 8px 0 4px; }
.register-card input[type="text"],
.register-card input[type="email"],
.register-card input[type="password"] {
  height: 39px;
  min-height: 39px;
  padding: 7px 11px;
  border-radius: 9px;
}
.register-card .err:empty { display: none; }
.register-card .err:not(:empty) { margin: 8px 0 2px; min-height: 0; font-size: 12px; }
.register-actions { display: grid; grid-template-columns: 1fr; gap: 9px; margin-top: 15px; }
.register-card .register-actions button {
  width: 100%; min-height: 42px; padding: 9px 14px;
  margin: 0; border-radius: 10px; font-weight: 650; line-height: 1.3;
}
.register-card .register-actions .register-cancel-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  box-shadow: none;
}
.register-card .register-actions .register-cancel-btn:hover {
  background: var(--accent-soft); border-color: var(--accent);
}
.desktop-app .register-view {
  display: flex;
  height: 100%; min-height: 0; padding: 12px 16px;
  align-items: center; justify-content: center;
  overflow-y: auto; scrollbar-width: none;
}
.desktop-app .register-view::-webkit-scrollbar { display: none; }
.desktop-app .register-view .register-card {
  flex: 0 1 470px; width: 100%; max-width: 470px;
  min-height: 0; padding: 18px 24px; margin: auto;
}
@media (max-height: 670px) {
  .desktop-app .register-view { padding: 8px 12px; }
  .desktop-app .register-view .register-card { padding: 12px 18px; }
  .register-card .brand img { max-height: 34px; }
  .register-card .brand { margin-bottom: 4px; }
  .register-card h2 { margin-top: 4px; font-size: 18px; }
  .register-card .register-intro { margin: 4px 0 7px; }
  .register-card label { margin: 6px 0 3px; }
  .register-card input[type="text"],
  .register-card input[type="email"],
  .register-card input[type="password"] { height: 35px; min-height: 35px; }
  .register-actions { margin-top: 10px; gap: 6px; }
  .register-card .register-actions button { min-height: 37px; }
}


/* Archiwum: jedna wyszukiwarka oraz lista zajmująca całą dostępną wysokość. */
.archive-panel .archive-layout {
  height: clamp(430px, 62vh, 780px);
  min-height: 430px;
  grid-template-columns: minmax(220px, 31%) minmax(0, 1fr);
  align-items: stretch;
}
.archive-panel .archive-room-list {
  height: 100%;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.archive-panel .archive-detail {
  height: 100%;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.archive-panel .archive-tools {
  flex: none;
  justify-content: flex-end;
}
.archive-panel .archive-message-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.archive-panel .archive-events {
  flex: none;
  max-height: 120px;
  overflow-y: auto;
}
.archive-panel .archive-events:empty { display: none; }
.archive-panel .archive-more { flex: none; }
@media (max-width: 650px) {
  .archive-panel .archive-layout {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: 0;
  }
  .archive-panel .archive-room-list {
    height: 215px;
    max-height: 215px;
  }
  .archive-panel .archive-detail { height: 365px; min-height: 365px; }
  .archive-panel .archive-message-list { min-height: 0; }
}
