* {
    color-scheme: dark;
}

:root {
    --primary-color: #198754;
    --success-color: #198754;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #0dcaf0;
    --dark-bg: #212529;
    --darker-bg: #181b1f;
    --sidebar-bg: #23272b;
    --input-bg: #23272b;
    --status-bar-bg: #181b1f;
    --light-text: #f8f9fa;
    --muted-text: #a0a4aa;
    --border-color: #2c3136;
    --shadow: 0 2px 8px 0 rgba(0,0,0,0.10);
    --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
    --font-mono: Menlo, Monaco, Consolas, "Courier New", monospace;
    
    
    --font-size-tiny: 0.75rem;      
    --font-size-small: 0.875rem;    
    --font-size-base: 1rem;         
    --font-size-medium: 1.125rem;   
    --font-size-large: 1.25rem;     
    --font-size-xlarge: 1.618rem;   
}

:root {
    --font-size-base: 16px;
    --font-size-small: 13px;
    --font-size-tiny: 10px;
    --font-size-micro: 9px;
}

body, html {
    font-family: var(--font-main);
    background: var(--dark-bg);
    color: var(--light-text);
    font-size: var(--font-size-base);
    margin: 0;
    padding: 0;
    letter-spacing: 0.01em;
}

a, .btn-link {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}
a:hover, .btn-link:hover {
    color: #fff;
}

small, .small, .text-muted {
    font-size: var(--font-size-tiny);
    color: var(--muted-text) !important;
}

.font-monospace {
    font-family: var(--font-mono);
    font-size: var(--font-size-small);
    color: var(--muted-text);
}

input.form-control, .form-control, .input-group-text {
    background: var(--input-bg) !important;
    color: var(--light-text) !important;
    border: 1px solid var(--border-color) !important;
    font-size: var(--font-size-base);
    border-radius: 0.7rem;
    transition: border-color 0.2s;
}

input.form-control:focus, .form-control:focus {
    background: var(--input-bg) !important;
    color: var(--light-text) !important;
    border: 1px solid var(--primary-color) !important;
    box-shadow: 0 0 0 2px rgba(25,135,84,0.10);
}

.navbar, .navbar-dark {
    background: var(--dark-bg) !important;
    border-bottom: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow);
    font-size: var(--font-size-base);
    font-weight: 500;
    letter-spacing: 0.01em;
}

.bg-body-secondary {
    background: linear-gradient(135deg, #23272b 60%, #181b1f 100%) !important;
    border-left: 1px solid var(--border-color) !important;
    box-shadow: -2px 0 8px 0 rgba(0,0,0,0.10);
    height: calc(100vh - 56px) !important;
    max-height: calc(100vh - 56px) !important;
    overflow: hidden;
}

.border-top {
    border-top: 1px solid var(--border-color) !important;
}

.border-bottom {
    border-bottom: 1px solid var(--border-color) !important;
}

#messages {
    font-size: var(--font-size-base);
    line-height: 1.6;
    padding-bottom: 0.5rem;
}

.message-bubble {
    background: linear-gradient(135deg, #23272b 60%, #181b1f 100%);
    color: var(--light-text);
    border-radius: 1.1rem;
    box-shadow: var(--shadow);
    padding: 13px 18px;
    margin-bottom: 10px;
    max-width: 80%;
    word-break: break-word;
    font-size: var(--font-size-base);
    font-weight: 400;
    border: none;
    transition: background 0.2s;
}

.message-bubble.own {
    background: linear-gradient(135deg, var(--primary-color) 60%, #146c43 100%);
    color: #fff;
    border-bottom-right-radius: 7px;
}

.message-bubble.other {
    background: linear-gradient(135deg, #23272b 60%, #181b1f 100%);
    color: var(--light-text);
    border-bottom-left-radius: 7px;
}

input#message-input {
    font-size: var(--font-size-base);
    padding: 0.7rem 1rem;
}

.input-group {
    gap: 0.5rem;
}

.btn, .btn-success, .btn-primary, .btn-outline-danger {
    font-size: var(--font-size-base);
    border-radius: 0.7rem;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}

.btn-success {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}
.btn-success:hover, .btn-success:focus {
    background: #157347;
    border-color: #157347;
    color: #fff;
}

.btn-primary {
    background: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}
.btn-primary:hover, .btn-primary:focus {
    background: #0b5ed7;
    border-color: #0b5ed7;
    color: #fff;
}

.btn-outline-danger {
    color: var(--danger-color);
    border-color: var(--danger-color);
    background: transparent;
    padding: 0.35rem 0.75rem;
    font-size: var(--font-size-small);
    border-radius: 0.5rem;
    min-width: 0;
    min-height: 0;
    line-height: 1.2;
}
.btn-outline-danger:hover, .btn-outline-danger:focus {
    background: var(--danger-color);
    color: #fff;
}


#clear-history {
    padding: 0.35rem 0.75rem !important;
    font-size: var(--font-size-small) !important;
    border-radius: 0.5rem !important;
    min-width: 0 !important;
    min-height: 0 !important;
    line-height: 1.2 !important;
}


.seeding-indicator {
    background: linear-gradient(90deg, rgba(25,135,84,0.15) 0%, rgba(20,108,67,0.12) 100%);
    color: var(--success-color);
    font-weight: 700;
    border-radius: 0.3rem;
    padding: 0.15em 0.5em;
    font-size: var(--font-size-tiny);
    letter-spacing: 0.02em;
    box-shadow: 0 1px 3px 0 rgba(25,135,84,0.1);
    display: inline-block;
    text-transform: uppercase;
    vertical-align: middle;
    border: 1px solid rgba(25,135,84,0.2);
}


.channel-badge {
    display: inline-block;
    background: linear-gradient(90deg, #23272b 60%, #181b1f 100%);
    color: var(--primary-color);
    font-family: var(--font-main);
    font-weight: 700;
    border-radius: 0.7rem;
    padding: 0.5em 1.2em;
    font-size: var(--font-size-medium);
    letter-spacing: 0.04em;
    border: 1.5px solid var(--primary-color);
    user-select: text;
    cursor: default;
    min-width: 80px;
    text-align: center;
    box-shadow: 0 1px 4px 0 rgba(25,135,84,0.07);
    margin: 0 auto;
    transition: background 0.2s, color 0.2s;
}

#channel-input[readonly] {
    font-family: var(--font-main);
    font-weight: 700;
    font-size: var(--font-size-medium);
    letter-spacing: 0.04em;
    text-align: center;
    background: none !important;
    border: none !important;
    color: var(--primary-color) !important;
    padding: 0;
    box-shadow: none !important;
    outline: none !important;
    cursor: default;
    pointer-events: none;
    width: auto;
    min-width: 80px;
}


aside .p-3 {
    border-bottom: 1px solid var(--border-color);
    padding: 1rem !important;
}

aside .p-3:last-child {
    border-bottom: none;
    flex: 1;
    overflow-y: auto;
}


aside .form-label,
aside .fw-semibold {
    font-size: var(--font-size-small);
    font-weight: 600;
    color: var(--light-text);
    margin-bottom: 0.5rem;
}

.peer-item {
    background: linear-gradient(135deg, #23272b 60%, #181b1f 100%);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    transition: background 0.2s;
    font-size: var(--font-size-small);
    color: var(--light-text);
    line-height: 1.4;
}

.peer-item:hover {
    background: linear-gradient(135deg, #262a2e 60%, #181b1f 100%);
}


.peer-item .font-monospace {
    font-size: var(--font-size-small);
    font-weight: 600;
    color: var(--light-text);
}

.peer-item .small {
    font-size: var(--font-size-tiny);
    color: var(--muted-text);
}


.torrent-stats {
    background: linear-gradient(135deg, #23272b 60%, #181b1f 100%) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--light-text);
    border-radius: 8px;
    box-shadow: var(--shadow);
    font-size: var(--font-size-small) !important;
    line-height: 1.3 !important;
    margin-bottom: 1rem;
    padding: 0.75rem !important;
}

.torrent-stats .small,
.torrent-stats .d-flex span,
.torrent-stats .d-flex,
.torrent-stats span,
.torrent-stats .text-success,
.torrent-stats .text-warning,
.torrent-stats .text-info {
    font-size: var(--font-size-small) !important;
    line-height: 1.3 !important;
}


.torrent-stats .ratio-line,
.torrent-stats .ratio-line span,
.torrent-stats .seeding-indicator,
.torrent-stats .mt-1.small,
.torrent-stats .mt-1.small span {
    font-size: var(--font-size-small) !important;
    line-height: 1.3 !important;
}


.torrent-stats .text-success,
.torrent-stats .text-warning {
    font-size: var(--font-size-small) !important;
    font-weight: 600 !important;
}


.small.text-muted.mt-1 {
    font-size: var(--font-size-small) !important;
}

.small.text-muted.mt-1 span {
    font-size: var(--font-size-small) !important;
}

#char-count {
    font-size: var(--font-size-small) !important;
    font-weight: 500;
}


#current-peer-id {
    font-size: var(--font-size-small) !important;
    font-weight: 600;
    color: var(--success-color) !important;
    font-family: var(--font-mono);
}

#peer-count-detail {
    font-size: var(--font-size-tiny) !important;
    line-height: 1.3 !important;
}


aside .d-flex.justify-content-between.small {
    font-size: var(--font-size-small) !important;
    margin-bottom: 0.25rem;
}

aside .d-flex.justify-content-between.small span {
    font-size: var(--font-size-small) !important;
}


.status-dot {
    width: 8px !important;
    height: 8px !important;
    min-width: 8px !important;
    border-radius: 50% !important;
    display: inline-block;
    animation: pulse 2s infinite;
    margin-right: 0.5rem;
    flex-shrink: 0;
}


#peers {
    max-height: none !important;
    overflow-y: visible !important;
}


aside i {
    font-size: var(--font-size-tiny) !important;
    vertical-align: middle;
}


.text-muted.small.d-flex.align-items-center {
    font-size: var(--font-size-tiny) !important;
}

.text-muted.small.d-flex.align-items-center i {
    font-size: var(--font-size-tiny) !important;
}


.peer-item .d-flex.justify-content-between {
    margin-bottom: 0.25rem;
}

.peer-item .d-flex.justify-content-between:last-child {
    margin-bottom: 0;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

::-webkit-scrollbar {
    width: 7px;
}
::-webkit-scrollbar-thumb {
    background: var(--sidebar-bg);
    border-radius: 4px;
}
::-webkit-scrollbar-track {
    background: var(--dark-bg);
}


#skeleton-screen {
    min-height: 100vh;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.skeleton-navbar {
    height: 56px;
    background: var(--dark-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    font-family: inherit;
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

.skeleton-navbar-brand {
    width: 100px;
    height: 20px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--darker-bg) 25%, var(--muted-text) 50%, var(--darker-bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    font-family: inherit;
    background: var(--dark-bg);
    min-height: 0;
    height: calc(100vh - 56px);
}

.skeleton-messages {
    flex: 1;
    padding: 1rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    font-family: inherit;
    background: var(--dark-bg);
    min-height: 0;
}

.skeleton-message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
}

.skeleton-message.own {
    align-items: flex-end;
}

.skeleton-message-bubble {
    width: 70vw;
    max-width: 90vw;
    height: 2.2rem;
    border-radius: 1rem;
    background: linear-gradient(90deg, #23272b 25%, #181b1f 50%, #23272b 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    box-shadow: var(--shadow);
}

.skeleton-message.own .skeleton-message-bubble {
    background: linear-gradient(90deg, var(--primary-color) 25%, var(--success-color) 50%, var(--primary-color) 75%);
}

.skeleton-input-area {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--input-bg);
    box-shadow: 0 -1px 8px 0 rgba(0,0,0,0.08);
    flex-shrink: 0;
}

.skeleton-input {
    width: 100%;
    height: 2.5rem;
    border-radius: 1.25rem;
    background: linear-gradient(90deg, #23272b 25%, #181b1f 50%, #23272b 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-sidebar {
    display: none;
}

.skeleton-status-bar {
    height: 40px;
    background: var(--status-bar-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 -2px 8px 0 rgba(0,0,0,0.10);
    flex-shrink: 0;
}

.skeleton-status-text {
    width: 120px;
    height: 16px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--dark-bg) 25%, var(--success-color) 50%, var(--dark-bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@media (min-width: 992px) {
    .skeleton-main {
        flex-direction: row;
        height: calc(100vh - 56px);
    }
    
    
    .skeleton-sidebar {
        display: flex;
        flex-direction: column;
        width: 260px;
        background: linear-gradient(135deg, #23272b 60%, #181b1f 100%);
        border-left: 1px solid var(--border-color);
        border-right: none;
        order: 2;
        font-family: inherit;
        box-shadow: -2px 0 8px 0 rgba(0,0,0,0.10);
        height: calc(100vh - 56px);
        max-height: calc(100vh - 56px);
        overflow: hidden;
    }
    
    .skeleton-sidebar > div {
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
    }
    
    .skeleton-sidebar > div:last-child {
        border-bottom: none;
        flex: 1;
        overflow-y: auto;
    }
    
    .skeleton-channel.channel-badge {
        background: linear-gradient(90deg, #23272b 60%, #181b1f 100%);
        border-radius: 0.7rem;
        border: 1px solid var(--primary-color);
        color: var(--primary-color);
        font-weight: 600;
        font-size: var(--font-size-medium);
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 auto;
        height: 32px;
        width: 100px;
    }
    
    .skeleton-peer-count,
    .skeleton-channel {
        background: linear-gradient(90deg, #23272b 25%, #181b1f 50%, #23272b 75%);
        border-radius: 4px;
        background-size: 200% 100%;
        animation: shimmer 1.5s infinite;
        margin-bottom: 0.5rem;
    }
    
    .skeleton-peer-list {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .skeleton-peer-item {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    .skeleton-peer-dot {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background: linear-gradient(90deg, #23272b 25%, var(--success-color) 50%, #23272b 75%);
        background-size: 200% 100%;
        animation: shimmer 1.5s infinite;
    }
    
    .skeleton-peer-name {
        width: 60px;
        height: 12px;
        border-radius: 3px;
        background: linear-gradient(90deg, #23272b 25%, #181b1f 50%, #23272b 75%);
        background-size: 200% 100%;
        animation: shimmer 1.5s infinite;
    }
    
    
    .skeleton-main > .d-flex.flex-column.flex-grow-1.w-100 {
        order: 1;
    }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}


#peer-count, #peer-count-detail {
    font-weight: 500;
    color: var(--primary-color);
    font-size: var(--font-size-small);
}


.badge.bg-success i,
#status .status-dot,
#clear-history i,
#send-btn i,
#join-channel i,
.torrent-stats i,
.peer-item i,
#connection-status i {
    font-size: 1em;
    vertical-align: middle;
    margin-right: 0.3em;
}

#current-channel i {
    margin-right: 0.3em;
    font-size: var(--font-size-tiny);
}


.peer-item i:not(.status-dot):not(.fa-shield-alt):not(.fa-user-circle):not(.fa-seedling) {
    display: none !important;
}


@media (max-width: 991.98px) {
    .bg-body-secondary, .skeleton-sidebar {
        display: none !important;
    }
    .navbar, .navbar-dark {
        font-size: var(--font-size-base);
    }
    .message-bubble {
        font-size: var(--font-size-base);
        padding: 10px 12px;
    }
    .peer-item {
        font-size: var(--font-size-small);
        padding: 7px 10px;
    }
    .torrent-stats {
        font-size: var(--font-size-tiny);
    }
}
