:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel2: #f9fafc;
  --text: #172033;
  --muted: #647084;
  --line: #dfe5ef;
  --line2: #ecf0f6;
  --brand: #2563eb;
  --brand2: #1d4ed8;
  --soft: #eff6ff;
  --good: #16a34a;
  --bad: #dc2626;
  --shadow: 0 12px 32px rgba(15, 23, 42, .08);
  --radius: 18px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.appShell { display: grid; grid-template-columns: 290px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.brandBlock { display:flex; align-items:center; gap:12px; margin-bottom: 4px; }
.logoMark { width:42px; height:42px; border-radius: 14px; background: linear-gradient(135deg, var(--brand), #60a5fa); color:#fff; display:grid; place-items:center; font-weight:800; }
.brandName { font-weight: 800; letter-spacing:-.03em; font-size:20px; }
.brandSub { color: var(--muted); font-size: 12px; margin-top:2px; }
.sectionLabel { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 11px; font-weight: 800; margin-top: 6px; }
.spaceList { display:flex; flex-direction:column; gap:8px; overflow:auto; padding-right: 2px; }
.spaceItem { border:1px solid transparent; background: transparent; color:var(--text); padding:12px 12px; border-radius:14px; text-align:left; display:flex; flex-direction:column; gap:3px; }
.spaceItem:hover { background: var(--panel2); border-color: var(--line2); }
.spaceItem.active { background: var(--soft); border-color:#bfdbfe; color:#0f3a8a; }
.spaceItem .title { font-weight: 750; }
.spaceItem .slug { color: var(--muted); font-size: 12px; }
.main { padding: 22px; min-width:0; display:flex; flex-direction:column; gap:14px; }
.topbar { background: var(--panel); border:1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; display:flex; justify-content:space-between; align-items:center; gap:18px; }
.pageTitle { font-weight: 850; font-size: 24px; letter-spacing: -.04em; }
.pageMeta { color: var(--muted); margin-top: 4px; font-size: 14px; }
.topActions { display:flex; align-items:center; gap:10px; flex-wrap:wrap; justify-content:flex-end; }
.status { border:1px solid var(--line); border-radius: 999px; padding:8px 11px; background: var(--panel2); color: var(--muted); font-size:13px; }
.status.online { color:#166534; border-color:#bbf7d0; background:#f0fdf4; }
.status.offline { color:#991b1b; border-color:#fecaca; background:#fff1f2; }
.tabs { display:flex; gap:8px; padding: 4px; background:#fff; border:1px solid var(--line); border-radius: 16px; width:max-content; max-width:100%; overflow:auto; }
.tab { border:0; background:transparent; border-radius: 12px; padding:10px 14px; color: var(--muted); font-weight:700; white-space: nowrap; }
.tab.active { background: var(--brand); color:#fff; }
.view { display:none; min-height:0; }
.view.active { display:block; }
.card { background: var(--panel); border:1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.feed { height: calc(100vh - 365px); min-height: 260px; overflow:auto; padding: 16px; display:flex; flex-direction:column; gap:12px; }
.emptyState { border:1px dashed #cbd5e1; background:#f8fafc; border-radius:16px; padding:30px; text-align:center; color:var(--muted); }
.post { border:1px solid var(--line2); border-radius:16px; padding:14px 15px; background:#fff; }
.post.mine { border-color:#bfdbfe; background:#fbfdff; }
.postTop { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom: 8px; }
.kind { background:#f1f5f9; color:#334155; border-radius:999px; padding:5px 9px; font-size:12px; font-weight:800; text-transform:uppercase; letter-spacing:.03em; }
.postTime { color:var(--muted); font-size:12px; }
.post h3 { margin: 0 0 8px; font-size:16px; }
.postBody { white-space:pre-wrap; line-height:1.48; color:#263348; }
.postFoot { display:flex; gap:7px; flex-wrap:wrap; margin-top:12px; }
.pill { background:#f8fafc; border:1px solid var(--line2); color:var(--muted); border-radius:999px; padding:4px 8px; font-size:12px; }
.composer { margin-top:14px; padding: 14px; }
.composer.disabled { opacity:.48; pointer-events:none; }
.composerGrid { display:grid; grid-template-columns: 160px 220px minmax(0, 1fr); gap:10px; margin-bottom:10px; }
.composer textarea { width:100%; min-height:96px; resize:vertical; }
.composerActions { display:grid; grid-template-columns: minmax(0,1fr) auto auto auto; align-items:center; gap:10px; margin-top:10px; }
input, textarea, select { border:1px solid var(--line); background:#fff; color:var(--text); border-radius:12px; padding:11px 12px; outline:none; }
input:focus, textarea:focus, select:focus { border-color:#93c5fd; box-shadow:0 0 0 4px rgba(37,99,235,.10); }
.button, .primary, .uploadBtn { border:1px solid var(--line); background:#fff; color:var(--text); border-radius:12px; padding:10px 13px; font-weight:750; }
.button:hover, .uploadBtn:hover { background:#f8fafc; }
.button.subtle { color:var(--muted); }
.primary { border-color:var(--brand); background:var(--brand); color:#fff; }
.primary:hover { background:var(--brand2); }
.wide { width:100%; justify-content:center; }
.uploadBtn { display:inline-flex; align-items:center; justify-content:center; }
.fileName { color: var(--muted); font-size:13px; max-width: 220px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.panelHead { padding:18px 20px; display:flex; justify-content:space-between; align-items:center; gap:16px; margin-bottom:14px; }
.panelHead.inline { box-shadow:none; border:0; padding:0; margin-bottom:12px; }
h2 { margin:0; font-size:19px; letter-spacing:-.02em; }
p { margin: 6px 0 0; color: var(--muted); }
.filesGrid { display:grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap:12px; }
.fileCard { background:#fff; border:1px solid var(--line); border-radius:18px; padding:15px; box-shadow: var(--shadow); display:flex; flex-direction:column; gap:12px; }
.fileIcon { width:40px; height:40px; border-radius:13px; background:var(--soft); color:var(--brand); display:grid; place-items:center; font-weight:900; }
.fileHead { display:flex; align-items:flex-start; gap:12px; }
.fileTitle { font-weight:800; overflow-wrap:anywhere; }
.fileMeta { color:var(--muted); font-size:13px; margin-top:3px; }
.fileActions { display:flex; gap:8px; flex-wrap:wrap; margin-top:auto; }
.membersLayout { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap:14px; margin-bottom:14px; }
.membersLayout .card, #viewMembers > .card { padding:18px; }
.membersLayout input, .membersLayout select, .membersLayout button { width:100%; margin-top:10px; }
.muted { color:var(--muted); font-size:14px; }
.keyBox { display:none; white-space:pre-wrap; background:#0f172a; color:#e5e7eb; border-radius:14px; padding:12px; overflow:auto; margin-top:12px; }
.keyBox.show { display:block; }
.memberList { display:flex; flex-direction:column; gap:8px; }
.memberRow { border:1px solid var(--line2); background:#fff; border-radius:14px; padding:12px; display:flex; align-items:center; justify-content:space-between; gap:12px; }
.memberRow small { color:var(--muted); margin-left:6px; }
.memberRole { color:var(--brand); font-weight:800; }
dialog { border:0; border-radius:20px; padding:0; box-shadow:0 24px 80px rgba(15,23,42,.24); width:min(520px, calc(100vw - 32px)); }
dialog::backdrop { background:rgba(15,23,42,.32); }
.dialogCard { padding:22px; display:flex; flex-direction:column; gap:11px; }
.dialogTitle { font-size:22px; font-weight:850; letter-spacing:-.03em; }
.dialogActions { display:flex; justify-content:flex-end; gap:10px; margin-top:8px; }
#toast { position:fixed; right:20px; bottom:20px; background:#111827; color:#fff; border-radius:14px; padding:12px 14px; opacity:0; transform:translateY(8px); transition:.18s; pointer-events:none; box-shadow: var(--shadow); }
#toast.show { opacity:1; transform:translateY(0); }
#toast.err { background:#991b1b; }
@media (max-width: 900px) {
  .appShell { grid-template-columns:1fr; }
  .sidebar { border-right:0; border-bottom:1px solid var(--line); }
  .spaceList { flex-direction:row; overflow:auto; }
  .spaceItem { min-width: 180px; }
  .topbar, .panelHead { flex-direction:column; align-items:flex-start; }
  .composerGrid, .composerActions, .membersLayout { grid-template-columns:1fr; }
  .feed { height: 420px; }
}
