:root{
  --brand-blue:#1991eb; --brand-blue-hover:#0f75c0;
  --dark-bg:#111; --panel-bg:#1a1a1a; --panel-border:#333; --panel-radius:8px;
  --track-h:6px; --thumb:16px;
}
*{box-sizing:border-box;margin:0;padding:0}
body{font-family:'Poppins',sans-serif;background:var(--dark-bg);color:#fff; overflow-x: hidden;}
a{color:var(--brand-blue);text-decoration:none}

/*──────── Sticky Header ────────*/
header{position:sticky;top:0;z-index:40;display:flex;padding:0.7rem 2rem;background:#18181b;border-bottom:1px solid #222;box-shadow:0 4px 12px #0008; align-items: center; flex-wrap: wrap;}
header h1{font-size:1.25rem; margin-right: 1.5rem;}
header h1 a {
color: #fff;
display: inline-flex;
align-items: center;
}

/* This new rule applies the gradient ONLY to the first letter's span */
header h1 a .gradient-letter {
background: linear-gradient(135deg, #4facfe, #c471ed);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
text-fill-color: transparent;
}

.header-controls-right { margin-left: auto; display: flex; gap: 0.5rem; }
.type-toggle { display: flex; gap: 0.5rem;}
.upload-buttons { display: flex; gap: 0.5rem; }

.type-toggle .upload-btn,
.upload-buttons .upload-btn {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    font-weight: normal;
    font-size: 0.9em;
    padding: .45rem .9rem;
    transition: background .15s, border-color .15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #fff;
    cursor: pointer;
}
 .type-toggle .upload-btn.active,
 .upload-buttons .upload-btn:hover,
 .type-toggle .upload-btn:hover {
    background: var(--brand-blue);
    border-color: var(--brand-blue-hover);
}
.upload-btn svg { vertical-align: middle; }

/*──────── PiP Tile ────────*/
#pip{position:fixed;border-radius: var(--panel-radius);bottom:1rem;right:1rem;width:120px;height:213px;border:1px solid var(--panel-border);overflow:hidden;box-shadow:0 4px 12px #0008;background:#000;z-index:60;cursor:pointer;transition: all .2s ease-in-out;}
#pip video,#pip canvas{width:100%;height:100%;object-fit:cover;display:block}
.pip-toolbar{position:absolute;bottom:4px;left:4px;right:4px;display:flex;justify-content:space-between;gap:4px;z-index:2}
.pip-toolbar button{border:none;background:rgba(0,0,0,.65);color:#fff;padding:4px 6px;border-radius:4px;font-size:.8rem;cursor:pointer}
#pip.hidden{display:none}
#pip.collapsed { height: 32px; width: 120px; }
#pip.collapsed #pip-canvas { display: none; }
#pip.collapsed .pip-toolbar { bottom: -1px; }
/* MODIFIED: PiP Progress Display */
#pip-progress-display {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.75);
    z-index: 10;
    pointer-events: none;
    font-size: 38px;
    border-radius: var(--panel-radius);
}
#pip.collapsed #pip-progress-display { display: none; }


/*──────── Editor Drawer ────────*/
#editor-drawer{position:fixed;top:0;right:0;width:320px;height:100%;background:#1a1a1a;box-shadow:-4px 0 16px #0008;transform:translateX(100%);transition:transform .25s cubic-bezier(.23,1,.32,1);z-index:70;overflow-y:auto;padding:1rem}
#editor-drawer.open{transform:translateX(0)}
.drawer-preview { position: relative; height: 400px; background: #000; border: 1px solid #333; border-radius: 8px; margin-bottom: 1rem; overflow: hidden; display: flex; justify-content: center; align-items: center; }
#output-canvas, .drawer-preview video, .drawer-preview canvas { max-width: 100%; max-height: 100%; object-fit: contain; display: block; margin: 0 auto; }
.close-btn{ position:absolute; top:8px; right:8px; width:32px; height:32px; border:none; border-radius:25%; background:rgba(0,0,0,.55); color:#fff; font-size:18px; line-height:32px; cursor:pointer; backdrop-filter:blur(6px); z-index: 20; }
.close-btn:hover{ background:rgba(0,0,0,.75); }

/*──────── Editor Loader ────────*/
#editor-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 26, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 25;
    pointer-events: none;
    backdrop-filter: blur(4px);
}
.loader-spinner {
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    border-top: 4px solid var(--brand-blue);
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/*──────── PiP Loader ────────*/
#pip-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5;
    pointer-events: none;
}
#pip-loader .loader-spinner {
    width: 30px;
    height: 30px;
    border-width: 3px;
}


/*──────── Editor Controls ────────*/
.generate button{font-size:1rem;padding:.5rem 1rem;background:var(--panel-bg);color:#fff;border:1px solid #444;border-radius:var(--panel-radius);cursor:pointer; width: 100%;}
.generate button:hover{background:var(--brand-blue);border-color:var(--brand-blue)}

.tabs-container {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--panel-radius);
    padding: 0.5rem;
    margin-bottom: 1rem;
}
.tabs{display: flex; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; white-space: nowrap; scroll-behavior: smooth; scrollbar-width: none; -ms-overflow-style: none; gap: 8px;}
.tabs::-webkit-scrollbar { display: none; }
.tabs button{ flex: 0 0 auto; padding: .5rem 1rem; background: var(--panel-bg); color: #fff; border: 1px solid #444; border-radius: var(--panel-radius); cursor: pointer;}
.tabs button.active{background:var(--brand-blue);border-color:var(--brand-blue)}

.controls-section{display:none;background:var(--panel-bg);border:1px solid var(--panel-border);border-radius:var(--panel-radius);padding:1rem;margin-bottom:1rem}
.controls-section.active{display:block}
.control-group{display:flex;flex-direction:column;gap:.4rem;margin-bottom:.75rem}
input[type=range]{-webkit-appearance:none;width:100%;height:var(--track-h);background:#444;border-radius:var(--track-h)}
input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:var(--thumb);height:var(--thumb);background:var(--brand-blue);border-radius:50%}
input[type=range]::-moz-range-thumb{width:var(--thumb);height:var(--thumb);background:var(--brand-blue);border-radius:50%}
.controls-section button:not(.icon-btn){padding:.6rem;background:var(--brand-blue);color:#fff;border:none;border-radius:var(--panel-radius);cursor:pointer}
.color-input-wrapper { display: flex; align-items: center; gap: 8px; }
.color-input-wrapper input[type="color"] {
    -webkit-appearance: none;
    width: 32px;
    height: 32px;
    border: none;
    padding: 0;
    background: none;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
}
.color-input-wrapper input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-input-wrapper input[type="color"]::-webkit-color-swatch { border: 1px solid #555; border-radius: 4px; }


.dynamic-controls-container .control-group { display: none; }
.dynamic-controls-container .control-group.active { display: flex; flex-direction: column; }

#effect-list, #font-select, #text-list, #blend-mode-select {
    flex: 1;
    min-width: 0;
    background-color: var(--dark-bg);
    color: #fff;
    border: 1px solid var(--panel-border);
    padding: 0.5rem 2.5rem 0.5rem 0.8rem;
    border-radius: 4px;
    height: 38px;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23cccccc' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    line-height: 1.5;
}

/*──────── Thumbnails Redesign (Mobile First) ────────*/
#thumbnail-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem; /* Increased gap */
    padding: 1rem;
}
.thumbnail-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
}

.thumbnail-user-header {
    display: none; /* Hidden on mobile */
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.25rem;
}
.thumbnail-user-info { display: flex; align-items: center; gap: 0.5rem; min-width: 0; flex: 1; }
.thumbnail-user-info img { width: 32px; height: 32px; max-width: 32px; max-height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.thumbnail-user-info span { color: #eee; font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.like-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}
.like-btn:hover {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.90);
}
.like-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.thumbnail { width: 100%; position: relative; overflow: hidden; display: flex; border-radius: var(--panel-radius); cursor: pointer; }
.thumbnail::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border-radius: inherit; /* Match the parent's border radius */
padding: 2px; /* This defines the border thickness */
background: linear-gradient(135deg, #4facfe, #c471ed);
-webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
-webkit-mask-composite: xor;
        mask-composite: exclude;
z-index: 2;
pointer-events: none;
opacity: 0; /* Hidden by default */
transition: opacity 0.2s ease-in-out;
}
.thumbnail.selected::before, .thumbnail:hover::before {
opacity: 1; /* Made visible on hover/selection */
}
.thumbnail .image-wrapper { width: 100%; aspect-ratio: 9 / 16; position: relative; overflow: hidden; background-color: #000; }
.thumbnail img, .thumbnail video { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumbnail.selected, .thumbnail:hover { }
.thumbnail-footer { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0 0.25rem; }
.thumbnail-name { color: #ccc; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/*──────── Icon Controls ────────*/
.icon-scrollbar { display: flex; flex-direction: row; overflow-x: auto; overflow-y: hidden; gap: 0.5rem; padding: 0.5rem 0; margin-top: 0.5rem; white-space: nowrap; scroll-behavior: smooth; scrollbar-width: none; -ms-overflow-style: none; }
.icon-scrollbar::-webkit-scrollbar { display: none; }
.icon-btn { flex: 0 0 auto; height: 36px; color: #fff; background: #222; border: 1px solid #444; border-radius: 8px; padding: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.icon-btn svg { vertical-align: middle; }
.icon-btn img { width: 24px; height: 24px; filter: brightness(1.5); }
.icon-btn.active { background: var(--brand-blue); border-color: var(--brand-blue-hover); }

/*──────── Main Layout ────────*/
.layout { display: flex; height: calc(100vh - 72px); overflow: hidden; }
#sidebar { width: 200px; background: var(--panel-bg); border-right: 1px solid var(--panel-border); padding: 1rem; overflow-y: auto; position: sticky; top: 72px; flex-shrink: 0; }
#content { flex: 1; overflow-y: auto; padding: 0; background: #0b0b0b; transition: margin-right .25s cubic-bezier(.23,1,.32,1); }
#content-header {
    padding: 1rem 1.5rem 1rem; background-color:#111;
}
#sidebar .sidebar-btn { width: 100%; padding: .5rem; margin-bottom: .5rem; background: var(--panel-bg); color: #fff; border: 1px solid var(--panel-border); border-radius: 4px; text-align: left; cursor: pointer; font-size:0.9em; }
#sidebar .sidebar-btn.active { background: var(--brand-blue); border-color: var(--brand-blue-hover); }
.search-container { position: relative; margin: 0 0 1rem; width: 100%; }
.search-container input[type="search"] { padding: .5rem .8rem; border: 1px solid var(--panel-border); border-radius: var(--panel-radius); background: var(--panel-bg); color: #fff; width: 100%; }
.sr-only { position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0; }
#mobile-menu-toggle {display: none;}

/*──────── Right Sidebar & Chatbox ────────*/
#right-sidebar {
    width: 280px;
    background: var(--panel-bg);
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease;
    position: fixed;
    z-index: 50;
    top: 82px;
    right: 1rem;
    bottom: calc(1rem + 213px + 1rem);
    height: auto;
    border-radius: var(--panel-radius);
    box-shadow: 0 4px 12px #0008;
}
.sidebar-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #eee;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--panel-border);
}

#chat-container h3 {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    opacity: 1;
    z-index: 3; /* MODIFICATION: Set to a higher value */
    pointer-events: none;
    margin: 0;
    padding: 0;
    border: none;
    white-space: nowrap;
}


.sidebar-section { margin-bottom: 1rem; }

#chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding-top: 1rem;
    /* MODIFICATION: Removed position and z-index to simplify stacking */
}
.chat-message {
    cursor: default;
    line-height: 1.4;
    word-wrap: break-word;
}
.chat-message-header {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    margin-right: 0.4em;
}
.chat-message-body {
    font-size: 0.85rem;
    color: #ccc;
}

#chat-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border-top: 1px solid var(--panel-border);
    padding-top: 1rem;
}
#chat-form .chat-input-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}
#chat-form input[type="text"], #chat-form textarea, #text-controls textarea {
    width: 100%;
    padding: .5rem .8rem;
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    background: var(--dark-bg);
    color: #fff;
    resize: vertical;
}
#chat-form .chat-input-line input[type="text"] {
    flex: 1;
    height: 38px;
}
#chat-form textarea {
    min-height: 60px;
}
#chat-form button[type="submit"] {
    background: var(--brand-blue);
    color: #fff;
    border: none;
    padding: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}
#chat-form button[type="submit"]:hover { background: var(--brand-blue-hover); }
#chat-form button[type="submit"]:disabled { background: #555; cursor: not-allowed; }

#emoji-btn {
    background: var(--dark-bg);
    border: 1px solid var(--panel-border);
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.2rem;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    height: 38px;
    width: 38px;
}
#emoji-btn:hover {
    background-color: #333;
}
#emoji-picker {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 5px;
    background: var(--dark-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--panel-radius);
    padding: 0.5rem;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.5rem;
    box-shadow: 0 4px 12px #0008;
    z-index: 80;
}
#emoji-picker.hidden {
    display: none;
}
#emoji-picker span {
    cursor: pointer;
    font-size: 1.2rem;
    text-align: center;
    padding: 0.25rem;
    border-radius: 4px;
}
#emoji-picker span:hover {
    background: #333;
}

/* NEW Countdown Timer Styles */
#countdown-timer {
    background: var(--dark-bg);
    border-radius: var(--panel-radius);
    padding: 1rem;
    margin-bottom: 1rem;
    text-align: center;
    position: relative; /* Required for the pseudo-element */
    z-index: 1; /* Ensures content stays on top */
}

#countdown-timer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit; /* Matches the parent's border-radius */
    padding: 2px; /* This creates the border thickness */
    background: linear-gradient(135deg, #4facfe, #c471ed);
    -webkit-mask: /* Creates a "hole" in the middle of the gradient */
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    z-index: -1; /* Places the gradient behind the main element */
}
    #countdown-timer h3 {
        font-size: 1rem;
        font-weight: 500;
        color: #eee;
        margin: 0 0 0.75rem 0;
        text-transform: uppercase;
        letter-spacing: 1px;
    }
    #timer-container {
        display: flex;
        justify-content: space-around;
        gap: 0.5rem;
    }
    .timer-unit {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 40px;
    }
    .timer-unit span {
        font-family: 'Roboto Mono', monospace;
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--brand-blue);
        line-height: 1.1;
    }
    .timer-unit label {
        font-size: 0.7rem;
        color: #aaa;
        text-transform: uppercase;
    }

    /* Notification Styles */
    #upload-notification, #complete-notification {
        position: fixed;
        bottom: -100px;
        left: 50%;
        transform: translateX(-50%);
        color: #fff;
        padding: 0.8rem 1.5rem;
        border-radius: var(--panel-radius);
        box-shadow: 0 4px 12px #0008;
        z-index: 110;
        opacity: 0;
        transition: bottom 0.4s ease-out, opacity 0.4s ease-out;
        pointer-events: none;
        max-width: calc(100vw - 2rem); /* Prevent overflow */
        text-align: center;
    }
    #upload-notification {
        background: var(--panel-bg);
        border: 1px solid var(--panel-border);
    }
    /* NEW: Video Complete Notification Style */
    #complete-notification {
        background: #28a745; /* Green */
        border: 1px solid #218838;
    }
    #upload-notification.show, #complete-notification.show {
        bottom: 2rem;
        opacity: 1;
    }


    /*──────── Desktop & Larger Screen Styles ────────*/
    @media (min-width: 769px) {
        body.editor-open #content { margin-right: 320px; }
        body.editor-open #right-sidebar { display: none; }
        body.editor-open header {
            padding-right: 320px;
            transition: padding-right .25s cubic-bezier(.23,1,.32,1);
        }
        #thumbnail-container {
            grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
            gap: 1.5rem;
            padding: 1.5rem;
        }

        /* NEW DESKTOP THUMBNAIL USER STYLES */
        .thumbnail .thumbnail-user-header {
            display: flex; /* Re-display for desktop */
            position: absolute;
            bottom: 10px; /* Padding from bottom */
            left: 10px; /* Padding from left */
            z-index: 3;
            background-color: rgba(0, 0, 0, 0.45);
            padding: 5px 8px;
            border-radius: 6px;
            backdrop-filter: blur(4px);
            -webkit-backdrop-filter: blur(4px);
            border: 1px solid rgba(255, 255, 255, 0.1);
            
            /* Fade in effect */
            opacity: 0;
            transition: opacity 0.2s ease-in-out;
            
            /* Reset mobile padding and set gap */
            padding: 5px 8px;
            gap: 0.5rem;
            align-items: center;
        }

        .thumbnail:hover .thumbnail-user-header {
            opacity: 1;
        }

        .thumbnail .thumbnail-user-info span {
            font-size: 0.8rem;
            font-weight: 500;
            color: #fff;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
        }
        
        .thumbnail .thumbnail-user-info img {
            width: 24px;
            height: 24px;
        }
    }
    
    @media (min-width: 1281px) {
        body:not(.editor-open) #content {
            margin-right: calc(280px + 2rem);
        }
    }

    @media (max-width: 1280px) {
        #right-sidebar {
            display: none;
        }
    }

    /*──────── Mobile Styles ────────*/
    @media (max-width: 768px) {
      header { flex-wrap: nowrap; padding: 0.5rem 1rem; }
      .header-controls-right {
          margin-left: auto;
          display: flex;
          align-items: center;
          overflow-x: auto;
          scrollbar-width: none;
          -ms-overflow-style: none;
      }
      .header-controls-right::-webkit-scrollbar { display: none; }
      .type-toggle, .upload-buttons { flex-shrink: 0; }
      .upload-btn { padding: .4rem .6rem; font-size: 0.8em; }
      h1 { font-size: 1.1rem; margin-right: 1rem; }
      #mobile-menu-toggle { display: block; background: none; border: none; color: white; font-size: 1.5rem; margin-right: 0.5rem; cursor: pointer; order: -1; }
      #sidebar { position: fixed; top: 0; left: -250px; width: 250px; height: 100vh; z-index: 100; transition: transform 0.3s ease; background: var(--panel-bg); }
      #sidebar.open { transform: translateX(250px); }
      #sidebar-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 99; display: none; }
      #sidebar-overlay.open { display: block; }
      .layout { flex-direction: column; height: auto; }
      #content { margin-left: 0; }
      #editor-drawer { width: 100vw; padding-bottom: 3rem; }
      .drawer-preview { height: 50vh; }
      #content-header { padding-left: 1rem; padding-right: 1rem; background-color:#111; }

      /* Prevent auto-zoom on form inputs on mobile */
      #search-input, #chat-name, #chat-message,
      #editor-drawer input[type="text"],
      #editor-drawer input[type="color"],
      #editor-drawer input[type="search"],
      #editor-drawer textarea,
      #editor-drawer select {
          font-size: 16px; /* Prevents auto-zoom on focus in iOS */
      }
      
      /* Mobile styles for external download bar */
      #external-download-bar {
        flex-direction: column;
        text-align: center;
        width: calc(100vw - 2rem);
        padding: 1.5rem 1rem 1rem;
        gap: 0.75rem;
      }
      #external-download-bar.show {
        bottom: 1rem;
      }
      #external-download-link {
        width: 100%;
        padding: 0.75rem 1rem;
      }
      #close-download-bar-btn {
        position: absolute;
        top: 0.25rem;
        right: 0.5rem;
        padding: 0.5rem; /* Larger tap area */
      }
    }
    
    .label-wrapper {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .reset-slider {
        font-size: 0.75em;
        color: #999;
        text-decoration: none;
        cursor: pointer;
        padding-left: 1rem;
    }
    .reset-slider:hover {
        color: var(--brand-blue);
    }
    
    /* NEW Text Control Styles */
    .alignment-options {
        display: flex;
        gap: 0.5rem;
    }
    .alignment-options .icon-btn {
        flex: 1;
        justify-content: center;
    }
    .font-color-control-wrapper {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    .font-color-control-wrapper select {
        flex: 1;
    }
    .font-color-control-wrapper input[type="color"] {
        -webkit-appearance: none;
        width: 36px;
        height: 36px;
        border: none;
        padding: 0;
        background: none;
        border-radius: 4px;
        overflow: hidden;
        cursor: pointer;
    }
    .font-color-control-wrapper input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
    .font-color-control-wrapper input[type="color"]::-webkit-color-swatch { border: 1px solid #555; border-radius: 4px; }

#external-download-bar {
  position: fixed;
  bottom: -100px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #1a1a1a;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 1rem 1.5rem;
  display: none;
  bottom: 20px;
  align-items: center;
  gap: 1rem;
  z-index: 1005;
  transition: bottom 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}
#external-download-bar.show {
  display:flex;
}
#external-download-link {
  background-color: var(--brand-blue);
  color: white;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 500;
  white-space: nowrap;
}
#close-download-bar-btn {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 1.5rem;
  padding: 0 0.5rem;
}
#close-download-bar-btn:hover {
  color: white;
}
/* 1. Make the main chat container a positioning reference */
#chat-container {
    position: relative;
}

.chat-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 10;
    background: rgba(26, 26, 26, 0.7); /* Semi-transparent dark bg */
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    padding: 1rem;
}
.chat-header h3 {
    border: none;
    padding: 0;
    margin: 0;
    font-size: .75rem;
    font-weight: 600;
    color: #eee;
    position: static;
    transform: none;
    opacity: 1;
}
#chat-messages {
    padding-top: 3.5rem;
}
#chat-container > h3 {
   display: none;
}
