:root {
  --aubergine: #3f0e40;
  --aubergine-dark: #350d36;
  --sidebar-text: #cfc3cf;
  --sidebar-hover: #350d36;
  --active: #1164a3;
  --text: #1d1c1d;
  --muted: #616061;
  --border: #dddddd;
  --hover: #f8f8f8;
  --link: #1264a3;
  --green: #007a5a;
  --red: #e01e5a;
  --board-bg: #0079bf;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Lato, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; color: var(--text); background: #fff;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Logowanie ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #f4ede4; padding: 16px; }
.auth-card { background: #fff; width: 100%; max-width: 420px; border-radius: 12px; padding: 36px 32px; box-shadow: 0 4px 24px rgba(0,0,0,.08); }
.auth-logo { width: 52px; height: 52px; border-radius: 12px; background: #4a154b; color: #fff; font-weight: 900; font-size: 22px; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.auth h1 { text-align: center; font-size: 28px; font-weight: 900; margin: 0 0 6px; }
.auth p.sub { text-align: center; color: var(--muted); margin: 0 0 24px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid #868686; border-radius: 6px; background: #fff; outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--link); box-shadow: 0 0 0 3px rgba(29,155,209,.3); }
.btn { border: none; border-radius: 6px; padding: 9px 16px; font-weight: 700; font-size: 15px; background: #fff; border: 1px solid #ccc; color: var(--text); }
.btn:hover { background: var(--hover); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: #148567; }
.btn-danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: #fdf0f4; }
.btn-block { width: 100%; padding: 12px; font-size: 17px; }
.error { color: var(--red); font-size: 14px; min-height: 18px; margin-bottom: 10px; }

/* ---------- Układ ---------- */
#app { height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 44px; background: var(--aubergine-dark); display: flex; align-items: center; padding: 0 12px; gap: 12px; flex-shrink: 0; box-shadow: 0 1px 0 rgba(255,255,255,.1); }
.topbar-title { flex: 1; text-align: center; color: #fff; font-weight: 700; font-size: 14px; opacity: .9; }
.icon-btn { background: transparent; border: none; color: inherit; padding: 4px 8px; border-radius: 4px; font-size: 16px; line-height: 1; }
.icon-btn:hover { background: rgba(0,0,0,.06); }
.menu-btn { color: #fff; display: none; }
.menu-btn:hover { background: rgba(255,255,255,.15); }
.me-btn { background: none; border: none; padding: 0; position: relative; }
.workspace { flex: 1; display: flex; min-height: 0; }

/* ---------- Pasek boczny ---------- */
.sidebar { width: 260px; background: var(--aubergine); color: var(--sidebar-text); display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto; }
.ws-header { padding: 0 16px; height: 50px; display: flex; align-items: center; border-bottom: 1px solid rgba(255,255,255,.12); color: #fff; font-weight: 900; font-size: 18px; flex-shrink: 0; }
.ws-header small { display: block; font-weight: 400; font-size: 12px; color: var(--sidebar-text); }
.side-section { padding: 10px 0 4px; }
.side-title { display: flex; align-items: center; padding: 4px 16px; font-size: 15px; color: var(--sidebar-text); user-select: none; }
.side-title .caret { width: 18px; font-size: 10px; }
.side-title .label { flex: 1; cursor: pointer; }
.side-title .add { visibility: hidden; color: var(--sidebar-text); background: none; border: none; font-size: 18px; padding: 0 6px; border-radius: 4px; line-height: 1; }
.side-title:hover .add { visibility: visible; }
.side-title .add:hover { background: rgba(255,255,255,.15); }
.side-item { display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 16px 0 26px; color: var(--sidebar-text); cursor: pointer; font-size: 15px; white-space: nowrap; overflow: hidden; border-radius: 6px; margin: 0 8px; padding-left: 18px; }
.side-item:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.side-item.active { background: var(--active); color: #fff; }
.side-item.unread { color: #fff; font-weight: 900; }
.side-item .hash { width: 16px; text-align: center; opacity: .8; }
.side-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.side-item .badge { background: var(--red); color: #fff; border-radius: 9px; padding: 0 7px; font-size: 12px; font-weight: 700; line-height: 18px; }
.side-item .add-link { opacity: .8; }
.side-collapsed .side-item:not(.active):not(.unread) { display: none; }

/* ---------- Awatary ---------- */
.avatar { display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; border-radius: 4px; flex-shrink: 0; position: relative; text-transform: uppercase; }
.avatar.s20 { width: 20px; height: 20px; font-size: 10px; }
.avatar.s24 { width: 24px; height: 24px; font-size: 11px; }
.avatar.s28 { width: 28px; height: 28px; font-size: 12px; }
.avatar.s36 { width: 36px; height: 36px; font-size: 15px; border-radius: 6px; }
.avatar.s72 { width: 72px; height: 72px; font-size: 28px; border-radius: 10px; }
.presence { width: 9px; height: 9px; border-radius: 50%; position: absolute; right: -3px; bottom: -3px; border: 2px solid var(--aubergine); background: transparent; box-shadow: inset 0 0 0 1.5px var(--sidebar-text); }
.presence.on { background: #2bac76; box-shadow: none; }
.topbar .presence { border-color: var(--aubergine-dark); }

/* ---------- Główna kolumna (czat) ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #fff; }
.chan-header { height: 50px; flex-shrink: 0; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 16px 0 20px; gap: 10px; }
.chan-header h2 { margin: 0; font-size: 18px; font-weight: 900; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.chan-header .desc { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.members-btn { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 6px; background: #fff; padding: 3px 8px 3px 4px; font-size: 13px; font-weight: 700; color: var(--muted); }
.members-btn:hover { background: var(--hover); }
.members-btn .stack { display: flex; }
.members-btn .stack .avatar { margin-right: -4px; border: 2px solid #fff; box-sizing: content-box; }

.messages { flex: 1; overflow-y: auto; padding: 8px 0 16px; }
.chan-intro { padding: 28px 20px 16px; }
.chan-intro h3 { font-size: 26px; font-weight: 900; margin: 0 0 6px; }
.chan-intro p { color: var(--muted); margin: 0; }
.load-older { display: block; margin: 8px auto; }

.day-divider { position: relative; text-align: center; margin: 16px 0 6px; height: 28px; }
.day-divider::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--border); }
.day-divider span { position: relative; display: inline-block; background: #fff; border: 1px solid var(--border); border-radius: 24px; padding: 0 16px; line-height: 26px; font-size: 13px; font-weight: 700; }

.msg { position: relative; display: flex; gap: 8px; padding: 8px 20px; }
.msg.compact { padding-top: 2px; padding-bottom: 2px; }
.msg:hover, .msg.menu-open { background: var(--hover); }
.msg .gutter { width: 36px; flex-shrink: 0; }
.msg .gutter .ts-hover { visibility: hidden; font-size: 12px; color: var(--muted); display: block; text-align: right; line-height: 22px; white-space: nowrap; }
.msg.compact:hover .gutter .ts-hover { visibility: visible; }
.msg .content { flex: 1; min-width: 0; }
.msg .meta { display: flex; align-items: baseline; gap: 8px; }
.msg .author { font-weight: 900; font-size: 15px; color: var(--text); cursor: pointer; }
.msg .author:hover { text-decoration: underline; }
.msg .time { font-size: 12px; color: var(--muted); }
.msg .body { line-height: 1.46668; word-wrap: break-word; overflow-wrap: anywhere; }
.msg .body p { margin: 0; }
.msg .edited { font-size: 12px; color: var(--muted); }
.body code { font-family: Monaco, Menlo, Consolas, monospace; font-size: 12px; color: #c01343; background: rgba(29,28,29,.04); border: 1px solid rgba(29,28,29,.13); border-radius: 3px; padding: 2px 3px 1px; }
.body pre { font-family: Monaco, Menlo, Consolas, monospace; font-size: 12px; background: rgba(29,28,29,.04); border: 1px solid rgba(29,28,29,.13); border-radius: 4px; padding: 8px; margin: 4px 0; white-space: pre-wrap; }
.body .mention { background: rgba(29,155,209,.1); color: var(--link); border-radius: 3px; padding: 0 2px; font-weight: 700; }
.body blockquote { border-left: 4px solid #ddd; margin: 4px 0; padding-left: 12px; }

.msg-actions { position: absolute; top: -16px; right: 20px; display: none; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,.08); padding: 2px; z-index: 5; }
.msg:hover .msg-actions, .msg.menu-open .msg-actions { display: flex; }
.msg-actions button { background: none; border: none; width: 32px; height: 32px; border-radius: 4px; font-size: 16px; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.msg-actions button:hover { background: #f0f0f0; color: var(--text); }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction { display: inline-flex; align-items: center; gap: 4px; background: rgba(29,28,29,.06); border: 1px solid transparent; border-radius: 24px; padding: 0 8px; height: 24px; font-size: 12px; font-weight: 700; color: var(--text); }
.reaction:hover { border-color: #aaa; background: #fff; }
.reaction.mine { background: #e8f5fa; border-color: #1d9bd1; color: #1264a3; }
.reaction .e { font-size: 15px; }
.reaction.add { color: var(--muted); }

.thread-summary { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; padding: 4px 8px 4px 4px; border: 1px solid transparent; border-radius: 6px; cursor: pointer; max-width: 600px; }
.thread-summary:hover { background: #fff; border-color: var(--border); }
.thread-summary .count { color: var(--link); font-weight: 700; font-size: 13px; }
.thread-summary .last { color: var(--muted); font-size: 13px; }
.thread-summary .avatars { display: flex; gap: 4px; }

.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.file-img { display: block; max-width: 360px; max-height: 300px; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; object-fit: cover; }
.file-card { display: flex; align-items: center; gap: 10px; width: 340px; max-width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: #fff; color: var(--text); }
.file-card:hover { text-decoration: none; background: var(--hover); }
.file-icon { width: 40px; height: 40px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 900; color: #fff; flex-shrink: 0; background: #5f6368; }
.file-icon.pdf { background: #e01e5a; } .file-icon.xls { background: #2bac76; } .file-icon.doc { background: #1d9bd1; } .file-icon.zip { background: #ecb22e; }
.file-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-sub { font-size: 12px; color: var(--muted); }

/* Kompozytor wiadomości */
.composer-wrap { padding: 0 20px 20px; flex-shrink: 0; }
.composer { border: 1px solid #b4b4b4; border-radius: 8px; background: #fff; }
.composer:focus-within { border-color: #868686; box-shadow: 0 0 0 1px rgba(0,0,0,.05), 0 1px 6px rgba(0,0,0,.08); }
.composer.dragging { border: 2px dashed var(--link); background: #f2f9fd; }
.fmt-bar { display: flex; gap: 2px; padding: 4px 6px; background: #f8f8f8; border-radius: 8px 8px 0 0; border-bottom: 1px solid #eee; }
.fmt-bar button { background: none; border: none; width: 28px; height: 28px; border-radius: 4px; color: var(--muted); font-size: 14px; }
.fmt-bar button:hover { background: #e8e8e8; color: var(--text); }
.composer textarea { display: block; width: 100%; border: none; outline: none; resize: none; padding: 10px 12px 6px; min-height: 42px; max-height: 300px; line-height: 1.46668; background: transparent; }
.composer .pending { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 12px 0; }
.pending-chip { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 10px; padding: 6px 8px; font-size: 13px; max-width: 260px; position: relative; }
.pending-chip img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.pending-chip .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-chip .x { position: absolute; top: -8px; right: -8px; width: 20px; height: 20px; border-radius: 50%; background: #1d1c1d; color: #fff; border: none; font-size: 11px; line-height: 20px; padding: 0; }
.comp-bottom { display: flex; align-items: center; padding: 4px 6px 6px; gap: 2px; }
.comp-bottom .tool { background: none; border: none; width: 28px; height: 28px; border-radius: 50%; color: var(--muted); font-size: 16px; display: flex; align-items: center; justify-content: center; }
.comp-bottom .tool:hover { background: #e8e8e8; color: var(--text); }
.comp-bottom .tool.plus { background: #e8e8e8; font-size: 18px; }
.comp-bottom .spacer { flex: 1; }
.send-btn { background: var(--green); border: none; color: #fff; width: 32px; height: 28px; border-radius: 4px; display: flex; align-items: center; justify-content: center; }
.send-btn:disabled { background: transparent; color: #bbb; cursor: default; }
.typing { height: 18px; font-size: 12px; color: var(--muted); padding: 2px 2px 0; }
.hint { font-size: 11px; color: var(--muted); }

/* Panel wątku */
.thread-pane { width: 420px; border-left: 1px solid var(--border); display: flex; flex-direction: column; background: #fff; flex-shrink: 0; }
.thread-header { height: 50px; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 12px 0 16px; gap: 8px; flex-shrink: 0; }
.thread-header h3 { margin: 0; font-size: 18px; font-weight: 900; }
.thread-header .sub { color: var(--muted); font-size: 13px; flex: 1; }
.thread-body { flex: 1; overflow-y: auto; padding: 8px 0; }
.thread-sep { display: flex; align-items: center; gap: 10px; padding: 4px 20px; color: var(--muted); font-size: 13px; }
.thread-sep::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.thread-pane .msg { padding-left: 16px; padding-right: 16px; }
.thread-pane .composer-wrap { padding: 0 16px 16px; }
.thread-pane .msg-actions { right: 12px; }

/* ---------- Tablica ---------- */
.board-view { flex: 1; display: flex; flex-direction: column; min-height: 0; background: linear-gradient(135deg, #0079bf 0%, #5067c5 100%); }
.board-header { padding: 12px 16px; display: flex; align-items: center; gap: 12px; color: #fff; flex-shrink: 0; }
.board-header h2 { margin: 0; font-size: 20px; font-weight: 900; }
.board-header .sub { opacity: .85; font-size: 14px; }
.board-header select { margin-left: auto; padding: 6px 10px; border-radius: 6px; border: none; background: rgba(255,255,255,.9); }
.board { flex: 1; display: flex; gap: 12px; align-items: flex-start; padding: 4px 16px 16px; overflow-x: auto; }
.list { flex: 1 1 0; min-width: 250px; max-width: 340px; background: #f1f2f4; border-radius: 12px; display: flex; flex-direction: column; max-height: 100%; box-shadow: 0 1px 1px rgba(9,30,66,.25); }
.list-head { padding: 10px 12px 6px 14px; display: flex; align-items: center; gap: 6px; }
.list-title { font-weight: 700; font-size: 14px; flex: 1; padding: 4px 6px; border-radius: 4px; cursor: pointer; border: none; background: transparent; text-align: left; }
.list-title:hover { background: rgba(0,0,0,.05); }
input.list-title { background: #fff; box-shadow: inset 0 0 0 2px #388bff; cursor: text; }
.list-count { font-size: 12px; color: #626f86; background: rgba(0,0,0,.06); border-radius: 10px; padding: 1px 8px; }
.cards { padding: 2px 8px; overflow-y: auto; min-height: 8px; display: flex; flex-direction: column; gap: 8px; }
.card { background: #fff; border-radius: 8px; box-shadow: 0 1px 1px rgba(9,30,66,.25); padding: 8px 10px; cursor: pointer; font-size: 14px; position: relative; }
.card:hover { box-shadow: 0 0 0 2px #388bff; }
.card.dragging { opacity: .4; }
.card .label { height: 8px; width: 40px; border-radius: 4px; margin-bottom: 6px; }
.card .title { word-wrap: break-word; overflow-wrap: anywhere; }
.card .badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; font-size: 12px; color: #44546f; align-items: center; }
.due { padding: 1px 6px; border-radius: 4px; }
.due.over { background: #c9372c; color: #fff; }
.due.soon { background: #f5cd47; color: #172b4d; }
.due.done { background: #1f845a; color: #fff; }
.card-placeholder { background: rgba(9,30,66,.1); border-radius: 8px; min-height: 36px; }
.add-card { margin: 6px 8px 8px; padding: 6px 8px; border-radius: 8px; border: none; background: transparent; text-align: left; color: #44546f; font-size: 14px; }
.add-card:hover { background: rgba(9,30,66,.08); color: var(--text); }
.add-card-form { padding: 0 8px 8px; }
.add-card-form textarea { width: 100%; border: none; border-radius: 8px; padding: 8px 10px; box-shadow: 0 1px 1px rgba(9,30,66,.25); resize: none; outline: none; margin-bottom: 6px; }
.add-card-form .row { display: flex; gap: 6px; align-items: center; }
.btn-blue { background: #0c66e4; color: #fff; border: none; border-radius: 4px; padding: 6px 12px; font-weight: 700; font-size: 14px; }
.btn-blue:hover { background: #0055cc; }

/* ---------- Zespół ---------- */
.page { flex: 1; overflow-y: auto; padding: 24px 28px; }
.page h2 { margin: 0 0 4px; font-size: 24px; font-weight: 900; }
.page .lead { color: var(--muted); margin: 0 0 20px; }
.people { width: 100%; border-collapse: collapse; }
.people th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 700; padding: 8px; border-bottom: 1px solid var(--border); }
.people td { padding: 10px 8px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.people .who { display: flex; align-items: center; gap: 10px; }
.tag { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: #eee; }
.tag.admin { background: #f9e7f9; color: #4a154b; }
.tag.off { background: #fde8ee; color: var(--red); }

/* ---------- Okna dialogowe ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 560px; box-shadow: 0 18px 48px rgba(0,0,0,.35); }
.modal-head { display: flex; align-items: center; padding: 20px 24px 8px; }
.modal-head h3 { margin: 0; font-size: 22px; font-weight: 900; flex: 1; }
.modal-body { padding: 8px 24px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 24px 20px; }
.modal-foot .left { margin-right: auto; }
.checklist { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; }
.checklist label { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; }
.checklist label:hover { background: var(--hover); }
.colors { display: flex; gap: 6px; flex-wrap: wrap; }
.colors button { width: 40px; height: 28px; border-radius: 4px; border: 2px solid transparent; }
.colors button.sel { border-color: #172b4d; box-shadow: inset 0 0 0 2px #fff; }
.card-meta { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.img-viewer { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; }
.img-viewer img { max-width: 100%; max-height: 100%; border-radius: 6px; }

/* Wyskakujące menu */
.popover { position: fixed; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.18); z-index: 150; padding: 6px 0; min-width: 200px; }
.popover .item { display: block; width: 100%; text-align: left; background: none; border: none; padding: 7px 20px; font-size: 15px; color: var(--text); }
.popover .item:hover { background: var(--active); color: #fff; }
.popover .sep { border-top: 1px solid var(--border); margin: 6px 0; }
.popover .head { padding: 8px 20px 10px; display: flex; gap: 10px; align-items: center; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 34px); gap: 2px; padding: 4px 8px; }
.emoji-grid button { background: none; border: none; font-size: 21px; height: 34px; border-radius: 4px; }
.emoji-grid button:hover { background: #f0f0f0; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1d1c1d; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 300; font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.empty { color: var(--muted); padding: 40px; text-align: center; }

/* ---------- Telefon ---------- */
@media (max-width: 900px) {
  .thread-pane { position: fixed; inset: 44px 0 0 0; width: auto; z-index: 40; }
}
@media (max-width: 700px) {
  .menu-btn { display: block; }
  .sidebar { position: fixed; top: 44px; bottom: 0; left: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 4px 0 24px rgba(0,0,0,.3); }
  .msg { padding-left: 12px; padding-right: 12px; }
  .composer-wrap { padding: 0 10px 10px; }
  .chan-header .desc { display: none; }
  .file-img { max-width: 100%; }
  .page { padding: 16px; }
  .people .hide-sm { display: none; }
  .comp-bottom .hint { display: none; }
}
