/* CynchCom — Discord-style dark UI, mobile-first */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg-0: #101116;
  --bg-1: #1a1c22;
  --bg-2: #23252d;
  --bg-3: #2c2f38;
  --text: #e6e7ea;
  --muted: #9a9da6;
  --accent: #5b8cff;
  --accent-2: #7aa2ff;
  --green: #3ecf8e;
  --red: #f0556b;
  --radius: 10px;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-0);
  color: var(--text);
  overscroll-behavior: none;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.8rem; }
button { cursor: pointer; font: inherit; }

/* ---------- auth ---------- */
.auth-screen {
  height: 100dvh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 20% -10%, #1e2743 0%, var(--bg-0) 60%);
  padding: 16px;
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--bg-1);
  border: 1px solid #2e3140; border-radius: 16px; padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.auth-card h1 { font-size: 1.7rem; letter-spacing: -0.02em; }
.auth-card h1 span, .sidebar-head h2 span { color: var(--accent); }
.tagline { color: var(--muted); margin: 4px 0 24px; font-size: .9rem; }
.auth-card form { display: flex; flex-direction: column; gap: 10px; }
.auth-card input {
  background: var(--bg-2); border: 1px solid #333645; color: var(--text);
  border-radius: var(--radius); padding: 12px 14px; font-size: 1rem; outline: none;
}
.auth-card input:focus { border-color: var(--accent); }
.auth-error { color: var(--red); font-size: .85rem; min-height: 1em; }
.form-note { color: var(--muted); font-size: .9rem; margin-bottom: 6px; }
.record-note { color: #e8b33e; font-size: .8rem; margin-top: 8px; }

.btn {
  border: none; border-radius: var(--radius); padding: 11px 16px;
  background: var(--bg-3); color: var(--text); font-weight: 600;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.call { background: var(--green); color: #06281a; }
.icon-btn {
  background: transparent; border: none; color: var(--muted); font-size: 1rem;
  padding: 6px 8px; border-radius: 8px;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text); }

/* ---------- layout ---------- */
.app { display: flex; height: 100dvh; overflow: hidden; }
.sidebar {
  width: 250px; min-width: 250px; background: var(--bg-1); display: flex;
  flex-direction: column; border-right: 1px solid #262935;
}
.sidebar-head { padding: 16px; border-bottom: 1px solid #262935; display: flex; justify-content: space-between; align-items: center; }
.sidebar-section { flex: 1; overflow-y: auto; padding: 12px 8px; }
.section-title {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 8px 6px; color: var(--muted); font-size: .75rem;
  text-transform: uppercase; letter-spacing: .08em;
}
.channel-list { list-style: none; }
.channel-list li {
  padding: 7px 10px; border-radius: 8px; color: var(--muted); cursor: pointer;
  font-size: .95rem;
  -webkit-tap-highlight-color: transparent;
}
.channel-list li:hover { background: var(--bg-2); color: var(--text); }
.channel-list li.active { background: var(--bg-3); color: var(--text); }
.channel-list li .hash { color: var(--accent); font-weight: 700; }
.channel-list li .lock { font-size: .75rem; }
.ch-row { display: flex; align-items: center; gap: 6px; }
.ch-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-online {
  margin-left: auto; font-size: .68rem; color: var(--muted);
  background: var(--bg-2); border-radius: 8px; padding: 1px 7px;
}
.channel-list li.active .ch-online { background: var(--bg-1); }
.voice-list { list-style: none; padding-left: 18px; }
.voice-list li { padding: 0; }
.voice-list .voice-row, .voice-list li {
  display: flex; align-items: center; gap: 6px;
  font-size: .8rem; color: var(--muted); padding: 2px 0;
}
.voice-icon { font-size: .7rem; }
.sidebar-foot {
  padding: 10px 12px; border-top: 1px solid #262935; display: flex;
  justify-content: space-between; align-items: center; gap: 8px;
}
.me { display: flex; align-items: center; gap: 8px; min-width: 0; }
.me-info { min-width: 0; }
.me-info > div:first-child { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: .9rem; flex-shrink: 0;
}
.foot-actions { display: flex; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.channel-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid #262935; background: var(--bg-1);
}
.channel-title { flex: 1; min-width: 0; }
.channel-title h3 { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-actions { display: flex; gap: 4px; align-items: center; }

.record-banner {
  background: #3a1420; color: #ff9daf; text-align: center; font-size: .78rem;
  padding: 5px 10px; letter-spacing: .03em;
}
.record-banner.warn { background: #3a2e10; color: #e8b33e; }

/* ---------- call stage ---------- */
.call-stage { background: #000; padding: 10px; border-bottom: 1px solid #262935; }
.rtk-mount { height: min(72dvh, 640px); }
.rtk-mount rtk-meeting { display: block; height: 100%; }
.video-grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.video-tile { position: relative; border-radius: 10px; overflow: hidden; background: var(--bg-2); aspect-ratio: 16/9; }
.video-tile video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.video-tile.screen video { object-fit: contain; }
.video-tile .label {
  position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.6);
  padding: 2px 8px; border-radius: 6px; font-size: .75rem;
}
.call-controls { display: flex; justify-content: center; gap: 12px; padding: 10px 0 4px; }
.ctl {
  width: 46px; height: 46px; border-radius: 50%; border: none;
  background: var(--bg-3); color: var(--text); font-size: 1.15rem;
}
.ctl.off { background: #4a1f29; }
.ctl.on { background: var(--accent); }
.ctl.danger { background: var(--red); }

/* ---------- chat ---------- */
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 2px; }
.msg { display: flex; gap: 10px; padding: 3px 6px; border-radius: 8px; }
.msg:hover { background: var(--bg-1); }
.msg.first { margin-top: 12px; }
.msg .avatar { width: 38px; height: 38px; }
.msg .spacer { width: 38px; flex-shrink: 0; }
.msg-body { min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-head .name { font-weight: 600; font-size: .95rem; }
.msg-head .name.guest { color: #e8b33e; }
.msg-head .time { color: var(--muted); font-size: .72rem; }
.msg-text { font-size: .95rem; line-height: 1.45; word-wrap: break-word; white-space: pre-wrap; }
.typing { min-height: 20px; padding: 0 18px; color: var(--muted); font-size: .78rem; font-style: italic; }
.chat-form { display: flex; gap: 8px; padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); background: var(--bg-1); }
.chat-form input {
  flex: 1; background: var(--bg-2); border: 1px solid #333645; color: var(--text);
  border-radius: var(--radius); padding: 12px 14px; font-size: 1rem; outline: none; min-width: 0;
}
.chat-form input:focus { border-color: var(--accent); }

/* ---------- members panel ---------- */
.members-panel {
  width: 230px; background: var(--bg-1); border-left: 1px solid #262935;
  padding: 12px; overflow-y: auto; flex-shrink: 0;
}
.members-panel.collapsed { display: none; }
.members-panel header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.members-panel h4 { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.members-panel ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.members-panel li {
  display: flex; align-items: center; gap: 8px; font-size: .9rem;
  padding: 4px 6px; border-radius: 8px;
}
.members-panel li:hover { background: var(--bg-2); }
.members-panel li.me-row .m-name { color: var(--accent-2); }
.members-panel .avatar.sm { width: 26px; height: 26px; font-size: .68rem; }
.members-panel .m-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.members-panel .m-tags { flex-shrink: 0; font-size: .8rem; }

/* ---------- modal / toast ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex;
  align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal {
  background: var(--bg-1); border: 1px solid #2e3140; border-radius: 14px;
  padding: 22px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 10px;
}
.modal h3 { margin-bottom: 4px; }
.modal input, .modal select {
  background: var(--bg-2); border: 1px solid #333645; color: var(--text);
  border-radius: var(--radius); padding: 11px 13px; font-size: 1rem; outline: none; width: 100%;
}
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.modal label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; }
.modal .link-out {
  background: var(--bg-2); padding: 10px; border-radius: 8px; font-size: .8rem;
  word-break: break-all; color: var(--accent-2);
}
/* ---------- settings ---------- */
.settings-modal { max-width: 540px; max-height: 88dvh; overflow-y: auto; }
.settings-section { border-top: 1px solid #262935; padding-top: 12px; margin-top: 8px; }
.settings-section h4 {
  text-transform: uppercase; font-size: .72rem; color: var(--muted);
  letter-spacing: .08em; margin-bottom: 10px;
}
.setting-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 10px;
}
.setting-row > label { color: var(--text); font-size: .9rem; flex-shrink: 0; }
.setting-row select, .setting-row input { width: auto; flex: 1; min-width: 0; max-width: 62%; }
.check-row {
  display: flex; align-items: center; gap: 10px; color: var(--text);
  font-size: .9rem; margin-bottom: 8px; cursor: pointer;
}
.check-row input { width: auto; accent-color: var(--accent); }
.mic-test { display: flex; align-items: center; gap: 10px; flex: 1; max-width: 62%; }
.meter { height: 10px; background: var(--bg-2); border-radius: 6px; overflow: hidden; flex: 1; }
.meter-fill { height: 100%; width: 0; background: var(--green); transition: width .06s linear; }
.cam-preview {
  width: 100%; aspect-ratio: 16/9; background: #000; border-radius: 10px;
  display: none; margin-bottom: 10px;
}
.cam-preview.active { display: block; }
.perm-note {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--bg-2); border-radius: 8px; padding: 10px 12px;
  color: var(--muted); font-size: .85rem; margin-bottom: 10px;
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-3); color: var(--text); padding: 10px 18px;
  border-radius: 10px; font-size: .9rem; z-index: 100;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}

/* ---------- mobile ---------- */
.mobile-only { display: none; }
@media (max-width: 760px) {
  .mobile-only { display: inline-flex; }
  .sidebar {
    position: fixed; z-index: 40; height: 100dvh; left: 0; top: 0;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.6);
  }
  .sidebar.open { transform: translateX(0); }
  .members-panel {
    display: none;
    position: fixed; right: 0; top: 0; height: 100dvh; z-index: 40;
    box-shadow: 0 0 40px rgba(0,0,0,.6);
  }
  .members-panel.open { display: block; }
  .video-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .btn.call { font-size: .85rem; padding: 8px 10px; }
}
