  :root {
    --bg-page: #f6f7f9;
    --bg-card: #ffffff;
    --bg-soft: #eef0f3;
    --border: #dbdee4;
    --text: #14161c;
    --text-muted: #5b6070;
    --text-faint: #9ba0ad;
    --accent: #6d3ce1;
    --accent-soft: #efe9fc;
    --accent-hover: #5a2fc2;
    --danger: #d8384a;
    --danger-soft: #fbe9ec;
    --success: #158059;
    --success-soft: #e4f3ec;
    --radius: 3px;
    --radius-sm: 2px;
    --font-display: "Space Grotesk", "Inter", sans-serif;
    --font-body: "Inter", system-ui, -apple-system, sans-serif;
    --font-mono: "JetBrains Mono", "SF Mono", monospace;
  }
  * { box-sizing: border-box; }
  body {
    font-family: var(--font-body);
    max-width: 1320px; margin: 0 auto; padding: 0 16px 28px;
    color: var(--text); background: var(--bg-page);
  }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 0; flex-wrap: nowrap; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
  .topbar-title { min-width: 0; }
  .topbar-title h1 { font-size: 17px; margin-bottom: 1px; }
  .topbar-title .subtitle { margin-bottom: 0; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
  .topbar-controls input[type=text] { width: 200px; flex: none; }
  .icon-btn-lg { background: var(--bg-card); border: 1px solid var(--border); padding: 8px 11px; font-size: 15px; line-height: 1; flex-shrink: 0; }
  .icon-btn-lg:hover { border-color: var(--accent); }
  #topbarAvatarImg, #topbarAvatarInitials { width: 32px; height: 32px; flex-shrink: 0; }
  h1 { font-family: var(--font-display); font-size: 20px; margin-bottom: 2px; font-weight: 700; letter-spacing: -0.01em; }
  .subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 18px; line-height: 1.4; }
  .card {
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 16px; margin-bottom: 14px; background: var(--bg-card);
  }
  .fingerprint {
    font-family: var(--font-mono); font-size: 11.5px; word-break: break-all;
    background: var(--bg-soft); color: var(--accent-hover); padding: 4px 8px; border-radius: var(--radius-sm);
    display: inline-block; border: 1px solid var(--border);
  }
  .fingerprint::before { content: "["; color: var(--text-faint); margin-right: 3px; }
  .fingerprint::after { content: "]"; color: var(--text-faint); margin-left: 3px; }
  .status {
    padding: 9px 14px; border-radius: var(--radius-sm); background: var(--bg-soft); color: var(--text-muted);
    margin-bottom: 14px; font-size: 13.5px; font-weight: 500; border: 1px solid var(--border);
  }
  .status.connected { background: var(--success-soft); color: var(--success); border-color: transparent; }
  .status.voice { background: var(--accent-soft); color: var(--accent-hover); border-color: transparent; }
  .row { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; }
  input[type=text], textarea, select {
    flex: 1; min-width: 0; padding: 9px 11px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 14px; box-sizing: border-box; font-family: inherit; background: var(--bg-card); color: var(--text);
    transition: border-color .15s ease;
  }
  input[type=text]:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
  textarea { resize: vertical; min-height: 40px; }
  button {
    padding: 9px 16px; border: 1px solid var(--accent); border-radius: var(--radius-sm); background: var(--accent); color: white;
    cursor: pointer; font-size: 13.5px; font-weight: 600; transition: background .12s ease, border-color .12s ease;
    font-family: var(--font-body);
  }
  button:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
  button:active:not(:disabled) { background: var(--accent-hover); }
  button:disabled { background: var(--bg-soft); color: var(--text-faint); border-color: var(--border); cursor: not-allowed; }
  button.secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
  button.secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-hover); }
  button.small { padding: 5px 10px; font-size: 12px; }
  button.danger { background: var(--danger); border-color: var(--danger); }
  button.danger:hover:not(:disabled) { background: #b82c3d; border-color: #b82c3d; }
  button.accept { background: var(--success); border-color: var(--success); }
  button.accept:hover:not(:disabled) { background: #0f6647; border-color: #0f6647; }
  .layout { display: flex; gap: 16px; }
  .sidebar { flex-shrink: 0; min-width: 0; }
  .sidebar-servers { width: 260px; order: 1; }
  .main { flex: 1; min-width: 0; order: 2; }
  .sidebar-people { width: 220px; order: 3; }
  .list-item {
    display: flex; align-items: center; gap: 6px; padding: 7px 8px 7px 9px; font-size: 13.5px;
    border-radius: 0; cursor: pointer; border-left: 2px solid transparent; transition: background .1s ease, border-color .1s ease;
  }
  .list-item:hover { background: var(--bg-soft); }
  .list-item.active { background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; border-left-color: var(--accent); }
  .list-item.in-voice { border-left-color: var(--success); }
  .list-item.dragging { opacity: 0.35; }
  .list-item.drag-over-top { border-top: 2px solid var(--accent); }
  .list-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .list-item .count { color: var(--text-faint); font-size: 11px; flex-shrink: 0; font-family: var(--font-mono); }
  .list-item .icon-btn { flex-shrink: 0; background: none; color: var(--text-faint); padding: 2px 5px; font-size: 12px; border-radius: var(--radius-sm); }
  .list-item .icon-btn:hover { color: var(--danger); background: var(--danger-soft); }
  .drag-handle { cursor: grab; color: var(--text-faint); font-size: 13px; flex-shrink: 0; }
  .drag-handle:active { cursor: grabbing; }
  .cat-header {
    display: flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 700; color: var(--text-faint);
    text-transform: uppercase; letter-spacing: .08em; margin: 14px 0 4px; padding: 0 4px; font-family: var(--font-mono);
  }
  .cat-header:first-child { margin-top: 2px; }
  .cat-header .icon-btn { background: none; color: var(--text-faint); font-size: 11px; padding: 0 3px; }
  #log {
    border: 1px solid var(--border); border-radius: var(--radius); height: 360px; overflow-y: auto;
    padding: 14px; margin-bottom: 12px; background: var(--bg-card);
  }
  .msg { margin-bottom: 12px; display: flex; gap: 9px; }
  .msg .content { flex: 1; min-width: 0; }
  .msg .meta { font-size: 11px; color: var(--text-faint); margin-bottom: 3px; display: flex; gap: 6px; align-items: center; font-family: var(--font-mono); }
  .msg .meta b { color: var(--text); cursor: pointer; font-weight: 600; font-family: var(--font-body); }
  .msg .meta b:hover { text-decoration: underline; }
  .msg .text { font-size: 14px; line-height: 1.45; }
  .msg.sys { justify-content: center; color: var(--text-faint); font-size: 12px; font-style: italic; margin-bottom: 8px; }
  .msg .del-btn { display: none; background: none; color: var(--danger); padding: 0 4px; font-size: 11px; font-weight: 500; }
  .msg:hover .del-btn { display: inline; }
  .avatar {
    width: 30px; height: 30px; border-radius: 6px; object-fit: cover; flex-shrink: 0;
    background: var(--accent); color: white; display: flex; align-items: center;
    justify-content: center; font-size: 12px; font-weight: 700; cursor: pointer; font-family: var(--font-mono);
  }
  .avatar.big { width: 64px; height: 64px; font-size: 22px; cursor: default; border-radius: 10px; }
  .avatar.small { width: 22px; height: 22px; font-size: 10px; border-radius: 4px; }
  .profile-row { display: flex; gap: 14px; align-items: center; }
  .profile-fields { flex: 1; min-width: 0; }
  .conv-title { font-weight: 700; margin-bottom: 10px; font-size: 15.5px; display: flex; align-items: center; gap: 10px; justify-content: space-between; font-family: var(--font-display); }
  .section-title {
    font-weight: 700; margin-bottom: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
    color: var(--text-muted); display: flex; justify-content: space-between; align-items: center; font-family: var(--font-mono);
  }
  .create-row { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
  .create-row .btns { display: flex; gap: 6px; }
  .create-row .btns button { flex: 1; }
  .role-badge {
    display: inline-flex; align-items: center; gap: 3px; font-size: 10px; font-weight: 600; padding: 2px 7px;
    border-radius: var(--radius-sm); color: white;
  }
  .role-dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex-shrink: 0; }
  .role-row {
    display: flex; align-items: center; gap: 7px; padding: 6px 6px; font-size: 12.5px; border-radius: var(--radius-sm);
    transition: background .1s ease;
  }
  .role-row:hover { background: var(--bg-soft); }
  .role-row.dragging { opacity: 0.35; }
  .role-row.drag-over { background: var(--accent-soft); }
  .role-row .name { flex: 1; font-weight: 500; }
  .icon-btn.danger-hover:hover { color: var(--danger); }
  .perm-checks { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; margin: 8px 0; color: var(--text-muted); }
  .perm-checks label { display: flex; align-items: center; gap: 4px; }
  .voice-bar {
    display: none; align-items: center; gap: 10px; background: var(--success-soft);
    border-color: var(--success);
  }
  .voice-participants { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
  .voice-participant {
    display: flex; align-items: center; gap: 5px; font-size: 12px; background: var(--bg-card);
    border-radius: var(--radius-sm); padding: 3px 10px 3px 3px; border: 1px solid var(--border);
  }
  .call-banner { display: flex; align-items: center; gap: 10px; background: var(--accent-soft); border-color: var(--accent); }
  .user-row { display: flex; align-items: center; gap: 6px; padding: 6px 4px; font-size: 13px; border-radius: var(--radius-sm); }
  .user-row:hover { background: var(--bg-soft); }
  .user-row .name-click { display:flex; align-items:center; gap:8px; cursor:pointer; flex:1; min-width:0; }
  .user-row .name-click span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight: 500; }

  .modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(10,10,16,0.55); align-items: center; justify-content: center; z-index: 100; }
  .modal-backdrop.open { display: flex; }
  .modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; width: 320px; max-width: 90vw; }
  .settings-modal { width: 420px; max-height: 82vh; overflow-y: auto; }
  .settings-tabs { display: flex; gap: 4px; margin: 4px 0 18px; border-bottom: 1px solid var(--border); }
  .settings-tab { background: none; color: var(--text-muted); font-weight: 600; padding: 8px 12px; border-radius: 0; border: none; border-bottom: 2px solid transparent; }
  .settings-tab:hover { background: var(--bg-soft); }
  .settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
  .settings-panel { font-size: 13px; }
  #meetingChevron { color: var(--text-faint); font-weight: normal; font-family: var(--font-mono); }
  .modal .close-btn { float: right; background: none; border: none; color: var(--text-faint); padding: 0 4px; font-size: 16px; }
  .modal .close-btn:hover { color: var(--text); }
  .modal-bio { font-size: 13px; color: var(--text-muted); margin: 10px 0; white-space: pre-wrap; line-height: 1.4; }
  .assign-chip-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
  .empty-hint { color: var(--text-faint); font-size: 12px; padding: 4px 2px; }
  .status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--text-faint); }
  .status-dot.online { background: var(--success); }
  .friend-star { background: none; color: var(--text-faint); font-size: 15px; padding: 2px 4px; flex-shrink: 0; }
  .friend-star.active { color: var(--accent); }
  .friend-star:hover { color: var(--accent); }
  .unverified-warning { font-size: 11px; color: var(--danger); margin-top: 3px; font-weight: 600; }

/* ============================================================
   MOTIVY — přepínají se přidáním třídy na <body>, přepisují stejné
   CSS proměnné definované v :root výš. Cokoli v appce, co používá
   var(--...), se automaticky přebarví. Palety navazují na to, čím
   appka skutečně je — self-hosted, šifrovaný, technický nástroj — ne
   náhodné pastelové motivy typické pro "SaaS appky".
   ============================================================ */

body.theme-dark {
  --bg-page: #0b0d12; --bg-card: #12151c; --bg-soft: #191d26;
  --border: #262b36; --text: #e7e9ee; --text-muted: #8b93a3; --text-faint: #565d6d;
  --accent: #8b6bff; --accent-soft: #241c42; --accent-hover: #a488ff;
  --danger: #ff6b7a; --danger-soft: #2e1620; --success: #34c99a; --success-soft: #10241d;
}
body.theme-midnight {
  --bg-page: #0a0b14; --bg-card: #12131f; --bg-soft: #191b2b;
  --border: #262842; --text: #ece9fb; --text-muted: #9691c4; --text-faint: #5f5a8c;
  --accent: #c05fff; --accent-soft: #2b1c42; --accent-hover: #d687ff;
  --danger: #ff6690; --danger-soft: #33172a; --success: #45d6b0; --success-soft: #12312a;
}
body.theme-terminal {
  --bg-page: #050805; --bg-card: #0b120b; --bg-soft: #101b10;
  --border: #1e2e1e; --text: #c8ffcb; --text-muted: #6fa377; --text-faint: #3e6146;
  --accent: #39ff6a; --accent-soft: #0f2a15; --accent-hover: #6bff93;
  --danger: #ff5c5c; --danger-soft: #2a0e0e; --success: #39ff6a; --success-soft: #0f2a15;
}
body.theme-amber {
  --bg-page: #120d08; --bg-card: #1a130c; --bg-soft: #241a10;
  --border: #362613; --text: #ffe3b0; --text-muted: #b8925c; --text-faint: #6e5636;
  --accent: #ffb020; --accent-soft: #3a2610; --accent-hover: #ffc658;
  --danger: #ff6b5c; --danger-soft: #331410; --success: #4fd48a; --success-soft: #14311f;
}

.theme-swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.theme-swatch {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  background: none; padding: 5px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer;
}
.theme-swatch:hover { background: var(--bg-soft); }
.theme-swatch.active { border-color: var(--accent); }
.theme-swatch .dot { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border); }
.theme-swatch .label { font-size: 9.5px; color: var(--text-muted); font-weight: 600; font-family: var(--font-mono); text-transform: uppercase; }
