
#content div[name="chat"]{
    --attachmentWidth: 250px; /* <- control this as you like */
}

/* Chat root: full-height flex column */
#content div[name="chat"] {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

/* ===== View (top) ===== */
#content div[name="chat"]>div[lid="viewWrap"] {
    flex: 1 1 auto;
    /* fills remaining space */
    min-height: 0;
    /* allows shrinking; enables iframe 100% height */
    display: flex;
    gap: 12px;
    padding: 8px;
    box-sizing: border-box;
}

#content div[name="chat"]>div[lid="viewWrap"]>div {
    /*height: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg);
    display: none;*/
    min-height: 0;                 /* critical so child can scroll */
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    display: none;
}


#content div[name="chat"]>div[lid="viewWrap"]>div.active {
    display: block;
}
/* LEFT (thread) pane: it is the scroll host */
#content div[name="chat"] > div[lid="viewWrap"] > div[lid="paneLeft"] {
    display: block;
    overflow: auto;                /* scrolls independently */
    border: none;
}

/* RIGHT (canvas) pane: no outer scroll (inner iframe will scroll) */
#content div[name="chat"] > div[lid="viewWrap"] > div[lid="paneRight"] {
    overflow: hidden;              /* keep look clean, no double bars */
}

#content div[name="chat"]>div[lid="viewWrap"]>div iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: var(--bg);
}

/* Thread iframe is centered with custom width (set via JS); keep these defaults safe */
#content div[name="chat"] > div[lid="viewWrap"] > div[lid="paneLeft"] iframe {
    display: block;
    margin: 0 auto;                /* center horizontally */
    height: auto;                  /* thread iframe auto-height (JS sets) */
}

/* ===== Input (bottom) ===== */
#content div[name="chat"]>div[lid="inputWrap"] {
    flex: 0 0 var(--chat-input-h, 30vh);
    /* fixed height; tweak via CSS var */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#content div[name="chat"] > div[lid="inputWrap"] > div[lid="inputWrapInner"] {
    width: 75%;
    height: 100%;
    display: flex;
    gap: 10px;                  /* a bit of space between panel and composer */
    align-items: stretch;       /* same height */
    max-width: 1300px;
}

#content div[name="chat"] > div[lid="inputWrap"] > div[lid="inputWrapInner"] > div[lid="filePanel"] {
    width: var(--attachmentWidth);               /* ~100px as requested */
    padding: 6px;               /* space inside; leaves 1px around buttons via child rule */
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;            /* click opens the hidden input */
    user-select: none;
}

#content div[name="chat"] > div[lid="inputWrap"] > div[lid="inputWrapInner"] > div[lid="filePanel"].dragging{
    outline: 2px dashed var(--ac);
    outline-offset: 4px;
}

#content div[name="chat"] > div[lid="inputWrap"] > div[lid="inputWrapInner"] > div[lid="filePanel"] > div[lid="fileList"] {
    display: flex;
    flex-direction: column;
    gap: 2px;                   /* tight vertical spacing; buttons add their own 1px padding */
    overflow: auto;             /* scroll if lots of files */
    min-height: 0;              /* allow shrinking inside */
}

/* File "buttons" (match your .btn look, full width, stacked) */
#content div[name="chat"] > div[lid="inputWrap"] div[lid="fileList"] .filebtn {
    display: block;
    width: 100%;
    min-height: 30px;
    line-height: 30px;
    border-radius: 10px;
    background: #0f172a;
    border: 1px solid var(--border);
    color: var(--fg);
    font-size: 12px;
    padding: 1px;             /* requested 1px padding all around */
    cursor: pointer;
    box-sizing: border-box;
    overflow: hidden;         /* we will scroll the content horizontally */
    white-space: nowrap;
}

#content div[name="chat"] > div[lid="inputWrap"] div[lid="fileList"] .filebtn > span{
    display: inline-block;
    padding: 0 6px;
}

/* Hover style special: shine in #7f1d1d */
#content div[name="chat"] > div[lid="inputWrap"] div[lid="fileList"] .filebtn:hover {
    border-color: #7f1d1d;
    background: rgba(127, 29, 29, .12);
    box-shadow: 0 6px 18px rgba(127, 29, 29, .3);
    color: var(--fg);
}

/* Processing overlay (blocks inputs while reading files) */
#content div[name="chat"] > div[lid="inputWrap"] > div[lid="fileOverlay"] {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.8); /* 0.8 as requested */
    border-radius: 18px;
    pointer-events: none;       /* off by default */
    opacity: 0;
    transition: opacity .15s ease;
}

/* Active (shown) state toggled by JS */
#content div[name="chat"] > div[lid="inputWrap"] > div[lid="fileOverlay"].active {
    pointer-events: all;        /* eat inputs */
    opacity: 1;
}


#content div[name="chat"] > div[lid="inputWrap"] > div[lid="inputWrapInner"] > .composer {
    width: calc(100% - (var(--attachmentWidth) + 10px));
    height: 100%;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 14px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Top row + controls */
#content div[name="chat"]>div[lid="inputWrap"] .toprow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

#content div[name="chat"]>div[lid="inputWrap"] .toprow .leftCtrl,
#content div[name="chat"]>div[lid="inputWrap"] .toprow .rightCtrl {
    display: flex;
    align-items: center;
    gap: 8px;
}

#content div[name="chat"]>div[lid="inputWrap"] .toprow .rightCtrl {
    justify-content: flex-end;
}

/* Inputs in toprow */
#content div[name="chat"]>div[lid="inputWrap"] .toprow select,
#content div[name="chat"]>div[lid="inputWrap"] .toprow input[type="number"] {
    height: 32px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #0f172a;
    color: var(--fg);
    padding: 0 10px;
    outline: none;
}

#content div[name="chat"]>div[lid="inputWrap"] .toprow select:focus,
#content div[name="chat"]>div[lid="inputWrap"] .toprow input[type="number"]:focus {
    border-color: var(--ac);
    /* no color-mix(): use plain rgba ring */
    box-shadow: 0 0 0 3px rgba(124, 77, 255, .28);
}


/* Message box */
#content div[name="chat"]>div[lid="inputWrap"] textarea[lid="msg"] {
    flex: 1 1 auto;
    height: auto;
    /* replaces 80% */
    min-height: 0;
    width: 100%;
    resize: none;
    background: transparent;
    color: var(--fg);
    border: 0;
    outline: none;
    font: 15px/1.5 system-ui, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

/* Buttons */
#content div[name="chat"]>div[lid="inputWrap"] .toprow .btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #0f172a;
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    cursor: pointer;
}

#content div[name="chat"]>div[lid="inputWrap"] .toprow .btn:hover {
    color: var(--ac);
    border-color: var(--ac);
    background: rgba(124, 77, 255, .10);
    box-shadow: 0 6px 18px rgba(124, 77, 255, .22);
}

#content div[name="chat"]>div[lid="inputWrap"] .toprow .btn svg {
    width: 18px;
    height: 18px;
    fill: var(--fg);
}

#content div[name="chat"] input[type="number"] {
    appearance: textfield;
    /* standard */
    -moz-appearance: textfield;
    /* Firefox */
}

/* Chrome/Edge/Safari */
#content div[name="chat"] input[type="number"]::-webkit-outer-spin-button,
#content div[name="chat"] input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}