body{
    margin:0;
    font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto;
    background-image:url("assets/all_i_know_background.jpg");
    background-size:cover;
    background-position:center;
    background-repeat:no-repeat;
    height:100vh;
    display:flex;
    flex-direction:column;
}

#chat-container{
    flex:1;
    overflow-y:auto;
    padding:30px;
}

.message{
    margin-bottom:20px;
    display:flex;
    position:relative;
}

.message.user{
    justify-content:flex-end;
}

.bubble{
    padding:14px 18px;
    border-radius:16px;
    line-height:1.45;
    font-weight:400;
}

.bubble strong{
    font-weight:600;
}

.bubble p{
    margin:0 0 4px 0;
    font-weight:400;
}

.bubble ul, .bubble ol{
    margin:6px 0 10px 18px;
}

.bubble li{
    margin-bottom:4px;
}

.user .bubble{
    background:rgba(19, 135, 193, 0.87);
    backdrop-filter:blur(2px);
    -webkit-backdrop-filter:blur(2px);
    color:white;
    border-bottom-right-radius:4px;
}

.ai .bubble{
    background:white;
    border:1px solid #e2e8f0;
    border-bottom-left-radius:4px;
    background:rgba(255,255,255,0.87);
    backdrop-filter:blur(2px);
    -webkit-backdrop-filter:blur(2px);
}

.stream-status{
    display:flex;
    align-items:center;
    gap:10px;
    color:#475569;
    font-size:14px;
    min-width:220px;
}

.stream-status-spinner{
    width:10px;
    height:10px;
    border-radius:999px;
    background:#1387c1;
    box-shadow:0 0 0 0 rgba(19, 135, 193, 0.45);
    animation:stream-status-pulse 1.2s ease-out infinite;
}

@keyframes stream-status-pulse{
    0%{
        transform:scale(0.9);
        box-shadow:0 0 0 0 rgba(19, 135, 193, 0.45);
    }
    70%{
        transform:scale(1);
        box-shadow:0 0 0 8px rgba(19, 135, 193, 0);
    }
    100%{
        transform:scale(0.9);
        box-shadow:0 0 0 0 rgba(19, 135, 193, 0);
    }
}

#input-bar{
    border-top:1px solid #e5e7eb;
    background:white;
    padding:15px 40px 15px 15px;
    display:flex;
    gap:10px;
    background:rgba(255,255,255,0.65);
    backdrop-filter:blur(2px);
    -webkit-backdrop-filter:blur(2px);
}

#role-editor{
    position:fixed;
    right:0;
    top:0;
    bottom:0;
    width:420px;
    height:auto;
    background:rgba(255, 255, 255, 0.65);
    backdrop-filter:blur(2px);
    -webkit-backdrop-filter:blur(2px);
    border-left:1px solid #e5e7eb;
    border-top:1px solid #e5e7eb;
    box-shadow:0 -4px 16px rgba(0,0,0,0.08);
    display:flex;
    flex-direction:column;
    padding:12px;
    font-family:system-ui;
    box-sizing:border-box;
    overflow:hidden;
    transition:width 0.18s ease, padding 0.18s ease;
}

#role-editor-header{
    display:flex;
    align-items:center;
    gap:6px;
    margin-bottom:8px;
    font-weight:600;
    cursor:pointer;
    user-select:none;
    white-space:nowrap;
}

#role-editor-body{
    flex:1;
    display:flex;
    flex-direction:column;
    min-height:0;
}

#role-editor-collapsed-handle{
    display:none;
    height:100%;
    width:100%;
    align-items:center;
    justify-content:center;
    font-size:18px;
    color:#334155;
    cursor:pointer;
    user-select:none;
}

#role-editor-collapsed-handle:hover{
    background:rgba(255,255,255,0.18);
}

#role-content{
    flex:1;
    width:100%;
    font-family:monospace;
    font-size:13px;
    padding:8px;
    border:1px solid #e5e7eb;
    border-radius:6px;
    resize:none;
    background: rgba(255, 255, 255, 0.65);
    box-sizing:border-box;
}

#role-select{
    margin-bottom:8px;
    padding:4px;
    background: rgba(255, 255, 255, 0.65);
}

#question{
    flex:1;
    font-size:16px;
    padding:12px 14px;
    border-radius:10px;
    border:1px solid #d1d5db;
}

#send{
    background:#2563eb;
    color:white;
    border:none;
    padding:12px 18px;
    border-radius:10px;
    cursor:pointer;
}

#send:hover{
    background:#1d4ed8;
}

#loading{
    font-size:14px;
    color:#64748b;
    margin-top:10px;
}

.sources{
    margin-top:12px;
    font-size:13px;
    color:#64748b;
}

.sources a{
    color:#2563eb;
    text-decoration:none;
}

.sources a:hover{
    text-decoration:underline;
}

/* Conversation message controls */
.message-controls{
    position:absolute;
    right:8px;
    bottom:6px;
    display:flex;
    gap:8px;
    font-size:13px;
    opacity:0;
    transition:opacity 0.15s ease;
}

.message:hover .message-controls{
    opacity:1;
}

.message-controls span{
    cursor:pointer;
    background:#ffffff;
    border:1px solid #e5e7eb;
    border-radius:6px;
    padding:2px 6px;
}

.message-controls span:hover{
    background:#f1f5f9;
}


/* --- App Layout --- */
.app-layout{
    display:flex;
    height:100vh;
    width:100%;
}

.chat-area{
    flex:1;
    display:flex;
    flex-direction:column;
    transition:margin-right 0.18s ease;
}

/* --- Thread Sidebar --- */
.thread-panel{
    width:300px;
    min-width:268px;
    border-right:1px solid #e5e7eb;
    background:rgba(255,255,255,0.65);
    backdrop-filter:blur(2px);
    -webkit-backdrop-filter:blur(2px);
    overflow-y:auto;
    padding:12px;
    display:flex;
    flex-direction:column;
}

.thread-row{
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:8px 10px;
    border-radius:8px;
    cursor:pointer;
    transition:background 0.15s ease;
}

.thread-row:hover{
    background:#f1f5f9;
}

.thread-row-active{
    background:#e8eefc;
}

.thread-title{
    font-size:14px;
    color:#111827;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}

/* --- Sidebar Buttons --- */
.new-thread-btn{
    width:100%;
    margin-bottom:12px;
    padding:10px;
    border-radius:8px;
    border:1px solid #d1d5db;
    background:#f8fafc;
    cursor:pointer;
}

.new-thread-btn:hover{
    background:#eef2f7;
}

/* --- Thread menu (...) --- */
.thread-menu-btn{
    border:none;
    background:transparent;
    cursor:pointer;
    font-size:16px;
    padding:2px 6px;
    border-radius:6px;
}

.thread-menu-btn:hover{
    background:#f1f5f9;
}

.thread-menu{
    position:absolute;
    background:#ffffff;
    border:1px solid #e5e7eb;
    border-radius:8px;
    box-shadow:0 6px 20px rgba(0,0,0,0.08);
    padding:6px 0;
    z-index:1000;
}

.thread-menu-item{
    padding:8px 14px;
    font-size:14px;
    cursor:pointer;
    white-space:nowrap;
}

.thread-menu-item:hover{
    background:#f1f5f9;
}

.app-brand{
    display:flex;
    align-items:center;
    gap:10px;
    padding:0px 12px 12px 12px;
    color:inherit;
    text-decoration:none;
    border-bottom:1px solid rgba(255,255,255,0.08);
    flex-shrink:0;
}

.app-brand:hover{
    background:rgba(255,255,255,0.04);
}

.app-brand img{
    width:48px;
    height:48px;
    object-fit:contain;
    flex-shrink:0;
}

.app-brand-title{
    font-size:28px;
    font-weight:700;
    letter-spacing:0.04em;
}

#thread-list{
    flex:1 1 auto;
    min-height:0;
    overflow:auto;
}

.user-panel{
    position:relative;
    margin-top:auto;
    padding:12px;
    border-top:1px solid rgba(255,255,255,0.08);
    flex-shrink:0;
}

.user-panel-trigger{
    width:100%;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    padding:12px 10px 12px 0px;
    border-radius:10px;
    border:1px solid rgba(255,255,255,0.08);
    background:rgba(255,255,255,0.04);
    color:inherit;
    cursor:pointer;
    font-size: 18px;
    font-weight: 700;
}

.user-panel-trigger:hover{
    background:rgba(255,255,255,0.08);
}

.user-panel-name{
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
    text-align:left;
}

.user-panel-menu{
    position:absolute;
    left:12px;
    right:12px;
    bottom:64px;
    background:#ffffff;
    color:#111827;
    border:1px solid #e5e7eb;
    border-radius:10px;
    box-shadow:0 12px 28px rgba(0,0,0,0.18);
    padding:6px;
    display:none;
    z-index:1000;
}

.user-panel-menu.open{
    display:block;
}

.user-panel-menu a{
    display:block;
    padding:10px 12px;
    border-radius:8px;
    color:#111827;
    text-decoration:none;
}

.user-panel-menu a:hover{
    background:#f3f4f6;
}
