/* Prywatne wiadomości (wiadomosci.html). Samodzielny arkusz: te same kolory i fonty co kalkulator. */
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
[hidden] { display: none !important; }
:root {
  --paper: #EDF0F6; --sheet: #FFFFFF; --ink: #16213A; --muted: #5B6680; --line: #D6DCE7;
  --accent: #2346B8; --accent-ink: #FFFFFF; --accent-soft: #E2E8FA;
  --ok: #1D7A4E; --warn: #9A5B00; --bad: #B3232C; --bad-soft: #FBE7E8;
  --head: #7A3FC2; --head-soft: #F0E7FB; --mod: #1D7A4E; --mod-soft: #E2F4EA;
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0E1320; --sheet: #161D2D; --ink: #E5E9F3; --muted: #95A1BB; --line: #2A3349;
    --accent: #93A9FF; --accent-ink: #0E1320; --accent-soft: #1F2947;
    --ok: #5DCB94; --warn: #E8B14E; --bad: #FF7C82; --bad-soft: #3A1B20;
    --head: #C9A2FF; --head-soft: #2C2045; --mod: #5DCB94; --mod-soft: #173326;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0E1320; --sheet: #161D2D; --ink: #E5E9F3; --muted: #95A1BB; --line: #2A3349;
  --accent: #93A9FF; --accent-ink: #0E1320; --accent-soft: #1F2947;
  --ok: #5DCB94; --warn: #E8B14E; --bad: #FF7C82; --bad-soft: #3A1B20;
  --head: #C9A2FF; --head-soft: #2C2045; --mod: #5DCB94; --mod-soft: #173326;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--font-body); }
.wrap { max-width: 1120px; margin: 0 auto; padding-inline: 16px; padding-block: 24px 40px; display: grid; gap: 20px; }
h1, h2 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.9rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 700; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.flush { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.top { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 24px; }
.top p { margin: 4px 0 0; color: var(--muted); }
.account-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.who { font-weight: 700; font-size: .9rem; overflow-wrap: anywhere; display: inline-flex; align-items: center; gap: 8px; }

.btn { border: 1px solid var(--line); background: var(--sheet); padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: .9rem; }
a.btn { display: inline-block; text-decoration: none; color: inherit; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); color: var(--accent-ink); }
.btn.small { padding: 4px 10px; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.card { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 12px; min-width: 0; }
.hint { margin: 0; font-size: .84rem; color: var(--muted); }
.form-error { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--bad-soft); color: var(--bad); font-size: .88rem; }
.muted-note { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--bad-soft); color: var(--bad); font-size: .88rem; }

/* Układ: lista rozmów + otwarta rozmowa; na telefonie jedno albo drugie */
.dm:not([hidden]) { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.back { display: none; }
@media (max-width: 820px) {
  .dm:not([hidden]) { grid-template-columns: minmax(0, 1fr); }
  .dm[data-view="list"] .thread-pane, .dm[data-view="thread"] .list-pane { display: none; }
  .back { display: inline-block; }
}

.new-form { display: flex; gap: 6px; }
.new-form input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 6px 10px; }
.new-form input:focus, .composer textarea:focus { border-color: var(--accent); }
.conversations { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 60vh; overflow-y: auto; }
.conv { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; padding: 8px; border-radius: 8px; cursor: pointer; border: 0; background: transparent; text-align: left; width: 100%; }
.conv:hover { background: var(--paper); }
.conv[aria-current="true"] { background: var(--accent-soft); }
.conv .avatar { grid-row: span 2; }
.conv-name { font-weight: 700; overflow-wrap: anywhere; display: flex; gap: 6px; align-items: center; }
.conv-time { font-size: .74rem; color: var(--muted); font-family: var(--font-mono); white-space: nowrap; }
.conv-last { grid-column: 2; font-size: .84rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.unread .conv-last { color: var(--ink); font-weight: 700; }
.count-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--bad); color: #fff; font-size: .72rem; line-height: 18px; text-align: center; font-weight: 700; }

.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none; display: inline-grid; place-items: center; font-weight: 700; font-size: .8rem; color: #fff; background: var(--muted); user-select: none; }
.avatar.small { width: 22px; height: 22px; font-size: .62rem; }
.badge { display: inline-block; padding: 0 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.badge.r-head { background: var(--head-soft); color: var(--head); }
.badge.r-moderator { background: var(--mod-soft); color: var(--mod); }

.thread-head { display: flex; align-items: center; gap: 10px; min-height: 36px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.thread-who { display: flex; align-items: center; gap: 10px; font-weight: 700; font-family: var(--font-display); font-size: 1.1rem; }
.thread-empty { padding: 40px 0; text-align: center; }
.bubbles { height: clamp(300px, calc(100dvh - 360px), 800px); overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 4px 2px; overscroll-behavior: contain; }
.day { align-self: center; margin: 8px 0 2px; padding: 1px 10px; border-radius: 999px; background: var(--paper); color: var(--muted); font-size: .74rem; font-weight: 700; }
.bubble { max-width: min(78%, 560px); padding: 7px 12px; border-radius: 14px 14px 14px 4px; background: var(--paper); align-self: flex-start; display: grid; gap: 2px; }
.bubble.mine { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-radius: 14px 14px 4px 14px; }
.bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble time { font-size: .7rem; opacity: .7; font-family: var(--font-mono); justify-self: end; }

.composer { display: flex; gap: 8px; align-items: end; border-top: 1px solid var(--line); padding-top: 12px; }
.composer textarea { flex: 1; min-width: 0; resize: vertical; min-height: 44px; max-height: 200px; border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 9px 12px; }
.composer-side { display: grid; gap: 4px; justify-items: end; }
.count { font-size: .74rem; color: var(--muted); }

dialog.notice { border: 2px solid var(--accent); border-radius: 14px; background: var(--sheet); color: var(--ink); padding: 22px; width: min(480px, calc(100% - 32px)); box-shadow: 0 20px 60px rgba(10, 20, 50, .25); }
dialog.notice::backdrop { background: rgba(14, 19, 32, .55); }
.notice .label { margin: 0 0 4px; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.notice-text { white-space: pre-wrap; overflow-wrap: anywhere; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 10px; font-size: .9rem; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.2); z-index: 10; }

/* Wylogowanie przez administratora */
.kicked-reason { padding: 8px 12px; border-left: 3px solid var(--warn); background: var(--paper); border-radius: 0 8px 8px 0; }

/* Ostrzeżenie przed automatycznym wylogowaniem */
.warn-dialog { border-color: var(--warn) !important; }
.warn-count { font-family: var(--font-mono); font-size: 1.6rem; font-weight: 600; color: var(--warn); margin: 4px 0 8px; }
