:root {
  color-scheme: dark;
  --discord-rail: #202225;
  --discord-sidebar: #2f3136;
  --discord-main: #36393f;
  --discord-main-alt: #2f3136;
  --discord-hover: #393c43;
  --discord-selected: #4f545c;
  --discord-text: #dcddde;
  --discord-muted: #b9bbbe;
  --discord-header: #f2f3f5;
  --discord-brand: #5738d2;
  --discord-green: #23a559;
  --discord-red: #f23f42;
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body, body.dark { margin: 0; color: var(--discord-text); background: var(--discord-main); font-family: "gg sans", "Noto Sans", system-ui, sans-serif; }
body::before { display: none !important; }
button, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.auth-screen {
  min-height: 100%; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(circle at 12% 20%, rgba(88,101,242,.45), transparent 32%),
    radial-gradient(circle at 88% 82%, rgba(35,165,89,.2), transparent 28%),
    linear-gradient(135deg, #20244a, #111320 68%);
}
.auth-card { width: min(480px, 100%); padding: 32px; border-radius: 5px; background: #313338; box-shadow: 0 8px 28px rgba(0,0,0,.38); text-align: center; }
.auth-card .brand-mark { margin: 0 auto 14px; }
.auth-card h1 { margin: 0 0 8px; color: #fff; font-size: 24px; }
.auth-card > p { margin: 0 0 22px; color: #b5bac1; }
.auth-tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 18px; background: #1e1f22; border-radius: 4px; }
.auth-tabs button { flex: 1; padding: 9px; border: 0; border-radius: 3px; background: transparent; color: #b5bac1; font-weight: 600; cursor: pointer; }
.auth-tabs button.active { background: #404249; color: #fff; }
.auth-form { display: grid; gap: 16px; text-align: left; }
.auth-form label { display: grid; gap: 8px; color: #b5bac1; font-size: 12px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.auth-form input, .new-chat-dialog input { width: 100%; border: 0; border-radius: 3px; outline: 0; padding: 12px; color: #f2f3f5; background: #1e1f22; }
.auth-form input:focus, .new-chat-dialog input:focus { box-shadow: 0 0 0 2px var(--discord-brand); }
.primary-button { min-height: 44px; border: 0; border-radius: 3px; background: var(--discord-brand); color: white; font-weight: 700; cursor: pointer; }
.primary-button:hover { background: #4752c4; }
.form-error { color: #fa777c !important; font-size: 13px; min-height: 18px; margin: 2px 0 0 !important; }

.app-shell { width: 100%; max-width: none; height: 100dvh; margin: 0; display: grid; grid-template-columns: 72px 300px minmax(380px, 1fr); border: 0; border-radius: 0; background: var(--discord-main); box-shadow: none; }
.rail { grid-column: 1; display: flex; flex-direction: column; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; background: var(--discord-rail); }
.rail-top, .rail-bottom { display: flex; flex-direction: column; align-items: center; gap: 9px; width: 100%; }
.rail-top::before { content: "N"; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 16px; background: var(--discord-brand); color: white; font-size: 22px; font-weight: 800; transition: border-radius .18s; }
.rail-top::after { content: ""; width: 32px; height: 2px; background: #35363c; order: 1; }
.rail-button, .rail .avatar-self { position: relative; display: grid; place-items: center; width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%; background: #313338; color: #b5bac1; cursor: pointer; transition: .16s ease; }
.rail-button:first-child { order: 2; }
.rail-button:not(:first-child) { order: 3; }
.rail-button:hover, .rail-button.active, .rail .avatar-self:hover { border-radius: 16px; color: white; background: var(--discord-brand); }
.rail-button.active::before { content: ""; position: absolute; left: -12px; width: 4px; height: 40px; border-radius: 0 4px 4px 0; background: white; }
.rail-button:disabled { opacity: .55; cursor: not-allowed; }
.rail-button .icon { width: 23px; height: 23px; }
.rail-button b { position: absolute; right: -2px; bottom: -2px; min-width: 18px; height: 18px; padding: 0 5px; border: 3px solid var(--discord-rail); border-radius: 10px; background: var(--discord-red); color: #fff; font-size: 10px; line-height: 12px; }

.sidebar { grid-column: 2; min-width: 0; display: flex; flex-direction: column; background: var(--discord-sidebar); }
.ios-status, .mobile-tabs, .mobile-menu, .mobile-camera, .archive-row, .encrypted-note { display: none !important; }
.sidebar-header { min-height: 49px; display: flex; align-items: center; padding: 0 16px; border-bottom: 1px solid #1f2023; box-shadow: 0 1px 0 rgba(0,0,0,.2); }
.sidebar-header h1 { flex: 1; margin: 0; color: #f2f3f5; font-size: 15px; font-weight: 700; }
.header-actions { display: flex; gap: 5px; }
.icon-button { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: #b5bac1; cursor: pointer; }
.icon-button:hover:not(:disabled) { color: #f2f3f5; background: #404249; }
.icon-button:disabled { opacity: .45; cursor: default; }
.icon { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.search-wrap { display: flex; align-items: center; gap: 8px; margin: 12px 10px 8px; padding: 7px 9px; border-radius: 4px; color: var(--discord-muted); background: #1e1f22; }
.search-wrap .icon { width: 16px; height: 16px; }
.search-wrap input { min-width: 0; flex: 1; border: 0; outline: 0; color: var(--discord-text); background: transparent; font-size: 13px; }
.filter-row { display: flex; gap: 4px; padding: 2px 10px 10px; }
.filter { border: 0; border-radius: 4px; padding: 5px 9px; background: transparent; color: var(--discord-muted); font-size: 12px; cursor: pointer; }
.filter:hover { background: var(--discord-hover); color: var(--discord-text); }
.filter.active { background: var(--discord-selected); color: white; }
.chat-list { flex: 1; overflow: auto; padding: 0 8px 72px; }
.chat-list::before { content: "DIRECT MESSAGES"; display: block; padding: 9px 8px 7px; color: var(--discord-muted); font-size: 11px; font-weight: 700; letter-spacing: .03em; }
.chat-row { position: relative; width: 100%; display: grid; grid-template-columns: 36px minmax(0,1fr) auto; align-items: center; gap: 10px; min-height: 44px; margin: 1px 0; padding: 4px 8px; border: 0; border-radius: 4px; background: transparent; color: var(--discord-muted); text-align: left; cursor: pointer; }
.chat-row:hover { background: var(--discord-hover); color: var(--discord-text); }
.chat-row.active { background: var(--discord-selected); color: #fff; }
.avatar { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; color: #fff; background: linear-gradient(145deg, #5865f2, #8b5cf6); font-size: 13px; font-weight: 700; }
.chat-copy { min-width: 0; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; column-gap: 6px; }
.chat-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 500; }
.chat-copy small { grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--discord-muted); font-size: 12px; }
.chat-copy time { font-size: 10px; color: var(--discord-muted); }
.unread-badge { min-width: 18px; padding: 2px 5px; border-radius: 9px; background: var(--discord-red); color: white; font-size: 10px; text-align: center; }
.empty-list { padding: 28px 16px; color: var(--discord-muted); text-align: center; font-size: 13px; }

.conversation { grid-column: 3; min-width: 0; display: flex; flex-direction: column; background: var(--discord-main); }
.conversation::before { display: none !important; }
.conversation-header { min-height: 49px; display: flex; align-items: center; padding: 0 12px 0 16px; border-bottom: 1px solid #25262a; box-shadow: 0 1px 0 rgba(0,0,0,.2); }
.mobile-back { display: none; }
.contact-info { min-width: 0; flex: 1; display: flex; align-items: center; gap: 9px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.contact-info .avatar { width: 28px; height: 28px; font-size: 10px; }
.contact-info > span:last-child { min-width: 0; display: flex; align-items: baseline; gap: 9px; }
.contact-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #f2f3f5; font-size: 16px; }
.contact-info small { color: var(--discord-muted); font-size: 12px; }
.contact-info small::before { content: "@"; }
.conversation-actions { display: flex; align-items: center; gap: 3px; }
.call-button { display: flex; align-items: center; gap: 5px; border: 0; border-radius: 4px; padding: 5px 8px; background: transparent; color: #b5bac1; }
.call-button:disabled { opacity: .45; }
.call-divider { width: 1px; height: 18px; background: #4e5058; }
.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; padding: 18px 0 10px; }
.empty-conversation { margin: auto; padding: 28px; text-align: center; color: var(--discord-muted); }
.empty-conversation .brand-mark, .brand-mark { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 20px; background: var(--discord-brand); color: white; font-size: 28px; font-weight: 800; }
.empty-conversation h2 { color: #f2f3f5; }
.message { position: relative; max-width: none; margin: 0; padding: 4px 64px 4px 72px; border-radius: 0; background: transparent !important; color: var(--discord-text); line-height: 1.42; overflow-wrap: anywhere; }
.message:hover { background: rgba(4,4,5,.07) !important; }
.message::before { content: ""; position: absolute; left: 16px; top: 5px; width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(145deg, #5865f2, #8b5cf6); }
.message.in::after, .message.out::after { position: absolute; left: 72px; top: -15px; color: #f2f3f5; font-size: 14px; font-weight: 600; }
.message.in.tail-in, .message.out.tail-out { margin-top: 24px; }
.message.in.tail-in::after { content: "Member"; }
.message.out.tail-out::after { content: "You"; color: #c9cdfb; }
.message:not(.tail-in):not(.tail-out)::before { display: none; }
.message:not(.tail-in):not(.tail-out) { padding-top: 1px; padding-bottom: 1px; }
.message .meta { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; color: var(--discord-muted); font-size: 10px; vertical-align: middle; }
.ticks { color: var(--discord-green); }
.voice-note { min-width: 220px; border: 0; border-radius: 4px; padding: 9px 12px; background: #232428; color: #fff; }
.composer { display: flex; align-items: center; gap: 6px; margin: 0 16px 24px; padding: 8px 10px; border-radius: 8px; background: #383a40; }
.composer input { min-width: 0; flex: 1; border: 0; outline: 0; color: #dbdee1; background: transparent; font-size: 15px; }
.composer input::placeholder { color: #949ba4; }
.composer .icon-button { color: #b5bac1; }
.composer .recording { color: var(--discord-red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

.details-panel { grid-column: 4; min-width: 0; overflow-y: auto; background: #232428; border-left: 1px solid #1e1f22; }
.details-panel header { height: 49px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-bottom: 1px solid #1e1f22; font-weight: 700; }
.details-profile { padding: 32px 18px 20px; text-align: center; background: #2b2d31; }
.avatar-large { width: 80px; height: 80px; margin: auto; font-size: 24px; }
.details-profile h2 { margin: 14px 0 3px; color: #f2f3f5; }
.details-profile p { margin: 0; color: var(--discord-muted); }
.details-card { margin: 16px; padding: 14px; border-radius: 8px; background: #2b2d31; }
.details-card small { color: #b5bac1; font-weight: 700; text-transform: uppercase; }
.details-card p { color: var(--discord-muted); font-size: 13px; }

.new-chat-dialog { width: min(480px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 5px; color: var(--discord-text); background: #313338; box-shadow: 0 12px 32px rgba(0,0,0,.45); }
.new-chat-dialog::backdrop { background: rgba(0,0,0,.72); }
.dialog-card { padding: 22px; }
.dialog-card header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.dialog-card h2 { margin: 0; color: #fff; }
.dialog-card header button { border: 0; background: transparent; color: var(--discord-muted); }
.dialog-card label { display: grid; gap: 8px; color: #b5bac1; font-size: 12px; font-weight: 700; text-transform: uppercase; }
.user-results { max-height: 320px; overflow-y: auto; margin-top: 14px; }
.user-result { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; border-radius: 4px; background: transparent; text-align: left; }
.user-result:hover { background: var(--discord-hover); }
.user-result > span:last-child { display: grid; }
.user-result small { color: var(--discord-muted); }
.connection-banner { position: fixed; top: 10px; left: 50%; z-index: 30; translate: -50%; padding: 8px 13px; border-radius: 16px; background: #f0b232; color: #1e1f22; font-size: 12px; font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 40; translate: -50% 20px; padding: 10px 14px; border-radius: 4px; opacity: 0; pointer-events: none; background: #111214; color: #fff; transition: .2s; }
.toast.show { opacity: 1; translate: -50% 0; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 64px 280px minmax(360px,1fr); }
  .rail-button, .rail .avatar-self, .rail-top::before { width: 44px; height: 44px; }
}

@media (max-width: 720px) {
  html, body { height: 100dvh; }
  .app-shell { position: relative; display: block; overflow: hidden; }
  .rail { display: none; }
  .sidebar, .conversation { position: absolute; inset: 0; width: 100%; transition: transform .22s ease; }
  .sidebar { transform: translateX(0); }
  .conversation { transform: translateX(100%); }
  .app-shell.chat-open .sidebar { transform: translateX(-25%); }
  .app-shell.chat-open .conversation { transform: translateX(0); }
  .sidebar-header { min-height: 56px; padding: env(safe-area-inset-top) 14px 0; }
  .sidebar-header h1 { position: static; inset: auto; z-index: auto; margin: 0; font-size: 19px; letter-spacing: 0; }
  #newChat { width: 32px; height: 32px; background: var(--discord-brand); }
  .filter-row { padding-bottom: 6px; }
  .chat-row { min-height: 58px; grid-template-columns: 44px minmax(0,1fr) auto; }
  .chat-row .avatar { width: 44px; height: 44px; }
  .conversation-header { min-height: calc(56px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
  .mobile-back { display: grid; }
  .contact-info small { display: none; }
  .conversation-actions .icon-button { display: none; }
  .messages { padding-top: 12px; }
  .message { padding-left: 64px; padding-right: 16px; }
  .message::before { left: 12px; }
  .message.in::after, .message.out::after { left: 64px; }
  .composer { margin: 0 8px calc(8px + env(safe-area-inset-bottom)); }
  .details-panel { position: fixed; inset: 0; z-index: 20; }
  .auth-card { padding: 24px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
