* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #1a1d21;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── App Shell ── */
.slack-app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
    width: 240px;
    min-width: 240px;
    background: #3F0E40;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid #522653;
}

.workspace-header {
    padding: 14px 16px 12px;
    border-bottom: 1px solid #522653;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.workspace-header:hover {
    background: rgba(255,255,255,0.05);
}

.workspace-name {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

.workspace-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #2BAC76;
    border-radius: 50%;
    border: 1.5px solid #3F0E40;
}

.workspace-user {
    font-size: 12px;
    color: rgba(255,255,255,0.65);
}

.compose-btn {
    width: 28px;
    height: 28px;
    background: rgba(255,255,255,0.15);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
}

.compose-btn:hover {
    background: rgba(255,255,255,0.25);
}

/* Sidebar nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 16px;
    font-size: 14px;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    border-radius: 6px;
    margin: 0 8px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.nav-item.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.nav-icon {
    font-size: 16px;
    width: 18px;
    text-align: center;
    opacity: 0.8;
}

/* Section headers */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 4px;
    font-size: 13px;
    font-weight: 700;
    color: rgba(255,255,255,0.55);
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
    user-select: none;
}

.section-header:hover {
    color: rgba(255,255,255,0.85);
}

.section-toggle {
    font-size: 10px;
    opacity: 0.7;
}

.section-add {
    font-size: 18px;
    opacity: 0.6;
    line-height: 1;
}

/* Channel items */
.channel-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 16px;
    font-size: 14px;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    border-radius: 6px;
    margin: 1px 8px;
    position: relative;
}

.channel-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.channel-item.active {
    background: #1164A3;
    color: #fff;
}

.channel-item.unread {
    color: #fff;
    font-weight: 700;
}

.channel-hash {
    font-size: 16px;
    color: inherit;
    opacity: 0.7;
    flex-shrink: 0;
}

.channel-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-badge {
    background: #E01E5A;
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* DM items */
.dm-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 16px;
    font-size: 14px;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    border-radius: 6px;
    margin: 1px 8px;
}

.dm-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.dm-avatar {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    position: relative;
}

.dm-online::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 7px;
    height: 7px;
    background: #2BAC76;
    border-radius: 50%;
    border: 1.5px solid #3F0E40;
}

.dm-away::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 7px;
    height: 7px;
    background: transparent;
    border-radius: 50%;
    border: 1.5px solid rgba(255,255,255,0.5);
}

/* ── Main Content ── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #1a1d21;
    overflow: hidden;
}

/* Channel Header */
.channel-header {
    padding: 12px 20px;
    border-bottom: 1px solid #2d2d2d;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1a1d21;
    flex-shrink: 0;
}

.channel-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.channel-header-hash {
    font-size: 20px;
    color: rgba(255,255,255,0.55);
}

.channel-header-name {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

.channel-header-desc {
    font-size: 13px;
    color: rgba(255,255,255,0.45);
    margin-left: 8px;
    border-left: 1px solid rgba(255,255,255,0.2);
    padding-left: 8px;
}

.channel-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-action {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: rgba(255,255,255,0.55);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.header-action:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.85);
}

.member-avatars {
    display: flex;
    margin-left: 2px;
}

.member-avatar {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    border: 2px solid #1a1d21;
    margin-left: -6px;
    font-size: 9px;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.member-avatar:first-child {
    margin-left: 0;
}

/* Messages Area */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px 20px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.messages-area::-webkit-scrollbar { width: 6px; }
.messages-area::-webkit-scrollbar-track { background: transparent; }
.messages-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* Date divider */
.date-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0 8px;
}

.date-divider::before,
.date-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,0.12);
}

.date-divider span {
    font-size: 12px;
    font-weight: 700;
    color: rgba(255,255,255,0.4);
    white-space: nowrap;
}

/* Message rows */
.message {
    display: flex;
    gap: 12px;
    padding: 4px 8px;
    border-radius: 8px;
    position: relative;
}

.message:hover {
    background: rgba(255,255,255,0.04);
}

.message:hover .message-actions {
    display: flex;
}

.message.grouped {
    padding-top: 2px;
    padding-bottom: 2px;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    margin-top: 2px;
}

.message.grouped .message-avatar {
    visibility: hidden;
}

.message-body {
    flex: 1;
    min-width: 0;
}

.message-meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}

.message.grouped .message-meta {
    display: none;
}

.message-author {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
}

.message-time {
    font-size: 11px;
    color: rgba(255,255,255,0.35);
}

.message-text {
    font-size: 14px;
    color: rgba(255,255,255,0.85);
    line-height: 1.5;
    word-break: break-word;
}

.message-text code {
    background: rgba(255,255,255,0.1);
    padding: 2px 5px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.message-text a {
    color: #1d9bd1;
    text-decoration: none;
}

.message-text a:hover {
    text-decoration: underline;
}

/* Grouped timestamp on left */
.message.grouped .grouped-time {
    position: absolute;
    left: 8px;
    top: 6px;
    font-size: 10px;
    color: rgba(255,255,255,0.25);
    display: none;
    white-space: nowrap;
    width: 36px;
    text-align: center;
}

.message.grouped:hover .grouped-time {
    display: block;
}

/* Reactions */
.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.reaction {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 13px;
    cursor: pointer;
    color: rgba(255,255,255,0.7);
}

.reaction:hover {
    background: rgba(255,255,255,0.14);
    border-color: rgba(255,255,255,0.25);
    color: #fff;
}

.reaction.mine {
    background: rgba(29,155,209,0.15);
    border-color: rgba(29,155,209,0.4);
    color: #1d9bd1;
}

.reaction-count {
    font-size: 12px;
    font-weight: 600;
}

/* Message actions toolbar */
.message-actions {
    display: none;
    position: absolute;
    top: -16px;
    right: 8px;
    background: #1a1d21;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
    z-index: 10;
}

.action-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    color: rgba(255,255,255,0.55);
}

.action-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

/* Typing indicator */
.typing-indicator {
    padding: 4px 8px 8px;
    height: 24px;
    font-size: 12px;
    color: rgba(255,255,255,0.45);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dots span {
    width: 5px;
    height: 5px;
    background: rgba(255,255,255,0.45);
    border-radius: 50%;
    animation: typing-bounce 1.2s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
    30% { transform: translateY(-4px); opacity: 0.9; }
}

/* Message Input */
.message-input-area {
    padding: 0 20px 16px;
    flex-shrink: 0;
}

.message-input-box {
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
    overflow: hidden;
}

.message-input-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.toolbar-btn {
    width: 28px;
    height: 28px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    color: rgba(255,255,255,0.4);
}

.toolbar-btn:hover {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.7);
}

.toolbar-divider {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.12);
    margin: 0 4px;
}

.message-input-field {
    display: flex;
    align-items: flex-end;
    padding: 8px 12px;
    gap: 8px;
    min-height: 44px;
}

.message-input-field input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 14px;
    color: rgba(255,255,255,0.85);
    font-family: inherit;
    resize: none;
}

.message-input-field input::placeholder {
    color: rgba(255,255,255,0.35);
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.send-btn {
    width: 30px;
    height: 30px;
    background: #007a5a;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    color: white;
    transition: background 0.15s;
}

.send-btn:hover {
    background: #148567;
}

/* Back link */
.back-link {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 100;
    border: 1px solid rgba(255,255,255,0.15);
    transition: all 0.2s;
}

.back-link:hover {
    background: rgba(255,255,255,0.18);
    color: white;
}

/* Scrollbar when new messages flash */
@keyframes message-flash {
    0% { background: rgba(255,200,0,0.08); }
    100% { background: transparent; }
}

.message.new-flash {
    animation: message-flash 1.5s ease-out forwards;
}

/* Responsive */
@media (max-width: 640px) {
    .sidebar { width: 0; min-width: 0; display: none; }
    .channel-header-desc { display: none; }
}
