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

  :root {
    --bg-primary:    #313338;
    --bg-secondary:  #2b2d31;
    --bg-tertiary:   #1e1f22;
    --bg-surface:    #383a40;
    --bg-floating:   #111214;
    --bg-accent:     #4e5058;

    --text-normal:   #dbdee1;
    --text-muted:    #949ba4;
    --text-link:     #00a8fc;

    --interactive-normal: #b5bac1;
    --interactive-hover:  #dbdee1;
    --interactive-muted:  #4e5058;

    --blurple:       #5865f2;
    --blurple-hover: #4752c4;
    --green:         #23a55a;
    --red:           #f23f43;
    --yellow:        #f0b232;

    --ch-default:    #8e9297;
    --ch-hover:      #dcddde;
    --ch-selected:   #ffffff;
    --ch-bg-hover:   rgba(255,255,255,0.06);
    --ch-bg-active:  rgba(255,255,255,0.10);

    --header-h:      48px;
    --sidebar-w:     240px;
    --server-w:      72px;

    --font: 'DM Sans', 'gg sans', 'Noto Sans', sans-serif;
    --mono: 'DM Mono', 'Consolas', monospace;

    --scrollbar-bg: rgba(0,0,0,0.2);
  }

  html, body { height: 100%; overflow: hidden; }

  body {
    display: flex;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-normal);
    background: var(--bg-tertiary);
  }

  body.light-mode {
    --bg-primary:    #f2f3f5;
    --bg-secondary:  #e3e5e8;
    --bg-tertiary:   #dfe1e5;
    --bg-surface:    #ffffff;
    --bg-floating:   #cfd3d8;
    --bg-accent:     #c7ccd1;

    --text-normal:   #1e1f22;
    --text-muted:    #5f6770;
    --text-link:     #0b79d0;

    --interactive-normal: #4d5560;
    --interactive-hover:  #1e1f22;
    --interactive-muted:  #8b939d;

    --ch-default:    #5f6770;
    --ch-hover:      #2f3136;
    --ch-selected:   #1e1f22;
    --ch-bg-hover:   rgba(0,0,0,0.06);
    --ch-bg-active:  rgba(0,0,0,0.12);

    --scrollbar-bg:  rgba(0,0,0,0.25);
  }

  
  ::-webkit-scrollbar { width: 8px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--scrollbar-bg); border-radius: 4px; }
  * { scrollbar-width: thin; scrollbar-color: var(--scrollbar-bg) transparent; }

  
  .server-list {
    width: var(--server-w);
    background: var(--bg-tertiary);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    gap: 8px;
    overflow-y: auto;
    flex-shrink: 0;
    scrollbar-width: none;
  }
  .server-list::-webkit-scrollbar { display: none; }

  .server-icon {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--blurple);
    cursor: pointer;
    position: relative;
    transition: border-radius 0.15s ease;
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-weight: 700; font-size: 18px;
    text-decoration: none;
    flex-shrink: 0;
  }
  .server-icon img {
    width: 100%; height: 100%; object-fit: cover; display: block;
  }
  .server-icon:hover, .server-icon.active { border-radius: 16px; }

  .server-icon::before {
    content: '';
    position: absolute;
    left: -8px; top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 4px; height: 8px;
    background: #fff;
    border-radius: 0 4px 4px 0;
    transition: transform 0.15s ease, height 0.15s ease;
  }
  .server-icon:hover::before {
    transform: translateY(-50%) scaleY(1);
    height: 20px;
  }
  .server-icon.active::before {
    transform: translateY(-50%) scaleY(1);
    height: 40px;
  }

  .server-divider {
    width: 32px; height: 2px;
    background: var(--bg-accent);
    border-radius: 1px;
    flex-shrink: 0;
  }

  
  .sidebar {
    width: var(--sidebar-w);
    background: var(--bg-secondary);
    display: flex; flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
  }

  .sidebar-header {
    height: var(--header-h);
    padding: 0 16px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--bg-floating);
    box-shadow: 0 1px 0 rgba(4,4,5,0.2), 0 2px 0 rgba(4,4,5,0.05);
    cursor: pointer; flex-shrink: 0;
    transition: background 0.1s;
  }
  .sidebar-header:hover { background: var(--ch-bg-hover); }
  .sidebar-header-name {
    font-size: 15px; font-weight: 700;
    color: var(--text-normal);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .sidebar-header-views {
    font-size: 11px; color: var(--text-muted);
    white-space: nowrap; flex-shrink: 0;
  }

  .sidebar-channels {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
  }

  .ch-category {
    padding: 16px 8px 4px 8px;
    display: flex; align-items: center; gap: 4px;
    cursor: pointer; user-select: none;
  }
  .ch-category-icon {
    color: var(--ch-default);
    font-size: 10px;
    transition: transform 0.1s;
    line-height: 1;
  }
  .ch-category-name {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--ch-default);
  }
  .ch-category:hover .ch-category-name,
  .ch-category:hover .ch-category-icon { color: var(--ch-hover); }

  .ch-item {
    display: flex; align-items: center; gap: 6px;
    padding: 2px 8px 2px 12px;
    margin: 1px 8px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    color: var(--ch-default);
    font-size: 15px; font-weight: 500;
    transition: background 0.1s, color 0.1s;
    min-height: 32px;
    position: relative;
  }
  .ch-item:hover { background: var(--ch-bg-hover); color: var(--ch-hover); }
  .ch-item.active { background: var(--ch-bg-active); color: var(--ch-selected); font-weight: 600; }
  .ch-hash {
    font-size: 20px; font-weight: 300; color: var(--interactive-muted);
    flex-shrink: 0; line-height: 1; margin-top: -1px;
  }
  .ch-item:hover .ch-hash,
  .ch-item.active .ch-hash { color: var(--interactive-normal); }
  .ch-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  
  .user-panel {
    height: 52px; padding: 0 8px;
    background: var(--bg-tertiary);
    display: flex; align-items: center; gap: 8px;
    flex-shrink: 0;
    position: relative;
  }
  .user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--blurple); flex-shrink: 0;
    overflow: visible;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 13px; font-weight: 700;
    position: relative; cursor: pointer;
  }
  .user-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
  .user-avatar::after {
    content: '';
    position: absolute; bottom: -1px; right: -1px;
    width: 10px; height: 10px;
    background: var(--green);
    border: 2px solid var(--bg-tertiary);
    border-radius: 50%;
  }
  .user-info { flex: 1; min-width: 0; }
  .user-name {
    font-size: 13px; font-weight: 600;
    color: var(--text-normal);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .user-status { font-size: 11px; color: var(--text-muted); }

  .up-btns { display: flex; gap: 2px; }
  .up-btn {
    width: 32px; height: 32px; border-radius: 4px;
    background: none; border: none;
    color: var(--interactive-normal);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.1s, color 0.1s;
  }
  .up-btn:hover { background: var(--ch-bg-hover); color: var(--interactive-hover); }
  .up-btn svg { width: 18px; height: 18px; }

  .settings-menu {
    position: absolute;
    right: 8px;
    bottom: 56px;
    min-width: 190px;
    padding: 6px;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 8px 20px rgba(0,0,0,0.35);
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
    transition: opacity 0.12s ease, transform 0.12s ease;
    z-index: 80;
  }
  .settings-menu.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
  .settings-item {
    width: 100%;
    height: 34px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-normal);
    font: inherit;
    font-size: 14px;
    text-align: left;
    padding: 0 10px;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
  }
  .settings-item:hover {
    background: var(--ch-bg-hover);
    color: var(--interactive-hover);
  }
  body.light-mode .settings-menu {
    border-color: rgba(0,0,0,0.12);
    box-shadow: 0 8px 20px rgba(0,0,0,0.18);
  }

  
  .main {
    flex: 1;
    background: var(--bg-primary);
    display: flex; flex-direction: column;
    overflow: hidden;
  }

  .main-header {
    height: var(--header-h); padding: 0 16px;
    display: flex; align-items: center; gap: 8px;
    border-bottom: 1px solid rgba(0,0,0,0.25);
    box-shadow: 0 1px 0 rgba(4,4,5,0.2), 0 2px 0 rgba(4,4,5,0.05);
    flex-shrink: 0; background: var(--bg-primary); z-index: 10;
  }
  .mh-hash { color: var(--ch-default); font-size: 22px; font-weight: 300; }
  .mh-name { font-size: 15px; font-weight: 700; color: var(--text-normal); }
  .mh-div { width: 1px; height: 20px; background: var(--bg-accent); margin: 0 4px; }
  .mh-topic { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  
  .chat {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 24px;
  }

  
  .ch-welcome {
    padding: 20px 16px 28px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    margin-bottom: 8px;
  }
  .ch-welcome-icon {
    width: 68px; height: 68px; border-radius: 50%;
    background: var(--blurple);
    display: flex; align-items: center; justify-content: center;
    font-size: 34px; margin-bottom: 16px;
  }
  .ch-welcome-title { font-size: 28px; font-weight: 700; color: var(--text-normal); margin-bottom: 6px; }
  .ch-welcome-desc { font-size: 15px; color: var(--text-muted); }

  
  .msg-group {
    padding: 2px 16px;
    display: flex; gap: 16px;
    position: relative;
    transition: background 0.05s;
  }
  .msg-group:hover { background: rgba(0,0,0,0.07); }
  .msg-group.new { margin-top: 16px; }

  .msg-avatar-wrap {
    width: 40px; height: 40px; flex-shrink: 0;
    border-radius: 50%; overflow: hidden;
    background: var(--blurple);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 16px; font-weight: 700;
    cursor: pointer; margin-top: 2px;
  }
  .msg-avatar-wrap img { width: 100%; height: 100%; object-fit: cover; }

  .msg-body { flex: 1; min-width: 0; }

  .msg-meta {
    display: flex; align-items: baseline; gap: 8px;
    margin-bottom: 2px;
  }
  .msg-author {
    font-size: 15px; font-weight: 500;
    color: var(--text-normal); cursor: pointer;
  }
  .msg-author:hover { text-decoration: underline; }
  .msg-source {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.01em;
  }
  .msg-badge {
    display: inline-flex; align-items: center;
    background: var(--blurple);
    color: #fff; font-size: 10px; font-weight: 700;
    padding: 1px 5px; border-radius: 3px;
    letter-spacing: 0.04em; text-transform: uppercase;
    vertical-align: baseline;
  }
  .msg-ts {
    font-size: 11px; color: var(--text-muted);
  }
  .msg-text {
    font-size: 15px; color: var(--text-normal); line-height: 1.375;
  }
  .msg-text a { color: var(--text-link); text-decoration: none; }
  .msg-text a:hover { text-decoration: underline; }

  
  .mention {
    background: rgba(88,101,242,0.3); color: #c9cdfb;
    padding: 0 3px; border-radius: 3px; cursor: pointer;
    transition: background 0.1s;
  }
  .mention:hover { background: var(--blurple); color: #fff; }

  
  .section-div {
    display: flex; align-items: center; gap: 12px;
    padding: 24px 16px 8px;
  }
  .section-div::after {
    content: ''; flex: 1; height: 1px;
    background: rgba(255,255,255,0.05);
  }
  .section-div-label {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted);
  }

  
  .view-chip {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--bg-secondary);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 12px; padding: 4px 12px;
    font-size: 13px; color: var(--text-muted);
    margin: 8px 0;
  }
  .vc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
  .vc-num { font-weight: 600; color: var(--text-normal); font-family: var(--mono); }

  
  .link-cards { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
  .link-card {
    display: flex; align-items: center; gap: 12px;
    background: var(--bg-secondary);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px; padding: 10px 14px;
    text-decoration: none; min-width: 170px;
    transition: background 0.1s, border-color 0.1s;
  }
  .link-card:hover { background: var(--bg-surface); border-color: rgba(255,255,255,0.12); }
  .lc-icon {
    width: 38px; height: 38px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  .lc-icon.dc  { background: #5865f2; }
  .lc-icon.gh  { background: #24292e; border: 1px solid rgba(255,255,255,0.1); }
  .lc-icon.st  { background: #1b2838; border: 1px solid rgba(255,255,255,0.1); }
  .lc-icon svg { width: 20px; height: 20px; }
  .lc-name { font-size: 14px; font-weight: 600; color: var(--text-normal); }
  .lc-sub  { font-size: 12px; color: var(--text-muted); }

  
  .reactions { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
  .reaction {
    display: flex; align-items: center; gap: 5px;
    background: rgba(88,101,242,0.12);
    border: 1px solid rgba(88,101,242,0.3);
    border-radius: 8px; padding: 3px 9px;
    font-size: 13px; color: #c9cdfb;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
    user-select: none;
  }
  .reaction:hover { background: rgba(88,101,242,0.25); border-color: rgba(88,101,242,0.55); }
  .reaction.on { background: rgba(88,101,242,0.28); border-color: var(--blurple); }
  .r-emoji { font-size: 15px; line-height: 1; }
  .r-text  { font-weight: 500; }
  body.light-mode .reaction {
    background: rgba(88,101,242,0.14);
    border-color: rgba(88,101,242,0.44);
    color: #2e3a9d;
  }
  body.light-mode .reaction:hover {
    background: rgba(88,101,242,0.22);
    border-color: rgba(88,101,242,0.62);
    color: #1f2878;
  }
  body.light-mode .reaction.on {
    background: rgba(88,101,242,0.30);
    border-color: #3f4bd9;
    color: #17205f;
    font-weight: 600;
  }

  
  .music-embed {
    max-width: 440px; border-radius: 10px; overflow: hidden;
    background: var(--bg-secondary); margin: 6px 0;
    border: 1px solid rgba(255,255,255,0.08);
  }
  body.light-mode .music-embed { border-color: rgba(0,0,0,0.12); }
  .me-body  { padding: 12px 14px 10px; }
  .me-meta  { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
  .me-title { font-size: 16px; font-weight: 600; color: var(--text-normal); margin-bottom: 2px; }
  .me-artist{ font-size: 13px; color: var(--text-muted); margin-bottom: 2px; }
  .sp-mini-wrap { padding: 0 12px 12px; }
  .sp-mini-player {
    width: 100%;
    height: 152px;
    border: 0;
    border-radius: 12px;
    display: block;
  }

  
  .embed {
    max-width: 520px; border-radius: 4px; overflow: hidden;
    background: var(--bg-secondary); border-left: 4px solid var(--blurple);
    padding: 12px 16px; margin: 4px 0;
  }
  .embed-title { font-size: 15px; font-weight: 600; color: var(--text-link); margin-bottom: 6px; text-decoration: none; display: block; }
  .embed-title:hover { text-decoration: underline; }
  .embed-desc { font-size: 14px; color: var(--text-normal); line-height: 1.4; }
  .embed-footer { font-size: 12px; color: var(--text-muted); margin-top: 10px; }

  
  .chat-footer { padding: 24px 16px 8px 72px; }
  .chat-footer-text { font-size: 12px; color: var(--text-muted); font-family: var(--mono); }
  .chat-footer-text a { color: var(--text-link); text-decoration: none; }
  .chat-footer-text a:hover { text-decoration: underline; }

  
  .mobile-bar { display: none; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 49; }
  .sidebar-overlay.on { display: block; }

  @media (max-width: 900px) {
    :root { --server-w: 0px; }
    .server-list { display: none; }
  }
  @media (max-width: 640px) {
    .sidebar {
      position: fixed; left: 0; top: 0; bottom: 0; z-index: 50;
      transform: translateX(-100%);
      transition: transform 0.2s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .main-header { display: none; }
    .mobile-bar {
      display: flex; align-items: center; gap: 10px;
      height: var(--header-h); padding: 0 12px;
      background: var(--bg-primary);
      border-bottom: 1px solid rgba(0,0,0,0.25);
      flex-shrink: 0;
    }
    .hbg {
      background: none; border: none; color: var(--interactive-normal);
      cursor: pointer; padding: 4px;
      display: flex; align-items: center; justify-content: center;
    }
    .hbg:hover { color: var(--interactive-hover); }
    .mobile-ch-name { font-size: 15px; font-weight: 700; color: var(--text-normal); }
  }

  
  @keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  .msg-group { animation: fadeUp 0.25s ease both; }
  .msg-group:nth-child(1) { animation-delay: 0.04s; }
  .msg-group:nth-child(2) { animation-delay: 0.08s; }
  .msg-group:nth-child(3) { animation-delay: 0.12s; }
  .msg-group:nth-child(4) { animation-delay: 0.16s; }
  .msg-group:nth-child(5) { animation-delay: 0.20s; }
  .msg-group:nth-child(6) { animation-delay: 0.24s; }
  .ch-welcome { animation: fadeUp 0.3s ease both; }

  
  [data-tip] { position: relative; }
  [data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute; left: 60px; top: 50%;
    transform: translateY(-50%);
    background: var(--bg-floating);
    color: var(--text-normal);
    font-size: 13px; font-weight: 600;
    padding: 6px 10px; border-radius: 4px;
    white-space: nowrap; pointer-events: none; z-index: 100;
    border: 1px solid rgba(255,255,255,0.06);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  }
