:root {
    --bg-primary: #313338;
    --bg-secondary: #2b2d31;
    --bg-tertiary: #1e1f22;
    --bg-accent: #4e5058;
    --bg-hover: rgba(4, 4, 5, 0.07);
    --bg-hover-alt: rgba(255, 255, 255, 0.06);
    --text-normal: #dcddde;
    --text-muted: #949ba4;
    --text-link: #00b0f4;
    --header-primary: #f2f3f5;
    --header-secondary: #b5bac1;
    --interactive-normal: #b5bac1;
    --interactive-hover: #dcddde;
    --interactive-active: #fff;
    --brand: #5865f2;
    --mention-bg: rgba(88, 101, 242, 0.3);
    --mention-hover: rgba(88, 101, 242, 0.45);
    --mention-fg: #c9cdfb;
    --spoiler-bg: #202225;
    --mono: "Consolas", "Andale Mono WT", "Andale Mono", "Lucida Console", "DejaVu Sans Mono", monospace;
}

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

body {
    background: var(--bg-primary);
    color: var(--text-normal);
    height: 100vh;
    overflow: hidden;
    font-family: "gg sans", "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 16px;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

#channel-header {
    height: 48px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    flex-shrink: 0;
    z-index: 1;
    box-shadow: 0 1px 0 rgba(4, 4, 5, .2), 0 1.5px 0 rgba(6, 6, 7, .05), 0 2px 0 rgba(4, 4, 5, .05);
}

.ch-hash {
    color: var(--text-muted);
    font-size: 22px;
    font-weight: 300;
    line-height: 1;
}

#hdr-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--header-primary);
}

#msgs-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

#msgs-scroll::-webkit-scrollbar {
    width: 8px;
}

#msgs-scroll::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

#msgs-scroll::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

#msgs-wrap {
    padding: 8px 0 24px;
}

.date-sep {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 20px 16px 0;
    margin-bottom: 0;
}

.date-sep-line {
    flex: 1;
    height: 1px;
    background: var(--bg-accent);
}

.date-sep-lbl {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    padding: 0 4px;
}

.msg {
    display: grid;
    grid-template-columns: 72px 1fr;
    padding: 2px 48px 2px 0;
    position: relative;
}

.msg:hover {
    background: var(--bg-hover);
}

.msg:not(.grouped) {
    margin-top: 17px;
}

.msg-left {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 2px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-radius .15s;
}

.avatar:hover {
    border-radius: 30%;
}

.compact-ts {
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0;
    align-self: center;
    white-space: nowrap;
    padding-right: 4px;
    line-height: 1.375;
    user-select: none;
}

.msg.grouped:hover .compact-ts {
    opacity: 1;
}

.msg-right {
    min-width: 0;
    position: relative;
}

.reply-ref {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.reply-ref::before {
    content: '';
    position: absolute;
    left: -38px;
    bottom: 50%;
    width: 30px;
    height: 16px;
    border-top: 2px solid var(--bg-accent);
    border-left: 2px solid var(--bg-accent);
    border-top-left-radius: 6px;
}

.reply-ref:hover {
    color: var(--header-primary);
}

.reply-av {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
}

.reply-name {
    font-weight: 600;
    color: var(--header-secondary);
    flex-shrink: 0;
}

.reply-txt {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msg-hdr {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 2px;
}

.msg-name {
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    line-height: 1.375;
}

.msg-name:hover {
    text-decoration: underline;
}

.bot-tag {
    background: var(--brand);
    color: #fff;
    font-size: 10px;
    font-weight: 500;
    padding: 1px 4px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: .02em;
    line-height: 1.4;
}

.msg-ts {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
    cursor: default;
}

.msg-body {
    font-size: 15px;
    line-height: 1.375;
    color: var(--text-normal);
    word-wrap: break-word;
}

.edited {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: 3px;
}

strong {
    font-weight: 700;
}

em {
    font-style: italic;
}

u {
    text-decoration: underline;
}

s {
    text-decoration: line-through;
}

.spoiler {
    background: var(--spoiler-bg);
    color: transparent;
    border-radius: 3px;
    cursor: pointer;
    padding: 0 2px;
}

.spoiler.revealed {
    background: rgba(0, 0, 0, .2);
    color: var(--text-normal);
}

.mention {
    background: var(--mention-bg);
    color: var(--mention-fg);
    border-radius: 3px;
    padding: 0 2px;
    cursor: pointer;
    font-weight: 500;
}

.mention:hover {
    background: var(--mention-hover);
}

code.ic {
    font-family: var(--mono);
    font-size: 85%;
    background: var(--bg-tertiary);
    border-radius: 3px;
    padding: 0 3px;
}

pre.cb {
    font-family: var(--mono);
    border: 1px solid rgba(0, 0, 0, .3);
    border-radius: 4px;
    margin: 4px 0;
    overflow-x: auto;
    padding: 0;
}

pre.cb code,
pre.cb .hljs {
    font-family: var(--mono);
    font-size: 14px;
    line-height: 1.5;
    background: var(--bg-tertiary) !important;
    padding: 8px 12px !important;
    border-radius: 4px !important;
    display: block;
    overflow-x: auto;
    white-space: pre;
}

.bq {
    display: flex;
    gap: 8px;
    margin: 4px 0;
    border-left: 4px solid var(--interactive-normal);
    padding-left: 8px;
}

.bq-txt {
    font-size: 15px;
    line-height: 1.375;
}

.dh {
    color: var(--header-primary);
    font-weight: 700;
}

.dh1 {
    font-size: 24px;
    margin: 8px 0 4px;
}

.dh2 {
    font-size: 20px;
    margin: 6px 0 3px;
}

.dh3 {
    font-size: 16px;
    margin: 4px 0 2px;
}

a {
    color: var(--text-link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.atts {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}

.att-placeholder {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
}

.att-img {
    max-width: 550px;
    max-height: 350px;
    border-radius: 4px;
    display: block;
    cursor: pointer;
}

.att-file {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    border: 1px solid rgba(0, 0, 0, .3);
    border-radius: 4px;
    padding: 10px 16px;
    max-width: 520px;
}

.file-icon {
    font-size: 28px;
}

.file-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.file-name {
    color: var(--text-link);
    font-weight: 500;
    font-size: 14px;
}

.file-size {
    color: var(--text-muted);
    font-size: 12px;
}

.embed {
    background: var(--bg-secondary);
    border-radius: 0 4px 4px 0;
    padding: 12px 16px 16px 12px;
    margin-top: 4px;
    max-width: 520px;
    position: relative;
}

.embed-author {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--header-primary);
}

.embed-author-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.embed-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--header-primary);
    margin-bottom: 8px;
}

.embed-title a {
    color: var(--header-primary);
}

.embed-desc {
    font-size: 14px;
    color: var(--text-normal);
    margin-bottom: 8px;
    line-height: 1.4;
}

.embed-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.embed-field {
    min-width: 0;
    flex: 1 1 150px;
}

.embed-field.inline {
    flex: 0 0 auto;
    min-width: 100px;
}

.embed-field-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--header-primary);
    margin-bottom: 4px;
}

.embed-field-val {
    font-size: 13px;
    color: var(--text-normal);
}

.embed-img {
    max-width: 100%;
    border-radius: 4px;
    margin-top: 8px;
}

.embed-thumb {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 80px;
    height: 80px;
    border-radius: 4px;
    object-fit: cover;
}

.embed-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.embed-footer-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.fwd-wrap {
    margin-top: 4px;
    border-left: 3px solid var(--bg-accent);
    border-radius: 0 4px 4px 0;
    background: var(--bg-secondary);
    padding: 6px 10px 8px;
    max-width: 520px;
}
.fwd-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.fwd-body { font-size: 14px; }

.reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.reaction {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(88, 101, 242, .15);
    border: 1px solid rgba(88, 101, 242, .3);
    border-radius: 8px;
    padding: 1px 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-normal);
}

.reaction:hover {
    background: rgba(88, 101, 242, .3);
}

.reaction-emoji {
    font-size: 16px;
}

.reaction-count {
    font-size: 13px;
    font-weight: 500;
}

.sys-msg {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 2px 48px 2px 16px;
    font-size: 15px;
    color: var(--text-muted);
    margin-top: 4px;
}

.sys-msg:hover {
    background: var(--bg-hover);
}

.sys-icon {
    width: 40px;
    text-align: center;
    font-size: 20px;
    flex-shrink: 0;
}