/* WEESchat. Colour tokens first; dark mode follows the OS unless the
   person picks a theme (data-theme on <html>, see base.html). */
:root {
  --bg: #f9f9f7;
  --surface: #ffffff;
  --surface-2: #f3f3f0;
  --hover: #f1f1ec;
  --text: #1a1a18;
  --text-2: #55544f;
  --muted: #8a8882;
  --border: rgba(11, 11, 11, 0.11);
  --brand: #227f85;
  --brand-ink: #ffffff;
  --accent: #2a78d6;
  --side-bg: #13383b;
  --side-text: #d5e6e6;
  --side-muted: #8fb2b3;
  --side-hover: rgba(255, 255, 255, 0.07);
  --side-active: #227f85;
  --mention-bg: rgba(250, 178, 25, 0.16);
  --mention-ink: #8a5c00;
  --mention-row: rgba(250, 178, 25, 0.09);
  --danger: #c02f2f;
  --good: #1f9d55;
  --away: #c98a00;
  --code-bg: #f1f1ec;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161716; --surface: #1d1e1d; --surface-2: #232523; --hover: #262826; --text: #ececea; --text-2: #b9b8b2;
    --muted: #85847e; --border: rgba(255, 255, 255, 0.11); --side-bg: #0e2426; --side-text: #d5e6e6;
    --side-muted: #7fa1a2; --mention-bg: rgba(250, 178, 25, 0.18); --mention-ink: #f5c55a;
    --mention-row: rgba(250, 178, 25, 0.07); --code-bg: #262826; --accent: #5aa0ef; --danger: #f26b6b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161716; --surface: #1d1e1d; --surface-2: #232523; --hover: #262826; --text: #ececea; --text-2: #b9b8b2;
  --muted: #85847e; --border: rgba(255, 255, 255, 0.11); --side-bg: #0e2426; --side-text: #d5e6e6;
  --side-muted: #7fa1a2; --mention-bg: rgba(250, 178, 25, 0.18); --mention-ink: #f5c55a;
  --mention-row: rgba(250, 178, 25, 0.07); --code-bg: #262826; --accent: #5aa0ef; --danger: #f26b6b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }
code { font-family: var(--mono); font-size: 0.88em; background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
pre, pre.code { font-family: var(--mono); font-size: 13px; background: var(--code-bg); padding: 10px 12px; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; border: 1px solid var(--border); }
pre code { background: none; padding: 0; }

/* ---------- buttons and inputs ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text); }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.wide { width: 100%; justify-content: center; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; }
.link.danger { color: var(--danger); }
.input, input.input, select.input, textarea.input, .field input, .field select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.input:focus, textarea:focus, input:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.field { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 12px; }
.field .input, .field input, .field select { margin-top: 5px; font-weight: 400; }
.field .errorlist { color: var(--danger); font-weight: 400; list-style: none; padding: 0; margin: 4px 0 0; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; margin: 6px 0 10px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pill { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 1px 6px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); vertical-align: 2px; }
.icon-btn { background: none; border: 0; cursor: pointer; padding: 6px; border-radius: 6px; line-height: 1; font-size: 16px; color: inherit; }
.icon-btn:hover { background: var(--hover); }
.icon-btn.small { font-size: 15px; padding: 0 6px; }

/* ---------- avatars ---------- */
.avatar-wrap { position: relative; display: inline-flex; flex: none; }
.avatar { width: 36px; height: 36px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 14px; user-select: none; }
.avatar.sm, .sm .avatar { width: 26px; height: 26px; font-size: 11px; border-radius: 6px; }
.xs .avatar { width: 20px; height: 20px; font-size: 9px; border-radius: 5px; }
.lg .avatar { width: 64px; height: 64px; font-size: 24px; border-radius: 12px; }
.xl .avatar { width: 96px; height: 96px; font-size: 34px; border-radius: 16px; }
.dot { position: absolute; right: -3px; bottom: -3px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--surface); background: transparent; box-shadow: inset 0 0 0 2px var(--muted); }
.xs .dot { width: 9px; height: 9px; right: -3px; bottom: -3px; }
.dot.online { background: var(--good); box-shadow: none; }
.dot.away { background: var(--surface); box-shadow: inset 0 0 0 2px var(--away); }
.dot.dnd { background: var(--danger); box-shadow: none; }
.sidebar .dot { border-color: var(--side-bg); }

/* ---------- app layout ---------- */
body.app { overflow: hidden; }
.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); height: 100vh; height: 100dvh; }
body.with-panel .shell { grid-template-columns: 260px minmax(0, 1fr) minmax(320px, 400px); }

.sidebar { background: var(--side-bg); color: var(--side-text); display: flex; flex-direction: column; overflow-y: auto; padding-bottom: 8px; }
.ws-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px 14px; }
.ws-name { font-weight: 800; font-size: 17px; flex: 1; color: #fff; }
.ws-head .icon-btn { color: var(--side-text); background: rgba(255, 255, 255, 0.1); }
.me-card { display: flex; gap: 10px; align-items: center; margin: 2px 8px 8px; padding: 8px; border-radius: 8px; background: none; border: 0; text-align: left; cursor: pointer; color: inherit; }
.me-card:hover { background: var(--side-hover); }
.me-text { display: flex; flex-direction: column; min-width: 0; }
.me-text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.me-status { font-size: 12px; color: var(--side-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-nav { display: flex; flex-direction: column; padding: 0 8px 6px; }
.side-link { display: flex; gap: 8px; align-items: center; padding: 5px 10px; border-radius: 6px; border: 0; background: none; color: var(--side-text); cursor: pointer; text-align: left; }
.side-link span:first-child { width: 18px; text-align: center; }
.side-link:hover { background: var(--side-hover); }
.side-link .badge { margin-left: auto; }
.side-section { padding: 6px 8px 0; }
.side-title { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; font-size: 13px; font-weight: 700; color: var(--side-muted); }
.side-title .icon-btn { color: var(--side-muted); }
.side-title .icon-btn:hover { color: #fff; background: var(--side-hover); }
.conv-list { list-style: none; margin: 0; padding: 0; }
.conv { width: 100%; display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 6px; border: 0; background: none; color: var(--side-muted); cursor: pointer; text-align: left; font-size: 15px; }
.conv:hover { background: var(--side-hover); }
.conv.unread { color: #fff; font-weight: 700; }
.conv.muted { opacity: .55; }
.conv.active { background: var(--side-active); color: #fff; }
.conv-icon { width: 20px; text-align: center; flex: none; opacity: .85; }
.conv-icon.count { font-size: 11px; font-weight: 700; background: rgba(255, 255, 255, 0.15); border-radius: 5px; height: 20px; line-height: 20px; }
.conv-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-emoji { font-size: 13px; }
.badge { background: #e01e5a; color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; min-width: 20px; text-align: center; }
.side-foot { margin-top: auto; display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 14px 18px 4px; font-size: 13px; }
.side-foot a, .side-foot .link { color: var(--side-muted); text-decoration: none; }
.side-foot a:hover, .side-foot .link:hover { color: #fff; }
.side-foot form { display: inline; }

.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); }
.pane-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); min-height: 58px; }
.pane-title { flex: 1; min-width: 0; }
.pane-title h1 { font-size: 17px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-topic { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-tools { display: flex; align-items: center; gap: 4px; }
.tool-btn { display: inline-flex; gap: 4px; align-items: center; background: none; border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; cursor: pointer; font-size: 13px; }
.tool-btn:hover { background: var(--hover); }
.search input { width: 260px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; }
.banner { background: #fff4d6; color: #6b4b00; text-align: center; font-size: 13px; padding: 4px; }
.mobile-only { display: none; }

/* ---------- messages ---------- */
.messages { flex: 1; overflow-y: auto; padding: 8px 0 12px; overscroll-behavior: contain; }
.loading { padding: 24px; text-align: center; color: var(--muted); }
.load-more { display: block; margin: 10px auto; background: none; border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; color: var(--text-2); }
.intro { padding: 28px 20px 12px; }
.intro h2 { margin: 10px 0 4px; font-size: 22px; }
.day { position: relative; text-align: center; margin: 14px 0 6px; }
.day::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--border); }
.day span { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 2px 12px; font-size: 12px; font-weight: 700; color: var(--text-2); }
.new-marker { position: relative; margin: 8px 0; text-align: right; padding-right: 16px; }
.new-marker::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid #e01e5a; }
.new-marker span { position: relative; background: var(--surface); color: #e01e5a; font-size: 11px; font-weight: 800; padding: 0 6px; }

.msg { position: relative; display: grid; grid-template-columns: 52px minmax(0, 1fr); padding: 6px 16px 6px 12px; }
.msg.cont { padding-top: 1px; padding-bottom: 1px; }
.msg:hover { background: var(--hover); }
.msg.mentioned { background: var(--mention-row); box-shadow: inset 3px 0 0 #e0a800; }
.msg.pinned { background: rgba(42, 120, 214, 0.06); }
.msg.flash { animation: flash 2.4s ease-out; }
@keyframes flash { 0%, 40% { background: rgba(250, 178, 25, 0.35); } 100% { background: transparent; } }
.gutter { padding-top: 2px; }
.gutter .avatar-wrap { cursor: pointer; }
.hover-time { display: none; font-size: 11px; color: var(--muted); padding-top: 4px; }
.msg.cont:hover .hover-time { display: block; }
.msg-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.msg-head .name { font-weight: 800; background: none; border: 0; padding: 0; cursor: pointer; color: var(--text); }
.msg-head .name:hover { text-decoration: underline; }
.msg-head .time { font-size: 12px; color: var(--muted); text-decoration: none; }
.msg-head .time:hover { text-decoration: underline; }
.status-emoji { font-size: 13px; }
.pin-tag { font-size: 11px; color: var(--accent); }
.body { overflow-wrap: anywhere; }
.body p { margin: 0; }
.body p + p, .body ul, .body ol, .body pre, .body blockquote { margin-top: 4px; }
.body ul, .body ol { margin-bottom: 0; padding-left: 22px; }
.body blockquote { margin: 4px 0; padding-left: 10px; border-left: 4px solid var(--border); color: var(--text-2); }
.body h1, .body h2, .body h3 { font-size: 1.05em; margin: 6px 0 2px; }
.me-action { font-style: italic; color: var(--text-2); }
.edited { font-size: 11px; color: var(--muted); margin-left: 4px; }
.mention { background: var(--mention-bg); color: var(--mention-ink); padding: 0 2px; border-radius: 3px; font-weight: 600; cursor: pointer; }
.mention-all { cursor: default; }
.channel-link { background: rgba(42, 120, 214, 0.1); padding: 0 2px; border-radius: 3px; text-decoration: none; }
.msg.system { display: flex; gap: 10px; align-items: baseline; padding: 3px 16px 3px 64px; color: var(--muted); font-size: 13px; }
.sys-time { font-size: 11px; min-width: 40px; }
.msg.system .body p { margin: 0; }
.msg.ephemeral { background: rgba(34, 127, 133, 0.08); border-left: 3px solid var(--brand); }
.reply-to { background: none; border: 0; padding: 0; color: var(--muted); font-size: 12px; cursor: pointer; }
.reply-to::before { content: "↳ "; }

.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.img-link img { max-width: min(360px, 100%); max-height: 300px; border-radius: 8px; border: 1px solid var(--border); display: block; }
.file { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: var(--text); background: var(--surface); max-width: 360px; }
.file span { display: flex; flex-direction: column; min-width: 0; }
.file strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-icon { font-size: 22px; }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction { display: inline-flex; gap: 4px; align-items: center; border: 1px solid var(--border); background: var(--surface-2); border-radius: 999px; padding: 1px 8px; font-size: 13px; cursor: pointer; }
.reaction .n { font-size: 12px; font-weight: 700; color: var(--text-2); }
.reaction.mine { border-color: var(--accent); background: rgba(42, 120, 214, 0.12); }
.reaction.add { opacity: 0; color: var(--muted); }
.msg:hover .reaction.add { opacity: 1; }
.thread-sum { display: inline-flex; gap: 6px; align-items: center; margin-top: 4px; padding: 3px 8px; border: 1px solid transparent; border-radius: 8px; background: none; cursor: pointer; color: var(--accent); font-size: 13px; }
.thread-sum:hover { border-color: var(--border); background: var(--surface); }

.actions { position: absolute; right: 16px; top: -14px; display: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); padding: 2px; }
.msg:hover .actions, .msg:focus-within .actions { display: flex; }
.actions button { background: none; border: 0; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 15px; line-height: 1; }
.actions button:hover { background: var(--hover); }
.edit-box textarea { width: 100%; min-height: 60px; border: 1px solid var(--brand); border-radius: 8px; padding: 8px; font: inherit; background: var(--surface); color: var(--text); resize: vertical; }
.edit-actions { display: flex; gap: 8px; align-items: center; margin-top: 6px; }

.typing { height: 20px; padding: 0 20px; font-size: 12px; color: var(--muted); font-style: italic; }
.join-bar { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 14px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: 14px; }

/* ---------- composer ---------- */
.composer { padding: 0 16px 10px; }
.composer-box { display: flex; align-items: flex-end; gap: 4px; border: 1px solid var(--border); border-radius: 10px; padding: 6px; background: var(--surface); }
.composer-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.composer textarea { flex: 1; border: 0; resize: none; background: transparent; color: var(--text); font: inherit; padding: 6px 4px; max-height: 240px; outline: none; }
.send-btn { background: var(--brand); color: #fff; border: 0; border-radius: 7px; width: 34px; height: 32px; cursor: pointer; font-size: 15px; }
.composer-hint { font-size: 11px; color: var(--muted); padding: 4px 4px 0; }
.file-chips, .picked { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chip { display: inline-flex; gap: 6px; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 13px; cursor: default; }
.chip button { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 2px 6px; }
button.chip { cursor: pointer; padding: 4px 10px; }
.also { display: flex; gap: 6px; font-size: 13px; color: var(--text-2); padding: 6px 4px 0; align-items: center; }

/* ---------- side panel ---------- */
.panel { display: flex; flex-direction: column; border-left: 1px solid var(--border); background: var(--surface); min-height: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); min-height: 58px; }
.panel-head h2 { font-size: 16px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-body { flex: 1; overflow-y: auto; padding: 8px 0; }
.panel-body .msg { grid-template-columns: 46px minmax(0, 1fr); padding-left: 10px; }
.panel-body > .btn { margin: 8px 14px; }
.thread-sep { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 4px 14px; }
.thread-sep::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.result { border-bottom: 1px solid var(--border); padding: 6px 0; }
.result-where { background: none; border: 0; padding: 2px 14px; font-size: 12px; font-weight: 700; color: var(--text-2); cursor: pointer; text-align: left; }
.result-where:hover { color: var(--accent); }
.pad { padding: 16px; }
.member { display: flex; align-items: center; gap: 10px; padding: 6px 14px; }
.member .name { background: none; border: 0; padding: 0; cursor: pointer; font-weight: 600; flex: 1; text-align: left; }
.profile { padding: 20px; text-align: center; }
.profile h2 { margin: 12px 0 4px; }
.profile dl { text-align: left; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 16px 0; font-size: 14px; }
.profile dt { color: var(--muted); }
.profile dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- popups, modals, toast ---------- */
.popup { position: fixed; z-index: 50; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18); max-height: 320px; overflow-y: auto; }
.ac-row { display: flex; gap: 8px; align-items: center; padding: 6px 10px; cursor: pointer; font-size: 14px; }
.ac-row.active { background: var(--brand); color: #fff; }
.ac-row.active .muted { color: rgba(255, 255, 255, 0.8); }
.ac-row .em { font-size: 18px; }
.emoji-pop { width: 300px; padding: 8px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; margin-top: 8px; }
.emoji-grid button { background: none; border: 0; font-size: 20px; padding: 4px; border-radius: 6px; cursor: pointer; }
.emoji-grid button:hover { background: var(--hover); }
.menu { min-width: 220px; padding: 4px; }
.menu-item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 7px 12px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.menu-item:hover { background: var(--brand); color: #fff; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger); color: #fff; }
.modal { border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100% - 24px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); }
.modal::backdrop { background: rgba(0, 0, 0, 0.45); }
.modal-inner { padding: 22px; }
.modal-inner h2 { margin: 0 0 14px; font-size: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal-links { display: flex; gap: 16px; margin-top: 8px; }
.pick-list { display: flex; flex-direction: column; max-height: 240px; overflow-y: auto; }
.pick { display: flex; gap: 8px; align-items: center; background: none; border: 0; padding: 6px 8px; border-radius: 6px; cursor: pointer; text-align: left; }
.pick:hover, .pick.active { background: var(--hover); }
.browse-list { max-height: 360px; overflow-y: auto; margin-bottom: 10px; }
.browse-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1a1a18; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 60; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); max-width: calc(100% - 32px); }
.drop-hint { position: fixed; inset: 12px; border: 3px dashed var(--brand); border-radius: 16px; background: rgba(34, 127, 133, 0.12); display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; color: var(--brand); z-index: 70; pointer-events: none; }

/* ---------- ordinary pages (sign in, profile, admin) ---------- */
body.page { overflow: auto; }
.page-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; background: var(--side-bg); color: #fff; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 800; text-decoration: none; font-size: 17px; }
.page-top nav { display: flex; gap: 18px; align-items: center; }
.page-top nav a, .page-top .link { color: var(--side-text); text-decoration: none; }
.page-top form { display: inline; }
.page-main { max-width: 1040px; margin: 0 auto; padding: 24px 16px 48px; }
.page-main.narrow { max-width: 640px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow-x: auto; }
.card h2 { margin-top: 0; font-size: 17px; }
.flash { list-style: none; padding: 0; margin: 0 0 16px; }
.flash li { padding: 10px 14px; border-radius: 8px; background: rgba(31, 157, 85, 0.12); border: 1px solid rgba(31, 157, 85, 0.35); margin-bottom: 8px; }
.flash li.error { background: rgba(192, 47, 47, 0.1); border-color: rgba(192, 47, 47, 0.35); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--text-2); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font-size: 12px; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); }
table.list td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list tr.inactive td { opacity: .55; }
table.list .avatar { vertical-align: middle; }
table.list select { padding: 4px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
form.inline { display: inline; }
.row-fields { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row-fields .grow { flex: 1; min-width: 220px; }
input.copy { font-family: var(--mono); font-size: 12px; min-width: 280px; }

.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: linear-gradient(160deg, var(--side-bg), #1f5d61); }
.auth-card { width: min(440px, 100%); background: var(--surface); border-radius: 16px; padding: 32px 28px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); text-align: center; }
.auth-card form { text-align: left; margin-top: 18px; }
.auth-card h1 { font-size: 22px; margin: 12px 0 6px; }
.form-error { background: rgba(192, 47, 47, 0.1); color: var(--danger); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .shell, body.with-panel .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; width: 280px; transform: translateX(-100%); transition: transform .2s; }
  body.show-sidebar .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, 0.4); }
  .panel { position: fixed; inset: 0; z-index: 45; }
  .mobile-only { display: inline-block; }
  .search input { width: 140px; }
  .composer-hint { display: none; }
  .pane-tools #pinsBtn, .pane-tools #starBtn { display: none; }
}
@media (max-width: 560px) {
  .search { display: none; }
  .two { grid-template-columns: 1fr; }
  .msg { grid-template-columns: 44px minmax(0, 1fr); padding-left: 8px; padding-right: 8px; }
  .actions { right: 8px; }
}

/* ---------- admin ---------- */
.page-main.admin-main { max-width: 1240px; }
.admin { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start; }
.admin-nav { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; }
.admin-ws { display: flex; flex-direction: column; padding: 6px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; overflow-wrap: anywhere; }
.admin-nav a { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 7px; text-decoration: none; color: var(--text-2); font-weight: 600; font-size: 14px; }
.admin-nav a:hover { background: var(--hover); }
.admin-nav a.active { background: var(--brand); color: #fff; }
.admin-nav .ni { width: 20px; text-align: center; }
.admin-nav .badge { margin-left: auto; }
.admin-body h1 { margin-top: 0; }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .v { font-size: 22px; font-weight: 800; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 2px; }
.pdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); margin-left: 6px; }
.pdot.online { background: var(--good); } .pdot.away { background: var(--away); }
.bars-chart { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-top: 8px; border-bottom: 1px solid var(--border); }
.bar-col { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.bar { width: 100%; min-height: 2px; background: var(--brand); border-radius: 3px 3px 0 0; }
.bar-col:hover .bar { filter: brightness(1.2); }
.chart-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.two-col > .card { margin-bottom: 16px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters .input { width: auto; min-width: 200px; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 12px 0; }
table.list.compact td, table.list.compact th { padding: 6px 12px; }
table.list .num, table.list .center { text-align: center; }
table.list td.num { text-align: right; }
table.list tr.current td { background: rgba(34, 127, 133, 0.08); }
.actions-cell { text-align: right; white-space: nowrap; }
.help { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 3px; }
.pill.good { background: rgba(31, 157, 85, 0.14); color: var(--good); border-color: transparent; }
.pill.bad { background: rgba(192, 47, 47, 0.12); color: var(--danger); border-color: transparent; }
.error-text { color: var(--danger); }
.features { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px; }
.features li.on { font-weight: 600; } .features li.off { color: var(--muted); }
.emoji-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.emoji-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.emoji-tile img { width: 40px; height: 40px; object-fit: contain; }
.bridge { border-top: 1px solid var(--border); padding: 12px 0; display: flex; flex-direction: column; gap: 6px; }
.bridge.inactive { opacity: .6; }
.steps { padding-left: 20px; font-size: 14px; color: var(--text-2); }
.report .quoted { border-left: 3px solid var(--border); padding: 6px 12px; margin: 8px 0; }
.card textarea.input { resize: vertical; }
img.emoji { width: 1.4em; height: 1.4em; vertical-align: -0.35em; object-fit: contain; }
.announcement { background: var(--brand); color: #fff; font-size: 14px; padding: 6px 16px; display: flex; gap: 12px; align-items: center; }
.announcement span { flex: 1; }
.announcement button { background: none; border: 0; color: #fff; cursor: pointer; font-size: 16px; }
@media (max-width: 900px) {
  .admin { grid-template-columns: 1fr; }
  .admin-nav { position: static; flex-direction: row; flex-wrap: wrap; }
  .admin-ws { width: 100%; }
  .two-col { grid-template-columns: 1fr; }
}

/* ---------- WEESchat Cloud public site ---------- */
body.site { background: var(--surface); }
.site-top { display: flex; justify-content: space-between; align-items: center; padding: 14px 32px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 5; }
.site-top .brand { color: var(--text); }
.site-top nav { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.site-top nav a:not(.btn) { color: var(--text-2); text-decoration: none; font-weight: 600; }
.hero { text-align: center; padding: 72px 16px 56px; background: linear-gradient(160deg, var(--side-bg), #1f5d61); color: #fff; }
.hero h1 { font-size: clamp(30px, 5vw, 48px); margin: 0 0 14px; }
.hero p { font-size: 19px; max-width: 680px; margin: 0 auto 10px; color: #d9ecec; }
.hero .muted { color: #a8cfd0; }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 24px 0 12px; }
.btn.big { padding: 13px 22px; font-size: 16px; }
.section { padding: 56px 16px; max-width: 1100px; margin: 0 auto; }
.section.alt { max-width: none; background: var(--bg); }
.section.alt > * { max-width: 1100px; margin-left: auto; margin-right: auto; }
.section h2 { text-align: center; font-size: 30px; margin: 0 0 24px; }
.center { text-align: center; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.feature-grid h3 { margin: 0 0 6px; font-size: 17px; }
.feature-grid p { margin: 0; color: var(--text-2); }
.price-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin: 24px auto; }
.price-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; text-align: center; }
.price-card.featured { border: 2px solid var(--brand); }
.price-card h3 { margin: 0 0 8px; }
.price { font-size: 26px; font-weight: 800; }
.price span { font-size: 13px; font-weight: 400; color: var(--muted); }
table.compare { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin: 24px auto; }
.site-foot { text-align: center; padding: 24px; color: var(--muted); border-top: 1px solid var(--border); }
.wide-card { width: min(520px, 100%); }
.slug-row { display: flex; align-items: center; gap: 4px; margin-top: 5px; }
.slug-row .input { margin-top: 0 !important; }
.slug-suffix { color: var(--muted); font-weight: 400; white-space: nowrap; }
@media (max-width: 700px) { .site-top { padding: 12px 16px; } .site-top nav a:not(.btn):not(:nth-last-child(2)) { display: none; } }
.pill.wees { background: var(--brand); color: #fff; border-color: transparent; }
.install-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 7px 16px; font-size: 13px; background: rgba(34, 127, 133, 0.10); border-bottom: 1px solid var(--border); }
.install-bar .install-text { flex: 1; min-width: 220px; }
.install-bar a.small:not(.btn) { color: var(--accent); }
.download-hero { text-align: center; margin: 12px 0 24px; }
.download-hero h1 { margin: 10px 0 6px; }
