*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #f5f6fa;
  --surface:  #ffffff;
  --border:   #e2e5ec;
  --accent:   #4f6ef7;
  --accent-h: #3b56d6;
  --text:     #1e2330;
  --muted:    #7a8499;
  --danger:   #e05252;
  --radius:   8px;
  --sidebar-w: 180px;
  --files-w:   220px;
}

body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); }

/* ---- Login ---- */
.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2.5rem 2rem; width: 340px;
  box-shadow: 0 4px 24px rgba(0,0,0,.07);
}
.login-card h1 { font-size: 1.8rem; margin-bottom: .25rem; }
.tagline { color: var(--muted); font-size: .9rem; margin-bottom: 1.5rem; }
.login-card input {
  width: 100%; padding: .65rem .8rem; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 1rem; margin-bottom: .75rem;
  outline: none; transition: border-color .15s;
}
.login-card input:focus { border-color: var(--accent); }
.btn-row { display: flex; gap: .5rem; }
.btn-row button {
  flex: 1; padding: .65rem; border: none; border-radius: var(--radius);
  font-size: 1rem; cursor: pointer; transition: background .15s;
}
#loginBtn    { background: var(--accent); color: #fff; }
#loginBtn:hover { background: var(--accent-h); }
#registerBtn { background: var(--border); color: var(--text); }
#registerBtn:hover { background: #d4d8e8; }
.error-banner {
  background: #fdeaea; color: var(--danger); border: 1px solid #f5c6c6;
  border-radius: var(--radius); padding: .6rem .8rem; margin-bottom: .75rem;
  font-size: .9rem;
}

/* ---- App Layout ---- */
.app-body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.topbar {
  display: flex; align-items: center; gap: 1rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: .6rem 1rem; flex-shrink: 0;
}
.logo { font-weight: 700; font-size: 1.2rem; color: var(--accent); margin-right: auto; }
.my-username { font-size: .9rem; color: var(--muted); }
.logout-btn {
  padding: .35rem .8rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: none; cursor: pointer;
  font-size: .85rem; color: var(--muted);
}
.logout-btn:hover { background: var(--bg); color: var(--danger); border-color: var(--danger); }

.layout { display: flex; flex: 1; overflow: hidden; }

/* Sidebars */
.sidebar, .files-panel {
  background: var(--surface); border-color: var(--border);
  flex-shrink: 0; padding: 1rem; overflow-y: auto;
}
.sidebar    { width: var(--sidebar-w); border-right: 1px solid var(--border); }
.files-panel { width: var(--files-w); border-left:  1px solid var(--border); }

.sidebar h3, .files-panel h3 {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin-bottom: .75rem;
}

.user-list, .file-list { list-style: none; }

.user-list li {
  padding: .4rem .5rem; border-radius: 6px; cursor: pointer;
  font-size: .9rem; display: flex; align-items: center; gap: .5rem;
}
.user-list li:hover { background: var(--bg); }
.user-list li.active { background: #eef0fd; color: var(--accent); font-weight: 600; }
.user-list li::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #4caf50; flex-shrink: 0; }
.user-list li.self::before { background: var(--accent); }

.file-list li {
  padding: .35rem 0; border-bottom: 1px solid var(--border);
  font-size: .82rem; word-break: break-all;
}
.file-list a { color: var(--accent); text-decoration: none; }
.file-list a:hover { text-decoration: underline; }
.file-meta { color: var(--muted); font-size: .75rem; }

/* Chat */
.chat-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.chat-header {
  padding: .6rem 1rem; border-bottom: 1px solid var(--border);
  background: var(--surface); display: flex; align-items: center; gap: .75rem; flex-shrink: 0;
}
.target-label { font-weight: 600; font-size: .95rem; }
.clear-target {
  font-size: .8rem; color: var(--muted); background: none; border: none;
  cursor: pointer; text-decoration: underline;
}

.messages {
  flex: 1; overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: .5rem;
}

.msg {
  max-width: 70%; padding: .5rem .8rem; border-radius: 12px;
  font-size: .9rem; line-height: 1.4; word-break: break-word;
}
.msg.me    { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 3px; }
.msg.other { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.msg.system { align-self: center; background: none; color: var(--muted); font-size: .8rem; font-style: italic; }
.msg .sender { font-weight: 600; font-size: .75rem; margin-bottom: .2rem; opacity: .8; }
.msg a { color: inherit; }
.msg.me a { color: #c8d6ff; }

/* Composer */
.composer {
  display: flex; gap: .5rem; padding: .75rem 1rem;
  border-top: 1px solid var(--border); background: var(--surface); flex-shrink: 0;
}
.composer input[type=text] {
  flex: 1; padding: .55rem .8rem; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: .95rem; outline: none;
}
.composer input[type=text]:focus { border-color: var(--accent); }
.composer button, .upload-label {
  padding: .55rem .9rem; border: none; border-radius: var(--radius);
  font-size: .9rem; cursor: pointer; background: var(--accent); color: #fff;
  white-space: nowrap; transition: background .15s;
}
.composer button:hover, .upload-label:hover { background: var(--accent-h); }
#linkBtn   { background: #6c757d; }
#linkBtn:hover { background: #5a6268; }
.upload-label { display: inline-flex; align-items: center; }
