/* === Theme Variables === */
:root {
    /* Backgrounds */
    --bg-primary: #e8e8e8;
    --bg-sidebar: #dedede;
    --bg-hover: #d0d0d0;
    --bg-hint-hover: #c8c8c8;

    /* Text */
    --text-primary: #4a4a4a;
    --text-bright: #1a1a1a;
    --text-white: #000000;
    --text-msg: #1a1a1a;
    --text-msg-self: #0a0a0a;
    --text-input: #3a3a3a;
    --text-dim: #8a8a8a;
    --text-dimmer: #9a9a9a;
    --text-muted: #7a7a7a;
    --text-muted-hover: #4a4a4a;
    --text-contact-active: #1a1a1a;
    --text-sidebar-header: #9a9a9a;
    --text-sidebar-btn: #aaaaaa;
    --text-sidebar-btn-hover: #4a4a4a;
    --text-self-username: #7a7a7a;
    --text-placeholder: #9a9a9a;
    --text-filter-placeholder: #b0b0b0;
    --text-watermark: #c8c8c8;
    --text-help-desc: #7a7a7a;

    /* Accent (teal/green) */
    --accent: #2a6a4a;
    --accent-glow: #2a6a4a44;
    --accent-light: #1a5a3a;
    --accent-lighter: #0a4a2a;
    --accent-dim: #5a9a7a;
    --accent-dimmer: #7aaa8a;
    --accent-channel: #2a6a4a;
    --accent-channel-active: #1a5a3a;
    --accent-channel-badge: #5a9a7a;
    --accent-cmd: #2a6a4a;

    /* Borders */
    --border-primary: #c0c0c0;
    --border-secondary: #cccccc;
    --border-input: #b0b0b0;
    --border-input-focus: #666;

    /* Semantic */
    --color-error: #aa3a3a;
    --color-error-hover: #cc4a4a;
    --color-admin-tag: #8a5a5a;
    --color-login-btn: #4a5a6a;
    --color-send-btn: #7a8a9a;
    --color-system-msg: #6a6a2a;

    /* Lock */
    --lock-tag: #7a6a2a;
    --lock-time: #8a8a4a;
    --lock-sender: #6a5a1a;
    --lock-sep: #b0b080;
    --lock-text: #5a5a1a;

    /* Scrollbar */
    --scrollbar-thumb: #222;
    --scrollbar-track: #1e1e1e;

    /* Misc */
    --offline-dot: #999999;
    --offline-dot-large: #888888;
    --contact-badge-off: #c8c8c8;
    --contact-unread: #2a6a4a;
    --logo-filter: brightness(0) invert(0);
    --sidebar-logo-filter: brightness(0) invert(0.7);

    /* Own messages */
    --msg-own-border: rgba(42, 106, 74, 0.2);
    --msg-own-bg: rgba(42, 106, 74, 0.06);

    /* System message divider */
    --system-divider: rgba(106, 106, 42, 0.3);
}

/* === Watermark === */
#watermark {
    position: fixed;
    bottom: 10px;
    right: 14px;
    font-size: 10px;
    color: var(--text-watermark);
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    pointer-events: none;
    z-index: 9999;
    letter-spacing: 0.05em;
}

/* === Utility === */
.hidden {
    display: none !important;
}

/* === Load animations === */
@keyframes emerge-down {
    from {
        opacity: 0;
        transform: translateY(-10px);
        filter: blur(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

@keyframes emerge-up {
    from {
        opacity: 0;
        transform: translateY(14px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === Skeleton loading === */
@keyframes skel-pulse {

    0%,
    100% {
        opacity: 0.08;
    }

    50% {
        opacity: 0.18;
    }
}

.message.skeleton {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 0;
}

.skel-line {
    display: block;
    height: 12px;
    border-radius: 3px;
    background: var(--text-primary);
    animation: skel-pulse 1.2s ease-in-out infinite;
}

.skel-short {
    width: 90px;
}

.skel-long {
    width: 60%;
}

body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

body.chat-mode {
    display: block;
    padding: 0;
    overflow: hidden;
    height: 100vh;
}

/* === Login View === */
#login-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.site-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 48px;
    animation: emerge-down 0.9s cubic-bezier(0.16, 1, 0.3, 1) both;
    user-select: none;
    -webkit-user-drag: none;
}



.logo {
    height: 77px;
    width: auto;
    filter: var(--logo-filter);
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

h1 {
    color: var(--text-bright);
    font-size: 42px;
    font-family: "Cinzel", serif;
    font-weight: normal;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    text-align: center;
    margin: 0;
    margin-top: -80px;
    word-spacing: 3em;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    max-width: 380px;
}

#login-error {
    font-size: 11px;
    color: var(--color-error);
    text-align: center;
    letter-spacing: 0.08em;
    min-height: 16px;
    margin-bottom: 6px;
}

.contact-unread {
    font-size: 10px;
    color: var(--contact-unread);
    margin-left: auto;
}

.bracket-wrap:nth-child(1) {
    animation: emerge-up 0.55s cubic-bezier(0.16, 1, 0.3, 1) both 0.45s;
}

.bracket-wrap:nth-child(2) {
    animation: emerge-up 0.55s cubic-bezier(0.16, 1, 0.3, 1) both 0.6s;
}

/* === Bracket-wrap container === */
.bracket-wrap {
    position: relative;
    padding: 6px 18px 0;
    margin-bottom: 18px;
}

/* Left bracket */
.bracket-wrap::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 10px;
    height: 100%;
    border-top: 1px solid var(--border-input-focus);
    border-bottom: 1px solid var(--border-input-focus);
    border-left: 1px solid var(--border-input-focus);
    box-sizing: border-box;
    pointer-events: none;
    opacity: 0;
    transform: translateX(6px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Right bracket */
.bracket-wrap::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 10px;
    height: 100%;
    border-top: 1px solid var(--border-input-focus);
    border-bottom: 1px solid var(--border-input-focus);
    border-right: 1px solid var(--border-input-focus);
    box-sizing: border-box;
    pointer-events: none;
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Show brackets on focus */
.bracket-wrap:focus-within::before,
.bracket-wrap:focus-within::after {
    opacity: 1;
    transform: translateX(0);
}

#username,
#password {
    width: 100%;
    padding: 10px 4px;
    font-size: 16px;
    border: none;
    border-bottom: 1px solid var(--border-input);
    border-radius: 0;
    background-color: transparent;
    color: var(--text-input);
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    outline: none;
    text-align: center;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

#username:focus,
#password:focus {
    border-bottom-color: var(--border-input-focus);
    caret-color: var(--text-bright);
}

#username::placeholder,
#password::placeholder {
    color: var(--text-placeholder);
}

#login-btn {
    animation: emerge-up 0.55s cubic-bezier(0.16, 1, 0.3, 1) both 0.77s;
    margin-top: 10px;
    padding: 10px 0;
    font-size: 14px;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    letter-spacing: 0.2em;
    background: none;
    color: var(--color-login-btn);
    border: none;
    outline: none;
    text-align: center;
    transition: color 0s;
}

#login-btn .bracket {
    display: inline-block;
    transition: transform 0.15s linear;
}

#login-btn:hover {
    color: var(--text-white);
}

#login-btn:hover .bracket.left {
    transform: translateX(-4px);
}

#login-btn:hover .bracket.right {
    transform: translateX(4px);
}

#login-btn .cursor {
    opacity: 0;
}

#login-btn:hover .cursor {
    opacity: 1;
    animation: terminal-blink 0.6s steps(2, start) infinite;
}

@keyframes terminal-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 30px;
        word-spacing: 2.5em;
        margin-top: -55px;
    }

    .logo {
        height: 48px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 30px;
        word-spacing: 3.5em;
        margin-top: -58px;
    }

    .logo {
        height: 46px;
    }

    .site-header {
        margin-bottom: 48px;
        gap: 12px;
    }

    #login-form {
        max-width: 100%;
        padding: 0 10px;
        box-sizing: border-box;
    }

    .bracket-wrap {
        margin-bottom: 26px;
    }

    #username,
    #password {
        padding: 12px 4px;
    }

    #login-btn {
        margin-top: 24px;
        padding: 14px 0;
    }
}

/* ========================================
   CHAT VIEW
   ======================================== */

#chat-view {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* === Sidebar === */
#chat-sidebar {
    width: 280px;
    min-width: 220px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 14px 14px;
    font-size: 11px;
    letter-spacing: 0.12em;
    color: var(--text-sidebar-header);
    border-bottom: 1px solid var(--border-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
    -webkit-user-drag: none;
}

.sidebar-logo {
    height: 18px;
    width: auto;
    filter: var(--sidebar-logo-filter);
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

#self-info {
    border-top: 1px solid var(--border-secondary);
    padding: 8px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
    margin-top: auto;
}

#self-info-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

#self-info .status-dot {
    position: static;
    top: unset;
    flex-shrink: 0;
}

#self-username {
    font-size: 11px;
    letter-spacing: 0.1em;
    color: var(--text-self-username);
}

/* === Sidebar Bottom Bar === */
.sidebar-bottom-bar {
    display: flex;
    flex-direction: row;
    border-top: 1px solid var(--border-secondary);
    flex-shrink: 0;
}

/* === Sidebar Buttons === */
.sidebar-btn {
    background: none;
    border: none;
    border-right: 1px solid var(--border-secondary);
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 11px;
    letter-spacing: 0.12em;
    color: var(--text-sidebar-btn);
    cursor: pointer;
    padding: 9px 8px;
    text-align: center;
    transition: color 0.15s;
    flex-shrink: 0;
    white-space: nowrap;
}

.sidebar-btn:last-child {
    border-right: none;
}

.sidebar-btn-exit {
    margin-left: auto;
    border-right: none;
    border-left: 1px solid var(--border-secondary);
    color: #8b3a3a;
}

.sidebar-btn-exit:hover {
    color: #c45050;
}

.sidebar-btn:hover {
    color: var(--text-sidebar-btn-hover);
}

.sidebar-btn .bracket {
    display: inline-block;
    transition: transform 0.15s;
}

.sidebar-btn:hover .bracket.left {
    transform: translateX(-2px);
}

.sidebar-btn:hover .bracket.right {
    transform: translateX(2px);
}

/* Audio toggle specific sidebar styling */
#audio-toggle.muted {
    color: var(--color-error);
}

#audio-toggle.muted:hover {
    color: var(--color-error-hover);
}

/* === Contact Filter === */
.contact-filter-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    margin: 7px 10px;
    background: var(--bg-hover);
    border: 1px solid var(--border-secondary);
    border-radius: 5px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 2;
    transition: border-color 0.15s;
}

.contact-filter-wrap:focus-within {
    border-color: var(--accent);
}

.contact-filter-prefix {
    color: var(--accent);
    font-size: 12px;
    flex-shrink: 0;
}

#contact-filter {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 12px;
    color: var(--text-primary);
    caret-color: var(--text-primary);
    letter-spacing: 0.05em;
    min-width: 0;
}

#contact-filter::placeholder {
    color: var(--text-filter-placeholder);
}

#contact-filter:focus {
    caret-shape: block;
}

.contact-filter-match {
    background: var(--accent);
    color: var(--bg-sidebar);
    border-radius: 1px;
    padding: 0 1px;
}

.contact-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

.contact {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.1s;
    font-size: 13px;
    color: var(--text-muted);
}

.contact:hover {
    background: var(--bg-hover);
    color: var(--text-muted-hover);
}

.contact.active {
    background: var(--bg-hover);
    color: var(--text-contact-active);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.online {
    background: #3ddc84;
    box-shadow: 0 0 6px #3ddc84, 0 0 12px rgba(61, 220, 132, 0.4);
}

.status-dot.offline {
    background: transparent;
    border: 1px solid var(--offline-dot);
    box-sizing: border-box;
    opacity: 0.3;
}

.contact-name-group {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.contact-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.contact-last-seen {
    font-size: 0.68rem;
    opacity: 0.45;
    line-height: 1.3;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Contact section headers (Online/Offline groups) */
.contact-section-header {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 10px 14px 4px;
    margin-top: 6px;
    user-select: none;
    border-top: 1px solid var(--border-primary);
}

.contact-section-header:first-of-type {
    border-top: none;
    margin-top: 2px;
}

.contact-section-collapsible {
    cursor: pointer;
}

.contact-section-collapsible:hover {
    color: var(--text-primary);
}

.section-toggle {
    opacity: 0.6;
    margin-left: 4px;
}

/* Online contacts: full opacity name */
.contact.contact-online .contact-name {
    opacity: 1;
}

/* Offline contacts: muted name */
.contact.contact-offline .contact-name {
    opacity: 0.5;
}

/* Favorite star toggle */
.contact-fav {
    font-size: 12px;
    color: var(--text-dim);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    flex-shrink: 0;
}

.contact:hover .contact-fav {
    opacity: 0.6;
}

.contact:hover .contact-fav:hover {
    opacity: 1;
    color: var(--accent);
}

.contact-fav.is-fav {
    opacity: 1;
    color: var(--accent);
}

/* Empty state hint */
.contact-list-empty-hint {
    text-align: center;
    color: var(--text-muted);
    opacity: 0.35;
    font-size: 11px;
    letter-spacing: 0.06em;
    padding: 24px 14px;
    user-select: none;
}

/* Channel entry in sidebar */
.contact.channel-entry .contact-name {
    color: var(--accent-channel);
}

.contact.channel-entry.active .contact-name {
    color: var(--accent-channel-active);
}

.contact.channel-entry .contact-badge {
    color: var(--accent-channel-badge);
}

.channel-separator {
    height: 1px;
    background: var(--border-primary);
    margin: 4px 14px;
}

/* === Chat Main === */
#chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    position: relative;
}

#chat-header {
    padding: 13px 20px;
    border-bottom: 1px solid var(--border-secondary);
    font-size: 13px;
    letter-spacing: 0.08em;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

#chat-with-label {
    color: var(--text-bright);
}

#close-chat-btn {
    margin-left: auto;
    background: none;
    border: none;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 14px;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px 0;
    flex-shrink: 0;
    transition: color 0.15s;
}
#close-chat-btn:hover {
    color: var(--text-bright);
}
#close-chat-btn .bracket {
    display: inline-block;
    transition: transform 0.15s;
}
#close-chat-btn:hover .bracket.left {
    transform: translateX(-3px);
}
#close-chat-btn:hover .bracket.right {
    transform: translateX(3px);
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    vertical-align: middle;
    position: relative;
    top: -1px;
    flex-shrink: 0;
}

.status-dot.online-dot {
    background-color: var(--accent);
    box-shadow: 0 0 6px var(--accent);
}

.status-dot.offline-dot {
    background-color: transparent;
    border: 1.5px solid var(--offline-dot-large);
    box-sizing: border-box;
    box-shadow: none;
}

#chat-status-label {
    font-size: 11px;
    letter-spacing: 0.1em;
}

#chat-status-label.online-label {
    color: var(--accent);
}

#chat-status-label.offline-label {
    color: var(--text-sidebar-header);
}

/* === Chat Placeholder (no chat selected) === */
#chat-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    position: relative;
    overflow: hidden;
}
#chat-placeholder.hidden { display: none !important; }
#chat-placeholder img {
    opacity: 0.06;
    width: 40%;
    max-width: 300px;
    filter: var(--logo-filter);
    user-select: none;
    pointer-events: none;
    -webkit-user-drag: none;
}

/* === Message Feed === */
#message-feed {
    flex: 1;
    overflow-y: auto;
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

#message-feed::-webkit-scrollbar {
    width: 3px;
}

#message-feed::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 2px;
}

.message {
    font-size: 13px;
    line-height: 1.6;
    animation: emerge-up 0.2s ease both;
    padding-left: 9px;
    border-left: 2px solid transparent;
}

.message.new-sender {
    margin-top: 8px;
}

.message .msg-time {
    color: var(--text-dim);
}

.message .msg-sender {
    /* color applied inline per-user via getColorHex() */
    margin-left: 4px;
    font-weight: bold;
    letter-spacing: 0.02em;
}

.msg-admin-tag {
    font-size: 10px;
    color: var(--color-admin-tag);
    margin-left: 5px;
    letter-spacing: 0.06em;
}

.message .msg-sep {
    color: var(--text-dimmer);
    margin: 0 4px;
    opacity: 0.5;
}

.message .msg-text {
    color: var(--text-msg);
}

.message.self .msg-text {
    color: var(--text-msg-self);
}

.message .msg-audio-btn {
    font-family: 'Share Tech Mono', monospace;
    font-size: 13px;
    background: transparent;
    border: 1px solid var(--border-primary);
    color: var(--text-msg);
    padding: 1px 8px;
    cursor: pointer;
    letter-spacing: 0.05em;
    transition: color 0.12s, border-color 0.12s;
}

.message .msg-audio-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.message.self .msg-audio-btn {
    color: var(--text-msg-self);
}

.message.self {
    border-left-color: var(--msg-own-border);
}

/* === Locked Messages === */
.message .msg-lock-tag {
    font-size: 10px;
    color: var(--lock-tag);
    margin-left: 5px;
    letter-spacing: 0.06em;
}

.message .msg-lock-btn {
    background: none;
    border: none;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 10px;
    color: var(--text-dimmer);
    cursor: pointer;
    margin-left: 8px;
    padding: 0;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    letter-spacing: 0.04em;
}

.message:hover .msg-lock-btn {
    opacity: 1;
}

.message .msg-lock-btn:hover {
    color: var(--lock-tag);
}

.message.locked .msg-lock-btn {
    opacity: 0.6;
    color: var(--lock-tag);
}

.message.locked:hover .msg-lock-btn {
    opacity: 1;
}

.message.locked .msg-time {
    color: var(--lock-time);
}

.message.locked .msg-sender {
    color: var(--lock-sender);
}

.message.locked .msg-sep {
    color: var(--lock-sep);
}

.message.locked .msg-text {
    color: var(--lock-text);
}

.system-msg {
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 0.08em;
    padding: 0;
    margin: 10px 0;
    animation: emerge-up 0.3s ease both;
    font-style: italic;
    text-transform: lowercase;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.system-msg::before,
.system-msg::after {
    content: '';
    flex: 1;
    max-width: 120px;
    height: 1px;
    background: var(--system-divider);
}

/* Color swatch — used in /color list output */
.system-msg .color-swatch-text {
    font-style: normal;
    font-weight: normal;
}

/* === Date Separators === */
.date-separator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0 6px;
}

.date-separator-line {
    flex: 1;
    height: 1px;
    background: var(--border-primary);
}

.date-separator-label {
    font-size: 10px;
    color: var(--text-dimmer);
    letter-spacing: 0.15em;
    white-space: nowrap;
}

/* === New Message Indicator === */
#new-msg-indicator {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-sidebar);
    border: 1px solid var(--accent-dim);
    color: var(--accent-light);
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 11px;
    letter-spacing: 0.1em;
    padding: 6px 16px;
    cursor: pointer;
    z-index: 50;
    transition: opacity 0.15s, color 0.15s;
    white-space: nowrap;
}

#new-msg-indicator:hover {
    color: var(--accent-lighter);
    border-color: var(--accent);
}

/* === Typing Indicator === */
#typing-indicator {
    padding: 2px 22px 8px;
    font-size: 12px;
    color: var(--accent-dimmer);
    letter-spacing: 0.05em;
    min-height: 22px;
    flex-shrink: 0;
}

.blink-cursor {
    animation: terminal-blink 0.6s steps(2, start) infinite;
}

/* === Command Hints === */
#cmd-hints {
    position: absolute;
    bottom: 52px;
    left: 20px;
    right: 20px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-primary);
    z-index: 60;
    max-height: 160px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

.cmd-hint {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.08s;
}

.cmd-hint:hover,
.cmd-hint.active {
    background: var(--bg-hint-hover);
}

.cmd-hint-name {
    color: var(--accent-cmd);
    white-space: nowrap;
}

.cmd-hint-desc {
    color: var(--text-dim);
    font-size: 11px;
}

/* === Input Area === */
#input-area {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 13px 20px;
    border-top: 1px solid var(--border-secondary);
    background: var(--bg-input-area);
    flex-shrink: 0;
}

.input-prefix {
    color: var(--accent);
    font-size: 14px;
    flex-shrink: 0;
}

#message-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 14px;
    color: var(--text-bright);
    caret-color: var(--text-bright);
    min-width: 0;
}

#message-input.input-offline::placeholder {
    opacity: 0.35;
}

#send-btn {
    background: none;
    border: none;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 14px;
    color: var(--color-send-btn);
    cursor: pointer;
    letter-spacing: 0.15em;
    padding: 4px 0;
    transition: color 0.15s;
    flex-shrink: 0;
}

#send-btn:hover {
    color: var(--text-bright);
}

#send-btn .bracket {
    display: inline-block;
    transition: transform 0.15s;
}

#send-btn:hover .bracket.left {
    transform: translateX(-3px);
}

#send-btn:hover .bracket.right {
    transform: translateX(3px);
}

.SoundBtn {
    background: none;
    border: none;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 12px;
    color: var(--color-send-btn);
    cursor: pointer;
    letter-spacing: 0.15em;
    padding: 4px 0;
    transition: color 0.15s;
    flex-shrink: 0;
}


/* === Help Modal === */
#help-modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}

#help-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

#help-modal-content {
    position: relative;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    padding: 24px 28px;
    max-width: 380px;
    width: 90%;
    z-index: 1;
}

.help-title {
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 0.12em;
    margin-bottom: 12px;
}

.help-title+.help-title {
    margin-top: 20px;
}

.help-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.help-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
    font-size: 12px;
}

.help-key {
    color: var(--accent-cmd);
    white-space: nowrap;
    min-width: 130px;
}

.help-desc {
    color: var(--text-help-desc);
}

#help-close-btn {
    background: none;
    border: none;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 11px;
    letter-spacing: 0.18em;
    color: var(--text-sidebar-btn);
    cursor: pointer;
    padding: 0;
    margin-top: 20px;
    transition: color 0.15s;
}

#help-close-btn:hover {
    color: var(--text-sidebar-btn-hover);
}

#help-close-btn .bracket {
    display: inline-block;
    transition: transform 0.15s;
}

#help-close-btn:hover .bracket.left {
    transform: translateX(-3px);
}

#help-close-btn:hover .bracket.right {
    transform: translateX(3px);
}

/* === Sidebar Toggle Button (hidden on desktop) === */
#sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 14px;
    color: var(--text-self-username);
    cursor: pointer;
    padding: 4px 0;
    flex-shrink: 0;
    transition: color 0.15s;
}

#sidebar-toggle:hover {
    color: var(--text-bright);
}

#sidebar-toggle .bracket {
    display: inline-block;
    transition: transform 0.15s;
}

#sidebar-toggle:hover .bracket.left {
    transform: translateX(-3px);
}

#sidebar-toggle:hover .bracket.right {
    transform: translateX(3px);
}

/* === Sidebar Backdrop (hidden by default) === */
#sidebar-backdrop {
    display: none;
}

/* === Mobile Responsive (≤ 600px) === */
@media (max-width: 600px) {

    /* Show toggle button — large tap target */
    #sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 56px;
        min-height: 56px;
        font-size: 24px;
        color: var(--color-login-btn);
        margin: -14px -4px -14px -10px;
    }

    /* Sidebar becomes fixed overlay */
    #chat-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        height: 100dvh;
        width: 260px;
        min-width: 260px;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    body.sidebar-open #chat-sidebar {
        transform: translateX(0);
    }

    /* Backdrop */
    body.sidebar-open #sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 150;
    }

    /* Chat main takes full width */
    #chat-main {
        width: 100%;
    }

    /* Use dvh for full viewport on iOS */
    #chat-view {
        height: 100vh;
        height: 100dvh;
    }

    /* Larger touch targets for contacts */
    .contact {
        padding: 12px 16px;
        min-height: 44px;
    }

    /* Chat header — tall and easy to interact with, safe-area for notch/dynamic island */
    #chat-header {
        padding: 16px 18px;
        padding-top: max(22px, env(safe-area-inset-top));
        gap: 10px;
        font-size: 13px;
        min-height: 54px;
    }

    #chat-status-label {
        font-size: 10px;
    }

    /* Message feed */
    #message-feed {
        padding: 12px;
    }

    .message {
        font-size: 12px;
        word-break: break-word;
    }

    .message .msg-time {
        font-size: 11px;
    }

    .message .msg-sender {
        font-size: 11px;
    }

    .msg-admin-tag {
        font-size: 9px;
    }

    /* Command hints on mobile */
    #cmd-hints {
        left: 14px;
        right: 14px;
        bottom: 48px;
    }

    /* Input area — safe area padding for iPhone home indicator */
    #input-area {
        padding: 10px 14px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    #message-input {
        min-height: 36px;
        height: 36px;
        font-size: 16px;
        /* prevents iOS zoom on focus */
    }

    #input-area {
        padding: 6px 14px;
        padding-bottom: max(6px, env(safe-area-inset-bottom));
    }

    /* Hide watermark on mobile */
    #watermark {
        display: none;
    }

    /* Window manager — fullscreen on mobile */
    .wm-window {
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: 100% !important;
        border: none;
        box-shadow: none;
        min-width: 0;
        min-height: 0;
    }

    .wm-resize-handle { display: none; }
    .wm-btn-max { display: none; }

    #wm-desktop { bottom: 0; }
    #wm-taskbar { display: none; }

    /* Keep header visible on mobile so toggle button is always accessible */
    #chat-header.hidden {
        display: flex !important;
    }
}

/* ========================================
   WINDOW MANAGER
   ======================================== */

#wm-desktop {
    position: absolute;
    inset: 0;
    bottom: 28px;
    z-index: 1;
}

#wm-taskbar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 28px;
    display: flex;
    align-items: center;
    gap: 0;
    border-top: 1px solid var(--border-primary);
    background: var(--bg-sidebar);
    z-index: 2;
    overflow-x: auto;
    padding: 0 4px;
}

#wm-taskbar:empty {
    border-top: none;
    background: transparent;
}

.wm-window {
    position: absolute;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-primary);
    background: var(--bg-primary);
    min-width: 220px;
    min-height: 120px;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
    animation: wm-appear 0.15s ease both;
}

@keyframes wm-appear {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

.wm-window.wm-focused {
    border-color: var(--accent);
    box-shadow: 0 0 6px var(--accent-glow, rgba(0, 0, 0, 0.1));
}

.wm-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    height: 26px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-primary);
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
}

.wm-titlebar:active {
    cursor: grabbing;
}

.wm-title {
    font-size: 11px;
    letter-spacing: 0.12em;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wm-focused .wm-title {
    color: var(--text-bright);
}

.wm-controls {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.wm-btn {
    background: none;
    border: none;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 11px;
    color: var(--text-sidebar-btn);
    cursor: pointer;
    padding: 2px 2px;
    transition: color 0.15s;
}

.wm-btn:hover {
    color: var(--text-sidebar-btn-hover);
}

.wm-btn-close:hover {
    color: var(--color-error-hover, #cc4444);
}

.wm-btn .bracket {
    display: inline-block;
    transition: transform 0.15s;
}

.wm-btn:hover .bracket.left {
    transform: translateX(-2px);
}

.wm-btn:hover .bracket.right {
    transform: translateX(2px);
}

.wm-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    font-size: 12px;
    line-height: 1.7;
    color: var(--text-primary);
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

.wm-resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 14px;
    height: 14px;
    cursor: nwse-resize;
}

.wm-resize-handle::after {
    content: '';
    position: absolute;
    right: 3px;
    bottom: 3px;
    width: 6px;
    height: 6px;
    border-right: 2px solid var(--border-primary);
    border-bottom: 2px solid var(--border-primary);
}

.wm-window.wm-maximized {
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: 100% !important;
    box-shadow: none;
}

.wm-window.wm-maximized .wm-resize-handle {
    display: none;
}

.wm-taskbar-entry {
    background: none;
    border: none;
    border-right: 1px solid var(--border-secondary);
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 10px;
    letter-spacing: 0.08em;
    color: var(--text-sidebar-btn);
    cursor: pointer;
    padding: 4px 10px;
    white-space: nowrap;
    transition: color 0.15s;
}

.wm-taskbar-entry:hover {
    color: var(--text-sidebar-btn-hover);
}

/* Welcome window content */
.wm-welcome-greeting {
    font-size: 13px;
    color: var(--accent);
    margin-bottom: 16px;
    letter-spacing: 0.04em;
}

.wm-welcome-user {
    color: var(--text-bright);
}

.wm-section-title {
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 0.14em;
    margin: 14px 0 8px;
}

.wm-tip {
    display: flex;
    gap: 12px;
    font-size: 11px;
    line-height: 1.8;
}

.wm-tip-key {
    color: var(--accent);
    min-width: 110px;
    white-space: nowrap;
}

.wm-tip-desc {
    color: var(--text-dim);
}

.wm-status-row {
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.8;
}

.wm-status-val {
    color: var(--accent);
    margin-left: 8px;
}

.wm-welcome-footer {
    margin-top: 18px;
    font-size: 11px;
    color: var(--text-muted);
}

.wm-blink {
    animation: wm-blink-cursor 1s step-end infinite;
}

@keyframes wm-blink-cursor {
    50% { opacity: 0; }
}

body.wm-dragging {
    user-select: none;
}

/* Desktop icons */
.wm-icon {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: default;
    user-select: none;
    width: 72px;
    padding: 6px;
    z-index: 1;
}

.wm-icon-symbol {
    width: 52px;
    height: 40px;
    border: 1px solid var(--border-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    transition: border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.wm-icon-label {
    font-size: 9px;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    text-align: center;
    word-break: break-all;
}

.wm-icon:hover .wm-icon-symbol {
    border-color: var(--border-primary);
    color: var(--text-primary);
}

.wm-icon.wm-icon-selected .wm-icon-symbol {
    border-color: var(--accent);
    color: var(--text-bright);
    box-shadow: 0 0 4px var(--accent-glow, rgba(0, 0, 0, 0.1));
}

.wm-icon.wm-icon-selected .wm-icon-label {
    color: var(--text-primary);
}

/* Settings app */
.wm-settings-themes {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 8px;
}

.wm-settings-theme-btn {
    width: 100%;
    background: none;
    border: none;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 12px;
    text-align: left;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px 0;
    transition: color 0.15s;
}

.wm-settings-theme-btn:hover {
    color: var(--text-primary);
}

.wm-settings-theme-btn.active {
    color: var(--accent);
}

.wm-settings-theme-name {
    margin-left: 10px;
    color: var(--text-muted);
    font-size: 10px;
}

.wm-settings-theme-btn.active .wm-settings-theme-name {
    color: var(--text-dim);
}

.wm-settings-theme-btn .bracket {
    display: inline-block;
    transition: transform 0.15s;
}

.wm-settings-theme-btn:hover .bracket.left {
    transform: translateX(-2px);
}

.wm-settings-theme-btn:hover .bracket.right {
    transform: translateX(2px);
}

.wm-settings-username-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.wm-settings-label {
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 0.1em;
}

.wm-settings-username-input-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.wm-settings-username-input {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-primary);
    color: var(--text-primary);
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 12px;
    padding: 3px 0;
    outline: none;
    min-width: 0;
    transition: border-color 0.15s;
}

.wm-settings-username-input:focus {
    border-color: var(--accent);
}

.wm-settings-save-btn {
    background: none;
    border: none;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 11px;
    color: var(--text-sidebar-btn);
    cursor: pointer;
    padding: 0;
    white-space: nowrap;
    transition: color 0.15s;
    flex-shrink: 0;
}

.wm-settings-save-btn:hover {
    color: var(--accent);
}

.wm-settings-save-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.wm-settings-save-btn .bracket {
    display: inline-block;
    transition: transform 0.15s;
}

.wm-settings-save-btn:hover:not(:disabled) .bracket.left {
    transform: translateX(-2px);
}

.wm-settings-save-btn:hover:not(:disabled) .bracket.right {
    transform: translateX(2px);
}

.wm-settings-msg {
    font-size: 10px;
    color: var(--text-muted);
    min-height: 14px;
    letter-spacing: 0.06em;
}

.wm-settings-msg.error {
    color: var(--color-error, #aa3a3a);
}

.wm-settings-msg.success {
    color: var(--accent);
}

/* ========================================
   THEMES
   ======================================== */

/* Midnight — blue-tinted dark */
[data-theme="midnight"] {
    --bg-primary: #0c0e16;
    --bg-sidebar: #080a12;
    --bg-hover: #101428;
    --bg-hint-hover: #121624;

    --text-primary: #8a8a9a;
    --text-bright: #c0c4d0;
    --text-white: #e8ecf4;
    --text-msg: #ccd0dc;
    --text-msg-self: #e0e4f0;
    --text-input: #9a9aaa;
    --text-dim: #3a3a5a;
    --text-dimmer: #2a2a4a;
    --text-muted: #404060;
    --text-muted-hover: #6a6a8a;
    --text-contact-active: #a0a0c0;
    --text-sidebar-header: #2a2a4a;
    --text-sidebar-btn: #252540;
    --text-sidebar-btn-hover: #7070a0;
    --text-self-username: #404068;
    --text-placeholder: #3a3a5a;
    --text-filter-placeholder: #1e1e34;
    --text-watermark: #1a1a2a;
    --text-help-desc: #4a4a6a;

    --accent: #4a6a9a;
    --accent-glow: #4a6a9a88;
    --accent-light: #5a8aba;
    --accent-lighter: #7aaada;
    --accent-dim: #2a3a5a;
    --accent-dimmer: #1a2a4a;
    --accent-channel: #4a6a8a;
    --accent-channel-active: #6a8aaa;
    --accent-channel-badge: #3a4a6a;
    --accent-cmd: #6a8aaa;

    --border-primary: #1a1c2a;
    --border-secondary: #14162a;
    --border-input: #2a2a3a;
    --border-input-focus: #5a5a8a;

    --color-error: #7a3a4a;
    --color-error-hover: #aa4a5a;
    --color-admin-tag: #8a6a7a;
    --color-login-btn: #6a7a9a;
    --color-send-btn: #3a4a6a;
    --color-system-msg: #6a7a9a;

    --lock-tag: #6a7a9a;
    --lock-time: #3a4a6a;
    --lock-sender: #7a8aaa;
    --lock-sep: #2a3a5a;
    --lock-text: #8aaace;

    --scrollbar-thumb: #2a2a4a;
    --scrollbar-track: #0c0c1a;

    --bg-input-area: #10122a;

    --offline-dot: #3a3a5a;
    --offline-dot-large: #4a4a6a;
    --contact-badge-off: #1e1e2e;
    --contact-unread: #4a6a8a;
    --msg-own-border: rgba(74, 106, 154, 0.18);
    --msg-own-bg: rgba(74, 106, 154, 0.05);
    --system-divider: rgba(106, 122, 154, 0.35);
    --logo-filter: brightness(0) invert(0.55) sepia(0.5) hue-rotate(200deg);
    --sidebar-logo-filter: brightness(0) invert(0.35) sepia(0.5) hue-rotate(200deg);
}

/* Phosphor — classic green CRT */
[data-theme="phosphor"] {
    --bg-primary: #040804;
    --bg-sidebar: #020602;
    --bg-hover: #0a140a;
    --bg-hint-hover: #0c180c;

    --text-primary: #33aa33;
    --text-bright: #44dd44;
    --text-white: #66ff66;
    --text-msg: #44dd44;
    --text-msg-self: #55ff55;
    --text-input: #33aa33;
    --text-dim: #1a5a1a;
    --text-dimmer: #145014;
    --text-muted: #1a6a1a;
    --text-muted-hover: #33aa33;
    --text-contact-active: #44cc44;
    --text-sidebar-header: #145014;
    --text-sidebar-btn: #0e3a0e;
    --text-sidebar-btn-hover: #33aa33;
    --text-self-username: #1a6a1a;
    --text-placeholder: #1a5a1a;
    --text-filter-placeholder: #0a2a0a;
    --text-watermark: #0a2a0a;
    --text-help-desc: #1a6a1a;

    --accent: #22aa22;
    --accent-glow: #22aa2288;
    --accent-light: #33cc33;
    --accent-lighter: #55ee55;
    --accent-dim: #0e5a0e;
    --accent-dimmer: #0a4a0a;
    --accent-channel: #22aa22;
    --accent-channel-active: #33cc33;
    --accent-channel-badge: #145a14;
    --accent-cmd: #33bb33;

    --border-primary: #0a1a0a;
    --border-secondary: #081808;
    --border-input: #0e2a0e;
    --border-input-focus: #33aa33;

    --color-error: #aa3333;
    --color-error-hover: #cc4444;
    --color-admin-tag: #559955;
    --color-login-btn: #33aa33;
    --color-send-btn: #145a14;
    --color-system-msg: #228822;

    --lock-tag: #559955;
    --lock-time: #1a5a1a;
    --lock-sender: #44aa44;
    --lock-sep: #145014;
    --lock-text: #55cc55;

    --scrollbar-thumb: #1a4a1a;
    --scrollbar-track: #040a04;

    --bg-input-area: #060c06;

    --offline-dot: #1a5a1a;
    --offline-dot-large: #2a6a2a;
    --contact-badge-off: #081808;
    --contact-unread: #22aa22;
    --msg-own-border: rgba(34, 170, 34, 0.18);
    --msg-own-bg: rgba(34, 170, 34, 0.05);
    --system-divider: rgba(34, 136, 34, 0.35);
    --logo-filter: brightness(0) invert(1) sepia(1) hue-rotate(90deg) saturate(4);
    --sidebar-logo-filter: brightness(0) invert(0.5) sepia(1) hue-rotate(90deg) saturate(4);
}

/* Amber — warm amber CRT */
[data-theme="amber"] {
    --bg-primary: #0a0800;
    --bg-sidebar: #060400;
    --bg-hover: #141000;
    --bg-hint-hover: #181200;

    --text-primary: #aa8833;
    --text-bright: #ddaa33;
    --text-white: #ffcc44;
    --text-msg: #ddbb55;
    --text-msg-self: #eedd66;
    --text-input: #aa8833;
    --text-dim: #5a4a1a;
    --text-dimmer: #504014;
    --text-muted: #6a5a1a;
    --text-muted-hover: #aa8833;
    --text-contact-active: #ccaa44;
    --text-sidebar-header: #504014;
    --text-sidebar-btn: #3a2a0e;
    --text-sidebar-btn-hover: #aa8833;
    --text-self-username: #6a5a1a;
    --text-placeholder: #5a4a1a;
    --text-filter-placeholder: #2a1a0a;
    --text-watermark: #2a1a0a;
    --text-help-desc: #6a5a1a;

    --accent: #aa8822;
    --accent-glow: #aa882288;
    --accent-light: #ccaa33;
    --accent-lighter: #eebb44;
    --accent-dim: #5a4a0e;
    --accent-dimmer: #4a3a0a;
    --accent-channel: #aa8822;
    --accent-channel-active: #ccaa33;
    --accent-channel-badge: #5a4a14;
    --accent-cmd: #bb9933;

    --border-primary: #1a1400;
    --border-secondary: #181000;
    --border-input: #2a2000;
    --border-input-focus: #aa8833;

    --color-error: #aa4433;
    --color-error-hover: #cc5544;
    --color-admin-tag: #998844;
    --color-login-btn: #aa8833;
    --color-send-btn: #5a4a14;
    --color-system-msg: #888822;

    --lock-tag: #998844;
    --lock-time: #5a4a1a;
    --lock-sender: #aa9944;
    --lock-sep: #504014;
    --lock-text: #ccbb55;

    --scrollbar-thumb: #4a3a10;
    --scrollbar-track: #0a0800;

    --bg-input-area: #100e02;

    --offline-dot: #5a4a1a;
    --offline-dot-large: #6a5a2a;
    --contact-badge-off: #181000;
    --contact-unread: #aa8822;
    --msg-own-border: rgba(170, 136, 34, 0.18);
    --msg-own-bg: rgba(170, 136, 34, 0.05);
    --system-divider: rgba(136, 136, 34, 0.35);
    --logo-filter: brightness(0) invert(0.7) sepia(1) saturate(3);
    --sidebar-logo-filter: brightness(0) invert(0.6) sepia(1) saturate(2);
}

/* Light — light terminal */
[data-theme="dark"] {
    --bg-primary: #0f0f0f;
    --bg-sidebar: #0a0a0a;
    --bg-hover: #111;
    --bg-hint-hover: #141414;

    --text-primary: #b0b0b0;
    --text-bright: #d0d0d0;
    --text-white: #ffffff;
    --text-msg: #e8eaee;
    --text-msg-self: #f2f3f5;
    --text-input: #b8b8b8;
    --text-dim: #808080;
    --text-dimmer: #6a6a6a;
    --text-muted: #858585;
    --text-muted-hover: #9a9a9a;
    --text-contact-active: #c0c0c0;
    --text-sidebar-header: #787878;
    --text-sidebar-btn: #747474;
    --text-sidebar-btn-hover: #c0c0c0;
    --text-self-username: #888888;
    --text-placeholder: #787878;
    --text-filter-placeholder: #686868;
    --text-watermark: #4a4a4a;
    --text-help-desc: #8a8a8a;

    --accent: #4a9a6a;
    --accent-glow: #4a9a6a88;
    --accent-light: #5aaa8a;
    --accent-lighter: #7adaaa;
    --accent-dim: #3a6a50;
    --accent-dimmer: #2a5040;
    --accent-channel: #5a9a7a;
    --accent-channel-active: #7abb9a;
    --accent-channel-badge: #4a7a5a;
    --accent-cmd: #8aaa7a;

    --border-primary: #2a2a2a;
    --border-secondary: #262626;
    --border-input: #333333;
    --border-input-focus: #777;

    --color-error: #9a4a4a;
    --color-error-hover: #bb5a5a;
    --color-admin-tag: #aa7a7a;
    --color-login-btn: #9aacbc;
    --color-send-btn: #5a8090;
    --color-system-msg: #9a8a4a;

    --lock-tag: #8a7a3a;
    --lock-time: #6a5a2a;
    --lock-sender: #9a8a4a;
    --lock-sep: #5a4a2a;
    --lock-text: #c8b868;

    --scrollbar-thumb: #3a3a3a;
    --scrollbar-track: #141414;

    --bg-input-area: #161616;

    --offline-dot: #c0c0c0;
    --offline-dot-large: #aaaaaa;
    --contact-badge-off: #c8c8c8;
    --contact-unread: #2a6a4a;
    --logo-filter: brightness(0) invert(1);
    --sidebar-logo-filter: brightness(0) invert(1);
    --msg-own-border: rgba(74, 154, 106, 0.18);
    --msg-own-bg: rgba(74, 154, 106, 0.05);
    --system-divider: rgba(154, 138, 74, 0.35);
}

/* =============================================
   SOUNDBOARD APP
   ============================================= */
.sb-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.sb-picker {
    position: absolute;
    z-index: 100;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    min-width: 120px;
}

.sb-picker-item {
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-primary);
    color: var(--text-primary);
    padding: 6px 10px;
    text-align: left;
    cursor: pointer;
    transition: color 0.1s, background 0.1s;
}

.sb-picker-item:last-child {
    border-bottom: none;
}

.sb-picker-item:hover {
    background: var(--accent);
    color: var(--bg-primary);
}

.sb-item {
    display: flex;
    gap: 4px;
}

.sb-item .sb-btn {
    flex: 1;
}

.sb-send-btn {
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    background: transparent;
    border: 1px solid var(--border-primary);
    color: var(--text-dim);
    padding: 0 6px;
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s;
    flex-shrink: 0;
}

.sb-send-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.sb-btn {
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    padding: 10px 4px;
    border: 1px solid var(--border-primary);
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.12s, color 0.12s, background 0.12s;
    text-align: center;
}

.sb-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.sb-btn.sb-btn-active {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

.sb-stop {
    display: block;
    width: 100%;
    margin-top: 10px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    background: transparent;
    border: 1px solid var(--border-primary);
    color: var(--text-dim);
    cursor: pointer;
    padding: 2px 6px;
    transition: color 0.12s, border-color 0.12s;
}

.sb-stop:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* ── LEADERBOARD APP ──────────────────────────── */
.lb-loading {
    color: var(--text-dim);
    font-size: 11px;
    padding: 8px 0;
}

.lb-header {
    display: grid;
    grid-template-columns: 42px 1fr 44px;
    gap: 4px;
    font-size: 10px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border-primary);
    padding-bottom: 4px;
    margin-bottom: 4px;
}

.lb-col-count {
    text-align: right;
}

.lb-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    max-height: calc(100% - 58px);
}

.lb-row {
    display: grid;
    grid-template-columns: 42px 1fr 44px;
    gap: 4px;
    font-size: 11px;
    padding: 2px 0;
    align-items: baseline;
}

.lb-row-me {
    color: var(--accent);
}

.lb-rank {
    color: var(--text-dim);
    font-size: 10px;
}

.lb-row-me .lb-rank {
    color: var(--accent);
}

.lb-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-count {
    text-align: right;
    color: var(--text-dim);
    font-size: 10px;
}

.lb-row-me .lb-count {
    color: var(--accent);
}

.lb-refresh {
    display: block;
    width: 100%;
    margin-top: 8px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    background: transparent;
    border: 1px solid var(--border-primary);
    color: var(--text-dim);
    cursor: pointer;
    padding: 2px 6px;
    transition: color 0.12s, border-color 0.12s;
    flex-shrink: 0;
}

.lb-refresh:hover {
    color: var(--accent);
    border-color: var(--accent);
}