html {
    height: 100%;
}
body {
    font-family: 'Segoe UI', Arial, Helvetica, sans-serif;
    min-width: 320px;
    background: #181a20;
    color: #e3e5eb;
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
}

h1 {
    font-size: 2.2em;
    margin-top: 0px;
    margin-bottom: 0px;
    letter-spacing: 1px;
    color: #58a6ff;
    text-shadow: 0 2px 8px #000a;
}

a {
    color: #58a6ff;
    text-decoration: none;
    transition: color 0.2s;
}
a:hover {
    color: #ffb300;
}

.head {
    margin-bottom: 15px;
    padding: 24px 0 8px 0;
    background: linear-gradient(90deg, #23243a 0%, #1a1b22 100%);
    box-shadow: 0 2px 12px #0004;
    text-align: center;
}

.subTitle {
    font-size: 1em;
    font-weight: bold;
    color: #b0b3c6;
    letter-spacing: 0.5px;
}

.usernamelink {
    color: #58a6ff;
    text-decoration: underline;
}

#roomStats {
    display: block;
    text-align: center;
    margin: 18px auto 18px auto;
    font-size: 1.15em;
    font-weight: 500;
    letter-spacing: 0.5px;
    width: 100%;
    max-width: 100vw;
}
#roomStats > div {
    display: block;
    margin: 4px 0;
}
#roomStats b {
    margin-right: 20px;
    color: #ffb300;
}

#kickStats {
    color: #fff;
    font-size: 1.08em;
    margin: 8px 0;
    text-align: center;
    font-weight: 500;
    letter-spacing: 0.5px;
}



.splitchattable, .splitstatetable {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
    table-layout: fixed;
}

.splitstatetable td {
    width: 50%;
}

.containerheader {
    text-align: left;
    font-size: 1.2em;
    font-weight: 600;
    letter-spacing: 1px;
    color: #58a6ff;
    margin: 0 0 12px 0;
    padding-left: 8px;
    text-shadow: 0 2px 8px #000a;
}

#mainChatContainer, #mainChatContainer * {
    box-sizing: border-box !important;
}

.chatcontainer, .eventcontainer {
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    word-wrap: break-word;
    background: #23243a;
    border-radius: 12px;
    box-shadow: 0 2px 16px #0006;
    padding: 12px 10px 24px 10px !important;
    margin: 0;
    min-width: 0;
    max-width: 100vw;
    transition: box-shadow 0.3s;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
.chatcontainer:hover {
    box-shadow: 0 4px 32px #58a6ff44;
}

.eventcontainer {
    height: 30vh;
}

.miniprofilepicture {
    height: 22px;
    width: 22px;
    border-radius: 50%;
    margin-right: 6px;
    border: 2px solid #58a6ff;
    box-shadow: 0 2px 8px #0006;
    object-fit: cover;
    transition: border 0.2s, box-shadow 0.2s;
    background: #222;
    padding: 0;
    display: inline-block;
    vertical-align: middle;
}

.chatcontainer div {
    display: block;
    flex-shrink: 0;
    background: rgba(40,44,60,0.85);
    border-radius: 8px;
    margin-bottom: 8px;
    padding: 8px 8px;
    box-shadow: 0 1px 6px #0003;
    animation: fadeInUp 0.5s;
    transition: background 0.2s, box-shadow 0.2s;
    font-size: 1em;
    line-height: 1.4;
}
.chatcontainer div:hover {
    background: #2c2f4a;
    box-shadow: 0 2px 12px #58a6ff33;
}

.chatcontainer b {
    color: #ffb300;
    margin-right: 6px;
    font-weight: 600;
    font-size: 1em;
    text-shadow: 0 1px 4px #000a;
}

.chatcontainer span {
    color: #e3e5eb;
    font-size: 1em;
    word-break: break-word;
    transition: color 0.2s;
}

/* Animated fade-in for chat messages */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

input[type="text"] {
    background: #23243a;
    color: #e3e5eb;
    border: 1.5px solid #58a6ff;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 1.1em;
    margin-right: 8px;
    outline: none;
    transition: border 0.2s, box-shadow 0.2s;
    width: 60vw;
    max-width: 320px;
    min-width: 100px;
    box-sizing: border-box;
}
input[type="text"]:focus {
    border: 1.5px solid #ffb300;
    box-shadow: 0 0 8px #ffb30044;
}

input[type="button"] {
    background: linear-gradient(90deg, #58a6ff 0%, #ffb300 100%);
    color: #181a20;
    border: none;
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 8px #0004;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
    min-width: 80px;
}
input[type="button"]:hover {
    background: linear-gradient(90deg, #ffb300 0%, #58a6ff 100%);
    color: #23243a;
    box-shadow: 0 4px 16px #58a6ff44;
}

.inputFields {
    margin: 24px 0 16px 0;
    text-align: center;
}

.inputFields p {
    margin: 8px 0 4px 0;
    text-align: center;
}
.inputFields input[type="text"],
.inputFields input[type="button"] {
    margin-bottom: 4px !important;
}

/* Responsive Design */
@media (max-width: 600px) {
    .head {
        padding: 16px 0 4px 0;
    }
    .containerheader {
        font-size: 1em;
        padding-left: 4px;
    }
    .chatcontainer, .eventcontainer {
        padding: 8px 2px 6px 2px;
        min-width: 0;
        max-width: 100vw;
        font-size: 0.98em;
    }
    .chatcontainer div {
        font-size: 0.98em;
        padding: 6px 4px;
    }
    .miniprofilepicture {
        height: 18px;
        width: 18px;
        margin-right: 4px;
    }
    .chatcontainer .kick-message .miniprofilepicture {
        height: 18px;
        width: 18px;
        margin-right: 4px;
    }
    input[type="text"] {
        font-size: 1em;
        padding: 8px 8px;
        max-width: 180px;
    }
    input[type="button"] {
        font-size: 1em;
        padding: 8px 12px;
        min-width: 60px;
    }
    .inputFields {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .inputFields input[type="text"],
    .inputFields input[type="button"] {
        margin-bottom: 8px;
    }
    #roomStats {
        font-size: 1em;
        margin: 12px auto;
    }
    #roomStats > div {
        margin: 2px 0;
    }
}

@media (max-width: 400px) {
    .chatcontainer, .eventcontainer {
        padding: 4px 0 4px 0;
        font-size: 0.95em;
    }
    .chatcontainer div {
        font-size: 0.95em;
        padding: 4px 2px;
    }
    .miniprofilepicture {
        height: 16px;
        width: 16px;
        margin-right: 3px;
    }
    .chatcontainer .kick-message .miniprofilepicture {
        height: 16px;
        width: 16px;
        margin-right: 3px;
    }
    input[type="text"] {
        font-size: 0.95em;
        padding: 6px 4px;
        max-width: 100px;
    }
    input[type="button"] {
        font-size: 0.95em;
        padding: 6px 6px;
        min-width: 40px;
    }
}

/* TikTok Message Styles */
.tiktok-message {
    background: rgba(40,44,60,0.85) !important;
    border-radius: 8px;
    margin-bottom: 8px;
    padding: 8px 8px 8px 12px;
    box-shadow: 0 1px 6px #0003;
    display: block;
    line-height: 1.4;
}

body.hide-tiktok-likes .tiktok-message.like-msg {
    display: none !important;
}

body.hide-tiktok-follows .tiktok-message.follow-msg {
    display: none !important;
}

body.hide-tiktok-joins .tiktok-message.join-msg {
    display: none !important;
}

/* Kick Chat Styles */
.kick-message {
    background: rgba(40,44,60,0.85) !important;
    border-radius: 8px;
    margin-bottom: 8px;
    padding: 8px 8px 8px 12px;
    box-shadow: 0 1px 6px #0cfc7033;
    display: block;
    line-height: 1.4;
}

/* Twitch Chat Styles */
.twitch-message {
    background: rgba(40,44,60,0.85) !important;
    border-radius: 8px;
    margin-bottom: 8px;
    padding: 8px 8px 8px 12px;
    box-shadow: 0 1px 6px #9146ff33;
    display: block;
    line-height: 1.4;
}

.twitch-message .platform-icon,
.kick-message .platform-icon,
.tiktok-message .platform-icon,
.platform-icon {
    width: 18px !important;
    height: 18px !important;
    vertical-align: middle !important;
    margin-right: 5px !important;
    display: inline-block !important;
    flex-shrink: 0;
    filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.8));
}

.twitch-badge-icon {
    display: inline-block;
    height: 1.2em;
    vertical-align: middle;
    margin-right: 3px;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s ease;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.twitch-badge-icon:hover {
    transform: scale(1.1);
}

/* Kick Gifted Sub Styles */
.kick-gifted-sub {
    background: rgba(40,44,60,0.85) !important;
    border-radius: 4px;
    margin-bottom: 2px;
    padding: 8px 8px 8px 12px;
    border-left: 4px solid #a855f7 !important;
    box-shadow: 0 1px 4px #0003;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1em;
}
.kick-gifted-sub-item {
    background: rgba(40,44,60,0.85) !important;
    border-radius: 4px;
    margin-bottom: 2px;
    padding: 8px 8px 8px 12px;
    border-left: 4px solid #a855f7 !important;
    box-shadow: 0 1px 4px #0003;
    display: flex;
    align-items: center;
    gap: 8px;
}
.kick-gifted-sub-icon {
    font-size: 1.4em;
    color: #a855f7;
    margin-right: 4px;
}
.kick-gifted-sub-column {
    display: flex;
    flex-direction: column;
}
.kick-gifted-sub-subtitle {
    font-size: 0.85em;
    color: #aaa;
    margin-top: 2px;
}

.twitch-badges {
    font-size: 0.9em;
    margin-right: 4px;
}


.kick-gift {
    margin: 3px 0;
    padding: 3px 8px;
    border-radius: 6px;
    background: linear-gradient(135deg, #ff6b6b, #ff8e8e);
    color: white;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: bold;
    animation: giftPulse 2s ease-in-out infinite;
}

.kick-subscription {
    margin: 3px 0;
    padding: 3px 8px;
    border-radius: 6px;
    background: linear-gradient(135deg, #a855f7, #c084fc);
    color: white;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: bold;
    animation: subGlow 3s ease-in-out infinite;
}

.kick-follow {
    margin: 3px 0;
    padding: 3px 8px;
    border-radius: 6px;
    background: linear-gradient(135deg, #10b981, #34d399);
    color: white;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: bold;
    animation: followSlide 1s ease-out;
}

.kick-stream-event {
    margin: 4px 0;
    padding: 4px 10px;
    border-radius: 8px;
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    text-align: center;
    justify-content: center;
    animation: streamPulse 4s ease-in-out infinite;
}

/* Badge Styles */
.badge {
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
}

.badge.moderator {
    background: #ef4444;
    color: white;
}

.badge.subscriber {
    background: #a855f7;
    color: white;
}

.badge.verified {
    background: #10b981;
    color: white;
}

/* Icon Styles */
.gift-icon {
    font-size: 16px;
    animation: giftBounce 1s ease-in-out infinite;
}

.sub-icon {
    font-size: 16px;
    animation: subSpin 2s linear infinite;
}

.follow-icon {
    font-size: 16px;
    animation: followWave 1s ease-in-out;
}

.stream-icon {
    font-size: 18px;
}

/* Animations */
@keyframes giftPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes giftBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@keyframes subGlow {
    0%, 100% { box-shadow: 0 0 5px rgba(168, 85, 247, 0.5); }
    50% { box-shadow: 0 0 15px rgba(168, 85, 247, 0.8); }
}

@keyframes subSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes followSlide {
    0% { transform: translateX(-20px); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

@keyframes followWave {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

@keyframes streamPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* Sub message styling */
.sub-message {
    font-style: italic;
    opacity: 0.9;
    margin-left: 5px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .kick-gift, .kick-subscription, .kick-follow, .kick-stream-event {
        font-size: 12px;
        padding: 2px 6px;
    }
    
    .gift-icon, .sub-icon, .follow-icon, .stream-icon {
        font-size: 14px;
    }
    
    /* Mobile-friendly scroll to bottom button */
    #scrollToBottomBtn {
        bottom: 15px !important;
        right: 15px !important;
        width: 45px !important;
        height: 45px !important;
        font-size: 18px !important;
    }
}

/* Desktop (default) */
.chatcontainer .kick-message .miniprofilepicture {
    width: 22px;
    height: 22px;
    border: 2px solid #4cff7a !important;
    margin-right: 6px;
    margin-left: 0;
    border-radius: 50%;
    object-fit: contain;
    object-position: left center;
    background: #222;
    box-shadow: 0 2px 8px #0006;
    display: inline-block;
    vertical-align: middle;
    transition: border 0.2s, box-shadow 0.2s;
    padding: 0;
}

@media (max-width: 600px) {
    .chatcontainer .kick-message .miniprofilepicture {
        height: 18px;
        width: 18px;
        margin-right: 4px;
    }
}

@media (max-width: 400px) {
    .chatcontainer .kick-message .miniprofilepicture {
        height: 16px;
        width: 16px;
        margin-right: 3px;
    }
}

/* Remove Kick-specific avatar wrapper styles */
.kick-avatar-circle { display: none !important; }
.kick-avatar-circle .miniprofilepicture { display: none !important; }

/* TikTok: circular avatar, no border */

.chatcontainer .tiktok-message .miniprofilepicture {
    border-radius: 50%;
    width: 22px;
    height: 22px;
    object-fit: cover;
    margin-right: 6px;
    border: none !important; /* Remove blue border for TikTok */
}

/* Username and message styling */

.tiktok-badge {
    display: inline-block;
    background: #58a6ff;
    color: #fff;
    font-weight: bold;
    font-size: 0.85em;
    border-radius: 4px;
    padding: 2px 8px;
    margin-right: 8px;
    letter-spacing: 1px;
    vertical-align: middle;
    box-shadow: 0 1px 4px #0003;
}

.description {
    text-align: center;
    margin: 16px 0;
    font-size: 1.08em;
}

.inputFields {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 100% !important;
}
.inputFields input[type="text"],
.inputFields input[type="button"] {
    display: block;
    margin-left: auto !important;
    margin-right: auto !important;
    margin-bottom: 8px !important;
    width: 90vw !important;
    max-width: 320px !important;
    min-width: 100px !important;
    box-sizing: border-box !important;
    text-align: center !important;
}

 .chatcontainer .kick-message b {
    color: #4cff7a;
} 

/* Kick badge styling */
.kick-badge {
    display: inline-block;
    height: 1.2em;
    vertical-align: middle;
    margin-right: 2px;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s ease;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.kick-badge:hover {
    transform: scale(1.1);
}

.kick-badge-moderator {
    filter: drop-shadow(0 1px 2px rgba(255, 0, 0, 0.3));
}

.kick-badge-subscriber {
    filter: drop-shadow(0 1px 2px rgba(255, 215, 0, 0.3));
}

.kick-badge-verified {
    filter: drop-shadow(0 1px 2px rgba(0, 255, 0, 0.3));
}

/* Kick emote styling */
.kick-emote {
    height: 1.5em;
    vertical-align: middle;
    border-radius: 2px;
    margin: 0 1px;
    transition: transform 0.1s ease;
}

.kick-emote:hover {
    transform: scale(1.2);
}

.live-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #aaa;
    box-shadow: 0 0 6px #0006;
    margin-right: 2px;
    border: 2px solid #222;
    transition: background 0.3s, box-shadow 0.3s;
}
.live-dot.live {
    background: #2ecc40;
    box-shadow: 0 0 8px #2ecc40cc, 0 0 2px #000a;
}
.live-dot.offline {
    background: #e74c3c;
    box-shadow: 0 0 8px #e74c3ccc, 0 0 2px #000a;
}

/* Twitch Context Menu Styling */
.context-menu {
    position: absolute;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 6px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.5);
    z-index: 1000;
    padding: 5px 0;
    color: white;
    font-family: inherit;
    min-width: 160px;
    max-height: 250px;
    overflow-y: auto;
}
.context-menu::-webkit-scrollbar {
    width: 6px;
}
.context-menu::-webkit-scrollbar-track {
    background: #2a2a2a;
    border-radius: 6px;
}
.context-menu::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 6px;
}
.context-menu::-webkit-scrollbar-thumb:hover {
    background: #777;
}
.context-menu-header {
    padding: 8px 15px;
    font-weight: bold;
    border-bottom: 1px solid #444;
    color: #9146FF;
    font-size: 1.1em;
    position: sticky;
    top: 0;
    background: #2a2a2a;
    z-index: 2;
}
.context-menu-item {
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.2s;
}
.context-menu-item:hover {
    background: #444;
}

#notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification-toast {
    background: #333;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    font-family: 'Open Sans', sans-serif;
    animation: slideInRight 0.3s ease-out forwards;
    border-left: 4px solid #9146FF;
    min-width: 200px;
}
.notification-toast.error {
    border-left-color: #ff5555;
}
.notification-toast.success {
    border-left-color: #53fc18;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}
@keyframes fadeOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

#chatInput:focus {
    border-color: #9146FF !important;
    box-shadow: 0 0 5px rgba(145, 70, 255, 0.5);
}

.chat-paused-indicator {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.8em;
    pointer-events: none;
    display: none;
    z-index: 100;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: #1f1f23;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #3a3a3d;
    border-radius: 3px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #4f4f53;
}

.emote-img {
    cursor: pointer;
    border-radius: 4px;
    padding: 2px;
    transition: background 0.2s;
    height: 28px;
}
.emote-img:hover {
    background: #444;
}
#toggleEmotePickerBtn:hover {
    color: #fff !important;
}

/* Chat Entry Animations */
@keyframes anim-none {
    from { opacity: 1; }
    to { opacity: 1; }
}
@keyframes anim-popIn {
    0% { transform: scale(0.5); opacity: 0; }
    80% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes anim-slideIn {
    0% { transform: translateX(-100%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}
@keyframes anim-fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}
@keyframes anim-bounceIn {
    0% { transform: translateY(20px); opacity: 0; }
    40% { transform: translateY(-10px); opacity: 1; }
    70% { transform: translateY(5px); }
    100% { transform: translateY(0); }
}
@keyframes anim-zoomIn {
    0% { transform: scale(0.1); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes anim-flipIn {
    0% { transform: perspective(400px) rotateX(90deg); opacity: 0; }
    40% { transform: perspective(400px) rotateX(-20deg); }
    60% { transform: perspective(400px) rotateX(10deg); opacity: 1; }
    80% { transform: perspective(400px) rotateX(-5deg); }
    100% { transform: perspective(400px) rotateX(0deg); opacity: 1; }
}
@keyframes anim-rotateIn {
    0% { transform: rotate(-90deg); opacity: 0; }
    100% { transform: rotate(0); opacity: 1; }
}
@keyframes anim-swingIn {
    0% { transform: rotateX(-100deg); transform-origin: top; opacity: 0; }
    100% { transform: rotateX(0); transform-origin: top; opacity: 1; }
}
@keyframes anim-rollIn {
    0% { transform: translateX(-100%) rotate(-120deg); opacity: 0; }
    100% { transform: translateX(0px) rotate(0deg); opacity: 1; }
}
/* Chat Filters */
.hide-chats .tiktok-message.chat-msg { display: none !important; }
.hide-joins .tiktok-message.join-msg { display: none !important; }
.hide-likes .tiktok-message.like-msg { display: none !important; }
.hide-gifts .tiktok-message.gift-msg { display: none !important; }
.hide-follows .tiktok-message.follow-msg { display: none !important; }

/* Twitch Channel Actions */
.game-search-item {
    padding: 8px 12px;
    cursor: pointer;
    color: #e3e5eb;
    border-bottom: 1px solid #333;
    transition: background 0.2s;
}

.game-search-item:hover {
    background: #333;
}
.game-search-item:last-child {
    border-bottom: none;
}

/* Poll Modal Mobile & iPhone Responsiveness */
#pollModal::-webkit-scrollbar {
    width: 6px;
}
#pollModal::-webkit-scrollbar-track {
    background: #121320;
    border-radius: 4px;
}
#pollModal::-webkit-scrollbar-thumb {
    background: #ffaa0066;
    border-radius: 4px;
}

@media (max-width: 600px) {
    #pollModal {
        width: 95vw !important;
        max-width: 95vw !important;
        max-height: 88vh !important;
        padding: 16px !important;
        border-radius: 12px !important;
    }
    #pollModal input[type="text"],
    #pollModal select {
        font-size: 16px !important; /* Prevents iOS Safari auto-zoom on input focus */
        padding: 10px 8px !important;
    }
    #pollModal button {
        min-height: 42px; /* Apple iOS touch target guideline */
    }
    .poll-option-row {
        gap: 6px !important;
    }
}

/* Chat Input Container Responsiveness */
.chat-input-flex-wrapper {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    position: relative;
    justify-content: space-between;
    align-items: center;
    width: 100% !important;
    max-width: 1000px;
    margin: 0 auto;
    box-sizing: border-box !important;
}

#chatInputContainer #chatInput {
    flex: 1 1 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 12px 15px;
    border-radius: 6px;
    border: 1px solid #444;
    background: #1a1a1a;
    color: white;
    outline: none;
    font-size: 16px;
    margin-right: 0 !important;
    box-sizing: border-box !important;
}

.chat-input-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

@media (max-width: 600px) {
    #chatInputContainer {
        padding: 8px 10px !important;
    }
    
    .chat-input-flex-wrapper {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px 6px !important;
        width: 100% !important;
    }
    
    #chatInputContainer #chatInput {
        order: 1 !important;
        flex: 1 1 calc(100% - 90px) !important;
        width: calc(100% - 90px) !important;
        max-width: calc(100% - 90px) !important; /* Override max-width: 180px / 100px from media query */
        min-width: 0 !important;
        font-size: 16px !important; /* Prevents iOS auto-zoom */
        padding: 10px 12px !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }
    
    #sendChatBtn {
        order: 2 !important;
        padding: 10px 16px !important;
        font-size: 15px !important;
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        margin: 0 !important;
    }

    .chat-input-actions {
        order: 3 !important;
        width: 100% !important;
        justify-content: space-around !important;
        padding-top: 6px !important;
        border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
        margin-top: 2px !important;
    }
    
    .chat-input-actions button {
        font-size: 1.5em !important;
        padding: 4px 10px !important;
    }
}

/* ==========================================================================
   Browser Tab Bar & Embedded Web View Styles
   ========================================================================== */
#browserTabBarContainer {
    background: #111218;
    border-bottom: 1px solid #2a2d3d;
    padding: 6px 10px 0 10px;
    display: flex;
    align-items: flex-end;
    gap: 6px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    scrollbar-width: none;
    user-select: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 45px;
    z-index: 900;
    box-sizing: border-box;
}

#browserTabBarContainer::-webkit-scrollbar {
    display: none;
}

.browser-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #1e202a;
    color: #9aa0b4;
    padding: 9px 15px;
    border-radius: 10px 10px 0 0;
    font-size: 0.88em;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    border-bottom: none;
    transition: all 0.2s ease;
    max-width: 220px;
    min-width: 100px;
    flex-shrink: 0;
    scroll-snap-align: start;
    white-space: nowrap;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.browser-tab:hover {
    background: #272a38;
    color: #e3e5eb;
}

.browser-tab.active {
    background: #181a20;
    color: #58a6ff;
    font-weight: 600;
    border-color: #383b4e;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
}

.browser-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: #181a20;
}

.tab-icon {
    font-size: 1.1em;
    flex-shrink: 0;
}

.tab-title-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.tab-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 12px;
    line-height: 1;
    color: #8a8f9e;
    transition: all 0.15s ease;
    margin-left: 4px;
    flex-shrink: 0;
}

.tab-close-btn:hover {
    background: #ff4d4d;
    color: #ffffff;
}

#addTabBtn,
.add-url-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 8px;
    background: rgba(88, 166, 255, 0.12);
    color: #58a6ff;
    font-size: 0.84em;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid rgba(88, 166, 255, 0.3);
    transition: all 0.2s ease;
    margin-bottom: 4px;
    flex-shrink: 0;
}

#addTabBtn:hover,
.add-url-tab-btn:hover {
    background: rgba(88, 166, 255, 0.24);
    border-color: #58a6ff;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 2px 10px rgba(88, 166, 255, 0.25);
}

.add-tab-plus {
    font-size: 1.15em;
    font-weight: bold;
    line-height: 1;
}

.quick-preset-chip {
    background: #1e202e;
    border: 1px solid #363b52;
    color: #c9d0e2;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.8em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.quick-preset-chip:hover {
    background: #2b2f44;
    color: #ffffff;
    border-color: #58a6ff;
    transform: translateY(-1px);
}

@media (max-width: 650px) {
    .add-tab-label {
        display: none;
    }
    #addTabBtn,
    .add-url-tab-btn {
        padding: 5px 8px;
    }
}

/* Modal Overlay & Dialog */
.tab-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease-out;
}

.tab-modal-card {
    background: linear-gradient(145deg, #1e202d 0%, #171822 100%);
    border: 1px solid #3d4157;
    border-radius: 14px;
    padding: 24px 28px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.6);
    color: #e3e5eb;
}

.tab-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.tab-modal-header h3 {
    margin: 0;
    font-size: 1.25em;
    color: #58a6ff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-modal-close {
    background: transparent;
    border: none;
    color: #aaa;
    font-size: 1.2em;
    cursor: pointer;
}
.tab-modal-close:hover {
    color: #fff;
}

.tab-modal-body label {
    display: block;
    font-size: 0.88em;
    color: #a0a5ba;
    margin-bottom: 6px;
    margin-top: 12px;
}

.tab-modal-body input[type="text"],
.tab-modal-body input[type="url"] {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #3a3d52;
    background: #12131a;
    color: #ffffff;
    font-size: 0.95em;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}

.tab-modal-body input:focus {
    border-color: #58a6ff;
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

.tab-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 22px;
}

.tab-btn-secondary {
    background: #2a2d3e;
    color: #aaa;
    border: 1px solid #444;
    padding: 9px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
}
.tab-btn-secondary:hover {
    background: #36394f;
    color: #fff;
}

.tab-btn-primary {
    background: linear-gradient(90deg, #58a6ff, #9146FF);
    color: white;
    border: none;
    padding: 9px 22px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.95em;
    box-shadow: 0 2px 10px rgba(88, 166, 255, 0.3);
    transition: transform 0.15s, box-shadow 0.15s;
}
.tab-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(88, 166, 255, 0.4);
}

/* Main Dashboard View Layout */
#mainDashboardView {
    display: none;
    flex-direction: column;
    position: fixed;
    top: 45px;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    background: #181a20;
}

#mainDashboardTop {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 0 10px 10px 10px;
    -webkit-overflow-scrolling: touch;
}

/* Embedded Web View Layout */
#customViewsContainer {
    position: fixed;
    top: 45px;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    overflow: hidden;
    background: #181a20;
}

.custom-tab-container {
    display: none;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.custom-tab-container.active {
    display: flex;
}

.custom-web-toolbar {
    background: #161822;
    border-bottom: 1px solid #2a2d3d;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: thin;
    box-sizing: border-box;
}

.custom-web-toolbar::-webkit-scrollbar {
    height: 4px;
}

.custom-web-toolbar::-webkit-scrollbar-thumb {
    background: #33374d;
    border-radius: 4px;
}

.custom-url-bar {
    flex: 1 1 auto;
    background: #0e0f16;
    border: 1px solid #2e3144;
    border-radius: 20px;
    padding: 3px 6px 3px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 140px;
    box-sizing: border-box;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.custom-url-bar:focus-within {
    border-color: #58a6ff;
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

.custom-url-title {
    color: #e3e5eb;
    font-weight: 600;
    font-size: 0.85em;
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.custom-url-separator {
    color: #484d64;
    font-size: 0.85em;
    flex-shrink: 0;
}

.custom-url-input {
    flex: 1 1 auto;
    min-width: 0 !important; /* CRITICAL: Allows input to shrink inside flex container without overflowing */
    background: transparent;
    border: none;
    color: #a4abbf;
    font-size: 0.85em;
    outline: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-sizing: border-box;
}

.custom-url-input:focus {
    color: #ffffff;
}

.custom-url-go-btn {
    background: linear-gradient(90deg, #58a6ff, #9146FF);
    color: white;
    border: none;
    border-radius: 14px;
    padding: 3px 10px;
    font-size: 0.78em;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.custom-url-go-btn:hover {
    opacity: 0.9;
}

.custom-web-actions-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.custom-web-btn {
    background: #252838;
    color: #d0d4e4;
    border: 1px solid #383c54;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.82em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    white-space: nowrap;
    transition: all 0.2s;
}

.custom-web-btn:hover {
    background: #33374d;
    color: #fff;
}

.custom-web-frame-wrapper {
    flex: 1;
    min-height: 0;
    position: relative;
    width: 100%;
    background: #0d0e14;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
}

.custom-web-frame {
    width: 100%;
    height: 100%;
    min-width: 100%;
    min-height: 100%;
    border: none;
    display: block;
    -webkit-overflow-scrolling: touch;
}

.btn-text-short {
    display: none;
}

/* Responsive Mobile Web Split-View Toolbar */
@media (max-width: 768px) {
    .btn-text-full {
        display: none;
    }
    .btn-text-short {
        display: inline;
    }

    .custom-web-toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 6px 10px;
        gap: 6px;
        height: auto;
        overflow-x: visible;
        overflow-y: visible;
        white-space: normal;
    }
    
    .custom-url-bar {
        width: 100% !important;
        flex: 1 1 100% !important;
        min-width: 0 !important;
        padding: 4px 8px 4px 10px;
        box-sizing: border-box;
    }

    .custom-url-title,
    .custom-url-separator {
        display: none !important; /* Save precious mobile space, tab header already shows title */
    }

    .custom-url-input {
        font-size: 14px !important; /* Clear readable size on mobile */
    }

    .custom-web-actions-row {
        width: 100%;
        display: flex;
        flex-wrap: wrap; /* ALL BUTTONS WRAP TO NEXT LINE SO NONE ARE CUT OFF */
        align-items: center;
        gap: 5px;
    }

    .custom-web-btn {
        padding: 5px 8px;
        font-size: 0.78em;
        flex: 0 0 auto;
    }
}

/* Mobile Phone Responsive Chat Dock Fix */
@media (max-width: 768px) {
    #mainDashboardView.active {
        display: flex !important;
        flex-direction: column !important;
        height: calc(100vh - 45px) !important;
        height: calc(100dvh - 45px) !important;
    }

    #mainDashboardTop {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    #mainDashboardBottomDock {
        height: 48vh;
        height: 48dvh;
        min-height: 100px;
        max-height: 85vh;
        flex-shrink: 0;
        display: flex !important;
        flex-direction: column !important;
    }

    #mainChatContainer {
        height: 100% !important;
        min-height: 0 !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .chatcontainer {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    #pinnedMessageContainer {
        flex-shrink: 0 !important;
        max-height: 120px !important;
    }

    #pinnedMessageContent {
        max-height: 75px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

/* Ensure fixed chat headers, pinned message box, ad banner, and chat input never shrink under flex pressure */
.containerheader,
#pinnedMessageContainer,
#twitchAdChatBanner,
#chatInputContainer {
    flex-shrink: 0 !important;
}

/* Bottom Chat Reader Dock inside custom web tabs */
.bottom-chat-dock {
    height: 380px;
    min-height: 180px;
    max-height: 70vh;
    background: #181a20;
    border-top: 2px solid #383b4e;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
    flex-shrink: 0;
}

/* Remove inner chat container cropping & inner handle when docked in custom tabs */
#mainChatContainer.in-dock {
    height: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    min-height: 0 !important;
}

#mainChatContainer.in-dock #chatResizeHandle {
    display: none !important;
}

.dock-resize-handle, #chatResizeHandle {
    height: 18px !important;
    min-height: 18px !important;
    background: #141620 !important;
    cursor: ns-resize !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    border-bottom: 1px solid #2a2d3d !important;
    user-select: none !important;
    touch-action: none !important;
    -webkit-tap-highlight-color: transparent !important;
}

.dock-resize-handle div, #chatResizeHandle div {
    width: 54px !important;
    height: 5px !important;
    background: #6a6e87 !important;
    border-radius: 3px !important;
    transition: background 0.2s, width 0.2s !important;
}

.dock-resize-handle:hover div, .dock-resize-handle:active div,
#chatResizeHandle:hover div, #chatResizeHandle:active div {
    background: #58a6ff !important;
    width: 65px !important;
}

.dock-header {
    background: #14161f;
    padding: 8px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #2a2d3d;
}

.dock-header h4 {
    margin: 0;
    font-size: 0.92em;
    color: #58a6ff;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dock-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dock-controls select, .dock-controls button {
    background: #232636;
    color: #e3e5eb;
    border: 1px solid #383c54;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.82em;
    cursor: pointer;
}



