:root {
  --bg-darker: #1e1f22;
  --bg-sidebar: #2b2d31;
  --bg-main: #313338;
  --bg-secondary: #232428;
  --bg-tertiary: #111214;
  --bg-modifier-selected: rgba(78, 80, 88, 0.6);
  --bg-modifier-hover: rgba(78, 80, 88, 0.3);
  --bg-input: #383a40;
  
  --text-normal: #dbdee1;
  --text-muted: #949ba4;
  --text-strong: #f2f3f5;
  --text-link: #00a8fc;
  
  --brand: #5865f2;
  --brand-hover: #4752c4;
  --green: #23a559;
  --danger: #f23f43;
  --yellow: #f0b232;
  
  --font-main: "gg sans", "Inter", "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100vh;
  background: var(--bg-darker);
  color: var(--text-normal);
  font-family: var(--font-main);
  overflow: hidden;
}

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #242529; }

button { border: 0; cursor: pointer; transition: all 150ms ease; background: none; color: inherit; font: inherit; padding: 0; }
input, select { border: 0; outline: none; background: var(--bg-input); color: var(--text-normal); font: inherit; }

.hidden { display: none !important; }

/* Auth Screen */
.auth-screen {
  display: grid;
  place-items: center;
  height: 100vh;
  background-image: url("https://discord.com/assets/f9a15998e94589d343f7.png");
  background-size: cover;
}
.auth-card {
  width: min(480px, 92vw);
  background: var(--bg-sidebar);
  border-radius: 8px;
  padding: 32px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  text-align: center;
}
.brand-large {
  width: 80px;
  height: 80px;
  background: var(--brand);
  color: #fff;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 40px;
  font-weight: 800;
  margin: 0 auto 20px;
}
.auth-card h1 { margin: 0 0 8px; color: var(--text-strong); }
.auth-card p { margin: 0 0 24px; color: var(--text-muted); }
#login-btn {
  width: 100%;
  background: var(--brand);
  color: #fff;
  padding: 12px;
  border-radius: 3px;
  font-weight: 600;
  font-size: 16px;
}
#login-btn:hover { background: var(--brand-hover); }

/* Main Layout */
.shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 72px 240px 1fr 240px;
  background: var(--bg-main);
}

/* Server Rail */
.server-rail {
  background: var(--bg-darker);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 8px;
  overflow-y: auto;
  scrollbar-width: none;
}
.server-rail::-webkit-scrollbar { display: none; }
.guild-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 0;
}

.brand, .guild-pill {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  position: relative;
  background: var(--bg-sidebar);
}

.brand { background: var(--brand); color: #fff; border-radius: 16px; margin-bottom: 2px; }
.brand:hover { border-radius: 16px; }

.separator {
  width: 32px;
  height: 2px;
  background: var(--bg-modifier-selected);
  margin-bottom: 2px;
  border-radius: 1px;
}

.guild-pill:hover, .guild-pill.active {
  border-radius: 16px;
  background: var(--brand);
  color: #fff;
}

.guild-pill::before {
  content: "";
  position: absolute;
  left: -12px;
  width: 4px;
  height: 0;
  background: #fff;
  border-radius: 0 4px 4px 0;
  transition: all 0.2s ease;
}
.guild-pill:hover::before { height: 20px; }
.guild-pill.active::before { height: 40px; }

.action-pill { color: var(--green); }
.action-pill:hover { background: var(--green); color: #fff; }

/* Channel Sidebar */
.channel-sidebar {
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 0 16px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--bg-darker);
  box-shadow: 0 1px 0 rgba(0,0,0,0.1);
  cursor: pointer;
  transition: background-color 0.1s;
}
.sidebar-header:hover { background: var(--bg-modifier-hover); }
.sidebar-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-action-btn {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
}
.header-action-btn:hover {
  background: var(--bg-modifier-hover);
  color: var(--text-normal);
}
.header-action-btn i {
  width: 16px;
  height: 16px;
}

.sidebar-scroll { flex: 1; overflow-y: auto; padding-top: 12px; }

.sidebar-group { margin-bottom: 20px; }
.group-title {
  padding: 0 8px 0 2px;
  display: flex;
  align-items: center;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.24px;
  cursor: pointer;
}
.group-title:hover { color: var(--text-normal); }
.group-toggle { width: 12px; height: 12px; margin-right: 2px; }
.group-title span { flex: 1; }
.add-btn {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  opacity: 0.7;
  transition: opacity 0.2s, background-color 0.2s;
  display: grid;
  place-items: center;
}
.add-btn:hover {
  opacity: 1;
  background: var(--bg-modifier-hover);
}
.add-btn i { width: 16px; height: 16px; }

.channel-list { padding: 0 8px; display: flex; flex-direction: column; gap: 2px; }
.channel-row {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-radius: 4px;
  color: var(--text-muted);
  font-weight: 500;
  gap: 6px;
}
.channel-row:hover { background: var(--bg-modifier-hover); color: var(--text-normal); }
.channel-row.active { background: var(--bg-modifier-selected); color: var(--text-strong); }
.channel-row i { width: 20px; height: 20px; opacity: 0.6; }

/* Sidebar Footer */
.sidebar-footer { background: var(--bg-secondary); padding: 0; }

.user-panel {
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
}
.user-panel:hover { background: var(--bg-modifier-hover); }

.avatar-wrapper { position: relative; }
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
}
.status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid var(--bg-secondary);
}
.status-dot.online { background: var(--green); }

.user-info { flex: 1; min-width: 0; }
.display-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-status { font-size: 12px; color: var(--text-muted); }

.user-actions { display: flex; gap: 2px; }
.user-actions button {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
}
.user-actions button:hover { background: var(--bg-modifier-hover); color: var(--text-normal); }
.user-actions i { width: 20px; height: 20px; }

/* Voice Connection */
.voice-connection {
  padding: 8px;
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.vc-info { display: flex; align-items: center; gap: 8px; }
.vc-icon { color: var(--green); width: 20px; }
.vc-text { flex: 1; display: flex; flex-direction: column; }
.vc-status { color: var(--green); font-size: 14px; font-weight: 700; }
.vc-name { color: var(--text-muted); font-size: 12px; }
.vc-actions { display: flex; gap: 4px; }
.vc-actions button {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  color: var(--text-muted);
  display: grid;
  place-items: center;
}
.vc-actions button:hover { background: var(--bg-modifier-hover); color: var(--text-normal); }

/* Chat Pane */
.chat-pane {
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  min-width: 0;
}

.chat-header {
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(0,0,0,0.2);
  box-shadow: 0 1px 0 rgba(0,0,0,0.1);
}
.header-icon { color: var(--text-muted); width: 24px; }
.chat-header h3 { margin: 0; font-size: 16px; font-weight: 700; color: var(--text-strong); }

.message-list {
  flex: 1;
  overflow-y: scroll;
  padding: 16px 0;
}

.msg {
  padding: 2px 16px;
  display: flex;
  gap: 16px;
  margin-top: 1.0625rem;
}
.msg:hover { background: rgba(0,0,0,0.05); }

.msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--brand);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 600;
}

.msg-content { flex: 1; min-width: 0; }
.msg-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.msg-author {
  font-weight: 600;
  color: var(--text-strong);
  cursor: pointer;
  font-size: 1rem;
}
.msg-author:hover { text-decoration: underline; }
.msg-time { font-size: 12px; color: var(--text-muted); }
.msg-body { color: var(--text-normal); line-height: 1.375rem; white-space: pre-wrap; word-wrap: break-word; }

.msg-grouped { margin-top: 0; padding-top: 0; padding-bottom: 0; }
.msg-grouped .msg-avatar, .msg-grouped .msg-header { display: none; }
.msg-grouped .msg-content { padding-left: 56px; }

/* Chat Input */
.chat-input-wrapper { padding: 0 16px 24px; }
.message-form {
  background: var(--bg-input);
  border-radius: 8px;
  padding: 11px 16px;
}
.message-form input {
  width: 100%;
  background: transparent;
  color: var(--text-normal);
  font-size: 16px;
}
.message-form input::placeholder { color: var(--text-muted); }

/* Member List */
.utility-sidebar {
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
}
.member-list-wrapper { flex: 1; overflow-y: auto; padding: 12px 8px; }
.member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
}
.member-row:hover { background: var(--bg-modifier-hover); color: var(--text-normal); }
.member-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}
.member-name {
  font-weight: 500;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Modals */
.modal-container {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  display: grid;
  place-items: center;
  z-index: 1000;
}
.modal {
  background: var(--bg-sidebar);
  width: min(440px, 95vw);
  border-radius: 5px;
  padding: 24px;
  color: var(--text-normal);
}
.modal h2 { margin: 0 0 16px; text-align: center; color: var(--text-strong); }
.form-item { margin-bottom: 20px; }
.form-item label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.form-item input {
  width: 100%;
  padding: 10px;
  border-radius: 3px;
  background: var(--bg-darker);
}

.modal-footer {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
  gap: 16px;
}
.cancel-btn { padding: 10px 20px; color: var(--text-strong); font-weight: 500; }
.cancel-btn:hover { text-decoration: underline; }
.submit-btn {
  background: var(--brand);
  color: #fff;
  padding: 10px 24px;
  border-radius: 3px;
  font-weight: 600;
}
.submit-btn:hover { background: var(--brand-hover); }

/* Radio Group for Channel Type */
.radio-group { display: flex; flex-direction: column; gap: 8px; }
.radio-item { cursor: pointer; position: relative; }
.radio-item input { position: absolute; opacity: 0; }
.radio-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--bg-modifier-hover);
  border-radius: 4px;
  transition: all 0.1s;
}
.radio-item input:checked + .radio-box { background: var(--bg-modifier-selected); color: var(--text-strong); }
.radio-box i { width: 24px; height: 24px; color: var(--text-muted); }
.radio-text { display: flex; flex-direction: column; }
.radio-text strong { font-size: 16px; }
.radio-text span { font-size: 12px; color: var(--text-muted); }

/* Mobile Overlay */
.overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 90;
  opacity: 1;
  transition: opacity 0.2s ease;
}
.overlay.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

/* Mobile Toggle Buttons */
.mobile-toggle-btn {
  display: none;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  color: var(--text-normal);
  background: transparent;
  margin-right: 8px;
}
.mobile-toggle-btn:hover {
  background: var(--bg-modifier-hover);
  border-radius: 4px;
}

@media (max-width: 1100px) {
  .shell { grid-template-columns: 72px 240px 1fr; }
  .utility-sidebar {
    position: fixed;
    top: 0; bottom: 0; right: 0;
    width: 240px;
    z-index: 100;
    box-shadow: -2px 0 10px rgba(0,0,0,0.5);
    transform: translateX(100%);
    transition: transform 0.2s ease;
  }
  .utility-sidebar.active {
    transform: translateX(0);
    display: flex;
  }
  
  .chat-header .mobile-toggle-btn { display: flex; }
}

@media (max-width: 768px) {
  .shell {
    grid-template-columns: 1fr;
  }
  
  /* Hide sidebars by default on mobile */
  .server-rail, .channel-sidebar {
    position: fixed;
    top: 0; bottom: 0;
    z-index: 100;
    transition: transform 0.2s ease;
  }

  .server-rail {
    left: 0;
    width: 72px;
    transform: translateX(-100%);
  }
  
  .channel-sidebar {
    left: 72px;
    width: 240px;
    transform: translateX(-312px); /* 72 + 240 */
    box-shadow: 2px 0 10px rgba(0,0,0,0.5);
  }

  /* When menu is active */
  .shell.menu-open .server-rail {
    transform: translateX(0);
  }
  .shell.menu-open .channel-sidebar {
    transform: translateX(0);
    display: flex; /* Override display: none from previous rule */
  }

  /* Adjust chat header for mobile */
  .chat-header {
    padding: 0 8px;
  }
}
