/* ============================================================
   TANDEM — plateforme collaborative
   Design : sidebar + main + (right rail). Tons bleus ardoise,
   bordures fines, typo Inter Tight pour le corps.
   ============================================================ */

* { box-sizing: border-box; }

:root {
  --bg-app: #0a1320;
  --bg-side: #0d1828;
  --bg-main: #111c2e;
  --bg-rail: #0e1827;
  --bg-card: #15233a;
  --bg-hover: #1c2c47;
  --bg-elev: #1f3050;

  --ink-0: #eef3fb;
  --ink-1: #b8c4d4;
  --ink-2: #7c8aa0;
  --ink-3: #4f5d72;

  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);

  --accent: #5cb8d8;
  --accent-strong: #7dd3ee;
  --accent-glow: rgba(92, 184, 216, 0.4);

  --warn: #f5a25b;
  --error: #f87171;
  --ok: #5dd391;

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter Tight', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius: 10px;
  --radius-lg: 14px;
}

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg-app);
  color: var(--ink-0);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}
body { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ================ App root ================ */
.app-root {
  height: 100vh;
  width: 100vw;
  display: grid;
  background: var(--bg-app);
}
.app-root[data-state="loading"] {
  place-items: center;
}
.app-root[data-state="login"], .app-root[data-state="redeem"] {
  place-items: center;
  background:
    radial-gradient(ellipse at top left, rgba(92, 184, 216, 0.18), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(92, 132, 216, 0.12), transparent 50%),
    var(--bg-app);
}
.app-root[data-state="app"] {
  grid-template-columns: 280px 1fr;
}
.app-root[data-state="app"].with-rail {
  grid-template-columns: 280px 1fr 320px;
}

.boot-loader {
  display: flex; gap: 6px;
  align-items: center; justify-content: center;
}
.boot-loader span {
  width: 9px; height: 9px;
  background: var(--accent);
  border-radius: 50%;
  animation: bounce 1.2s ease-in-out infinite;
}
.boot-loader span:nth-child(2) { animation-delay: 0.15s; }
.boot-loader span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50% { transform: translateY(-8px); opacity: 1; }
}

/* ================ Login screen ================ */
.login-card {
  width: 100%;
  max-width: 440px;
  background: linear-gradient(180deg, var(--bg-card), var(--bg-side));
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 40px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}
.login-brand {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 32px;
}
.login-mark {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #2a5d80);
  display: grid; place-items: center;
  position: relative;
  box-shadow: 0 8px 24px var(--accent-glow);
}
.login-mark::before, .login-mark::after {
  content: ''; width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid white;
  position: absolute;
}
.login-mark::before { left: 8px; }
.login-mark::after { right: 8px; }
.login-name {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700;
  letter-spacing: 0.18em;
}
.login-tag {
  font-size: 12px;
  color: var(--ink-2);
  letter-spacing: 0.04em;
}
.login-card h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 8px 0;
  letter-spacing: -0.02em;
}
.login-card .subtitle {
  color: var(--ink-1);
  font-size: 14px;
  margin: 0 0 28px 0;
}
.login-card .form-row { margin-bottom: 16px; }
.login-card label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.login-card input {
  width: 100%;
  background: var(--bg-app);
  border: 1px solid var(--line-strong);
  color: var(--ink-0);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.login-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.login-card .form-error {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--error);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #428aa8);
  color: white;
  border: none;
  padding: 13px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
  transition: transform 0.18s, box-shadow 0.18s;
  box-shadow: 0 6px 20px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 24px var(--accent-glow); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-secondary {
  display: inline-flex;
  align-items: center; justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--ink-0);
  border: 1px solid var(--line-strong);
  padding: 11px 16px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 14px;
  transition: background 0.18s, border-color 0.18s;
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--ink-2); }
.btn-ghost {
  background: transparent;
  border: none;
  color: var(--ink-1);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  transition: color 0.18s, background 0.18s;
}
.btn-ghost:hover { color: var(--ink-0); background: var(--bg-hover); }
.btn-danger {
  background: rgba(248, 113, 113, 0.16);
  color: var(--error);
  border: 1px solid rgba(248, 113, 113, 0.3);
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 13px;
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.25); }

.login-foot {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-2);
  display: flex; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
}
.login-foot a { color: var(--accent-strong); }
.login-hint {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-app);
  border: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-2);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}
.login-hint strong { color: var(--ink-1); }

/* ================ Sidebar ================ */
.sidebar {
  background: var(--bg-side);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-mark {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #2a5d80);
  display: grid; place-items: center;
  position: relative;
  box-shadow: 0 4px 14px var(--accent-glow);
  flex-shrink: 0;
}
.sidebar-mark::before, .sidebar-mark::after {
  content: ''; width: 11px; height: 11px;
  border-radius: 50%;
  border: 1.6px solid white;
  position: absolute;
}
.sidebar-mark::before { left: 6px; }
.sidebar-mark::after { right: 6px; }
.sidebar-title {
  flex: 1;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.16em;
}
.sidebar-back {
  display: flex; align-items: center;
  color: var(--ink-2);
  padding: 6px;
  border-radius: 6px;
}
.sidebar-back:hover { color: var(--ink-0); background: var(--bg-hover); }

.sidebar-nav {
  padding: 12px 12px 0;
}
.nav-section {
  margin-bottom: 16px;
}
.nav-section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 4px;
}
.nav-section-head button {
  background: none; border: none;
  color: var(--ink-2);
  padding: 4px;
  border-radius: 5px;
  display: inline-flex;
}
.nav-section-head button:hover { color: var(--ink-0); background: var(--bg-hover); }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  background: none; border: none;
  color: var(--ink-1);
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 14px;
  text-align: left;
  transition: background 0.16s, color 0.16s;
  margin-bottom: 1px;
}
.nav-item:hover { background: var(--bg-hover); color: var(--ink-0); }
.nav-item.is-active {
  background: linear-gradient(90deg, rgba(92, 184, 216, 0.18), rgba(92, 184, 216, 0.04));
  color: var(--ink-0);
  border-left: 2px solid var(--accent);
  padding-left: 8px;
}
.nav-item-icon {
  width: 18px; height: 18px;
  color: var(--ink-2);
  flex-shrink: 0;
}
.nav-item.is-active .nav-item-icon { color: var(--accent); }
.nav-item-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  background: rgba(245, 162, 91, 0.18);
  color: var(--warn);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.06em;
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--line);
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.16s;
}
.user-chip:hover { background: var(--bg-hover); }
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 600;
  color: white;
  font-size: 13px;
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.18);
}
.user-info { flex: 1; overflow: hidden; }
.user-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 11px;
  color: var(--ink-2);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ================ Main column ================ */
.main {
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  overflow: hidden;
  position: relative;
}
.main-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 24, 40, 0.7);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}
.main-head h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  display: flex; align-items: center; gap: 8px;
}
.main-head h2 svg { color: var(--accent); }
.main-head-meta {
  font-size: 13px;
  color: var(--ink-2);
  display: flex; align-items: center; gap: 8px;
}
.main-head-actions {
  margin-left: auto;
  display: flex; gap: 8px;
}
.head-tabs {
  display: flex; gap: 0;
  margin-left: 16px;
}
.head-tab {
  background: none; border: none;
  color: var(--ink-2);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}
.head-tab:hover { color: var(--ink-0); background: var(--bg-hover); }
.head-tab.is-active {
  color: var(--accent-strong);
  background: rgba(92, 184, 216, 0.12);
}

.main-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Messages */
.msg-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.msg {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 12px;
  padding: 6px 8px 6px 8px;
  border-radius: 8px;
  transition: background 0.12s;
  position: relative;
}
.msg:hover { background: rgba(255, 255, 255, 0.025); }
.msg.is-grouped { grid-template-rows: auto; padding-top: 2px; padding-bottom: 2px; }
.msg.is-grouped .msg-avatar { visibility: hidden; }
.msg.is-grouped .msg-head { display: none; }
.msg-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 600;
  color: white;
  font-size: 13px;
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.16);
  user-select: none;
}
.msg-content { min-width: 0; }
.msg-head {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 2px;
}
.msg-author {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-0);
}
.msg-role-pill {
  font-family: var(--font-mono);
  font-size: 9px;
  background: rgba(92, 184, 216, 0.18);
  color: var(--accent-strong);
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.msg-time {
  font-size: 11px;
  color: var(--ink-2);
  font-family: var(--font-mono);
}
.msg-body {
  font-size: 14.5px;
  color: var(--ink-1);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg-body em { color: var(--ink-0); font-style: italic; }
.msg-attach {
  margin-top: 8px;
  display: inline-flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  max-width: 420px;
  text-decoration: none;
}
.msg-attach:hover { border-color: var(--accent); background: var(--bg-elev); }
.msg-attach-icon {
  width: 32px; height: 32px;
  background: var(--bg-elev);
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--accent-strong);
  flex-shrink: 0;
}
.msg-attach-meta { min-width: 0; }
.msg-attach-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-0);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 280px;
}
.msg-attach-detail {
  font-size: 11px;
  color: var(--ink-2);
  font-family: var(--font-mono);
}
.msg-actions {
  position: absolute;
  top: 0; right: 8px;
  display: none;
  gap: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
}
.msg:hover .msg-actions { display: flex; }
.msg-action-btn {
  background: none; border: none;
  color: var(--ink-2);
  padding: 5px;
  border-radius: 5px;
  display: inline-flex;
}
.msg-action-btn:hover { color: var(--ink-0); background: var(--bg-hover); }
.msg-action-btn.is-danger:hover { color: var(--error); }

.msg-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 14px 0 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-2);
  letter-spacing: 0.08em;
}
.msg-divider::before, .msg-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.msg-empty {
  margin: auto;
  padding: 60px 30px;
  text-align: center;
  color: var(--ink-2);
}
.msg-empty-icon {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: var(--bg-card);
  display: grid; place-items: center;
  color: var(--accent);
}
.msg-empty h3 {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--ink-0);
  margin: 0 0 6px 0;
}
.msg-empty p { margin: 0; font-size: 14px; }

/* Composer */
.composer {
  border-top: 1px solid var(--line);
  padding: 14px 24px 18px;
  background: rgba(13, 24, 40, 0.5);
  flex-shrink: 0;
}
.composer-bar {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 8px 10px;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.composer-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.composer-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink-0);
  resize: none;
  min-height: 36px;
  max-height: 200px;
  font-size: 14.5px;
  line-height: 1.45;
  padding: 8px 6px;
  font-family: inherit;
}
.composer-input::placeholder { color: var(--ink-2); }
.composer-btn {
  background: none; border: none;
  color: var(--ink-2);
  width: 36px; height: 36px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.16s, color 0.16s;
}
.composer-btn:hover { color: var(--ink-0); background: var(--bg-hover); }
.composer-send {
  background: var(--accent);
  color: white;
}
.composer-send:hover:not(:disabled) {
  background: var(--accent-strong);
  color: var(--bg-app);
}
.composer-send:disabled { opacity: 0.4; cursor: default; }
.composer-attached {
  margin-top: 8px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--ink-1);
}
.composer-attached button {
  background: none; border: none;
  color: var(--ink-2);
  padding: 2px;
  display: inline-flex;
}
.composer-attached button:hover { color: var(--error); }

/* Drag-drop overlay */
.drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(13, 24, 40, 0.92);
  backdrop-filter: blur(6px);
  border: 2px dashed var(--accent);
  border-radius: 16px;
  margin: 16px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
}
.drop-overlay.is-active { display: flex; }
.drop-overlay-inner {
  text-align: center;
  color: var(--accent-strong);
}
.drop-overlay-inner h3 {
  font-family: var(--font-display);
  font-size: 24px;
  margin: 8px 0 4px;
}
.drop-overlay-inner p { color: var(--ink-1); margin: 0; font-size: 14px; }

/* ================ Right rail ================ */
.rail {
  background: var(--bg-rail);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.rail-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}
.rail-head h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  margin: 0 0 4px 0;
}
.rail-head p {
  font-size: 12px;
  color: var(--ink-2);
  margin: 0;
}
.rail-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 20px;
}
.rail-section { margin-bottom: 28px; }
.rail-section h4 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 10px 0;
}
.rail-member {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0;
}
.rail-member-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  color: white;
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.16);
}
.rail-member-info { flex: 1; min-width: 0; }
.rail-member-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rail-member-job {
  font-size: 11px;
  color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ================ Files view ================ */
.files-grid {
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  overflow-y: auto;
}
.file-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  display: flex; flex-direction: column;
  gap: 10px;
  transition: border-color 0.18s, transform 0.18s;
  position: relative;
}
.file-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.file-icon-wrap {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--bg-elev);
  display: grid; place-items: center;
  color: var(--accent-strong);
}
.file-icon-wrap.is-img { background: linear-gradient(135deg, rgba(95, 132, 216, 0.18), rgba(92, 184, 216, 0.05)); color: #a4d8ff; }
.file-icon-wrap.is-video { background: linear-gradient(135deg, rgba(216, 92, 132, 0.16), rgba(216, 92, 92, 0.04)); color: #f0a4d4; }
.file-icon-wrap.is-archive { background: linear-gradient(135deg, rgba(216, 184, 92, 0.16), rgba(180, 132, 60, 0.04)); color: #f0d090; }
.file-name {
  font-weight: 500;
  font-size: 14px;
  word-break: break-word;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.file-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px;
  color: var(--ink-2);
  font-family: var(--font-mono);
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.file-actions {
  position: absolute;
  top: 12px; right: 12px;
  display: flex; gap: 4px;
  opacity: 0;
  transition: opacity 0.18s;
}
.file-card:hover .file-actions { opacity: 1; }
.file-action {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--ink-1);
  width: 28px; height: 28px;
  border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
}
.file-action:hover { color: var(--ink-0); border-color: var(--accent); }
.file-action.is-danger:hover { color: var(--error); border-color: var(--error); }

/* ================ Empty states ================ */
.empty-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 30px;
  text-align: center;
  color: var(--ink-2);
}
.empty-pane h3 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink-0);
  margin: 14px 0 6px 0;
  letter-spacing: -0.01em;
}
.empty-pane p {
  margin: 0; font-size: 14px;
  max-width: 360px;
  line-height: 1.5;
}
.empty-icon {
  width: 64px; height: 64px;
  border-radius: 16px;
  background: var(--bg-card);
  display: grid; place-items: center;
  color: var(--accent);
  margin-bottom: 8px;
}

/* ================ Admin panel ================ */
.admin-pane {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
.admin-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
}
.stat-card-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 8px;
}
.stat-card-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink-0);
}

.admin-section {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
}
.admin-section-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
}
.admin-section h3 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  flex: 1;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.admin-table thead th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-weight: 500;
}
.admin-table tbody td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: var(--bg-hover); }
.role-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.role-pill.is-admin { background: rgba(245, 162, 91, 0.18); color: var(--warn); }
.role-pill.is-member { background: rgba(92, 184, 216, 0.18); color: var(--accent-strong); }
.invite-row code {
  font-family: var(--font-mono);
  background: var(--bg-app);
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--accent-strong);
  border: 1px solid var(--line);
}

/* ================ Modal ================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 18, 0.72);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 30px;
  animation: fade-in 0.18s ease-out;
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--bg-side);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  animation: pop-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}
@keyframes pop-in {
  from { transform: translateY(20px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 24px 14px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  margin: 0;
}
.modal-close {
  background: none; border: none;
  color: var(--ink-2);
  width: 32px; height: 32px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
}
.modal-close:hover { color: var(--ink-0); background: var(--bg-hover); }
.modal-body { padding: 22px 24px; }
.modal-foot {
  padding: 16px 24px 22px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.field {
  display: flex; flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.field input, .field textarea, .field select {
  background: var(--bg-app);
  border: 1px solid var(--line-strong);
  color: var(--ink-0);
  padding: 11px 14px;
  border-radius: 9px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.field textarea { resize: vertical; min-height: 80px; font-family: inherit; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.field-help {
  font-size: 12px;
  color: var(--ink-2);
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Invite link card */
.invite-result {
  background: var(--bg-app);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
}
.invite-result h4 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 10px 0;
  display: flex; align-items: center; gap: 6px;
}
.invite-link-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card);
  padding: 10px 12px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--accent-strong);
  word-break: break-all;
}
.invite-link-box button {
  flex-shrink: 0;
  background: none; border: 1px solid var(--line);
  color: var(--ink-1);
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 11px;
}
.invite-link-box button:hover { color: var(--ink-0); border-color: var(--accent); }
.invite-result .invite-line {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px;
  color: var(--ink-1);
  padding: 6px 0;
}
.invite-result .invite-line span { color: var(--ink-2); }
.invite-result .invite-line strong code {
  font-family: var(--font-mono);
  background: var(--bg-card);
  color: var(--accent-strong);
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 12px;
  letter-spacing: 0.08em;
}

/* ================ Toasts ================ */
.toasts {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13.5px;
  color: var(--ink-0);
  max-width: 360px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  animation: slide-in 0.22s ease-out;
}
.toast.is-error { border-color: rgba(248, 113, 113, 0.45); }
.toast.is-ok { border-color: rgba(93, 211, 145, 0.45); }
@keyframes slide-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ================ Scrollbars ================ */
.msg-list::-webkit-scrollbar,
.rail-body::-webkit-scrollbar,
.admin-pane::-webkit-scrollbar,
.files-grid::-webkit-scrollbar,
.modal::-webkit-scrollbar {
  width: 10px;
}
.msg-list::-webkit-scrollbar-track,
.rail-body::-webkit-scrollbar-track,
.admin-pane::-webkit-scrollbar-track,
.files-grid::-webkit-scrollbar-track,
.modal::-webkit-scrollbar-track {
  background: transparent;
}
.msg-list::-webkit-scrollbar-thumb,
.rail-body::-webkit-scrollbar-thumb,
.admin-pane::-webkit-scrollbar-thumb,
.files-grid::-webkit-scrollbar-thumb,
.modal::-webkit-scrollbar-thumb {
  background: var(--bg-elev);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.msg-list::-webkit-scrollbar-thumb:hover,
.rail-body::-webkit-scrollbar-thumb:hover,
.admin-pane::-webkit-scrollbar-thumb:hover,
.files-grid::-webkit-scrollbar-thumb:hover,
.modal::-webkit-scrollbar-thumb:hover {
  background: var(--bg-hover);
  background-clip: padding-box;
}

/* ================ Responsive ================ */
@media (max-width: 1100px) {
  .app-root[data-state="app"] { grid-template-columns: 240px 1fr; }
  .app-root[data-state="app"].with-rail { grid-template-columns: 240px 1fr; }
  .rail { display: none; }
  .admin-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .app-root[data-state="app"] { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .login-card { padding: 28px; max-width: 92vw; }
  .files-grid { padding: 16px; }
}
