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

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

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

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

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

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

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