@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  color-scheme: dark;

  --bg: #0E141A;
  --panel: #141B22;
  --raised: #1D2631;
  --raised-hover: #232E3B;
  --field: #11181F;
  --selected: #16283E;
  --border: #242E3A;
  --border-field: #26313F;
  --border-hover: #37475A;
  --btn-border: #232C3B;
  --divider: #1C2632;
  --text: #F0F4F8;
  --text-muted: #97A9BE;
  --text-dim: #66768A;

  --accent: #1078FE;
  --accent-rim: #1B87FF;
  --accent-hover: #08448D;
  --accent-active: #0C61D0;
  --accent-text: #2297F0;
  --accent-focus: #1A94F0;
  --accent-soft: rgba(16, 120, 254, 0.14);
  --accent-ring: rgba(26, 148, 240, 0.22);

  --info-bg: #0E2137;
  --info-border: #0C4175;
  --info-text: #74B6E5;
  --ok-bg: #122522;
  --ok-border: #226043;
  --ok-text: #7BC8B2;
  --warn-bg: #26261A;
  --warn-border: #7D631C;
  --warn-text: #EDCE69;
  --err-bg: #26171C;
  --err-border: #8A2F2E;
  --err-text: #F27368;

  --amber: #F2A33C;
  --red: #F27368;
  --danger: #E5484D;
  --green: #4FCB7A;
  --purple: #562AAC;
  --notify: #F15E7D;

  --font-ui: 'Inter', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', Consolas, monospace;
}

* { box-sizing: border-box; }

/* a class that sets its own `display` (eg. ".nav-item { display: flex }") otherwise wins the
   cascade over the browser's own "[hidden] { display: none }" rule at equal specificity, so the
   hidden attribute would silently do nothing on such an element without this */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  height: 100%;
}

/* No zooming: pinch and double tap are switched off, scrolling still works. The viewport meta in
   index.html and script.js do the same for the browsers that do not follow touch-action. */
html, body {
  touch-action: pan-x pan-y;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

.mono { font-family: var(--font-mono); }

button {
  font-family: inherit;
  cursor: pointer;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--raised);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  color: var(--accent-text);
}

.screen {
  min-height: 100vh;
  min-height: 100dvh;
}

#login-screen[hidden],
#workspace-screen[hidden] {
  display: none;
}

/* ============ LOGIN ============ */

#login-screen {
  display: flex;
  align-items: stretch;
  background:
    radial-gradient(ellipse 900px 500px at 15% 20%, rgba(16, 120, 254, 0.08), transparent 60%),
    var(--bg);
}

.login-frame {
  width: 100%;
  max-width: 640px;
  margin-left: 8vw;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px 24px 32px 0;
}

.login-top {
  display: flex;
  align-items: center;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--divider);
}

.login-top .brand-logo {
  height: 44px;
}

/* DevPortal logo in the menu (sidebar / drawer and the mobile top bar) */
.brand-logo {
  display: block;
  width: auto;
  height: 36px;
  max-width: 100%;
}

.mobile-topbar .brand-logo {
  height: 30px;
}

.clock {
  font-family: var(--font-mono);
  font-size: inherit;
  letter-spacing: inherit;
  color: inherit;
  font-variant-numeric: tabular-nums;
}

.login-body {
  padding-top: 22vh;
}

.login-eyebrow {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 15px;
}

.login-body h1 {
  margin: 0 0 18px;
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: -0.015em;
  max-width: 11ch;
}

.login-sub {
  margin: 0 0 36px;
  max-width: 46ch;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1.6;
}

.login-form {
  max-width: 380px;
}

.login-field,
.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* a field with the show / hide button inside it */
.password-field {
  position: relative;
  display: block;
}

.login-form .password-field input,
.modal-form .password-field input {
  width: 100%;
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  transform: translateY(-50%);
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-muted);
  -webkit-tap-highlight-color: transparent;
}

.password-toggle svg {
  width: 18px;
  height: 18px;
}

.password-toggle .icon-hide {
  display: none;
}

.password-toggle[aria-pressed="true"] .icon-show {
  display: none;
}

.password-toggle[aria-pressed="true"] .icon-hide {
  display: block;
}

@media (hover: hover) {
  .password-toggle:hover {
    background: var(--raised);
    color: var(--text);
  }
}

.login-error {
  margin: 0;
  padding: 10px 14px;
  background: var(--err-bg);
  border: 1px solid var(--err-border);
  border-radius: 8px;
  color: var(--err-text);
  font-size: 13px;
  line-height: 1.5;
}

.login-error[hidden] {
  display: none;
}

.login-form .login-submit {
  width: 100%;
  margin-top: 4px;
  padding: 13px 22px;
  font-size: 15px;
}

.login-form input[aria-invalid="true"],
.login-form input[aria-invalid="true"]:focus,
.password-form input[aria-invalid="true"],
.password-form input[aria-invalid="true"]:focus {
  border-color: #E53F3C;
}

.login-form input[aria-invalid="true"]:focus,
.password-form input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgba(229, 63, 60, 0.2);
}

/* browsers paint autofilled fields in a light colour; keep them in the dark theme */
.login-form input:-webkit-autofill,
.login-form input:-webkit-autofill:hover,
.login-form input:-webkit-autofill:focus,
.modal-form input:-webkit-autofill,
.modal-form input:-webkit-autofill:hover,
.modal-form input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  box-shadow: 0 0 0 1000px var(--field) inset;
  transition: background-color 9999s ease-out 0s;
}

.login-hint {
  margin: 22px 0 0;
  padding: 11px 14px;
  max-width: 46ch;
  font-size: 13px;
  line-height: 1.6;
  color: var(--info-text);
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: 8px;
}

.login-foot {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--divider);
  color: #576779;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.7;
  letter-spacing: 0.08em;
}

/* ============ WORKSPACE ============ */

#workspace-screen {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  /* menu palette: the whole look of the menu is driven from these */
  --menu-bg: #10161D;
  --menu-card: #1A212C;
  --menu-card-hover: #212A38;
  --menu-active: #1C232E;
  --menu-line: #212835;
  --menu-text: #FFFFFF;
  --menu-muted: #A3B2CF;
  --menu-sub: #8E9DB5;
  --menu-close: #ACB8D3;
  --menu-badge: #F15E7D;

  width: 248px;
  flex-shrink: 0;
  background: var(--menu-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: sticky;
  top: 0;
  padding: 18px 15px 20px 16.5px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar-top {
  padding: 0 0 20px 5.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-topbar {
  display: none;
}

.menu-toggle,
.menu-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 7px;
  align-items: center;
  justify-content: center;
}

.menu-toggle svg,
.menu-close svg {
  width: 20px;
  height: 20px;
}

.menu-toggle:hover,
.menu-close:hover {
  background: var(--raised);
  color: var(--text);
}

/* bigger X; the padding only enlarges the tap area, the negative margins keep the layout at 24px */
.menu-close {
  padding: 10px;
  margin: -9px -9px -9px 0;
  color: var(--menu-close);
}

.menu-close svg {
  width: 22px;
  height: 22px;
}

.sidebar-overlay {
  display: none;
}

.session-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  margin-bottom: 20px;
  background: var(--menu-card);
  border-radius: 10px;
  /* the card is a link to "Moje dane" */
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease;
}

.session-chevron {
  width: 10px;
  height: 11px;
  margin-left: auto;
  flex-shrink: 0;
  color: var(--menu-muted);
  transition: color 0.12s ease, transform 0.12s ease;
}

@media (hover: hover) {
  .session-card:hover {
    background: var(--menu-card-hover);
  }

  .session-card:hover .session-chevron {
    color: var(--menu-text);
    transform: translateX(2px);
  }
}

.session-card:active {
  background: var(--menu-card-hover);
}

.session-card:active .session-chevron {
  color: var(--menu-text);
}

.session-card:focus-visible {
  outline: 2px solid var(--accent-focus);
  outline-offset: 2px;
}

/* every avatar (a real upload or the lettered placehold.co fallback) is painted as a
   background-image set inline by JS, over the flat colour below as a loading/failure fallback */
.session-avatar,
.dm-avatar,
.chat-avatar,
.chat-head-avatar,
.user-cell-avatar,
.call-avatar,
.call-bar-avatar,
.call-video-tile-avatar,
.incoming-call-avatar .call-avatar,
.mydata-avatar {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.session-avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background-color: var(--amber);
  color: #1a1206;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.session-avatar.small {
  width: 28px;
  height: 28px;
  font-size: 13px;
  border-radius: 7px;
}

.sidebar .session-avatar {
  background-color: #F39D35;
}

.session-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.session-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.session-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 16px;
  color: var(--menu-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  line-height: 13px;
  color: var(--menu-sub);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(79, 203, 122, 0.18);
  flex-shrink: 0;
}

/* status dot in the menu: green ring with a light core */
.session-status .dot {
  width: 8px;
  height: 8px;
  box-sizing: border-box;
  border: 2px solid #27A26F;
  background: #D4EFEB;
  box-shadow: none;
}

/* rank pill on the profile card */
.session-card .rank-badge {
  padding: 2px 6px;
  border: 1px solid transparent;
  border-color: color-mix(in srgb, currentColor 30%, transparent);
  border-radius: 7px;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  line-height: 10px;
  letter-spacing: 0.04em;
}

.session-card .rank-badge.rank-dev {
  color: #57B3F9;
  background: #172C4B;
  border-color: #184476;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 17px;
  background: none;
  border: none;
  color: var(--menu-muted);
  padding: 8px 8px 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-item svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--menu-muted);
}

.nav-item:hover {
  background: var(--menu-active);
  color: var(--menu-text);
}

.nav-item.active {
  background: var(--menu-active);
  color: var(--menu-text);
}

.nav-badge {
  margin-left: auto;
  background: var(--menu-badge);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  line-height: 19px;
  height: 19px;
  min-width: 19px;
  padding: 0 5px;
  border-radius: 10px;
  text-align: center;
}

.nav-badge[hidden] {
  display: none;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  background: none;
  border: 1px solid var(--menu-line);
  color: #838FA3;
  padding: 0 12px 0 11px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  margin-top: 12px;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.logout-btn svg {
  width: 20px;
  height: 20px;
  color: #929DB4;
}

.logout-btn:hover svg {
  color: var(--red);
}

.logout-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

.workspace {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 36px 48px 60px;
  overflow-y: auto;
}

.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 28px;
  gap: 20px;
}

.view-header h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.view-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14.5px;
}

/* --- czaty --- */

/* chat palette, scoped like the menu palette */
#view-czaty {
  --chat-line: #17212C;
  --chat-card: #0F151C;
  --chat-card-line: #1C2430;
  --chat-field: #101720;
  --chat-field-line: #202A36;
  --chat-tile: #131B25;
  --chat-tile-line: #1E2834;
  --chat-avatar: #1E2836;
  --chat-selected: #112135;
  --chat-icon: #B0C7E6;
  --chat-label: #AEBCD0;
  --chat-row: #C6D6EA;
  --chat-time: #6C7D8F;
}

.chat-layout {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  min-height: 420px;
}

/* Czaty go full-screen on every device: no section header, no card chrome;
   the thread fills everything below the topbar/sidebar, like a real
   messaging app. */
.workspace:has(#view-czaty.active) {
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#view-czaty.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#view-czaty .view-header {
  display: none;
}

#view-czaty .chat-layout {
  flex: 1;
  min-height: 0;
  border: none;
  border-radius: 0;
  background: none;
}

#view-czaty .chat-main {
  min-height: 0;
}

/* channel list: docked flush against the thread on wide screens, a sliding drawer with a
   dim backdrop on narrower desktops and phones (see the responsive block) */
.chat-channels {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 6;
  display: none;
  flex-direction: column;
  gap: 16px;
  width: 238px;
  padding: 16px 13px 13px;
  overflow-y: auto;
  background: var(--chat-card);
  border-right: 1px solid var(--chat-card-line);
}

@media (min-width: 1180px) {
  .chat-channels {
    display: flex;
  }

  .chat-layout.channels-collapsed .chat-channels {
    display: none;
  }

  .chat-layout:not(.channels-collapsed) .chat-main {
    padding-left: 239px;
  }
}

@media (min-width: 861px) and (max-width: 1179px) {
  .chat-channels {
    display: flex;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .chat-channels.open {
    transform: translateX(0);
  }

  .channels-overlay {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 5;
    background: rgba(3, 5, 9, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .channels-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }
}

.chat-channels-head {
  display: none;
  align-items: center;
  justify-content: space-between;
}

.chat-channels-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.chat-channels-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-right: -8px;
  background: none;
  border: none;
  border-radius: 10px;
  color: #C4CCDF;
}

.chat-channels-close svg {
  width: 22px;
  height: 22px;
}

.chat-search {
  position: relative;
  display: block;
  flex-shrink: 0;
}

.chat-search svg {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  color: var(--chat-label);
  pointer-events: none;
}

.chat-search input {
  width: 100%;
  height: 32px;
  padding: 0 10px 0 33px;
  background: var(--chat-field);
  border: 1px solid var(--chat-field-line);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chat-channels-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-channel-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-channels-group[hidden],
.channel[hidden] {
  display: none;
}

.chat-channels-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 26px;
  margin-bottom: 3px;
  padding-left: 4px;
}

.chat-channels-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--chat-label);
}

.chat-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background: var(--chat-tile);
  border: 1px solid var(--chat-tile-line);
  border-radius: 7px;
  color: var(--chat-icon);
}

.chat-add-btn svg {
  width: 13px;
  height: 13px;
}

.chat-channels-empty {
  margin: 0;
  padding: 6px 4px;
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}

.channels-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 37px;
  height: 37px;
  flex-shrink: 0;
  padding: 0;
  background: var(--chat-tile);
  border: 1px solid var(--chat-tile-line);
  border-radius: 9px;
  color: var(--chat-icon);
}

.channels-toggle svg {
  width: 18px;
  height: 18px;
}

.channels-overlay {
  display: none;
}

.channel {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  background: none;
  border: none;
  border-radius: 9px;
  color: var(--chat-row);
  font-family: var(--font-ui);
  font-size: 13.5px;
  text-align: left;
}

.channel-hash {
  flex-shrink: 0;
  width: 14px;
  font-size: 15px;
  text-align: center;
  color: var(--chat-label);
}

@media (hover: hover) {
  .channel:hover {
    background: rgba(255, 255, 255, 0.035);
  }
}

.channel.active {
  background: var(--chat-selected);
  color: #fff;
}

.badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  height: 20px;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 10px;
  text-align: center;
}

.channel.dm {
  min-height: 37px;
  padding-left: 6px;
}

.dm-avatar {
  width: 27px;
  height: 27px;
  border-radius: 8px;
  background: var(--chat-avatar);
  color: #B9D0EA;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
}

.channel.dm .rank-badge {
  margin-left: auto;
}

.rank-badge {
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 13px;
  letter-spacing: 0.04em;
  padding: 3px 7px;
  border-radius: 6px;
  flex-shrink: 0;
}

.rank-badge.rank-ceo {
  color: #F5B031;
  background: #2B2217;
}

.rank-badge.rank-mng {
  color: #84BFF3;
  background: #132741;
}

.rank-badge.rank-devplus {
  color: #66E0A8;
  background: #17302B;
}

.rank-badge.rank-dev {
  color: #B7C4D8;
  background: #1E2938;
}

.chat-thread {
  display: flex;
  flex-direction: column;
  padding: 22px 28px 12px 24px;
}

.chat-day {
  position: relative;
  display: flex;
  justify-content: center;
  margin-bottom: 22px;
}

.chat-day::before {
  content: '';
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 1px;
  background: var(--chat-line);
}

.chat-day span {
  position: relative;
  padding: 4px 13px;
  background: var(--bg);
  border: 1px solid #1A222D;
  border-radius: 9px;
  font-size: 12px;
  color: #B4C1D4;
}

/* hint in a thread without messages; margin: auto centres it inside the flex column */
.chat-empty {
  max-width: 34ch;
  margin: auto;
  padding: 24px 0;
  text-align: center;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-muted);
}

.chat-empty strong {
  display: block;
  margin-bottom: 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.chat-empty p {
  margin: 0;
  overflow-wrap: anywhere;
}

.chat-msg {
  position: relative;
  display: flex;
  gap: 14px;
  margin-top: 20px;
  border-radius: 6px;
  touch-action: pan-y;
}

.chat-msg:first-child,
.chat-day + .chat-msg {
  margin-top: 0;
}

.chat-msg.swiping {
  transition: none;
}

.chat-msg.swipe-reset {
  transition: transform 0.2s ease;
}

.chat-reply-btn {
  position: absolute;
  top: -6px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--border-field);
  color: var(--text-muted);
  border-radius: 7px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.chat-reply-btn svg {
  width: 14px;
  height: 14px;
}

.chat-msg:hover .chat-reply-btn {
  opacity: 1;
  pointer-events: auto;
}

.chat-reply-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.chat-reply-quote {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 4px 0 4px;
  padding: 5px 10px;
  border-left: 2px solid var(--accent);
  background: var(--raised);
  border-radius: 0 6px 6px 0;
  font-size: 12.5px;
  max-width: 100%;
  min-width: 0;
  cursor: pointer;
}

.chat-reply-quote:hover {
  background: var(--raised-hover, var(--raised));
  border-left-color: var(--accent-focus);
}

.chat-msg.highlight-flash .chat-body p {
  display: inline-block;
  padding: 1px 4px;
  margin-left: -4px;
  border-radius: 4px;
  animation: chat-highlight-flash 1s ease-out;
}

@keyframes chat-highlight-flash {
  0% { background: color-mix(in srgb, var(--accent) 35%, transparent); }
  100% { background: transparent; }
}

.chat-reply-name {
  color: var(--accent-text);
  font-weight: 600;
  flex-shrink: 0;
}

.chat-reply-text {
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* --- reply preview above the composer --- */

.chat-reply-preview[hidden] {
  display: none;
}

.chat-reply-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 20px 8px 14px;
  padding: 8px 12px;
  border: 1px solid var(--chat-field-line);
  border-radius: 10px;
  background: var(--chat-field);
}

.chat-reply-preview svg {
  width: 15px;
  height: 15px;
  color: var(--accent-text);
  flex-shrink: 0;
}

.chat-reply-preview-body {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.chat-reply-preview-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-text);
  flex-shrink: 0;
}

.chat-reply-preview-text {
  font-size: 12.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-reply-preview-close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-dim);
  border-radius: 6px;
}

.chat-reply-preview-close svg {
  width: 13px;
  height: 13px;
  color: inherit;
}

.chat-reply-preview-close:hover {
  background: var(--panel);
  color: var(--text);
}

.chat-msg.stacked {
  margin-top: 2px;
}

.chat-msg.stacked:hover {
  background: var(--raised);
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--chat-avatar);
  color: var(--chat-icon);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 17px;
  flex-shrink: 0;
}

.chat-avatar-spacer {
  width: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  opacity: 0;
}

.chat-msg.stacked:hover .chat-avatar-spacer {
  opacity: 1;
}

.chat-body {
  min-width: 0;
  flex: 1;
}

.chat-body p {
  margin: 3px 0 0;
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  max-width: 56ch;
  overflow-wrap: anywhere;
}

.chat-msg.stacked .chat-body p {
  margin-top: 0;
}

.chat-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 21px;
}

.chat-name {
  font-size: 14px;
  font-weight: 700;
}

.chat-time {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--chat-time);
}

.chat-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.chat-thread-head {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  height: 64px;
  padding: 0 20px 0 14px;
  border-bottom: 1px solid var(--chat-line);
}

.chat-thread-title {
  min-width: 0;
  margin-left: 18px;
  overflow: hidden;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-hash {
  font-weight: 400;
  color: #B8CDEA;
}

#chat-thread-rank {
  margin-left: 10px;
}

.chat-head-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-left: auto;
  padding-left: 12px;
}

.chat-head-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 37px;
  height: 37px;
  padding: 0;
  background: var(--chat-tile);
  border: 1px solid var(--chat-tile-line);
  border-radius: 9px;
  color: var(--chat-icon);
}

.chat-head-icon svg {
  width: 17px;
  height: 17px;
}

.chat-head-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 33px;
  margin-left: 20px;
  border-radius: 8px;
  background-color: #F39D35;
  color: #1a1206;
  font-size: 15px;
  font-weight: 700;
}

.call-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 37px;
  padding: 0 16px;
  background: var(--chat-tile);
  border: 1px solid var(--chat-tile-line);
  border-radius: 9px;
  color: #C3D4EC;
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.call-btn svg {
  width: 16px;
  height: 16px;
}

.call-btn:hover {
  border-color: var(--green);
  color: var(--green);
}

.chat-main .chat-thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.chat-composer {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0 20px 16px 14px;
  padding: 12px;
  border: 1px solid var(--chat-field-line);
  border-radius: 12px;
}

.chat-input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.chat-input-wrap input {
  width: 100%;
  height: 38px;
  padding: 0 44px 0 14px;
  background: var(--chat-field);
  border: 1px solid var(--chat-field-line);
  border-radius: 9px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chat-emoji-btn {
  position: absolute;
  top: 50%;
  right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  transform: translateY(-50%);
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--chat-icon);
}

.chat-emoji-btn svg {
  width: 18px;
  height: 18px;
}

.chat-composer input::placeholder {
  color: var(--text-dim);
}

.chat-send-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent-rim);
  border-radius: 9px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.chat-send-btn svg {
  width: 17px;
  height: 17px;
}

.chat-attach-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--chat-tile);
  border: 1px solid var(--chat-tile-line);
  color: var(--chat-icon);
  border-radius: 9px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.chat-attach-btn svg {
  width: 17px;
  height: 17px;
}

.chat-attachment-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 20px 8px 14px;
  padding: 8px 12px;
  border: 1px solid var(--chat-field-line);
  border-radius: 10px;
  background: var(--chat-field);
}

.chat-attachment-preview[hidden] {
  display: none;
}

.chat-attachment-preview .thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-attachment-preview .file-icon {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.chat-attachment-preview .file-icon svg {
  width: 18px;
  height: 18px;
}

.chat-attachment-preview .file-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-attachment-preview .remove-attachment {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-dim);
  border-radius: 6px;
}

.chat-attachment-preview .remove-attachment svg {
  width: 14px;
  height: 14px;
}

.chat-attachment-preview .remove-attachment:hover {
  background: var(--panel);
  color: var(--red);
}

.chat-attachment {
  margin-top: 8px;
}

.chat-attachment img {
  max-width: 260px;
  max-height: 200px;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  display: block;
}

.chat-attachment-file {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  max-width: 300px;
  margin-top: 8px;
  padding: 7px 14px 7px 7px;
  background: #0F171F;
  border: 1px solid #242D3B;
  border-radius: 10px;
}

.chat-attachment-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #17202C, #1E2939);
  border-radius: 8px;
  color: var(--chat-icon);
}

.chat-attachment-icon svg {
  width: 19px;
  height: 19px;
}

.chat-attachment-meta {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.chat-attachment-name {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-attachment-size {
  font-size: 11.5px;
  color: var(--text-muted);
}

.chat-attachment-dl {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--chat-icon);
}

.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 80;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.lightbox-overlay.open {
  display: flex;
}

.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.lightbox-close {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
}

.lightbox-close svg {
  width: 18px;
  height: 18px;
}

.lightbox-close:hover {
  border-color: var(--text-muted);
}

/* --- call screen --- */

.call-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(9, 11, 14, 0.92);
  backdrop-filter: blur(6px);
  z-index: 90;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.call-overlay.open {
  display: flex;
}

.call-overlay.leaving {
  opacity: 0;
}

.call-overlay.leaving .call-screen {
  transform: scale(0.9);
}

.call-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px;
  transition: transform 0.25s ease, width 0.2s ease, height 0.2s ease;
}

/* status/avatar/name/rank/timer: a plain stack of flex children in a voice call (`display:
   contents` takes the wrapper itself out of layout), a small overlay pill once video is on */
.call-info {
  display: contents;
}

/* controls + hangup: likewise a no-op wrapper in a voice call, a floating bottom bar once video
   is on - same two children as before (`.call-controls`, the hangup button), just grouped so both
   layout modes can be expressed as a couple of rules each instead of repositioning five elements */
.call-chrome {
  display: contents;
}

.call-status {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.call-avatar {
  width: 96px;
  height: 96px;
  border-radius: 24px;
  background-color: var(--amber);
  color: #1a1206;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 6px;
}

/* replaces .call-avatar the instant the call connects - full-bleed, one tile per participant from
   then on, camera/screen-share if they have one on, their initial otherwise, same as Discord.
   Always full-bleed because the stage is only ever visible once connected (`hidden` otherwise) -
   there is no separate "boxed" layout to maintain here.
   Two zones: .call-video-main (empty and collapsed until a tile is pinned) and .call-video-grid
   (every tile, arranged as an even grid normally - tapping a tile moves its real DOM node into
   .call-video-main instead and the grid becomes a filmstrip of everyone else, Discord-style). */
.call-video-stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.call-video-main {
  flex: 1;
  position: relative;
  display: none;
}

.call-video-stage.focused .call-video-main {
  display: block;
}

.call-video-main .call-video-tile {
  position: absolute;
  inset: 0;
}

.call-video-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  grid-auto-rows: 1fr;
  gap: 4px;
}

/* Discord-like sizing for the common small counts; auto-fit above already does fine for a crowd */
.call-video-grid[data-count="1"] { grid-template-columns: 1fr; }
.call-video-grid[data-count="2"] { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* once something is pinned, the grid becomes a short, horizontally-scrolling filmstrip instead */
.call-video-stage.focused .call-video-grid {
  flex: 0 0 96px;
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  gap: 4px;
}

.call-video-stage.focused .call-video-grid .call-video-tile {
  flex: 0 0 120px;
  width: 120px;
}

@keyframes call-tile-in {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.call-video-tile {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: var(--raised);
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s ease;
  animation: call-tile-in 0.2s ease;
}

.call-video-tile.speaking {
  border-color: var(--ok-text);
}

.call-video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.call-video-tile-avatar {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--amber);
  color: #1a1206;
  font-size: clamp(20px, 8vw, 48px);
  font-weight: 700;
}

.call-video-tile-info {
  position: absolute;
  left: 8px;
  bottom: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.call-video-tile-name {
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(10, 14, 19, 0.65);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-video-tile-mic-off {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--danger);
  color: #fff;
}

.call-video-tile-mic-off svg {
  width: 13px;
  height: 13px;
}

.call-name {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}

.call-timer {
  font-size: 14px;
  color: var(--text-dim);
  margin: 6px 0 32px;
}

/* ---- full-bleed video mode: the moment a camera or shared screen is on anywhere in the call,
   the video grid fills the whole screen (Discord-style) and the rest becomes two small overlays
   instead of a centered stack - a status pill top-left, a floating control bar at the bottom */
.call-screen.has-video {
  width: 100%;
  height: 100%;
  max-width: none;
  padding: 0;
  gap: 0;
  justify-content: flex-end;
}

.call-screen.has-video .call-info {
  display: flex;
  align-items: center;
  gap: 8px;
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 1;
  padding: 6px 14px 6px 6px;
  border-radius: 999px;
  background: rgba(10, 14, 19, 0.65);
}

.call-screen.has-video .call-info .call-avatar { width: 30px; height: 30px; border-radius: 10px; font-size: 14px; margin: 0; }
.call-screen.has-video .call-info .call-name { font-size: 14px; }
.call-screen.has-video .call-info .call-status { margin: 0; font-size: 12px; }
.call-screen.has-video .call-info .call-timer { margin: 0; font-size: 12px; }
.call-screen.has-video .call-info .rank-badge { transform: scale(0.85); }

.call-screen.has-video .call-chrome {
  display: flex;
  align-items: center;
  gap: 18px;
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, rgba(10, 14, 19, 0.85), transparent);
  justify-content: center;
}

.call-screen.has-video .call-controls {
  gap: 10px;
}

.call-screen.has-video .call-hangup-btn {
  margin-top: 0;
}

.call-screen.has-video .call-minimize-btn {
  /* the un-prefixed rule floats this above the card by its own height, which only makes sense
     when the card is a small centered box with room above it - full-bleed video has no such
     room, so here it moves back onto the screen instead */
  top: 16px;
  right: 16px;
  z-index: 2;
  background: rgba(10, 14, 19, 0.65);
  border-color: transparent;
}

.call-hangup-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.15s ease;
}

.call-hangup-btn svg {
  width: 24px;
  height: 24px;
}

.call-hangup-btn:hover {
  filter: brightness(1.1);
}

.call-overlay .call-hangup-btn {
  margin-top: 22px;
}

.call-minimize-btn {
  position: absolute;
  top: -44px;
  right: 0;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--border-field);
  color: var(--text-muted);
  border-radius: 8px;
}

.call-minimize-btn svg {
  width: 16px;
  height: 16px;
}

.call-screen {
  position: relative;
}

.call-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 28px 0 6px;
}

.call-control-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px;
}

.call-control-btn svg {
  width: 22px;
  height: 22px;
}

.call-control-btn svg[hidden] {
  display: none;
}

.call-control-btn > span:last-child {
  font-size: 11px;
  color: var(--text-dim);
}

.call-control-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--raised);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.call-control-btn:hover .call-control-icon {
  border-color: var(--text-muted);
}

.call-control-btn[aria-pressed="true"] .call-control-icon {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* anchors the device picker right under the "Urządzenia" button, not a centered modal */
.call-devices-wrap {
  position: relative;
}

.call-devices-panel {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  min-width: 220px;
  max-width: calc(100vw - 32px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  text-align: left;
}

.call-devices-panel select {
  width: 100%;
}

/* --- floating call bar: stays visible over every tab while a call is active --- */

.call-bar[hidden] {
  display: none;
}

.call-bar {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.call-bar.dragging {
  transition: none;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  cursor: grabbing;
  opacity: 0.95;
}

.call-bar.leaving {
  opacity: 0;
  transform: scale(0.85) translateY(12px);
}

.call-bar-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 40px;
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  border-radius: 8px;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.call-bar-drag-handle svg {
  width: 12px;
  height: 20px;
  pointer-events: none;
}

.call-bar-drag-handle:hover {
  background: var(--raised);
  color: var(--text-muted);
}

.call-bar-drag-handle:active {
  cursor: grabbing;
  background: var(--raised);
}

.call-bar-main {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  padding: 4px 8px 4px 4px;
  border-radius: 10px;
  transition: background 0.15s ease;
}

.call-bar-main:hover {
  background: var(--raised);
}

.call-bar-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background-color: var(--amber);
  color: #1a1206;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}

.call-bar-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
  min-width: 0;
}

.call-bar-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.call-bar-status {
  font-size: 11px;
  color: var(--green);
}

.call-bar .call-timer {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 2px;
}

.call-bar .call-hangup-btn {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
}

.call-bar .call-hangup-btn svg {
  width: 17px;
  height: 17px;
}

@media (max-width: 860px) {
  .call-bar {
    right: 12px;
    bottom: 12px;
    justify-content: space-between;
  }

  .call-bar-name {
    max-width: 40vw;
  }
}

/* --- incoming call: a full screen that pops up when somebody calls (built by script.js) --- */

.incoming-call {
  z-index: 100;
}

.incoming-call-label {
  margin-bottom: 22px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.incoming-call-avatar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  margin-bottom: 18px;
}

.incoming-call-avatar .call-avatar {
  position: relative;
  margin-bottom: 0;
}

.incoming-call-ring {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(79, 203, 122, 0.6);
  border-radius: 24px;
  opacity: 0;
  animation: incoming-call-pulse 2s ease-out infinite;
}

.incoming-call-ring-late {
  animation-delay: 1s;
}

@keyframes incoming-call-pulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }

  100% {
    transform: scale(1.75);
    opacity: 0;
  }
}

.incoming-call-status {
  margin: 8px 0 44px;
  font-size: 14px;
  color: var(--text-muted);
}

.incoming-call-actions {
  display: flex;
  gap: 56px;
}

.incoming-call-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.incoming-call-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 68px;
  padding: 0;
  border: none;
  border-radius: 50%;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.incoming-call-btn svg {
  width: 28px;
  height: 28px;
}

.incoming-call-btn.decline {
  background: var(--danger);
}

.incoming-call-btn.decline svg {
  transform: rotate(135deg);
}

.incoming-call-btn.accept {
  background: #25A35A;
}

.incoming-call-btn:active {
  transform: scale(0.94);
}

@media (hover: hover) {
  .incoming-call-btn:hover {
    filter: brightness(1.12);
  }
}

@media (prefers-reduced-motion: reduce) {
  .incoming-call-ring {
    animation: none;
  }
}

/* --- todo --- */

.todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.todo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.todo-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-size: 14.5px;
}

.todo-id {
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.todo-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.todo-title.high {
  color: var(--red);
  font-weight: 600;
}

.todo-item.done .todo-title {
  color: var(--text-dim);
  text-decoration: line-through;
}

.todo-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.todo-details-btn,
.expense-info-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border-field);
  color: var(--text-muted);
  border-radius: 7px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.todo-details-btn svg,
.expense-info-btn svg {
  width: 15px;
  height: 15px;
}

.empty-state {
  list-style: none;
  padding: 32px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.todo-claim-btn {
  flex-shrink: 0;
  background: var(--raised);
  border: 1px solid var(--btn-border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.todo-assignee {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.todo-assignee .dot {
  background: var(--warn-text);
  box-shadow: 0 0 0 3px rgba(237, 206, 105, 0.18);
}

.todo-assignee.done {
  color: var(--text-dim);
}

.todo-assignee.done .dot {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(79, 203, 122, 0.18);
}

/* --- ogłoszenia --- */

.announcement {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 24px;
  margin-bottom: 14px;
}

.announcement.pinned {
  border-color: rgba(26, 148, 240, 0.45);
  background: linear-gradient(180deg, rgba(16, 120, 254, 0.07), transparent 45%), var(--panel);
}

.announcement-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.announcement-head-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pin {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-text);
  font-family: var(--font-mono);
}

.announcement-date {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.announcement h2 {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 600;
}

.announcement p {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  max-width: 64ch;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.announcement-author {
  font-size: 12.5px;
  color: var(--text-dim);
}

/* --- wydatki --- */

.view-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.total-chip {
  font-size: 13.5px;
  color: var(--text-muted);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  white-space: nowrap;
}

.add-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent-rim);
  border-radius: 8px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.add-btn svg {
  width: 17px;
  height: 17px;
}

.total-chip strong {
  color: var(--text);
  font-family: var(--font-mono);
  font-weight: 500;
}

.expenses-table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
  max-width: 100%;
}

.expenses-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 13.5px;
}

.expenses-table th {
  text-align: left;
  font-weight: 500;
  color: var(--text-dim);
  font-size: 11.5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.expenses-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.expenses-table tr:last-child td { border-bottom: none; }

.expenses-table .num {
  text-align: right;
  font-family: var(--font-mono);
}

.cat {
  font-size: 11px;
  padding: 2px 9px;
  border: 1px solid transparent;
  border-radius: 20px;
  font-weight: 600;
}

.cat-infra {
  background: #0B78FD;
  color: #fff;
}

.cat-tools {
  background: #252E3B;
  border-color: #2E3948;
  color: #E2E8F0;
}

.cat-other {
  background: var(--purple);
  color: #fff;
}

/* --- dziennik --- */

.log-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.log-entry {
  display: flex;
  gap: 20px;
  padding: 18px 4px;
  border-bottom: 1px solid var(--border);
}

.log-entry:last-child { border-bottom: none; }

.log-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-self: flex-start;
}

.log-date {
  width: 56px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 2px;
}

.log-day {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: lowercase;
}

.log-daynum {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.log-range {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 6px;
}

.log-duration {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent-text);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 5px;
  margin-left: 4px;
}

.log-detail p {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 62ch;
}

.log-detail .log-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.log-attachment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 7px 12px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 7px;
  max-width: 260px;
}

.log-attachment svg {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.log-attachment span {
  font-size: 12.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- modals --- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 60;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.modal-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.modal-tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  background: var(--raised);
  padding: 3px 8px;
  border-radius: 5px;
}

.modal-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  border-radius: 6px;
}

.modal-close svg { width: 15px; height: 15px; }

.modal-close:hover {
  background: var(--raised);
  color: var(--text);
}

.task-modal h2,
.expense-info-modal h2,
.control-modal h2 {
  margin: 0 0 12px;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.35;
}

.modal-desc {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
}

.modal-meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 22px;
  padding: 16px;
  background: var(--raised);
  border-radius: 10px;
}

.modal-meta div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.modal-meta dt {
  color: var(--text-dim);
}

.modal-meta dd {
  margin: 0;
  color: var(--text);
  font-weight: 500;
  text-align: right;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.modal-form #log-task-fields,
.modal-form #log-other-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-form #log-task-fields[hidden],
.modal-form #log-other-fields[hidden],
.modal-form label[hidden] {
  display: none;
}

.modal-hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--info-text);
  line-height: 1.5;
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  padding: 10px 12px;
  border-radius: 8px;
}

.modal-hint-inline {
  color: var(--text-dim);
  font-weight: 400;
}

/* input with a fixed "#" in front of it (channel name) */
.modal-input-prefix {
  position: relative;
  display: block;
}

.modal-input-prefix > span {
  position: absolute;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.modal-input-prefix input {
  width: 100%;
  padding-left: 30px;
}

.modal-form-row {
  display: flex;
  gap: 14px;
}

.modal-form-row label {
  flex: 1;
}

.modal-form input,
.modal-form select,
.modal-form textarea {
  background: var(--field);
  border: 1px solid var(--border-field);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  padding: 11px 14px;
  border-radius: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.modal-form textarea {
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}

.modal-form input[type="file"] {
  padding: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.modal-form input[type="file"]::file-selector-button {
  background: var(--raised);
  border: 1px solid var(--btn-border);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: 6px;
  margin-right: 10px;
  cursor: pointer;
}

.modal-submit-btn {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent-rim);
  padding: 11px 20px;
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}

/* --- przycinanie zdjęcia profilowego --- */

.avatar-crop-stage {
  position: relative;
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 14px;
  background: var(--raised);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.avatar-crop-stage:active {
  cursor: grabbing;
}

.avatar-crop-image {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}

.avatar-crop-zoom-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.avatar-crop-zoom-icon {
  width: 16px;
  height: 16px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.avatar-crop-zoom-range {
  flex: 1;
  accent-color: var(--accent);
}

.avatar-crop-actions {
  gap: 10px;
  margin-top: 20px;
}

/* ============ TOUCH SCREENS ============ */

/* iOS Safari zooms into a field whose font is under 16px when it gets focus. The phone layout
   below sets 16px already; this covers touch screens that are wider than that (landscape,
   tablets). The Planer title is bigger than 16px anyway. */
@media (pointer: coarse) {
  input:not(.planner-name-input),
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* ============ RESPONSIVE ============ */

@media (max-width: 860px) {
  .login-frame { margin-left: 6vw; margin-right: 6vw; }
  .login-body { padding-top: 14vh; }
  .login-top .brand-logo { height: 36px; }

  /* iOS Safari zooms the whole page in on focus if a text input's
     font-size is under 16px, which is the "page grows" bug on mobile. */
  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  .todo-id {
    display: none;
  }

  #workspace-screen {
    flex-direction: column;
  }

  .mobile-topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    height: 56px;
    padding: 0 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--divider);
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .mobile-topbar .menu-toggle {
    justify-self: start;
  }

  .mobile-topbar .session-avatar {
    justify-self: end;
    width: 30px;
    height: 30px;
    border-radius: 8px;
  }

  .menu-toggle,
  .menu-close {
    display: flex;
  }

  .menu-close {
    margin-left: auto;
  }

  /* drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    width: min(282px, 82vw);
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.35);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-top { display: flex; }
  .session-card { display: flex; }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    z-index: 30;
  }

  .sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  .nav-item span { display: inline; }
  .workspace { padding: 20px 18px 40px; }
  .view-header { flex-wrap: wrap; }

  /* Czaty on phones: two header rows, drawer with the channel list, roomier composer */
  .chat-layout {
    overflow: visible;
  }

  .chat-thread-head {
    height: 71px;
    padding: 0 14px 0 16px;
  }

  .channels-toggle {
    width: 43px;
    height: 39px;
  }

  .chat-thread-title {
    margin-left: 20px;
  }

  .call-btn {
    height: 39px;
    padding: 0 15px;
  }

  .chat-head-icon,
  .chat-head-avatar,
  .chat-day {
    display: none;
  }

  .chat-thread {
    padding: 20px 20px 14px;
  }

  .chat-msg {
    gap: 14px;
    margin-top: 26px;
  }

  .chat-name {
    font-size: 15px;
  }

  .chat-time {
    font-size: 13px;
  }

  .chat-body p {
    margin-top: 4px;
    font-size: 15px;
    line-height: 24px;
  }

  .chat-composer {
    gap: 12px;
    margin: 0;
    padding: 17px 14px calc(14px + env(safe-area-inset-bottom, 0px));
    border: none;
    border-top: 1px solid var(--chat-line);
    border-radius: 0;
  }

  .chat-attach-btn,
  .chat-send-btn {
    width: 47px;
    height: 47px;
    border-radius: 11px;
  }

  .chat-input-wrap input {
    height: 47px;
    padding-left: 15px;
    border-radius: 11px;
  }

  .chat-emoji-btn {
    right: 8px;
  }

  .chat-reply-preview,
  .chat-attachment-preview {
    margin: 0 14px 8px;
  }

  .chat-channels {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    display: flex;
    gap: 20px;
    width: min(306px, 78vw);
    height: 100vh;
    height: 100dvh;
    max-height: none;
    padding: 20px 16px 24px;
    background: var(--chat-card);
    border: none;
    border-radius: 0 16px 16px 0;
    box-shadow: 12px 0 32px rgba(0, 0, 0, 0.45);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }

  .chat-channels.open {
    transform: translateX(0);
  }

  .chat-channels-head {
    display: flex;
  }

  .chat-search svg {
    left: 14px;
    width: 18px;
    height: 18px;
  }

  .chat-search input {
    height: 46px;
    padding-left: 42px;
    border-radius: 9px;
  }

  .chat-channels-label {
    font-size: 14px;
  }

  .chat-add-btn {
    width: 33px;
    height: 32px;
  }

  .chat-add-btn svg {
    width: 15px;
    height: 15px;
  }

  .chat-channels-group,
  .chat-channel-list {
    gap: 0;
  }

  .channel {
    min-height: 42px;
    padding: 0 12px;
    font-size: 15px;
  }

  .channel-hash {
    width: 16px;
    font-size: 18px;
  }

  .channel.dm {
    min-height: 44px;
    padding-left: 8px;
  }

  .dm-avatar {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .channels-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(3, 5, 9, 0.66);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }

  .channels-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }
}

/* --- sidebar divider --- */

.nav-divider {
  display: block;
  height: 1px;
  margin: 8px 7px 8px 11px;
  background: var(--menu-line);
}

/* --- Użytkownicy view --- */

.users-table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
  max-width: 100%;
}

.users-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 13.5px;
}

.users-table th {
  text-align: left;
  font-weight: 500;
  color: var(--text-dim);
  font-size: 11.5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.users-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.users-table tr:last-child td { border-bottom: none; }

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-cell-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--raised);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.user-cell-avatar.small {
  width: 22px;
  height: 22px;
  font-size: 10.5px;
}

.user-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.user-row-disabled { opacity: 0.55; }

.user-status .dot {
  background: var(--text-dim);
  box-shadow: none;
}

.user-status.online {
  color: var(--text-muted);
}

.user-status.online .dot {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(79, 203, 122, 0.18);
}

.user-actions {
  text-align: right;
}

.user-perms-btn,
.user-activity-btn,
.user-manage-btn,
.user-remove-btn {
  background: none;
  border: 1px solid var(--border-field);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 7px;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.user-activity-btn,
.user-manage-btn,
.user-perms-btn {
  margin-right: 6px;
}

.user-remove-btn {
  color: var(--err-text);
  border-color: var(--err-border);
}

.user-manage-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* phones: every row becomes a small card, the person with status and rank on top, the buttons below */
@media (max-width: 700px) {
  .users-table,
  .users-table tbody {
    display: block;
    min-width: 0;
  }

  .users-table thead {
    display: none;
  }

  .users-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }

  .users-table tr:last-child {
    border-bottom: none;
  }

  .users-table td {
    padding: 0;
    border-bottom: none;
  }

  .users-table .user-cell {
    min-width: 0;
  }

  .users-table .user-cell span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* the cells are written person, rank, status, buttons; on the card the status comes before the rank */
  .users-table .user-status-cell {
    order: 1;
  }

  .users-table .user-rank-cell {
    order: 2;
  }

  .users-table .user-actions {
    order: 3;
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px;
  }

  .users-table .user-activity-btn,
  .users-table .user-manage-btn,
  .users-table .user-perms-btn {
    margin-right: 0;
  }
}

/* --- Aktywność użytkownika (window opened from the Użytkownicy table) --- */

.activity-modal {
  max-width: 520px;
}

.activity-user,
.manage-user {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-bottom: 16px;
}

.activity-user-name,
.manage-user-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 600;
}

.activity-user .user-status,
.manage-user .user-status {
  margin-left: auto;
  flex-shrink: 0;
}

.activity-modal .modal-meta {
  margin-bottom: 8px;
}

.activity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.activity-table th {
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 500;
  text-align: left;
  color: var(--text-dim);
}

.activity-table th:last-child {
  text-align: right;
}

.activity-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.activity-table tr:last-child td {
  border-bottom: none;
}

.activity-table .activity-day th {
  padding: 16px 8px 6px;
  border-bottom: none;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  color: var(--text-muted);
}

.activity-table .activity-span {
  text-align: right;
  white-space: nowrap;
  color: var(--text-muted);
}

.activity-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ok-text);
}

.activity-next-day {
  margin-left: 4px;
  font-size: 11px;
  color: var(--text-dim);
}

.activity-empty {
  margin: 0;
  padding: 18px 0 4px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
}

/* --- Zarządzanie użytkownikiem (window opened from the Użytkownicy table) --- */

.manage-modal {
  max-width: 640px;
}

.manage-tabs {
  margin-bottom: 16px;
  overflow-x: auto;
}

.manage-tabs .perms-tab {
  padding-left: 14px;
  padding-right: 14px;
  white-space: nowrap;
}

.manage-balance {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 16px;
  margin-bottom: 16px;
  background: var(--raised);
  border-radius: 10px;
}

.manage-balance-main,
.manage-balance-side {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.manage-balance-side {
  align-items: flex-end;
  text-align: right;
}

.manage-balance-label {
  font-size: 12px;
  color: var(--text-dim);
}

.manage-balance-amount {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
}

.manage-balance-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.manage-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.manage-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

.manage-form-actions .control-file-btn {
  align-self: auto;
}

.manage-modal .modal-subhead {
  margin: 22px 0 6px;
}

.manage-history {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.manage-entry {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.manage-entry:last-child,
.manage-item:last-child {
  border-bottom: none;
}

.manage-entry-date {
  font-size: 12px;
  color: var(--text-dim);
}

.manage-entry-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-width: 0;
}

.manage-entry-note {
  overflow-wrap: anywhere;
  color: var(--text-muted);
}

.manage-entry-amount {
  font-family: var(--font-mono);
  font-weight: 600;
  white-space: nowrap;
  color: var(--text);
}

.manage-entry-amount.plus {
  color: var(--ok-text);
}

.manage-kind {
  padding: 2px 9px;
  border: 1px solid transparent;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.manage-kind-accrual,
.manage-kind-done {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok-text);
}

.manage-kind-payout,
.manage-kind-open {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info-text);
}

.manage-kind-correction {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-text);
}

.manage-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.manage-item-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.manage-item-title {
  overflow-wrap: anywhere;
  font-weight: 500;
  color: var(--text);
}

.manage-item-meta {
  font-size: 12px;
  color: var(--text-dim);
}

.manage-empty {
  padding: 14px 0 4px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
}

@media (max-width: 520px) {
  .manage-form-row {
    grid-template-columns: 1fr;
  }

  .manage-entry {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .manage-entry-main {
    order: 3;
    grid-column: 1 / -1;
  }

  .manage-balance {
    flex-direction: column;
    align-items: flex-start;
  }

  .manage-balance-side {
    align-items: flex-start;
    text-align: left;
  }
}

/* --- Uprawnienia view --- */

.perms-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  align-items: start;
  min-height: 0;
}

.perms-layout > * {
  min-width: 0;
}

.perms-sidebar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.perms-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.perms-tab {
  flex: 1;
  background: none;
  border: none;
  color: #7C8DA3;
  font-size: 12.5px;
  font-weight: 600;
  padding: 12px 8px;
  transition: color 0.12s ease, background 0.12s ease;
}

.perms-tab:hover {
  color: var(--text);
}

.perms-tab.active {
  color: var(--accent-text);
  box-shadow: inset 0 -2px 0 var(--accent-focus);
}

.perms-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  max-height: 560px;
  overflow-y: auto;
}

.perms-list[hidden] {
  display: none;
}

.perms-list-item {
  display: flex;
  align-items: center;
  gap: 9px;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}

.perms-list-item:hover {
  background: var(--raised);
  color: var(--text);
}

.perms-list-item.active {
  background: var(--selected);
  color: var(--text);
}

.perms-list-item.add-role-btn {
  color: var(--accent-text);
  border: 1px dashed rgba(26, 148, 240, 0.45);
  margin-bottom: 4px;
}

.perms-list-item.add-role-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.perms-list-item.add-role-btn:hover {
  background: var(--accent-soft);
}

.perms-list-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.perms-list-rank {
  margin-left: auto;
}

.perms-detail {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px 26px;
  min-height: 400px;
}

.perms-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 350px;
  color: var(--text-dim);
  font-size: 13.5px;
  text-align: center;
  max-width: 320px;
  margin: 0 auto;
}

.perms-detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.perms-detail-head h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.perms-builtin-tag {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  background: var(--raised);
  padding: 2px 8px;
  border-radius: 20px;
}

.perms-role-select-label {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.perms-role-select {
  background: var(--field);
  border: 1px solid var(--border-field);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.perms-detail-hint {
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.5;
  max-width: 62ch;
  margin-bottom: 22px;
}

.perms-hint-rank {
  font-weight: 600;
}

.perm-groups {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.perm-group h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.perm-rows {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.perm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.perm-row:last-child { border-bottom: none; }

.perm-row-label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text);
}

.perm-effective {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 1px 7px;
  border-radius: 20px;
  font-weight: 600;
}

.perm-effective.yes {
  color: var(--green);
  background: rgba(79, 203, 122, 0.14);
}

.perm-effective.no {
  color: var(--red);
  background: rgba(242, 115, 104, 0.14);
}

.perm-toggle2,
.perm-toggle3 {
  display: flex;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.perm-btn2,
.perm-btn3 {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 12px;
  transition: background 0.12s ease, color 0.12s ease;
}

.perm-btn2:not(:last-child),
.perm-btn3:not(:last-child) {
  border-right: 1px solid var(--border);
}

.perm-btn2:hover,
.perm-btn3:hover {
  color: var(--text);
}

.perm-btn2.on {
  background: rgba(79, 203, 122, 0.14);
  color: var(--green);
}

.perm-btn2.off {
  background: rgba(242, 115, 104, 0.14);
  color: var(--red);
}

.perm-btn3.on.active {
  background: rgba(79, 203, 122, 0.14);
  color: var(--green);
}

.perm-btn3.neutral.active {
  background: var(--raised);
  color: var(--text-muted);
}

.perm-btn3.off.active {
  background: rgba(242, 115, 104, 0.14);
  color: var(--red);
}

@media (max-width: 860px) {
  .perms-layout {
    grid-template-columns: 1fr;
  }

  .perms-list {
    max-height: 260px;
  }

  .perm-row {
    flex-wrap: wrap;
  }
}

/* --- split rachunku (modal wydatków) --- */

.expense-split-checkbox {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  font-size: 13.5px !important;
  color: var(--text) !important;
  cursor: pointer;
}

.modal-checkbox-field {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  font-size: 13.5px !important;
  color: var(--text) !important;
  cursor: pointer;
}

.modal-form #expense-split-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 14px 16px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.modal-form #expense-split-fields[hidden] {
  display: none;
}

.split-people-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.split-person-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 9px;
  font-size: 13px !important;
  color: var(--text) !important;
  cursor: pointer;
}

.split-mode-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.split-mode-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 9px 10px;
  transition: background 0.12s ease, color 0.12s ease;
}

.split-mode-btn:not(:last-child) {
  border-right: 1px solid var(--border);
}

.split-mode-btn:hover {
  color: var(--text);
}

.split-mode-btn.active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.modal-form #split-unequal-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-form #split-unequal-fields[hidden] {
  display: none;
}

.split-amounts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.split-amount-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.split-amount-row span {
  font-size: 13px;
  color: var(--text);
}

.split-amount-row input {
  width: 110px;
  flex-shrink: 0;
}

.split-amounts-summary {
  margin: 0;
  font-size: 12px;
  color: var(--green);
  font-family: var(--font-mono);
}

.split-amounts-summary.split-amounts-summary-off {
  color: var(--red);
}

.split-tag {
  display: inline-block;
  margin-left: 8px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--raised);
  padding: 2px 7px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.split-tag:hover {
  color: var(--accent-text);
  background: var(--raised-hover);
}

/* --- szczegóły wydatku i podział rachunku (modale) --- */

.expenses-table .expense-actions {
  width: 1%;
  padding-left: 0;
  white-space: nowrap;
}

.expenses-table .expense-info-btn {
  margin-left: auto;
}

.modal-subhead {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.modal-meta .modal-meta-total {
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.modal-meta .modal-meta-warn dd {
  color: var(--red);
}

@media (max-width: 860px) {
  /* bigger tap target for the split tag on phones */
  .split-tag {
    padding: 6px 11px;
    font-size: 11px;
  }
}

/* --- role color picker (modal Nowa ranga) --- */

.color-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-form input[type="color"] {
  width: 44px;
  height: 40px;
  padding: 3px;
  flex-shrink: 0;
  cursor: pointer;
}

.modal-form input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.modal-form input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 5px;
}

.modal-form input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 5px;
}

.color-hex-input {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* --- Moje dokumenty --- */

.documents-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.document-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.document-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--raised);
  border-radius: 9px;
  color: var(--accent-text);
}

.document-icon svg {
  width: 18px;
  height: 18px;
}

.document-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.document-title-row {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.document-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.document-meta {
  font-size: 12px;
  color: var(--text-dim);
}

.document-meta strong {
  color: var(--text-muted);
  font-weight: 600;
}

.document-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.document-action-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border-field);
  border-radius: 8px;
  color: var(--text-muted);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.document-action-btn svg {
  width: 16px;
  height: 16px;
}

.cat-doc-umowa { background: #0B78FD; color: #fff; }
.cat-doc-zgoda { background: var(--purple); color: #fff; }
.cat-doc-rozliczenie { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-text); }
.cat-doc-zaswiadczenie { background: var(--err-bg); border-color: var(--err-border); color: var(--err-text); }
.cat-doc-inne { background: #252E3B; border-color: #2E3948; color: #E2E8F0; }

.document-preview-modal {
  max-width: 760px;
  width: calc(100% - 32px);
  height: calc(100vh - 80px);
  height: calc(100dvh - 80px);
  display: flex;
  flex-direction: column;
}

.document-preview-frame {
  flex: 1;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--raised);
}

/* --- Moje dane --- */

.mydata-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.mydata-grid > .mydata-card {
  min-width: 0;
}

.mydata-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 24px;
}

.mydata-card h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 16px;
}

.mydata-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mydata-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.mydata-form input,
.mydata-form select {
  background: var(--field);
  border: 1px solid var(--border-field);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  padding: 11px 14px;
  border-radius: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.mydata-save-btn {
  align-self: flex-start;
  padding: 9px 18px;
}

.mydata-profile {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.mydata-avatar {
  width: 72px;
  height: 72px;
  border-radius: 14px;
  background-color: var(--amber);
  color: #1a1206;
  flex-shrink: 0;
}

.mydata-avatar-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.mydata-avatar-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mydata-avatar-btn {
  background: none;
  border: 1px solid var(--border-field);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 7px;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.mydata-avatar-btn:hover {
  background: var(--raised);
  border-color: var(--border-hover);
  color: var(--text);
}

.mydata-avatar-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.mydata-avatar-remove-btn {
  color: var(--err-text);
  border-color: var(--err-border);
}

.mydata-avatar-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}

.mydata-balance-current {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding-bottom: 18px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.mydata-balance-label {
  font-size: 12px;
  color: var(--text-dim);
}

.mydata-balance-amount {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-mono);
}

.mydata-payout-btn {
  margin-top: 2px;
  padding: 9px 18px;
}

.mydata-salary-history-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.mydata-salary-history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mydata-salary-history-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.mydata-salary-history-list li > span:first-child {
  color: var(--text-dim);
  font-size: 12px;
  width: 78px;
  flex-shrink: 0;
}

.mydata-salary-history-list li > span:nth-child(2) {
  color: var(--text);
  font-weight: 500;
  flex: 1;
}

@media (max-width: 860px) {
  .document-card {
    flex-wrap: wrap;
  }

  .mydata-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Wystaw dokument --- */

.issue-doc-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}

.issue-doc-layout > .mydata-card {
  min-width: 0;
}

.issue-doc-list-card .documents-list {
  gap: 10px;
}

.issue-doc-empty {
  margin: 0;
  padding: 24px 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

@media (max-width: 900px) {
  .issue-doc-layout {
    grid-template-columns: 1fr;
  }
}

/* --- Kontrola (weryfikacja plików) --- */

.header-icon-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--raised);
  color: var(--text-muted);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.header-icon-btn svg {
  width: 18px;
  height: 18px;
}

.control-access {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.control-perm {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  white-space: nowrap;
}

.control-perm::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
}

.control-perm.yes {
  color: var(--text);
}

.control-perm.yes::before {
  background: var(--green);
}

.control-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-card .document-title {
  overflow-wrap: anywhere;
}

.control-card .document-meta .rank-badge {
  margin-left: 6px;
}

/* on phones the actions wrap under the title instead of squeezing it */
.control-card .document-info {
  flex: 1 1 200px;
}

.control-card .document-actions {
  align-items: center;
  margin-left: auto;
}

.control-version {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.control-card .document-meta {
  overflow-wrap: anywhere;
}

.control-modal .modal-meta dd {
  overflow-wrap: anywhere;
}

.control-status {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 9px;
  border: 1px solid transparent;
  border-radius: 20px;
  white-space: nowrap;
}

.control-status.pending { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.control-status.verified { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-text); }
.control-status.rejected { background: var(--err-bg); border-color: var(--err-border); color: var(--err-text); }

.document-action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.control-modal [hidden] {
  display: none !important;
}

.control-modal h2 {
  overflow-wrap: anywhere;
}

.control-verdict-note {
  margin: 0 0 20px;
  padding-left: 12px;
  border-left: 3px solid var(--border);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.control-text {
  margin: 0 0 20px;
  padding: 12px 14px;
  background: var(--raised);
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.control-download {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.control-file-btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--raised);
  border: 1px solid var(--btn-border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.control-file-btn svg {
  width: 16px;
  height: 16px;
}

.control-file-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.verdict-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.verdict-label {
  font-size: 13px;
  color: var(--text-muted);
}

.verdict-toggle {
  position: relative;
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.verdict-toggle input {
  position: absolute;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.modal-form .verdict-toggle label {
  flex: 1;
  display: block;
  padding: 10px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.modal-form .verdict-toggle label + input + label {
  border-left: 1px solid var(--border);
}

.verdict-toggle input:focus-visible + label {
  outline: 2px solid var(--accent-focus);
  outline-offset: -2px;
}

#control-verdict-ok:checked + label {
  background: rgba(79, 203, 122, 0.14);
  color: var(--green);
}

#control-verdict-bad:checked + label {
  background: rgba(242, 115, 104, 0.14);
  color: var(--red);
}

.control-rank-table {
  display: flex;
  flex-direction: column;
  padding: 2px 14px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.control-rank-row {
  display: grid;
  grid-template-columns: 1fr 74px 84px;
  align-items: center;
  gap: 8px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.control-rank-row:last-child {
  border-bottom: none;
}

.control-rank-head {
  padding: 10px 0 8px;
  font-size: 11.5px;
  color: var(--text-dim);
}

.control-rank-head span + span {
  justify-self: center;
}

.control-rank-row .rank-badge {
  justify-self: start;
  font-size: 11px;
  padding: 3px 8px;
}

.modal-form .control-rank-row input[type="checkbox"] {
  justify-self: center;
}

/* --- Materiały --- */

.control-id {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.control-status.published {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info-text);
}

.materials-section + .materials-section {
  margin-top: 26px;
}

.materials-heading {
  margin: 0 0 12px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.material-desc {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
}

.material-card {
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.material-card:hover {
  border-color: var(--text-dim);
}

.material-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 16px -4px;
  padding: 6px 10px 6px 4px;
  background: none;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.material-back svg {
  width: 16px;
  height: 16px;
}

.material-back:hover {
  background: var(--raised);
  color: var(--text);
}

.material-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 22px;
}

.material-head h1 {
  margin: 0 0 10px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.material-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.material-download-main {
  background: var(--accent);
  border-color: var(--accent-rim);
  color: #fff;
  font-weight: 600;
}

.material-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.material-tab {
  margin-bottom: -1px;
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13.5px;
  font-weight: 500;
  color: #7C8DA3;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.material-tab:hover {
  color: var(--text);
}

.material-tab.active {
  color: var(--accent-text);
  border-bottom-color: var(--accent-focus);
}

.material-about {
  margin: 0 0 26px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#material-info dd {
  overflow-wrap: anywhere;
}

.material-versions {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.material-version {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.material-version-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.material-version-label {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.material-version-date {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-dim);
}

.material-version-notes {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.material-version-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.material-version-meta {
  flex: 1 1 200px;
  min-width: 0;
  font-size: 12px;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}

@media (max-width: 860px) {
  .material-download-main {
    width: 100%;
    justify-content: center;
  }
}

/* ============ UI KIT: SHARED CONTROLS & STATES ============
   Kept at the very end on purpose: these rules refine the base rules above at
   equal specificity, so they have to come after every one of them. */

::selection {
  background: rgba(26, 148, 240, 0.35);
}

button:focus-visible {
  outline: 2px solid var(--accent-focus);
  outline-offset: 2px;
}

/* --- fields: placeholder, select chevron, focus glow, error, disabled --- */

input::placeholder,
textarea::placeholder {
  color: var(--text-dim);
  opacity: 1;
}

.modal-form select,
.mydata-form select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1.5 1.75 6 6.25l4.5-4.5' stroke='%23C5CFDD' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 8px;
  cursor: pointer;
}

.perms-role-select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1.5 1.75 6 6.25l4.5-4.5' stroke='%23C5CFDD' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 8px;
  cursor: pointer;
}

select option {
  background: #12171E;
  color: var(--text);
}

.modal-form input:focus,
.modal-form select:focus,
.modal-form textarea:focus,
.mydata-form input:focus,
.mydata-form select:focus,
.chat-composer input:focus,
.chat-search input:focus,
.perms-role-select:focus {
  outline: none;
  border-color: var(--accent-focus);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.modal-form input:user-invalid,
.modal-form select:user-invalid,
.modal-form textarea:user-invalid,
.mydata-form input:user-invalid,
.mydata-form select:user-invalid {
  border-color: #E53F3C;
}

.modal-form input:user-invalid:focus,
.modal-form select:user-invalid:focus,
.modal-form textarea:user-invalid:focus,
.mydata-form input:user-invalid:focus,
.mydata-form select:user-invalid:focus {
  box-shadow: 0 0 0 3px rgba(229, 63, 60, 0.2);
}

.modal-form input:disabled,
.modal-form select:disabled,
.modal-form textarea:disabled,
.mydata-form input:disabled,
.mydata-form select:disabled {
  background-color: #181F28;
  border-color: #26313C;
  color: #495463;
  cursor: not-allowed;
}

.modal-form select:disabled,
.mydata-form select:disabled {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1.5 1.75 6 6.25l4.5-4.5' stroke='%235F6F81' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* --- checkbox: 20px box, accent fill and a dark tick when checked --- */

.modal-checkbox-field input[type="checkbox"],
.expense-split-checkbox input[type="checkbox"],
.split-person-item input[type="checkbox"],
.modal-form .control-rank-row input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin: 0;
  padding: 0;
  background: var(--field) center / 14px 14px no-repeat;
  border: 2px solid #313B49;
  border-radius: 5px;
  box-shadow: none;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.modal-checkbox-field input[type="checkbox"]:checked,
.expense-split-checkbox input[type="checkbox"]:checked,
.split-person-item input[type="checkbox"]:checked,
.modal-form .control-rank-row input[type="checkbox"]:checked {
  background-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none'%3E%3Cpath d='M2.6 7.5 5.7 10.4 11.4 3.9' stroke='%23111B3B' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  border-color: var(--accent);
}

.modal-checkbox-field input[type="checkbox"]:focus-visible,
.expense-split-checkbox input[type="checkbox"]:focus-visible,
.split-person-item input[type="checkbox"]:focus-visible,
.modal-form .control-rank-row input[type="checkbox"]:focus-visible {
  border-color: var(--accent-focus);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.modal-checkbox-field input[type="checkbox"]:disabled,
.expense-split-checkbox input[type="checkbox"]:disabled,
.split-person-item input[type="checkbox"]:disabled,
.modal-form .control-rank-row input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- secondary + ghost buttons: one shared hover / pressed feel --- */

@media (hover: hover) {
  .header-icon-btn:hover,
  .todo-claim-btn:hover,
  .control-file-btn:hover:not(:disabled),
  .todo-details-btn:hover,
  .expense-info-btn:hover,
  .document-action-btn:hover:not(:disabled),
  .chat-attach-btn:hover,
  .user-perms-btn:hover,
  .user-activity-btn:hover,
  .user-manage-btn:hover:not(:disabled),
  .call-minimize-btn:hover,
  .channels-toggle:hover,
  .chat-head-icon:hover,
  .chat-add-btn:hover {
    background: var(--raised-hover);
    border-color: var(--border-hover);
    color: var(--text);
  }
}

.header-icon-btn:active,
.todo-claim-btn:active,
.control-file-btn:active:not(:disabled),
.todo-details-btn:active,
.expense-info-btn:active,
.document-action-btn:active:not(:disabled),
.chat-attach-btn:active,
.user-perms-btn:active,
.user-activity-btn:active,
.user-manage-btn:active:not(:disabled),
.call-minimize-btn:active,
.channels-toggle:active,
.chat-head-icon:active,
.chat-add-btn:active {
  background: var(--raised);
  border-color: var(--border-hover);
  color: var(--text);
}

/* --- primary buttons (after the secondary block: .material-download-main is also a .control-file-btn) --- */

@media (hover: hover) {
  .add-btn:hover:not(:disabled),
  .modal-submit-btn:hover:not(:disabled),
  .chat-send-btn:hover:not(:disabled),
  .material-download-main:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: #0A4899;
    color: #fff;
  }
}

.add-btn:active:not(:disabled),
.modal-submit-btn:active:not(:disabled),
.chat-send-btn:active:not(:disabled),
.material-download-main:active:not(:disabled) {
  background: var(--accent-active);
  border-color: var(--accent-active);
  color: #fff;
}

.add-btn:disabled,
.modal-submit-btn:disabled,
.chat-send-btn:disabled,
.material-download-main:disabled {
  background: #19202A;
  border-color: #1F2834;
  color: #5F6F81;
  opacity: 1;
  filter: none;
  cursor: not-allowed;
}

/* --- Wiki --- */
/* a plain, always-expanded list grouped by category (materials-section/materials-heading,
   reused as-is), not an accordion: every topic is one click away, nothing to open first */

.wiki-empty {
  margin: 0;
  padding: 32px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.wiki-topic-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wiki-topic {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 9px 10px;
  border-radius: 7px;
  font-family: var(--font-ui);
  font-size: 13.5px;
  text-align: left;
  overflow-wrap: anywhere;
  transition: background 0.12s ease, color 0.12s ease;
}

.wiki-topic:active {
  background: var(--raised);
  color: var(--text);
}

@media (hover: hover) {
  .wiki-topic:hover {
    background: var(--raised);
    color: var(--text);
  }
}

#wiki-content {
  white-space: pre-wrap;
}

/* --- Planer --- */

.planner-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: 14px;
}

.planner-head-main {
  flex: 1 1 280px;
  min-width: 0;
}

.planner-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* result of loading a plan from a file */
.planner-status {
  margin: 0 0 14px;
  padding: 10px 14px;
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: 8px;
  color: var(--info-text);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.planner-status[hidden] {
  display: none;
}

.planner-status.is-ok {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok-text);
}

.planner-status.is-error {
  background: var(--err-bg);
  border-color: var(--err-border);
  color: var(--err-text);
}

.header-icon-btn:disabled {
  background: #19202A;
  border-color: #1F2834;
  color: #5F6F81;
  cursor: not-allowed;
}

.planner-name-input {
  display: block;
  width: 100%;
  margin: 0 0 8px;
  padding: 2px 0 4px;
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: border-color 0.15s ease;
}

@media (hover: hover) {
  .planner-name-input:hover {
    border-bottom-color: var(--border);
  }
}

.planner-name-input:focus {
  outline: none;
  border-bottom-color: var(--accent-focus);
}

.planner-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.planner-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 8px 12px;
  background: var(--raised);
  border: 1px solid var(--btn-border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.planner-tool-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.planner-tool-btn[hidden] {
  display: none;
}

.planner-tool-btn.icon-only {
  padding: 8px 10px;
}

.planner-tool-btn.primary {
  background: var(--accent);
  border-color: var(--accent-rim);
  color: #fff;
  font-weight: 600;
}

.planner-tool-btn.danger {
  color: var(--err-text);
}

.planner-tool-btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-focus);
  color: var(--accent-text);
}

.planner-tool-btn:disabled {
  background: #19202A;
  border-color: #1F2834;
  color: #5F6F81;
  cursor: not-allowed;
}

@media (hover: hover) {
  .planner-tool-btn:hover:not(:disabled) {
    background: var(--raised-hover);
    border-color: var(--border-hover);
  }

  .planner-tool-btn.primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: #0A4899;
  }

  .planner-tool-btn.is-active:hover:not(:disabled) {
    background: var(--accent-soft);
    border-color: var(--accent-focus);
  }
}

.planner-tool-btn:active:not(:disabled) {
  background: var(--raised);
}

.planner-tool-btn.primary:active:not(:disabled) {
  background: var(--accent-active);
  border-color: var(--accent-active);
}

.planner-hint {
  margin: 0 0 10px;
  min-height: 20px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-dim);
}

.planner-canvas {
  position: relative;
  height: min(70vh, 680px);
  min-height: 340px;
  overflow: auto;
  touch-action: pan-x pan-y;
  background-color: var(--field);
  background-image: radial-gradient(circle, #1B2631 1px, transparent 1.5px);
  background-size: 24px 24px;
  background-attachment: local;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.planner-stage {
  position: relative;
  min-width: 100%;
  min-height: 100%;
}

.planner-edges {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.planner-edge {
  fill: none;
  stroke: #3A4A60;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.planner-edge.is-cross {
  stroke-dasharray: 5 5;
}

.planner-edge.is-hot {
  stroke: var(--accent-focus);
}

.planner-guide {
  fill: none;
  stroke: #1D2935;
  stroke-width: 1;
}

.planner-arrow-head {
  fill: #3A4A60;
}

.planner-arrow-head.is-hot {
  fill: var(--accent-focus);
}

.planner-node,
.planner-cell,
.planner-tool-btn {
  -webkit-tap-highlight-color: transparent;
}

.planner-node {
  position: absolute;
  width: 168px;
  height: 84px;
  background: var(--panel);
  border: 1px solid #2B3849;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.planner-node.is-start {
  border-color: #2F5F9E;
}

.planner-node.is-selected {
  border-color: var(--accent-focus);
  box-shadow: 0 0 0 3px var(--accent-ring), 0 2px 10px rgba(0, 0, 0, 0.28);
}

.planner-node-tag {
  position: absolute;
  top: -9px;
  left: 10px;
  padding: 1px 7px;
  background: #0F2A4C;
  border: 1px solid #1E4E8C;
  border-radius: 6px;
  color: var(--accent-text);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  line-height: 14px;
  text-transform: uppercase;
  pointer-events: none;
}

.planner-node-text {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 9px 11px;
  background: transparent;
  border: none;
  border-radius: 10px;
  resize: none;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.35;
  scrollbar-width: thin;
  pointer-events: none;
}

.planner-node.is-selected .planner-node-text {
  pointer-events: auto;
  cursor: text;
}

.planner-node-text:focus {
  outline: none;
}

.planner-stage.is-picking .planner-node-text {
  pointer-events: none;
}

.planner-stage.is-picking .planner-node:not(.is-selected) {
  outline: 2px dashed rgba(26, 148, 240, 0.55);
  outline-offset: 2px;
}

.planner-cell {
  position: absolute;
  width: 168px;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: 1px dashed #263241;
  border-radius: 10px;
  color: #3A4A60;
  font-size: 22px;
  line-height: 1;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}

.planner-cell::before {
  content: '+';
}

@media (hover: hover) {
  .planner-cell:hover {
    background: var(--accent-soft);
    border-color: var(--accent-focus);
    color: var(--accent-text);
  }
}

.planner-stage.mode-move .planner-cell {
  background: var(--accent-soft);
  border-color: var(--accent-focus);
  color: var(--accent-text);
}

.planner-stage.mode-connect .planner-cell {
  opacity: 0.35;
}

.planner-confirm-actions {
  gap: 10px;
}

.modal-danger-btn {
  background: #3C171A;
  border: 1px solid #561B1E;
  padding: 10px 18px;
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}

@media (hover: hover) {
  .modal-danger-btn:hover {
    background: #521C1E;
    border-color: #6B2326;
  }
}

.modal-danger-btn:active {
  background: #671E1F;
  border-color: #7A2326;
}

@media (max-width: 860px) {
  /* the whole editor should fit on one phone screen */
  .planner-canvas {
    height: min(58vh, 600px);
    min-height: 300px;
  }

  .planner-tool-btn {
    min-height: 40px;
  }

  /* inputs are forced to 16px on phones (iOS zooms in otherwise); the title keeps a heading size */
  .planner-name-input {
    font-size: 20px !important;
  }

  /* 16px text needs the room: three lines fit in a box */
  .planner-node-text {
    padding: 7px 10px;
    line-height: 1.3;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* --- app-level notices: network and permission errors a handler could not show inline --- */

.app-toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 110;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
  width: min(420px, calc(100vw - 32px));
}

.app-toast {
  padding: 11px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.4;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.app-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.app-toast-error {
  background: var(--err-bg);
  border-color: var(--err-border);
  color: var(--err-text);
}

.app-toast-message {
  background: var(--selected);
  border-color: var(--accent-rim);
}

.app-toast-clickable {
  pointer-events: auto;
  cursor: pointer;
}

/* --- chat: a few bits the prototype did not need (older messages, deletion, uploading) --- */

.chat-load-older {
  display: flex;
  justify-content: center;
  padding: 4px 0 10px;
}

.chat-msg.is-deleted .chat-body p {
  color: var(--text-dim);
}

.chat-attachment-file[data-file-id] {
  cursor: pointer;
}
